diff options
author | kris <kris@FreeBSD.org> | 2005-02-12 11:38:37 +0800 |
---|---|---|
committer | kris <kris@FreeBSD.org> | 2005-02-12 11:38:37 +0800 |
commit | a41a3ce9e00d6c398bb8cae2b4f2a1784d815bdb (patch) | |
tree | 7810695fb093fa5d3d501e9e5a0d08037914d36b | |
parent | 22adbba73a0ba9b0934955cab641bd073be8f01f (diff) | |
download | freebsd-ports-gnome-a41a3ce9e00d6c398bb8cae2b4f2a1784d815bdb.tar.gz freebsd-ports-gnome-a41a3ce9e00d6c398bb8cae2b4f2a1784d815bdb.tar.zst freebsd-ports-gnome-a41a3ce9e00d6c398bb8cae2b4f2a1784d815bdb.zip |
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.
-rwxr-xr-x | Tools/portbuild/scripts/cleanup-chroots | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/Tools/portbuild/scripts/cleanup-chroots b/Tools/portbuild/scripts/cleanup-chroots index 421ef3e84406..4254318c9e7f 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 |