Easy Chroot 0.3.1
[easy-deb-chroot] / fremantle / easy-chroot / src / sbin / qmount
index f44d3db..12c808f 100755 (executable)
@@ -46,6 +46,13 @@ if [ "x$MNTPT" = "x" ] || [ "x`echo $MNTPT | grep '/'`" = "x"  ] ; then
   exit 9
 fi
 
+# Strip off a trailing slash
+LASTCHAR=`echo $MNTPT | cut -c ${#MNTPT}`
+if [ "$LASTCHAR" = "/" ] ; then
+   echo "..stripping trailing slash..." >/dev/stderr
+   MNTPT=`echo $MNTPT | cut -c 0-$((${#MNTPT}-1))`
+fi
+
 #Check to see if already mounted
 if [ -f "$MNTPT/var/lock/qmount-complete" ] ; then
   echo "$MNTPT has a qmount already!" >/dev/stderr
@@ -139,7 +146,7 @@ if [ ! -f "$MNTPT/var/lock/qmount-complete" ] ; then
        # use "regular" loop
 
        echo "mounting $IMGFILE on loop" >/dev/stderr
-       NEXTLOOP=""
+       NEXTLOOP=`mount | grep loop | tail -1 | awk '{print $1}' | awk -F "/" '{print $3}' | cut -c 5-6 | awk '{print $0+1}'`
        if [ "x$NEXTLOOP" = "x"  ] ; then
          NEXTLOOP=0
        fi