Check-in [d8d8b428eb]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

SHA1 Hash:d8d8b428eb0538cb3bcc23293dde01bafad46fcb
Date: 2012-02-20 09:41:32
User: BarryK
Comment:npierce: bugfix /usr/sbin/filemnt, sfs files of same name

Tags And Properties
Changes

Changes to woof-code/rootfs-skeleton/usr/sbin/filemnt

@@ -8,10 +8,12 @@
 #101221 yaf-splash fix.
 #111016 fix for 3.x kernel.
 #111110 handle encrypted save-files.
 #111112 small fixes.
 #120201 rodin.s: internationalization.
+#120220 npierce: improved test and message for already mounted file, also prevent mkdir if file not found, and fix adding pwd prefix
+#120220 npierce: add slash to pwd prefix; exit on failed stat. refer: http://murga-linux.com/puppy/viewtopic.php?t=71767&start=450
 
 export TEXTDOMAIN=filemnt
 export OUTPUT_CHARSET=UTF-8
 . gettext.sh
 
@@ -36,13 +38,13 @@
   SFSMAJOR=4
  fi
 fi
 
  imgFile="$1"
- if [ -z "$imgFile" ] ;then exit 1 ;fi
- if [ "`dirname $imgFile`" = '\.' ] ;then
-  imgFile="`pwd``echo $imgFile |sed 's/^\.//'`"
+ if [ ! -f "$imgFile" ];then echo "No regular file: $imgFile";exit 1;fi #120220
+ if [ "`dirname $imgFile`" = '.' ] ;then                                #120220
+  imgFile="`pwd`/`echo $imgFile |sed 's/^\.//'`"                        #120220
  fi
  MntPt='/mnt/'`echo "$imgFile" |sed "s#^\.##g" |sed "s#/#+#g"`
 
 
 if [ 1 -eq 2 ] ;then	##############################################	JUMP OVER this SECTION.
@@ -63,22 +65,26 @@
 
 							### file's not mounted, mount it
 # if [ $i -eq 16 ] ;then
 
  imgFileBASE="`basename "$imgFile"`" #BK
+ imgFileDEV_INODE="`stat -L -c "%d_%i" "$imgFile"`" || exit #120220
 
  if [ ! -d "$MntPt" ] ;then
 
   #BK check if already mounted elsewhere...
   for ONELOOP in `mount | grep '^/dev/loop' | cut -f 1 -d ' ' | tr '\n' ' '`
   do
-   MNTDIMG="`losetup-FULL $ONELOOP | cut -f 2 -d '(' | cut -f 1 -d ')'`"
-    IMGBASE="`basename "$MNTDIMG"`"
-    #echo "IMGBASE=$IMGBASE imgFileBASE=$imgFileBASE" #TEST
-    #not perfect, but paths may be symlinks...
-    if [ "$IMGBASE" = "$imgFileBASE" ];then #if [ "$MNTDIMG" = "$imgFile" ];then
-     xmessage "`eval_gettext \"Sorry \\\$imgFile is already mounted and in-use by Puppy\"`"
+   MNTDIMG_MNT_PT="`mount | grep "^$ONELOOP" | cut -f 3 -d ' '`"   #120220...
+   MNTDIMG=""
+   [ "`echo $MNTDIMG_MNT_PT | cut -f 2 -d /`" = "initrd" ] && MNTDIMG="/initrd"
+   MNTDIMG="${MNTDIMG}`losetup-FULL $ONELOOP | cut -f 2 -d '(' | cut -f 1 -d ')'`"
+   MNTDIMG_DEV_INODE="`stat -L -c "%d_%i" "$MNTDIMG"`"             #120220
+   #not perfect, but paths may be symlinks...
+   if [ "$MNTDIMG_DEV_INODE" = "$imgFileDEV_INODE" ];then          #120220...
+    xmessage "Sorry $imgFile is already mounted and in-use by Puppy
+on $MNTDIMG_MNT_PT from $MNTDIMG"    #120220
      exit
     fi
   done
 
   Ext=`echo "$imgFile" |sed 's/^.*\.//'`	# get file type from extention