udev-151: mount.sh: Now using dirsync and label names (if possible).
authorMichael Mrozek <EvilDragon@openpandora.de>
Sun, 20 Jun 2010 23:37:17 +0000 (01:37 +0200)
committerDavid-John Willis <John.Willis@Distant-earth.com>
Mon, 4 Apr 2011 19:15:44 +0000 (20:15 +0100)
recipes/udev/udev-151/omap3-pandora/mount.sh [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 7ba2b3f..5f20c85
@@ -8,7 +8,10 @@
 MOUNT="/bin/mount"
 PMOUNT="/usr/bin/pmount"
 UMOUNT="/bin/umount"
+blkid="/usr/sbin/blkid"
 name="`basename "$DEVNAME"`"
+name2="`$blkid "$DEVNAME" -o value -s LABEL`"
+name3=$(echo $DEVNAME | sed 's/.*dev.//g')
 
 for line in `cat /etc/udev/mount.blacklist | grep -v ^#`
 do
@@ -20,16 +23,25 @@ do
 done
 
 automount() {  
+       if [ -n "$name2" ] 
+       then
+               c=1
+               while ( cat /proc/mounts | grep "/media/$name2" ); do
+                       name2="$name2-$c"
+                       c=$(expr $c + 1)
+               done
+               name="$name2"
+       fi
        ! test -d "/media/$name" && mkdir -p "/media/$name"
        
-       if ! $MOUNT -t auto -o sync,noatime,umask=0 $DEVNAME "/media/$name" && \
-                       ! $MOUNT -t auto -o sync,noatime $DEVNAME "/media/$name"
+       if ! $MOUNT -t auto -o dirsync,noatime,umask=0 $DEVNAME "/media/$name" && ! $MOUNT -t auto -o dirsync,noatime $DEVNAME "/media/$name"
        then
                #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/media/$name\" failed!"
                rm_dir "/media/$name"
        else
                logger "mount.sh/automount" "Auto-mount of [/media/$name] successful"
-               touch "/tmp/.automount-$name"
+               touch "/tmp/.automount-$name3"
+               echo $name3 > /tmp/test
        fi
 }
        
@@ -65,10 +77,12 @@ if [ "$ACTION" = "remove" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then
        do
                # 20100306: Remove the mount point forcibly (Lazy) as the user has already removed the device by the 
                # DJWillis: time this fires so any handles are bad anyway. This should stop 'stale' folders being
-               #           left around all the time.
-               $UMOUNT -l $mnt
+               #           left around all the time. | cut -d ' ' -f 2 | sed 's/\\040/ /g'
+               mnt2=$(echo $mnt | sed 's/\\040/ /g')
+               $UMOUNT -l "$mnt2"
        done
        
        # Remove empty directories from auto-mounter
-       test -e "/tmp/.automount-$name" && rm_dir "/media/$name"
+       
+       test -e "/tmp/.automount-$name3" && rm_dir "$mnt2"
 fi