WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: snap2usb 5.x bug  (Read 2088 times)

Offline am

  • Newbie
  • *
  • Posts: 5
snap2usb 5.x bug
« on: August 21, 2014, 04:17:24 AM »
Hi there,

I've noticed some occasionally odd behaviour with snap2usb. On systems that have multiple vfat volumes, snap2usb will either report that the USB drive isn't mounted or else run without completing, despite the fact that a USB vfat volume is mounted.

Running snap2usb from a terminal, I've observed the following output, leading up to the bug:
+ blkid
+ grep sd[a-z]
+ grep+  ./drive_info
grep -c LABEL="PENDRIVE"
+ [ 0 -ne 0 ]
+ grep sdb ./drive_info
+ grep -c TYPE="ext[0-9]"
+ [ 0 -ne 0 ]
+ grep sdb ./drive_info+ grep -c TYPE="vfat"
+ [ 1 -ne 0 ]
+ grep TYPE="vfat" ./drive_info
+ grep -o sd[a-z][0-9]
+ usb_is=sda1
sdb1

After this point, with multiple devices set in $usb_is, things tend to go badly wrong, with multiple attempts to mount:

+ usb_is=sda1
sdb1
+ usb_type=Removable Drive
+ break
+ [ -n sda1
sdb1 ]
+ f_mount_test
+ grep -c sda1
sdb1 /etc/mtab
+ is_mounted=0
+ [ 0 -eq 0 ]
+ /bin/mount /dev/sda1 sdb1
mount: mounting /dev/sda1 on sdb1 failed: No such file or directory
+ f_mount_test
+ grep -c sda1
sdb1 /etc/mtab
+ is_mounted=0
+ [ 0 -eq 0 ]
+ /bin/mount /dev/sda1 sdb1
mount: mounting /dev/sda1 on sdb1 failed: No such file or directory
:
:

In the case above, sda1 contains a vfat volume on an internal HDD, sdb1 contains a vfat volume on a USB drive.

I propose the following patch, which seems to work in testing here with systems containing both single and multiple vfat volumes:

for i in $usb_drives; do
    if [ $(grep "$i" ./drive_info | grep -c LABEL=\"PENDRIVE\") -ne 0 ]; then
        usb_is=`grep LABEL=\"PENDRIVE\" ./drive_info | grep -o sd[a-z][0-9] `
        usb_type=PENDRIVE
        break
    elif [ $(grep "$i" ./drive_info | grep -c TYPE=\"ext[0-9]\") -ne 0 ]; then
        usb_is=`grep "$i" ./drive_info | grep -o sd[a-z][0-9] `
        usb_type="Removable Drive"
        break
    elif [ $(grep "$i" ./drive_info | grep -c TYPE=\"vfat\") -ne 0 ]; then
-       usb_is=`grep TYPE=\"vfat\" ./drive_info | grep -o sd[a-z][0-9] `
+       usb_is=`grep "$i" ./drive_info | grep -o sd[a-z][0-9] `
        usb_type="Removable Drive"
        break
    fi
done

Thanks!
Andy

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: snap2usb 5.x bug
« Reply #1 on: August 21, 2014, 10:21:22 AM »
Thanks Andy, will test the patch and advise.