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
This commit is contained in:
Mark Salyzyn 2019-01-22 14:05:32 -08:00
parent c11f8e55b1
commit 89b88b4e2d

View file

@ -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,8 +829,9 @@ 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);
}
}
}
}