diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 11:35:03 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 11:35:03 +0000 |
commit | 42682e6ca7f57100d2aac14c5570dee9d4455ab3 (patch) | |
tree | 21fc5afb06ab4fff333b121ead3c452b18b03f6b | |
parent | 9c4a7b0ed999118cb96ed6e22baeefb8adf51ee6 (diff) | |
parent | 5d4c782b1fedfbf339e7e8a3b5547dd5b29a9526 (diff) | |
download | core-aml_adb_340912350.tar.gz |
Snap for 10453938 from 5d4c782b1fedfbf339e7e8a3b5547dd5b29a9526 to mainline-adbd-releaseaml_adb_340912530aml_adb_340912350aml_adb_340912200aml_adb_340912000android14-mainline-adbd-release
Change-Id: I1750150c93b3fe718829c8b56b34ce5657703141
-rw-r--r-- | fs_mgr/fs_mgr_fstab.cpp | 35 | ||||
-rw-r--r-- | fs_mgr/include_fstab/fstab/fstab.h | 1 |
2 files changed, 25 insertions, 11 deletions
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp index 598a3d2ec..da9e45f4e 100644 --- a/fs_mgr/fs_mgr_fstab.cpp +++ b/fs_mgr/fs_mgr_fstab.cpp @@ -51,6 +51,7 @@ namespace fs_mgr { namespace { constexpr char kDefaultAndroidDtDir[] = "/proc/device-tree/firmware/android"; +constexpr char kProcMountsPath[] = "/proc/mounts"; struct FlagList { const char *name; @@ -697,9 +698,7 @@ void EnableMandatoryFlags(Fstab* fstab) { } } -bool ReadFstabFromFile(const std::string& path, Fstab* fstab_out) { - const bool is_proc_mounts = (path == "/proc/mounts"); - +static bool ReadFstabFromFileCommon(const std::string& path, Fstab* fstab_out) { std::string fstab_str; if (!android::base::ReadFileToString(path, &fstab_str, /* follow_symlinks = */ true)) { PERROR << __FUNCTION__ << "(): failed to read file: '" << path << "'"; @@ -707,11 +706,22 @@ bool ReadFstabFromFile(const std::string& path, Fstab* fstab_out) { } Fstab fstab; - if (!ParseFstabFromString(fstab_str, is_proc_mounts, &fstab)) { + if (!ParseFstabFromString(fstab_str, path == kProcMountsPath, &fstab)) { LERROR << __FUNCTION__ << "(): failed to load fstab from : '" << path << "'"; return false; } - if (!is_proc_mounts) { + + EnableMandatoryFlags(&fstab); + + *fstab_out = std::move(fstab); + return true; +} + +bool ReadFstabFromFile(const std::string& path, Fstab* fstab) { + if (!ReadFstabFromFileCommon(path, fstab)) { + return false; + } + if (path != kProcMountsPath) { if (!access(android::gsi::kGsiBootedIndicatorFile, F_OK)) { std::string dsu_slot; if (!android::gsi::GetActiveDsu(&dsu_slot)) { @@ -723,20 +733,23 @@ bool ReadFstabFromFile(const std::string& path, Fstab* fstab_out) { PERROR << __FUNCTION__ << "(): failed to read DSU LP names"; return false; } - TransformFstabForDsu(&fstab, dsu_slot, Split(lp_names, ",")); + TransformFstabForDsu(fstab, dsu_slot, Split(lp_names, ",")); } else if (errno != ENOENT) { PERROR << __FUNCTION__ << "(): failed to access() DSU booted indicator"; return false; } - } - - SkipMountingPartitions(&fstab, false /* verbose */); - EnableMandatoryFlags(&fstab); - *fstab_out = std::move(fstab); + SkipMountingPartitions(fstab, false /* verbose */); + } return true; } +bool ReadFstabFromProcMounts(Fstab* fstab) { + // Don't call `ReadFstabFromFile` because the code for `path != kProcMountsPath` has an extra + // code size cost, even if it's never executed. + return ReadFstabFromFileCommon(kProcMountsPath, fstab); +} + // Returns fstab entries parsed from the device tree if they exist bool ReadFstabFromDt(Fstab* fstab, bool verbose) { std::string fstab_buf = ReadFstabFromDt(); diff --git a/fs_mgr/include_fstab/fstab/fstab.h b/fs_mgr/include_fstab/fstab/fstab.h index a914b53bb..9cb1546c5 100644 --- a/fs_mgr/include_fstab/fstab/fstab.h +++ b/fs_mgr/include_fstab/fstab/fstab.h @@ -101,6 +101,7 @@ std::string GetFstabPath(); bool SkipMountWithConfig(const std::string& skip_config, Fstab* fstab, bool verbose); bool ReadFstabFromFile(const std::string& path, Fstab* fstab); +bool ReadFstabFromProcMounts(Fstab* fstab); bool ReadFstabFromDt(Fstab* fstab, bool verbose = true); bool ReadDefaultFstab(Fstab* fstab); bool SkipMountingPartitions(Fstab* fstab, bool verbose = false); |