Loading fs_mgr/fs_mgr_overlayfs.cpp +18 −7 Original line number Original line Diff line number Diff line Loading @@ -575,8 +575,14 @@ std::vector<std::string> fs_mgr_candidate_list(Fstab* fstab, const char* mount_p } } // Mount kScratchMountPoint // Mount kScratchMountPoint bool fs_mgr_overlayfs_mount_scratch(const std::string& device_path, const std::string mnt_type) { 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 (!fs_mgr_rw_access(device_path)) return false; } if (setfscreatecon(kOverlayfsFileContext)) { if (setfscreatecon(kOverlayfsFileContext)) { PERROR << "setfscreatecon " << kOverlayfsFileContext; PERROR << "setfscreatecon " << kOverlayfsFileContext; } } Loading @@ -589,6 +595,7 @@ bool fs_mgr_overlayfs_mount_scratch(const std::string& device_path, const std::s entry.mount_point = kScratchMountPoint; entry.mount_point = kScratchMountPoint; entry.fs_type = mnt_type; entry.fs_type = mnt_type; entry.flags = MS_RELATIME; entry.flags = MS_RELATIME; if (readonly) entry.flags |= MS_RDONLY; auto save_errno = errno; auto save_errno = errno; auto mounted = fs_mgr_do_mount_one(entry) == 0; auto mounted = fs_mgr_do_mount_one(entry) == 0; if (!mounted) { if (!mounted) { Loading Loading @@ -806,11 +813,15 @@ bool fs_mgr_overlayfs_mount_all(Fstab* fstab) { scratch_can_be_mounted = false; scratch_can_be_mounted = false; auto scratch_device = fs_mgr_overlayfs_scratch_device(); auto scratch_device = fs_mgr_overlayfs_scratch_device(); if (fs_mgr_overlayfs_scratch_can_be_mounted(scratch_device) && if (fs_mgr_overlayfs_scratch_can_be_mounted(scratch_device) && fs_mgr_wait_for_file(scratch_device, 10s) && fs_mgr_wait_for_file(scratch_device, 10s)) { fs_mgr_overlayfs_mount_scratch(scratch_device, const auto mount_type = fs_mgr_overlayfs_scratch_mount_type(); fs_mgr_overlayfs_scratch_mount_type()) && if (fs_mgr_overlayfs_mount_scratch(scratch_device, mount_type, !fs_mgr_access(kScratchMountPoint + kOverlayTopDir)) { true /* readonly */)) { auto has_overlayfs_dir = fs_mgr_access(kScratchMountPoint + kOverlayTopDir); fs_mgr_overlayfs_umount_scratch(); 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; if (fs_mgr_overlayfs_mount(mount_point)) ret = true; Loading Loading
fs_mgr/fs_mgr_overlayfs.cpp +18 −7 Original line number Original line Diff line number Diff line Loading @@ -575,8 +575,14 @@ std::vector<std::string> fs_mgr_candidate_list(Fstab* fstab, const char* mount_p } } // Mount kScratchMountPoint // Mount kScratchMountPoint bool fs_mgr_overlayfs_mount_scratch(const std::string& device_path, const std::string mnt_type) { 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 (!fs_mgr_rw_access(device_path)) return false; } if (setfscreatecon(kOverlayfsFileContext)) { if (setfscreatecon(kOverlayfsFileContext)) { PERROR << "setfscreatecon " << kOverlayfsFileContext; PERROR << "setfscreatecon " << kOverlayfsFileContext; } } Loading @@ -589,6 +595,7 @@ bool fs_mgr_overlayfs_mount_scratch(const std::string& device_path, const std::s entry.mount_point = kScratchMountPoint; entry.mount_point = kScratchMountPoint; entry.fs_type = mnt_type; entry.fs_type = mnt_type; entry.flags = MS_RELATIME; entry.flags = MS_RELATIME; if (readonly) entry.flags |= MS_RDONLY; auto save_errno = errno; auto save_errno = errno; auto mounted = fs_mgr_do_mount_one(entry) == 0; auto mounted = fs_mgr_do_mount_one(entry) == 0; if (!mounted) { if (!mounted) { Loading Loading @@ -806,11 +813,15 @@ bool fs_mgr_overlayfs_mount_all(Fstab* fstab) { scratch_can_be_mounted = false; scratch_can_be_mounted = false; auto scratch_device = fs_mgr_overlayfs_scratch_device(); auto scratch_device = fs_mgr_overlayfs_scratch_device(); if (fs_mgr_overlayfs_scratch_can_be_mounted(scratch_device) && if (fs_mgr_overlayfs_scratch_can_be_mounted(scratch_device) && fs_mgr_wait_for_file(scratch_device, 10s) && fs_mgr_wait_for_file(scratch_device, 10s)) { fs_mgr_overlayfs_mount_scratch(scratch_device, const auto mount_type = fs_mgr_overlayfs_scratch_mount_type(); fs_mgr_overlayfs_scratch_mount_type()) && if (fs_mgr_overlayfs_mount_scratch(scratch_device, mount_type, !fs_mgr_access(kScratchMountPoint + kOverlayTopDir)) { true /* readonly */)) { auto has_overlayfs_dir = fs_mgr_access(kScratchMountPoint + kOverlayTopDir); fs_mgr_overlayfs_umount_scratch(); 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; if (fs_mgr_overlayfs_mount(mount_point)) ret = true; Loading