From 0cba7afd67b6be89dc9d18e649934c4db900989b Mon Sep 17 00:00:00 2001 From: Yi-Yo Chiang Date: Fri, 23 Sep 2022 12:19:24 +0800 Subject: [PATCH] remount: Remove errno test & improve messaging of fs_mgr_overlayfs_mount_all * remount don't check errno after calling fs_mgr_overlayfs_mount_all() as we don't report error status through errno anymore. * fs_mgr_overlayfs_mount_all() returns false if any failure. * fs_mgr_overlayfs_mount_all() returns true if no overlayfs to mount or all overlayfs are either already mounted or mounted successfully. Bug: 241179247 Bug: 248295731 Test: Treehugger Change-Id: Ia9c7ac686f6538a9f5da7efc4cda6f28aff056f6 --- fs_mgr/fs_mgr_overlayfs.cpp | 10 +++++----- fs_mgr/fs_mgr_remount.cpp | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/fs_mgr/fs_mgr_overlayfs.cpp b/fs_mgr/fs_mgr_overlayfs.cpp index 1d5a04ba1..1d8a45225 100644 --- a/fs_mgr/fs_mgr_overlayfs.cpp +++ b/fs_mgr/fs_mgr_overlayfs.cpp @@ -1331,22 +1331,22 @@ static void TryMountScratch() { } bool fs_mgr_overlayfs_mount_all(Fstab* fstab) { - auto ret = false; - if (fs_mgr_overlayfs_invalid()) return ret; - + if (fs_mgr_overlayfs_invalid()) { + return false; + } + auto ret = true; auto scratch_can_be_mounted = true; for (const auto& entry : fs_mgr_overlayfs_candidate_list(*fstab)) { if (fs_mgr_is_verity_enabled(entry)) continue; auto mount_point = fs_mgr_mount_point(entry.mount_point); if (fs_mgr_overlayfs_already_mounted(mount_point)) { - ret = true; continue; } if (scratch_can_be_mounted) { scratch_can_be_mounted = false; TryMountScratch(); } - if (fs_mgr_overlayfs_mount(mount_point)) ret = true; + ret &= fs_mgr_overlayfs_mount(mount_point); } return ret; } diff --git a/fs_mgr/fs_mgr_remount.cpp b/fs_mgr/fs_mgr_remount.cpp index 2202fda4a..a78f9453b 100644 --- a/fs_mgr/fs_mgr_remount.cpp +++ b/fs_mgr/fs_mgr_remount.cpp @@ -451,10 +451,9 @@ static int do_remount(Fstab& fstab, const std::vector& partition_ar } // Mount overlayfs. - errno = 0; - if (!fs_mgr_overlayfs_mount_all(&partitions) && errno) { - PLOG(ERROR) << "Can not mount overlayfs for partitions"; - return BAD_OVERLAY; + if (!fs_mgr_overlayfs_mount_all(&partitions)) { + LOG(WARNING) << "Cannot mount overlayfs for some partitions"; + // Continue regardless to handle raw remount case. } // Get actual mounts _after_ overlayfs has been added.