Check-in [c2d6e84dff]
Not logged in

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

Overview

SHA1 Hash:c2d6e84dff8dae49b87e936c56f122bf01c2d1f5
Date: 2012-05-16 02:13:49
User: BarryK
Comment:fixed old bug: EventManager can set automounting, but it was not working

Tags And Properties
Changes

Changes to woof-code/rootfs-skeleton/usr/local/bin/drive_all

@@ -30,10 +30,11 @@
 #110720 should not open a layer inside aufs, ex: session saved entire partition, desktop drive icon is /initrd/pup_rw.
 #110721 detect if have clicked on a close-box of mounted partition.
 #120110 running as fido, popup password box changes mouse pointer position, need read before run sudo.
 #120129 karl godt: fix ZOMBIES, see http://murga-linux.com/puppy/viewtopic.php?t=71767&start=420. see also rc.shutdown, pmount, pup_event_frontend_d.
 #120323 partial replace 'xmessage' with 'pupmessage'.
+#120516 pup_event_frontend_d may call here when a drive plugged in, fix handling of automounting.
 
 [ ! -f /tmp/desktop_drives_curpos ] && getcurpos > /tmp/desktop_drives_curpos #120110
 [ "`whoami`" != "root" ] && exec sudo -A ${0} ${@} #110505
 CURPOS="`cat /tmp/desktop_drives_curpos`" #120110
 rm -f /tmp/desktop_drives_curpos #120110
@@ -357,20 +358,35 @@
  fi
  FSTYPE="iso9660"
 fi
 
 #if dropped down here, it is likely to be a data partition...
+
+#120516 pup_event_frontend_d may call here when a drive plugged in, but only passes one parameter (PARAM1). want FSTYPE also...
+# also, for AUTOTARGET=true in /etc/eventmanager will come here, and a plugged in drive may be more than one partition to automount...
+if [ "$FSTYPE" != "" ];then
+ DOPARTS=${ONEDRVNAME}|${FSTYPE}
+else
+ #ONEDRVNAME is probably a drive name, ex sda...
+ pPTN="/dev/${ONEDRVNAME}" #no space on end!
+ DOPARTS="`probepart -m | grep "$pPTN" | cut -f 1,2 -d '|' | cut -f 3 -d '/' | grep -E 'ext2|ext3|ext4|udf|is09660|vfat|reiser|btrfs|ntfs|msdos|minix' | tr '\n' ' '`" #ex: sda1|ext3 sda2|vfat sda3|ext3
+fi
+
 #if it is a mountable partition then mount and open with rox. If already mntd then open in rox...
 #if [ "$ICONPARTITIONS" = "true" ];then
-if [ "$FSTYPE" != "" ];then
+EXITFLAG=no
+for ONEDO in $DOPARTS
+do
+ xONEDRVNAME="`echo -n "$ONEDO" | cut -f 1 -d '|'`"
+ xFSTYPE="`echo -n "$ONEDO" | cut -f 2 -d '|'`"
  if [ "`df | grep "$dPATTERN"`" = "" ];then
   #not mounted...
-  mkdir -p /mnt/$ONEDRVNAME
-  case $FSTYPE in
+  mkdir -p /mnt/$xONEDRVNAME
+  case $xFSTYPE in
    ntfs)
     #'mount' is a script that takes care of mounting ntfs...
-    mount -t ntfs /dev/$ONEDRVNAME /mnt/$ONEDRVNAME
+    mount -t ntfs /dev/$xONEDRVNAME /mnt/$xONEDRVNAME
     RETVAL1=$?
     ;;
    vfat)
     #w476 modify codepage and iocharset (note: this code also in /usr/sbin/pmount)...
     #note, could also set iocharset=iso8859-2 (default: codepage=437, iocharset=iso8859-1)
@@ -379,36 +395,37 @@
     if [ -f /etc/codepage ]; then #100127...
      grep -q -i '850' /etc/codepage && [ "$(echo $LANG|cut -d'.' -f1)" != "en_US" ] && NLS_PARAM=",codepage=850"
      grep -q -i '852' /etc/codepage && NLS_PARAM=",codepage=852,iocharset=iso8859-2"
     fi
     echo $LANG | grep -q -i '\.utf' && NLS_PARAM="$NLS_PARAM,utf8"
-    mount -t vfat -o shortname=mixed,quiet${NLS_PARAM} /dev/$ONEDRVNAME /mnt/$ONEDRVNAME #v411
+    mount -t vfat -o shortname=mixed,quiet${NLS_PARAM} /dev/$xONEDRVNAME /mnt/$xONEDRVNAME #v411
     RETVAL1=$?
     ;;
    #100127 not certain about this (inserted by shinobar)... 100131 shinobar informs needed for cds created in windows...
    iso9660)
-    mount -t $FSTYPE -o iocharset=utf8 /dev/$ONEDRVNAME /mnt/$ONEDRVNAME
+    mount -t $xFSTYPE -o iocharset=utf8 /dev/$xONEDRVNAME /mnt/$xONEDRVNAME
     RETVAL1=$?
     ;;
    *)
-    mount -t $FSTYPE /dev/$ONEDRVNAME /mnt/$ONEDRVNAME
+    mount -t $xFSTYPE /dev/$xONEDRVNAME /mnt/$xONEDRVNAME
     RETVAL1=$?
     ;;
   esac
   if [ $RETVAL1 -eq 0 ];then
-   exec rox -x /mnt/$ONEDRVNAME -d /mnt/$ONEDRVNAME
+   rox -x /mnt/$xONEDRVNAME -d /mnt/$xONEDRVNAME &
+   EXITFLAG=yes
   else
    #091223 why did it fail?
-   dd if=/dev/$ONEDRVNAME of=/dev/null bs=512 count=1 > /dev/null 2>&1
+   dd if=/dev/$xONEDRVNAME of=/dev/null bs=512 count=1 > /dev/null 2>&1
    if [ $? -ne 0 ];then
     #/tmp/pup_event_frontend_block_request is used in /sbin/pup_event_frontend_d to refresh drv...
-    case $ONEDRVNAME in
+    case $xONEDRVNAME in
      mmcblk*)
-      yONEDRV="`echo -n "$ONEDRVNAME" | cut -c 1-7`"
+      yONEDRV="`echo -n "$xONEDRVNAME" | cut -c 1-7`"
      ;;
      *)
-      yONEDRV="`echo -n "$ONEDRVNAME" | cut -c 1-3`"
+      yONEDRV="`echo -n "$xONEDRVNAME" | cut -c 1-3`"
      ;;
     esac
     echo "$yONEDRV" > /tmp/pup_event_frontend_block_request
    fi
   fi
@@ -422,15 +439,16 @@
   case $MNTPT in
    /initrd/pup_*)
     MNTPT="/" #open rox at top of aufs layers.
    ;;
   esac
-  #exec rox -x /mnt/$ONEDRVNAME -d /mnt/$ONEDRVNAME
-  exec rox -x $MNTPT -d $MNTPT
+  #exec rox -x /mnt/$xONEDRVNAME -d /mnt/$xONEDRVNAME
+  rox -x $MNTPT -d $MNTPT &
+  EXITFLAG=yes
  fi
-fi
-
+done
+[ "$EXITFLAG" = "yes" ] && exit
 
 #NOTE: if pmount already running, don't really want to kill then restart,
 # just want to bring the window up if it's minimised ...how?
 
 if [ "`pidof gtkdialog_pmount`" != "" ];then #if pmount running, kill it.