From ecac1f3bd478a81a3a960d60ed7ebc4a99375dbe Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Wed, 3 Jun 2020 17:05:36 -0500 Subject: image: ISO: Try harder to umount before rm -rf --- image/backends/iso.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'image/backends/iso.cc') diff --git a/image/backends/iso.cc b/image/backends/iso.cc index 7dca2e1..eee9b5a 100644 --- a/image/backends/iso.cc +++ b/image/backends/iso.cc @@ -15,6 +15,8 @@ #include /* ifstream, ofstream */ #include +#include + #include "basic.hh" #include "hscript/util.hh" #include "util/filesystem.hh" @@ -182,15 +184,22 @@ public: } /* REQ: ISO.1 */ - /*if(fs::exists(this->ir_dir, ec)) { + if(fs::exists(this->ir_dir, ec)) { output_info("CD backend", "removing old IR tree", this->ir_dir); + /* try to umount first, just in case + * We don't care if the call fails. + */ + for(const std::string &mount : {"dev", "proc", "sys"}) { + const std::string path = this->ir_dir + "/target/" + mount; + ::umount(path.c_str()); + } fs::remove_all(this->ir_dir, ec); if(ec) { output_warning("CD backend", "could not remove IR tree", - ec.message());*/ + ec.message()); /* we can _try_ to proceed anyway... */ - //} - //} + } + } output_info("CD backend", "creating directory tree"); -- cgit v1.2.3-60-g2f50