[PC-BSD Commits] r16409 - pcbsd/current/src-sh/pbi-manager
svn at pcbsd.org
svn at pcbsd.org
Sat Apr 14 13:53:30 PDT 2012
Author: kris
Date: 2012-04-14 20:53:30 +0000 (Sat, 14 Apr 2012)
New Revision: 16409
Modified:
pcbsd/current/src-sh/pbi-manager/pbi-manager
Log:
When doing a PBI removal, check if anything is mounted in the
PBI directory and try to umount it. If that fails bail, so we don't
end up destroying something we didn't mean to.
Modified: pcbsd/current/src-sh/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-sh/pbi-manager/pbi-manager 2012-04-14 10:43:47 UTC (rev 16408)
+++ pcbsd/current/src-sh/pbi-manager/pbi-manager 2012-04-14 20:53:30 UTC (rev 16409)
@@ -4147,6 +4147,31 @@
fi
}
+# Function to check the supplied $1 dir for any mounts before we
+# do a rm -rf
+umount_before_rm()
+{
+ if [ -z "${1}" ] ; then return 0 ; fi
+
+ local _ddir="$1"
+ echo "$_ddir" | rev | grep -q '^/'
+ if [ $? -ne 0 ] ; then
+ _ddir="${_ddir}/"
+ fi
+
+ mount | grep -q "on ${_ddir}"
+ if [ $? -ne 0 ] ; then return 0; fi
+
+ for i in `mount | grep "on ${_ddir}" | awk '{print $3}'`
+ do
+ umount -f ${i} >/dev/null 2>/dev/null
+ if [ $? -ne 0 ] ; then
+ exit_err "Could not umount ${i} before rm -rf, bailing!"
+ fi
+ done
+ return 0
+}
+
# Remove the pbi directory
remove_pbidir() {
if [ -z "${PBI_PROGDIRPATH}" ] ; then return 0 ; fi
@@ -4155,6 +4180,10 @@
if [ "$PBI_VERBOSE" = "YES" ] ; then
echo "Removing: ${PBI_PROGDIRPATH}"
fi
+
+ # Make sure we are unmounted
+ umount_before_rm "${PBI_PROGDIRPATH}"
+
rm -rf "${PBI_PROGDIRPATH}" >/dev/null 2>/dev/null
# Do we have leftovers?
More information about the Commits
mailing list