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

Commit 22d31c2e authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

fs_mgr: overlay: device tree and system as root

fs_mgr_overlayfs_mount_all() should pick up /system even if device tree
does not specify / or /system.

Because of change where we pass fstab to fs_mgr_overlayfs_mount_all(),
/ (or rather /system) overlayfs mount got shifted to early init and
did not occur in first stage init. We need the assumption that /
mount is implied when not specified in the dt fstab to be considered
by overlayfs logic.

Test: manual
Bug: 109821005
Bug: 115751838
Change-Id: Ia8fc5d8e8cc50c66197a91efa80e46d66c2d108d
parent a535e5a6
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -219,6 +219,15 @@ bool fs_mgr_overlayfs_already_mounted(const std::string& mount_point) {
    return false;
}

bool fs_mgr_overlayfs_verity_enabled(const std::string& basename_mount_point) {
    auto found = false;
    fs_mgr_update_verity_state(
            [&basename_mount_point, &found](fstab_rec*, const char* mount_point, int, int) {
                if (mount_point && (basename_mount_point == mount_point)) found = true;
            });
    return found;
}

bool fs_mgr_wants_overlayfs(const fstab_rec* fsrec) {
    if (!fsrec) return false;

@@ -242,14 +251,7 @@ bool fs_mgr_wants_overlayfs(const fstab_rec* fsrec) {

    if (!fs_mgr_overlayfs_enabled(fsrec)) return false;

    // Verity enabled?
    const auto basename_mount_point(android::base::Basename(fsrec_mount_point));
    auto found = false;
    fs_mgr_update_verity_state(
            [&basename_mount_point, &found](fstab_rec*, const char* mount_point, int, int) {
                if (mount_point && (basename_mount_point == mount_point)) found = true;
            });
    return !found;
    return !fs_mgr_overlayfs_verity_enabled(android::base::Basename(fsrec_mount_point));
}

bool fs_mgr_rm_all(const std::string& path, bool* change = nullptr) {
@@ -395,6 +397,15 @@ std::vector<std::string> fs_mgr_candidate_list(const fstab* fstab,
        }
        if (!duplicate_or_more_specific) mounts.emplace_back(new_mount_point);
    }
    // if not itemized /system or /, system as root, fake up
    // fs_mgr_wants_overlayfs evaluation of /system as candidate.

    if ((std::find(mounts.begin(), mounts.end(), "/system") == mounts.end()) &&
        !fs_mgr_get_entry_for_mount_point(const_cast<struct fstab*>(fstab), "/") &&
        !fs_mgr_get_entry_for_mount_point(const_cast<struct fstab*>(fstab), "/system") &&
        !fs_mgr_overlayfs_verity_enabled("system")) {
        mounts.emplace_back("/system");
    }
    return mounts;
}