Merge "fs_mgr: overlayfs_mount_scratch don't write to system_other"
This commit is contained in:
commit
55c083901d
1 changed files with 18 additions and 7 deletions
|
@ -575,8 +575,14 @@ std::vector<std::string> fs_mgr_candidate_list(Fstab* fstab, const char* mount_p
|
|||
}
|
||||
|
||||
// Mount kScratchMountPoint
|
||||
bool fs_mgr_overlayfs_mount_scratch(const std::string& device_path, const std::string mnt_type) {
|
||||
if (!fs_mgr_rw_access(device_path)) return false;
|
||||
bool fs_mgr_overlayfs_mount_scratch(const std::string& device_path, const std::string mnt_type,
|
||||
bool readonly = false) {
|
||||
if (readonly) {
|
||||
if (!fs_mgr_access(device_path)) return false;
|
||||
} else {
|
||||
if (!fs_mgr_rw_access(device_path)) return false;
|
||||
}
|
||||
|
||||
if (setfscreatecon(kOverlayfsFileContext)) {
|
||||
PERROR << "setfscreatecon " << kOverlayfsFileContext;
|
||||
}
|
||||
|
@ -589,6 +595,7 @@ bool fs_mgr_overlayfs_mount_scratch(const std::string& device_path, const std::s
|
|||
entry.mount_point = kScratchMountPoint;
|
||||
entry.fs_type = mnt_type;
|
||||
entry.flags = MS_RELATIME;
|
||||
if (readonly) entry.flags |= MS_RDONLY;
|
||||
auto save_errno = errno;
|
||||
auto mounted = fs_mgr_do_mount_one(entry) == 0;
|
||||
if (!mounted) {
|
||||
|
@ -806,11 +813,15 @@ bool fs_mgr_overlayfs_mount_all(Fstab* fstab) {
|
|||
scratch_can_be_mounted = false;
|
||||
auto scratch_device = fs_mgr_overlayfs_scratch_device();
|
||||
if (fs_mgr_overlayfs_scratch_can_be_mounted(scratch_device) &&
|
||||
fs_mgr_wait_for_file(scratch_device, 10s) &&
|
||||
fs_mgr_overlayfs_mount_scratch(scratch_device,
|
||||
fs_mgr_overlayfs_scratch_mount_type()) &&
|
||||
!fs_mgr_access(kScratchMountPoint + kOverlayTopDir)) {
|
||||
fs_mgr_overlayfs_umount_scratch();
|
||||
fs_mgr_wait_for_file(scratch_device, 10s)) {
|
||||
const auto mount_type = fs_mgr_overlayfs_scratch_mount_type();
|
||||
if (fs_mgr_overlayfs_mount_scratch(scratch_device, mount_type,
|
||||
true /* readonly */)) {
|
||||
auto has_overlayfs_dir = fs_mgr_access(kScratchMountPoint + kOverlayTopDir);
|
||||
fs_mgr_overlayfs_umount_scratch();
|
||||
if (has_overlayfs_dir)
|
||||
fs_mgr_overlayfs_mount_scratch(scratch_device, mount_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fs_mgr_overlayfs_mount(mount_point)) ret = true;
|
||||
|
|
Loading…
Reference in a new issue