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

Commit 89b88b4e authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

fs_mgr: overlayfs: validate that kernel supports scratch filesystem

Check for /sys/fs/<fs_type> existence to confirm kernel has
the file system type available.

Test: adb-remount-test.sh
Bug: 109821005
Bug: 123079041
Change-Id: Ic4388e2044bccea8b8edc7762d4ac9b3047206ac
parent c11f8e55
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -626,8 +626,8 @@ const std::string kMkExt4("/system/bin/mke2fs");

// Only a suggestion for _first_ try during mounting
std::string fs_mgr_overlayfs_scratch_mount_type() {
    if (!access(kMkF2fs.c_str(), X_OK)) return "f2fs";
    if (!access(kMkExt4.c_str(), X_OK)) return "ext4";
    if (!access(kMkF2fs.c_str(), X_OK) && fs_mgr_access("/sys/fs/f2fs")) return "f2fs";
    if (!access(kMkExt4.c_str(), X_OK) && fs_mgr_access("/sys/fs/ext4")) return "ext4";
    return "auto";
}

@@ -829,11 +829,12 @@ bool fs_mgr_overlayfs_mount_all(Fstab* fstab) {
                                                   true /* readonly */)) {
                    auto has_overlayfs_dir = fs_mgr_access(kScratchMountPoint + kOverlayTopDir);
                    fs_mgr_overlayfs_umount_scratch();
                    if (has_overlayfs_dir)
                    if (has_overlayfs_dir) {
                        fs_mgr_overlayfs_mount_scratch(scratch_device, mount_type);
                    }
                }
            }
        }
        if (fs_mgr_overlayfs_mount(mount_point)) ret = true;
    }
    return ret;