]> git.wh0rd.org Git - home.git/commitdiff
use /proc/mounts for better checking
authorMike Frysinger <vapier@gentoo.org>
Tue, 12 Jun 2012 14:17:00 +0000 (10:17 -0400)
committerMike Frysinger <vapier@gentoo.org>
Tue, 12 Jun 2012 14:17:00 +0000 (10:17 -0400)
.bin/umount-tree

index bcf866f2efd2ada9d489ca4d0181cb550f4e126e..340b61abb036c6d17f46f3b9069a8c9c910eeed6 100755 (executable)
@@ -1,17 +1,21 @@
 #!/bin/bash
 
-root=$1
 if [[ -z $1 ]] ; then
        echo "Usage: $0 <root>"
        exit 1
 fi
 
-mounts=$(mount | grep " on ${root%/}/" | awk '{print $3}' | tac)
+while [[ $# -gt 0 ]] ; do
+
+root=$1
+shift
+
+mounts=$(gawk -v p="${root%/}" '$2 ~ "^"p { print $2 }' /proc/mounts | tac)
 if [[ -z ${mounts} ]] ; then
        echo "No mounts found ..."
        echo
        mount
-       exit 0
+       continue
 fi
 
 echo "Unmounting: "
@@ -20,3 +24,5 @@ printf '\t%s\n' ${mounts}
 printf "OK? [y/N] "
 read v
 [[ ${v} == "y" ]] && sudo umount -v ${mounts}
+
+done