Cleanup dangling mount on update_engine start
If update_engine crashed during postintall, the snapshotted partition
would still be mounted at /postinstall. Therefore cleanup on startup.
Test: th
Change-Id: Ieaa327422bd242231466eedcb1d274d239340847
diff --git a/payload_consumer/postinstall_runner_action.cc b/payload_consumer/postinstall_runner_action.cc
index e489dfc..a72462a 100644
--- a/payload_consumer/postinstall_runner_action.cc
+++ b/payload_consumer/postinstall_runner_action.cc
@@ -91,9 +91,17 @@
fs_mount_dir_ = temp_dir.value();
#endif // __ANDROID__
CHECK(!fs_mount_dir_.empty());
+ EnsureUnmounted();
LOG(INFO) << "postinstall mount point: " << fs_mount_dir_;
}
+void PostinstallRunnerAction::EnsureUnmounted() {
+ if (utils::IsMountpoint(fs_mount_dir_)) {
+ LOG(INFO) << "Found previously mounted filesystem at " << fs_mount_dir_;
+ utils::UnmountFilesystem(fs_mount_dir_);
+ }
+}
+
void PostinstallRunnerAction::PerformAction() {
CHECK(HasInputObject());
CHECK(boot_control_);
@@ -167,10 +175,7 @@
}
// Double check that the fs_mount_dir is not busy with a previous mounted
// filesystem from a previous crashed postinstall step.
- if (utils::IsMountpoint(fs_mount_dir_)) {
- LOG(INFO) << "Found previously mounted filesystem at " << fs_mount_dir_;
- utils::UnmountFilesystem(fs_mount_dir_);
- }
+ EnsureUnmounted();
#ifdef __ANDROID__
// In Chromium OS, the postinstall step is allowed to write to the block
diff --git a/payload_consumer/postinstall_runner_action.h b/payload_consumer/postinstall_runner_action.h
index 41be201..66721af 100644
--- a/payload_consumer/postinstall_runner_action.h
+++ b/payload_consumer/postinstall_runner_action.h
@@ -70,6 +70,7 @@
// exposed for testing purposes only
void SetMountDir(std::string dir) { fs_mount_dir_ = std::move(dir); }
+ void EnsureUnmounted();
void PerformPartitionPostinstall();
[[nodiscard]] bool MountPartition(