Merge changes from topic 'cpuset_setall' into oc-dev
* changes:
init: use read_file and write_file to implement do_copy builtin
init: Use std::string for write_file()
diff --git a/fs_mgr/fs_mgr_avb.cpp b/fs_mgr/fs_mgr_avb.cpp
index 7c82bb1..83bf8a7 100644
--- a/fs_mgr/fs_mgr_avb.cpp
+++ b/fs_mgr/fs_mgr_avb.cpp
@@ -493,6 +493,10 @@
return nullptr;
}
+ // Sets the MAJOR.MINOR for init to set it into "ro.boot.avb_version".
+ avb_handle->avb_version_ =
+ android::base::StringPrintf("%d.%d", AVB_VERSION_MAJOR, AVB_VERSION_MINOR);
+
// Verifies vbmeta images against the digest passed from bootloader.
if (!avb_verifier->VerifyVbmetaImages(*avb_handle->avb_slot_data_)) {
LERROR << "VerifyVbmetaImages failed";
diff --git a/fs_mgr/include/fs_mgr_avb.h b/fs_mgr/include/fs_mgr_avb.h
index 526a5ce..a66ff42 100644
--- a/fs_mgr/include/fs_mgr_avb.h
+++ b/fs_mgr/include/fs_mgr_avb.h
@@ -72,7 +72,8 @@
// Otherwise, returns false.
bool SetUpAvb(fstab_rec* fstab_entry, bool wait_for_verity_dev);
- bool AvbHashtreeDisabled() { return status_ == kFsManagerAvbHandleHashtreeDisabled; }
+ bool hashtree_disabled() const { return status_ == kFsManagerAvbHandleHashtreeDisabled; }
+ const std::string& avb_version() const { return avb_version_; }
FsManagerAvbHandle(const FsManagerAvbHandle&) = delete; // no copy
FsManagerAvbHandle& operator=(const FsManagerAvbHandle&) = delete; // no assignment
@@ -92,6 +93,7 @@
private:
AvbSlotVerifyData* avb_slot_data_;
FsManagerAvbHandleStatus status_;
+ std::string avb_version_;
};
#endif /* __CORE_FS_MGR_AVB_H */
diff --git a/init/init.cpp b/init/init.cpp
index 83a59dd..a75ced5 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -1040,10 +1040,11 @@
return false;
}
+ setenv("INIT_AVB_VERSION", avb_handle->avb_version().c_str(), 1);
for (auto rec : fstab_recs) {
bool need_create_dm_device = false;
if (fs_mgr_is_avb(rec)) {
- if (avb_handle->AvbHashtreeDisabled()) {
+ if (avb_handle->hashtree_disabled()) {
LOG(INFO) << "avb hashtree disabled for '" << rec->mount_point << "'";
} else if (avb_handle->SetUpAvb(rec, false /* wait_for_verity_dev */)) {
need_create_dm_device = true;
@@ -1390,12 +1391,14 @@
property_set("ro.boottime.init.selinux", getenv("INIT_SELINUX_TOOK"));
// Set libavb version for Framework-only OTA match in Treble build.
- property_set("ro.boot.init.avb_version", std::to_string(AVB_MAJOR_VERSION).c_str());
+ const char* avb_version = getenv("INIT_AVB_VERSION");
+ if (avb_version) property_set("ro.boot.avb_version", avb_version);
// Clean up our environment.
unsetenv("INIT_SECOND_STAGE");
unsetenv("INIT_STARTED_AT");
unsetenv("INIT_SELINUX_TOOK");
+ unsetenv("INIT_AVB_VERSION");
// Now set up SELinux for second stage.
selinux_initialize(false);
diff --git a/rootdir/init.rc b/rootdir/init.rc
index e354d4b..0517884 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -157,25 +157,25 @@
# this ensures that the cpusets are present and usable, but the device's
# init.rc must actually set the correct cpus
mkdir /dev/cpuset/foreground
- write /dev/cpuset/foreground/cpus 0
- write /dev/cpuset/foreground/mems 0
+ copy /dev/cpuset/cpus /dev/cpuset/foreground/cpus
+ copy /dev/cpuset/mems /dev/cpuset/foreground/mems
mkdir /dev/cpuset/foreground/boost
- write /dev/cpuset/foreground/boost/cpus 0
- write /dev/cpuset/foreground/boost/mems 0
+ copy /dev/cpuset/cpus /dev/cpuset/foreground/boost/cpus
+ copy /dev/cpuset/mems /dev/cpuset/foreground/boost/mems
mkdir /dev/cpuset/background
- write /dev/cpuset/background/cpus 0
- write /dev/cpuset/background/mems 0
+ copy /dev/cpuset/cpus /dev/cpuset/background/cpus
+ copy /dev/cpuset/mems /dev/cpuset/background/mems
# system-background is for system tasks that should only run on
# little cores, not on bigs
# to be used only by init, so don't change system-bg permissions
mkdir /dev/cpuset/system-background
- write /dev/cpuset/system-background/cpus 0
- write /dev/cpuset/system-background/mems 0
+ copy /dev/cpuset/cpus /dev/cpuset/system-background/cpus
+ copy /dev/cpuset/mems /dev/cpuset/system-background/mems
mkdir /dev/cpuset/top-app
- write /dev/cpuset/top-app/cpus 0
- write /dev/cpuset/top-app/mems 0
+ copy /dev/cpuset/cpus /dev/cpuset/top-app/cpus
+ copy /dev/cpuset/mems /dev/cpuset/top-app/mems
# change permissions for all cpusets we'll touch at runtime
chown system system /dev/cpuset