diff options
author | SzuWei Lin <szuweilin@google.com> | 2019-04-22 17:27:52 +0800 |
---|---|---|
committer | SzuWei Lin <szuweilin@google.com> | 2019-04-24 15:38:58 +0800 |
commit | 917446b29d259d1ffcab314fae4fb9fee3e3fc73 (patch) | |
tree | 3f894ddca05c341b35a377baed2ccd04e9a0dea3 /fs_mgr | |
parent | 3689ba66aa6d35b3b25f81adf80671d3e9e3c0ee (diff) | |
download | system_core-917446b29d259d1ffcab314fae4fb9fee3e3fc73.tar.gz system_core-917446b29d259d1ffcab314fae4fb9fee3e3fc73.tar.bz2 system_core-917446b29d259d1ffcab314fae4fb9fee3e3fc73.zip |
Remove the mount points defined in skip_mount.cfg from ReadDefaultFstab()
The first stage init skips mounting the mount points defined in
skip_mount.cfg, but these mount points still return from
ReadDefaultFstab(). The behavior causes some error logic which
try to access the partition which had been skipped.
After applying the patch. ReadDefaultFstab() will not contain the
skipped mount points.
Bug: 128961335
Test: `fastboot delete-logical-partition product_a`
Test: `fastboot flash system aosp_arm64-userdebug`
Test: `fastboot -w reboot` and boot to home screen
Change-Id: I3156260b5d37647dbecf98ca90601a089bea5c46
Merged-In: I3156260b5d37647dbecf98ca90601a089bea5c46
(cherry picked from commit 77c28476f19c910a869af878c8983d52e53c07b4)
Diffstat (limited to 'fs_mgr')
-rw-r--r-- | fs_mgr/fs_mgr_fstab.cpp | 33 | ||||
-rw-r--r-- | fs_mgr/include_fstab/fstab/fstab.h | 1 |
2 files changed, 34 insertions, 0 deletions
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp index 4043fc6a1..da049efa5 100644 --- a/fs_mgr/fs_mgr_fstab.cpp +++ b/fs_mgr/fs_mgr_fstab.cpp @@ -38,6 +38,7 @@ using android::base::ParseByteCount; using android::base::ParseInt; +using android::base::ReadFileToString; using android::base::Split; using android::base::StartsWith; @@ -660,6 +661,8 @@ bool ReadFstabFromFile(const std::string& path, Fstab* fstab) { TransformFstabForGsi(fstab); } + SkipMountingPartitions(fstab); + return true; } @@ -687,6 +690,36 @@ bool ReadFstabFromDt(Fstab* fstab, bool log) { return false; } + SkipMountingPartitions(fstab); + + return true; +} + +// For GSI to skip mounting /product and /product_services, until there are +// well-defined interfaces between them and /system. Otherwise, the GSI flashed +// on /system might not be able to work with /product and /product_services. +// When they're skipped here, /system/product and /system/product_services in +// GSI will be used. +bool SkipMountingPartitions(Fstab* fstab) { + constexpr const char kSkipMountConfig[] = "/system/etc/init/config/skip_mount.cfg"; + + std::string skip_config; + if (!ReadFileToString(kSkipMountConfig, &skip_config)) { + return true; + } + + for (const auto& skip_mount_point : Split(skip_config, "\n")) { + if (skip_mount_point.empty()) { + continue; + } + auto it = std::remove_if(fstab->begin(), fstab->end(), + [&skip_mount_point](const auto& entry) { + return entry.mount_point == skip_mount_point; + }); + fstab->erase(it, fstab->end()); + LOG(INFO) << "Skip mounting partition: " << skip_mount_point; + } + return true; } diff --git a/fs_mgr/include_fstab/fstab/fstab.h b/fs_mgr/include_fstab/fstab/fstab.h index 88da41deb..d7afed654 100644 --- a/fs_mgr/include_fstab/fstab/fstab.h +++ b/fs_mgr/include_fstab/fstab/fstab.h @@ -99,6 +99,7 @@ using Fstab = std::vector<FstabEntry>; bool ReadFstabFromFile(const std::string& path, Fstab* fstab); bool ReadFstabFromDt(Fstab* fstab, bool log = true); bool ReadDefaultFstab(Fstab* fstab); +bool SkipMountingPartitions(Fstab* fstab); FstabEntry* GetEntryForMountPoint(Fstab* fstab, const std::string& path); |