diff options
author | remko <remko@FreeBSD.org> | 2008-03-20 12:56:49 +0000 |
---|---|---|
committer | remko <remko@FreeBSD.org> | 2008-03-20 12:56:49 +0000 |
commit | f0a936f08baa3af224589d4dd8639a7e2a25a173 (patch) | |
tree | 5c331d609cab619a3308ba4649e227fb8571d40e /tools | |
parent | c69ad0290e26f599bd79a92d1ad1ed33793187a7 (diff) | |
download | FreeBSD-src-f0a936f08baa3af224589d4dd8639a7e2a25a173.zip FreeBSD-src-f0a936f08baa3af224589d4dd8639a7e2a25a173.tar.gz |
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
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/tools/tinybsd/tinybsd | 20 |
1 files changed, 14 insertions, 6 deletions
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 } |