Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7783a98 authored by Yi-Yo Chiang's avatar Yi-Yo Chiang
Browse files

fs_mgr: Add fs_mgr_flag overlayfs_remove_missing_lowerdir

If this flag is given, then fs_mgr_mount_overlayfs_fstab_entry() shall
filter out missing directories in the lowerdir= list.

For example,

  test /mnt/vendor/overlay_test overlay \
    ro,lowerdir=/dir1:/dir2:/missing_dir3 \
    first_stage_mount,overlayfs_remove_missing_lowerdir

should mount the overlayfs device with "lowerdir=/dir1:/dir2".

Bug: 186342252
Test: Manual boot test with modified fstab on CF
Change-Id: Id06b37d0c236528cef981e495280b4f4e9c2b4bb
parent d6ddc20d
Loading
Loading
Loading
Loading
+18 −1
Original line number Original line Diff line number Diff line
@@ -2322,7 +2322,24 @@ bool fs_mgr_mount_overlayfs_fstab_entry(const FstabEntry& entry) {
        return false;
        return false;
    }
    }


    auto options = "lowerdir=" + entry.lowerdir;
    auto lowerdir = entry.lowerdir;
    if (entry.fs_mgr_flags.overlayfs_remove_missing_lowerdir) {
        bool removed_any = false;
        std::vector<std::string> lowerdirs;
        for (const auto& dir : android::base::Split(entry.lowerdir, ":")) {
            if (access(dir.c_str(), F_OK)) {
                PWARNING << __FUNCTION__ << "(): remove missing lowerdir '" << dir << "'";
                removed_any = true;
            } else {
                lowerdirs.push_back(dir);
            }
        }
        if (removed_any) {
            lowerdir = android::base::Join(lowerdirs, ":");
        }
    }

    auto options = "lowerdir=" + lowerdir;
    if (overlayfs_valid_result == OverlayfsValidResult::kOverrideCredsRequired) {
    if (overlayfs_valid_result == OverlayfsValidResult::kOverrideCredsRequired) {
        options += ",override_creds=off";
        options += ",override_creds=off";
    }
    }
+1 −0
Original line number Original line Diff line number Diff line
@@ -181,6 +181,7 @@ void ParseFsMgrFlags(const std::string& flags, FstabEntry* entry) {
        CheckFlag("fsverity", fs_verity);
        CheckFlag("fsverity", fs_verity);
        CheckFlag("metadata_csum", ext_meta_csum);
        CheckFlag("metadata_csum", ext_meta_csum);
        CheckFlag("fscompress", fs_compress);
        CheckFlag("fscompress", fs_compress);
        CheckFlag("overlayfs_remove_missing_lowerdir", overlayfs_remove_missing_lowerdir);


#undef CheckFlag
#undef CheckFlag


+1 −0
Original line number Original line Diff line number Diff line
@@ -86,6 +86,7 @@ struct FstabEntry {
        bool fs_verity : 1;
        bool fs_verity : 1;
        bool ext_meta_csum : 1;
        bool ext_meta_csum : 1;
        bool fs_compress : 1;
        bool fs_compress : 1;
        bool overlayfs_remove_missing_lowerdir : 1;
    } fs_mgr_flags = {};
    } fs_mgr_flags = {};


    bool is_encryptable() const {
    bool is_encryptable() const {