summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorremko <remko@FreeBSD.org>2008-03-20 12:56:49 +0000
committerremko <remko@FreeBSD.org>2008-03-20 12:56:49 +0000
commitf0a936f08baa3af224589d4dd8639a7e2a25a173 (patch)
tree5c331d609cab619a3308ba4649e227fb8571d40e
parentc69ad0290e26f599bd79a92d1ad1ed33793187a7 (diff)
downloadFreeBSD-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
-rwxr-xr-xtools/tools/tinybsd/tinybsd20
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
}
OpenPOWER on IntegriCloud