From f1820a1b8df759249fac03f7586ee28eb82155ea Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Wed, 22 May 2024 12:02:42 -0500 Subject: image: ISO backend: Bail out on umount failure Only if the error is EBUSY - which implies there *is* a filesystem mounted at the specified path - we treat umount as an error and stop. This should prevent /dev from being erased host-side. --- image/backends/iso.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/image/backends/iso.cc b/image/backends/iso.cc index 00f5ae4..18dc23e 100644 --- a/image/backends/iso.cc +++ b/image/backends/iso.cc @@ -203,8 +203,12 @@ public: */ for(const std::string mount : {"dev", "proc", "sys"}) { const std::string path = this->ir_dir + "/target/" + mount; - if(::umount(path.c_str()) == EBUSY) { - run_command("umount", {"-R", path}); + if(::umount(path.c_str()) == -1) { + if(errno == EBUSY && + run_command("umount", {"-R", path}) != 0) { + output_error("CD backend", "could not umount " + path); + return FS_ERROR; + } } } fs::remove_all(this->ir_dir, ec); -- cgit v1.2.3-60-g2f50