From f0a936f08baa3af224589d4dd8639a7e2a25a173 Mon Sep 17 00:00:00 2001 From: remko Date: Thu, 20 Mar 2008 12:56:49 +0000 Subject: Alert properly when we have stale mounts left after interupting a tinybsd build. If we do not do this, we can accidentally remove critical files from directories like /lib (if mounted). PR: misc/121763 Submitted by: Richard Arends < richard at unixguru dot nl > MFC after: 3 days --- tools/tools/tinybsd/tinybsd | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/tools/tools/tinybsd/tinybsd b/tools/tools/tinybsd/tinybsd index 7f368bb..912a797 100755 --- a/tools/tools/tinybsd/tinybsd +++ b/tools/tools/tinybsd/tinybsd @@ -248,12 +248,20 @@ rotate_buidlog() { } remove_workdir() { - chflags -R noschg ${WORKDIR} - echo "${TS} Removing "${WORKDIR} - rm -rf ${WORKDIR} - echo "${TS} Removing Build Kernel Directory" - rm -rf /usr/obj/usr/src/sys/${KERNCONF} - echo "${TS} done." + # Before removing check if there is not a mount under $WORKDIR anymore + MOUNT_CHECK=`mount|egrep "on ${WORKDIR}"` + + if [ ! -z "${MOUNT_CHECK}" ]; then + echo "There are mounts under the workdir (${WORKDIR}). Please umount them before running this script" + exit 1 + else + chflags -R noschg ${WORKDIR} + echo "${TS} Removing "${WORKDIR} + rm -rf ${WORKDIR} + echo "${TS} Removing Build Kernel Directory" + rm -rf /usr/obj/usr/src/sys/${KERNCONF} + echo "${TS} done." + fi } -- cgit v1.1