From 2a99f950ff3eb863c913a2bf25911933670c47de Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Wed, 22 May 2024 11:25:19 -0500 Subject: image: ISO backend: Recursively umount if busy If an image creation run is interrupted (i.e. ^C) and the target FSes aren't umounted, the ISO backend tries to umount them during creation. However, it doesn't recursively umount /dev or /sys, which leaves them mounted (with an EBUSY error). This leads to the fs::remove_all call clearing out /dev nodes, which has personally irked me many times. Now we retry with recursion when we hit EBUSY, so that this won't happen. --- image/backends/iso.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'image') diff --git a/image/backends/iso.cc b/image/backends/iso.cc index 52f0367..00f5ae4 100644 --- a/image/backends/iso.cc +++ b/image/backends/iso.cc @@ -203,7 +203,9 @@ public: */ for(const std::string mount : {"dev", "proc", "sys"}) { const std::string path = this->ir_dir + "/target/" + mount; - ::umount(path.c_str()); + if(::umount(path.c_str()) == EBUSY) { + run_command("umount", {"-R", path}); + } } fs::remove_all(this->ir_dir, ec); if(ec) { -- cgit v1.2.3-70-g09d2