[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [PATCH] Unmount all mounts in chroot



Hello,

 I've attached a patch that looks for ${PWD}/chroot/ instead of just /chroot/. Kudos to kelmo for helping with the awk foo.

Cheers,

--
Cody A.W. Somerville
Software Systems Release Engineer
Foundations Team
Custom Engineering Solutions Group
Canonical OEM Services
Phone: +1-781-850-2087
Cell: +1-506-471-8402
Email: cody.somerville@canonical.com
diff --git a/functions/exit.sh b/functions/exit.sh
index 980d2d1..16dda8c 100755
--- a/functions/exit.sh
+++ b/functions/exit.sh
@@ -18,10 +18,10 @@ Exit ()
 	# Always exit true in case we are not able to unmount
 	# (e.g. due to running processes in chroot from user customizations)
 	Echo_message "Begin unmounting filesystems..."
-	umount chroot/dev/pts > /dev/null 2>&1 || true
-	umount chroot/proc > /dev/null 2>&1 || true
-	umount chroot/selinux > /dev/null 2>&1 || true
-	umount chroot/sys > /dev/null 2>&1 || true
+	for DIRECTORY in $(awk -v dir="${PWD}/chroot/" '$2 ~ dir { print $2 }' /proc/mounts | sort -r)
+	do
+		umount ${DIRECTORY} > /dev/null 2>&1 || true
+	done
 }
 
 Setup_cleanup ()

Reply to: