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

[PATCH] Unmount all mounts in chroot



Hello,

 As discussed on IRC earlier, here is a patch that removes the hard coded calls to umount in functions/exit.sh and instead looks at /proc/mounts to determine all active mounts within a chroot and attempts to umount each one.

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
From abb0aed5040a76ab9fd3db0693a953b7ee9bb830 Mon Sep 17 00:00:00 2001
From: Cody A.W. Somerville <cody.somerville@canonical.com>
Date: Wed, 15 Apr 2009 20:25:36 -0300
Subject: [PATCH] Replaced hard coded umounts in functions/exit.sh with smarter code that iterates over all the mounts in the chroot umounting each one.

---
 functions/exit.sh |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/functions/exit.sh b/functions/exit.sh
index 980d2d1..f593d3a 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 $(grep "${PWD}/chroot/" /proc/mounts | awk '{ print $2 }')
+	do
+		umount ${DIRECTORY} > /dev/null 2>&1 || true
+	done
 }
 
 Setup_cleanup ()
-- 
1.6.0.4


Reply to: