summaryrefslogtreecommitdiffstats
path: root/Tools/portbuild
diff options
context:
space:
mode:
authorkris <kris@FreeBSD.org>2005-02-12 03:38:37 +0000
committerkris <kris@FreeBSD.org>2005-02-12 03:38:37 +0000
commita41a3ce9e00d6c398bb8cae2b4f2a1784d815bdb (patch)
tree7810695fb093fa5d3d501e9e5a0d08037914d36b /Tools/portbuild
parent22adbba73a0ba9b0934955cab641bd073be8f01f (diff)
downloadFreeBSD-ports-a41a3ce9e00d6c398bb8cae2b4f2a1784d815bdb.zip
FreeBSD-ports-a41a3ce9e00d6c398bb8cae2b4f2a1784d815bdb.tar.gz
Instead of using umount -f to unmount things, first use fstat to look for
processes holding open references within the FS and kill them, then use regular umount. This is necessary now that devfs cannot be force-unmounted, and has the benefit that processes can't hang around holding references to files between port builds.
Diffstat (limited to 'Tools/portbuild')
-rwxr-xr-xTools/portbuild/scripts/cleanup-chroots36
1 files changed, 35 insertions, 1 deletions
diff --git a/Tools/portbuild/scripts/cleanup-chroots b/Tools/portbuild/scripts/cleanup-chroots
index 421ef3e..4254318 100755
--- a/Tools/portbuild/scripts/cleanup-chroots
+++ b/Tools/portbuild/scripts/cleanup-chroots
@@ -5,6 +5,38 @@
# in 24 hours (corresponding to port builds that have timed out or shut down uncleanly)
# and prunes them to reclaim space.
+kill_procs()
+{
+ dir=$1
+
+ pids="XXX"
+ while [ ! -z "${pids}" ]; do
+ pids=$(fstat -f "$dir" | tail +2 | awk '{print $3}' | sort -u)
+ if [ ! -z "${pids}" ]; then
+ echo "Killing off pids in ${dir}"
+ ps -p $pids
+ kill -KILL ${pids} 2> /dev/null
+ sleep 2
+ fi
+ done
+}
+
+cleanup_mount() {
+ chroot=$1
+ mount=$2
+
+ if [ -d ${chroot}${mount} ]; then
+ mdir=$(fstat -f ${chroot}${mount} | head -2 | tail -1 | awk '{print $5}')
+ if [ "${mdir}" = "MOUNT" ]; then
+ umount ${chroot}${mount} || echo "Cleanup of ${chroot}${mount} failed!"
+ fi
+ if [ "${mdir}" = "${chroot}${mount}" ]; then
+ kill_procs ${chroot}${mount}
+ umount ${chroot}${mount} || echo "Cleanup of ${chroot}${mount} failed!"
+ fi
+ fi
+}
+
pb=/var/portbuild
arch=$(cat /etc/arch)
@@ -37,7 +69,9 @@ fi
for i in ${old2}; do
mounts=$(mount | grep $i | awk '{print $3}')
if [ ! -z "${mounts}" ]; then
- umount -f ${mounts}
+ for j in ${mounts}; do
+ umount ${j} || cleanup_mount ${j}
+ done
fi
done
OpenPOWER on IntegriCloud