summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-11-24 16:37:29 +0100
committerDave Reisner <dreisner@archlinux.org>2012-11-26 02:08:57 +0100
commitb9d81a088ad0aa694b335118cf4ee70ad3ad1712 (patch)
tree33cd5a4d3b329e6b6da48a08c0ea8d1b055221a3
parentd64243de39f6d76edf8150b1d81d586345758fed (diff)
downloadmkinitcpio-b9d81a088ad0aa694b335118cf4ee70ad3ad1712.tar.gz
mkinitcpio-b9d81a088ad0aa694b335118cf4ee70ad3ad1712.tar.xz
shutdown: teardown loop devices only after umount
This still isn't really ideal, but attempting to detach loops while they're still mounted will definitely fail. Ideally, the loop device is in autoclear mode and dropping its refcount to 0 on umount will cause the backing file to be detached from the loop. Of course, this all gets way too complicated for userspace to handle when dealing with the sort of rat's nest of loop devices that ArchISO sets up. The kernel doesn't help us out here by populating things like holders/ and slaves/, but I'm not sure it could. Maybe there's a better way... Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-rw-r--r--shutdown12
1 files changed, 6 insertions, 6 deletions
diff --git a/shutdown b/shutdown
index dc293d4..b0934b7 100644
--- a/shutdown
+++ b/shutdown
@@ -75,12 +75,6 @@ fi
# chdir, so that we can avoid a lot of path chopping
cd /sys/class/block
-printf '%s\n' 'Detaching loop devices.'
-
-for loop in loop*/loop; do
- [ -e "$loop" ] && losetup -d "${loop%/loop}"
-done
-
printf '%s\n' "Unmounting all devices."
# unmount everything in /oldroot
@@ -99,6 +93,12 @@ END {
umount "$mount"
done
+printf '%s\n' 'Detaching loop devices.'
+
+for loop in loop*/loop; do
+ [ -e "$loop" ] && losetup -d "${loop%/loop}"
+done
+
printf '%s\n' "Disassembling stacked devices."
# iterate over devices with holders