diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2024-05-22 12:02:42 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2024-10-04 10:43:49 -0500 |
commit | 771f9add609f139a08fddead97ced72a9ba302c2 (patch) | |
tree | 736390f11284754fc2c3ff51c09bc3ae3bc69df0 /image/backends | |
parent | 584ec96ab97804952faf419b4f290044dade03b3 (diff) | |
download | horizon-771f9add609f139a08fddead97ced72a9ba302c2.tar.gz horizon-771f9add609f139a08fddead97ced72a9ba302c2.tar.bz2 horizon-771f9add609f139a08fddead97ced72a9ba302c2.tar.xz horizon-771f9add609f139a08fddead97ced72a9ba302c2.zip |
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.
Diffstat (limited to 'image/backends')
-rw-r--r-- | image/backends/iso.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/image/backends/iso.cc b/image/backends/iso.cc index 00f5ae4..9be8029 100644 --- a/image/backends/iso.cc +++ b/image/backends/iso.cc @@ -203,8 +203,14 @@ 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 EBUSY, it will remain mounted when we fs::remove_all + * which will affect the host's environment. Bail out. */ + 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); |