212,213b USB flash names not retained in Pmount, Univ Inst

Please post any bugs you have found
Message
Author
User avatar
pakt
Posts: 1157
Joined: Sat 04 Jun 2005, 16:54
Location: Sweden

#46 Post by pakt »

pakt wrote:Ineresting to see what happens when using 'stock' 2.13b2 pmount with plinej's probedisk:

pmount reports correctly:
sda 'SanDisk' drive /dev/sda1
sdb 'USB 2.0' /dev/sdb1

Pulled 'SanDisk', now pmount doesn't report *any* USB drive.

Plugged 'SanDisk' back in, pmount reports both USB drives exactly as before.

Pulled 'USB 2.0', pmount correctly reports the SanDisk sda drive.

Seems like pmount stops looking for USB drives if it can't find sda.

Paul
Okay, I got another clue here. It's probepart that reports both USB drives gone when only sda is pulled out!

When I plug sda back in, probepart again reports both drives as present. :roll:
Methinks Raspberry Pi were ideal for runnin' Puppy Linux

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#47 Post by plinej »

I see the problem when there is no /dev/sda but there is a /dev/sdb (or c, d, e, whatever). That problem lies in probepart. If it doesn't see sda it won't look further. I'll compile that latest cvs of libhardware and see if it works any better, otherwise we'll have to work on more wrapper scripts or something.

--edit--

posted before I saw pakt's comment.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#48 Post by plinej »

Nope, the cvs version is corrupt too. Both probedisk and probepart have the same problems as the normal puppy version. I'll see if I can think up a wrapper script for probepart too.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#49 Post by plinej »

I figured out a better way to make a wrapper script for probedisk using cdrecord -scanbus. I did alot of messing with it and it appears to list the drives in order so getting the brand/model information seems more reliable that way and not to mention made my script much smaller. I also just finished up a wrapper script for probepart. I made a dotpup package with dougal and my updates to pmount and my probedisk/probepart modifications. The package contains the three mentioned files and also the original probedisk and probepart renamed to probedisk2 and probepart2. Give it a try and let me know if it works.

--edit--

had to add a cross reference with /var/log/messages to verify correct device found from cdrecord -scanbus since they don't always print in order.

--edit--

removed this version and posted another furthur down
Last edited by plinej on Wed 03 Jan 2007, 02:48, edited 6 times in total.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#50 Post by plinej »

Here's my probedisk script:

Code: Select all

#!/bin/sh

### wrapper script to fix probedisk issues with usb drives

if [ -d /tmp/probedisk ]; then
rm -r /tmp/probedisk
fi
if [ -f /tmp/probedisk ]; then
rm -f /tmp/probedisk
fi

if [ "`cat /proc/partitions | grep sd`" != "" ]; then
mkdir /tmp/probedisk
cat /proc/partitions | grep sd | sed -e 's/[0-9]//g' | sed -e 's/ //g' | sort -u > /tmp/probedisk/usbdevices  ### get current existing usb device names
cdrecord -scanbus 2>/dev/null | grep Disk > /tmp/probedisk/scanbus
START=1
cat /tmp/probedisk/usbdevices | while read DEV
do
BRAND=`cat /tmp/probedisk/scanbus | sed -n ""$START"p" | cut -f 2 -d "'" | tr -s ' '`
MODEL=`cat /tmp/probedisk/scanbus | sed -n ""$START"p" | cut -f 4 -d "'" | tr -s ' '`
if [ "`cat /var/log/messages | grep "$MODEL"`" != "" ]; then
NUMLINES="`cat /var/log/messages | grep "$MODEL" -A 2 | grep -v Direct-Access | grep -v "$MODEL" | wc -l | sed -e 's/ *//' | sed -e 's/ .*//g'`"
DEV2="`cat /var/log/messages | grep "$MODEL" -A 2 | grep -v Direct-Access | grep -v "$MODEL" | cut -f 4 -d ':' | sed -e 's/SCSI//g' | sed -e 's/device//g' | sed -e 's/ //g' | sed -n ""$NUMLINES"p" | grep sd`"
if [ "$DEV2" != "" ]; then
DEV="$DEV2"
fi
fi
echo \/dev\/"$DEV"\|Direct-Access\|"$BRAND""$MODEL" >> /tmp/probedisk/probedisk  ### reorganize to output how original probedisk outputs
START=`expr "$START" + 1`
done
cat /tmp/probedisk/probedisk | sort -u > /tmp/probedisk/probedisk
fi

probedisk2 2>/dev/null | grep -v '/dev/sd'
if [ -f /tmp/probedisk/probedisk ]; then
cat /tmp/probedisk/probedisk
fi

rm -r /tmp/probedisk
probepart:

Code: Select all

#!/bin/sh

### wrapper script to fix probepart issues with usb drives

if [ "`cat /proc/partitions | grep sd`" != "" ]; then

if [ -d /tmp/probepart ]; then
rm -r /tmp/probepart
fi
if [ -f /tmp/probepart ]; then
rm -f /tmp/probepart
fi
mkdir /tmp/probepart
mkdir /tmp/probepart/mnt

cat /proc/partitions | grep sd | tr -s ' ' | sed -e 's/ /\|/g' | cut -f 5 -d '|' | grep [0-9] | sort -u > /tmp/probepart/usbdevices

cat /tmp/probepart/usbdevices | sed -e 's/[0-9]//g' | sort -u | while read DEV2
do
fdisk -l /dev/"$DEV2" > /tmp/probepart/probeparttemp
cat /tmp/probepart/probeparttemp | grep -v bytes | grep -v cylinders | grep -v Blocks | sed -e 's/\*//g' | sed -e 's/\+//g' | tr -s ' ' | sed '/^$/d' | sed -e 's/ /\|/g' >> /tmp/probepart/probepart2
done

cat /tmp/probepart/usbdevices | while read DEV
do
if [ "`cat /etc/mtab | grep /dev/"$DEV"`" = "" ]; then
mount /dev/"$DEV" /tmp/probepart/mnt >/dev/null
touch /tmp/probepart/tempmount
fi
SIZE=`cat /proc/partitions | grep "$DEV" | tr -s ' ' | sed -e 's/ /\|/g' | cut -f 4 -d '|'`
SIZE2=`echo "(( "$SIZE" * 2 ))" | bc -l`
if [ "$1" = -m ]; then
SIZE2=`echo "(( "$SIZE2" / 2048.12749 ))" | bc -l | cut -f 1 -d '.'`
fi
TYPE=`cat /etc/mtab | grep /dev/"$DEV" | cut -f 3 -d ' '`
if [ "$TYPE" = "" ]; then
TYPE=`cat /tmp/probepart/probepart2 | grep "$DEV" | cut -f 6 -d '|'`
fi
echo \/dev\/"$DEV"\|`echo "$TYPE"`\|`echo "$SIZE2"`\|`cat /tmp/probepart/probepart2 | grep "$DEV" | cut -f 6 -d '|'` >> /tmp/probepart/probepart
if [ -f /tmp/probepart/tempmount ]; then
umount /tmp/probepart/mnt >/dev/null
rm -f /tmp/probepart/tempmount
fi
done
fi

probepart2 2>/dev/null | grep -v '/dev/sd'
if [ -f /tmp/probepart/probepart ]; then
cat /tmp/probepart/probepart
fi
rm -r /tmp/probepart
Last edited by plinej on Tue 02 Jan 2007, 16:46, edited 1 time in total.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#51 Post by plinej »

found a potential problem in the propepart script so I modified a line and re-uploaded the dotpup.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#52 Post by plinej »

nope, looks like cdrecord -scanbus isn't going to work. I'll have to do some more modifying.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#53 Post by plinej »

Okay, re-uploaded again. This time probedisk still uses cdrecord -scanbus to get the brand and model information but it cross references the device info with /var/log/messages if the model is found within in the log. I would just use /proc/scsi/scsi but I have a usb drive that shows up in there three times for some reason where cdrecord -scanbus shows it correctly.

PaulBx1
Posts: 2312
Joined: Sat 17 Jun 2006, 03:11
Location: Wyoming, USA

#54 Post by PaulBx1 »

Looks like I missed some fun.

One factor which MAY have some bearing on my case is that my PC is an old, slow laptop with a hub off a USB 1.1 bus. Maybe timing is an issue. However looks like this is a pretty general issue.

I too saw both flash "disappear" (according to pmount) when pulling sda...

Antonio got back to me; the email is on my laptop so I can't report exactly what he said, however IIRC he said (approximately) that he never intended probedisk/probepart to work with hot-pluggable devices, and also that he was not interested in fixing it to work with them. So I guess we're on our own...

gn2 mentioned udev on another thread, a standard way to deal with such devices, I wondered if that is somehow implemented in Puppy? I guess not, since we have to fiddle with using the logs to figure out what is what. Maybe udev is too big? On the other hand, my concern about the logs being non-deterministic may be exaggerated since it is a one-user system. Although it is not the cleanest implementation, maybe it's "good enough for government work". :lol: Anyway once this is cleaned up I think all those applications that use probedisk/probepart will be a lot more solid, a good thing.
I would just use /proc/scsi/scsi but I have a usb drive that shows up in there three times for some reason
Use "uniq"? A bit strange that there is not a way in /proc/... to connect a device name like /dev/sda with a device description. Maybe that is what udev does?

I'm going to be on the road for a few days, will check back in as soon as I can.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#55 Post by plinej »

Yeah I thought of using uniq but the lines are a bit different even though it's the same device. It's just easier to use cdrecord -scanbus since it will report all devices it finds and will do so only once. The problem is that the only place that I can find in the system files that reports the brand/model & the actual device (sda) is /var/log/messages. /proc/scsi/scsi doesn't list the device and they aren't listed in order so it's impossible to just get the needed information from there. I think this bit of code I came up with should work pretty good. I have also seen MUT lose the Model information of a drive in all my testing over the last few days. My probepart wrapper script I believe should take care of the problem in regards to pulling sda and pmount doesn't see any of the other devices. In my testing I've done it seems to have fixed this problem and I think that code should be very good in finding all devices.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#56 Post by plinej »

I found a little cli utility called sg_map that could be just what we need to use as a wrapper to probedisk that should be more reliable than using my probedisk script. Here's what it outputs:

Code: Select all

sh-3.00# sg_map -i
/dev/sg0  /dev/scd0  LITE-ON   DVDRW SHW-1635S   YS0N
/dev/sg1  /dev/sda  WD        1600JB External   0107
/dev/sg2  /dev/sdb  GENERIC   USB Storage-CFC   010D
/dev/sg3  /dev/sdc  GENERIC   USB Storage-MMC   010D
/dev/sg4  /dev/sdd  GENERIC   USB Storage-MSC   010D
/dev/sg5  /dev/sde  JetFlash  TS1GJF110         0.00
I'll work on making a script to utilize this tool but I would think this may be exactly what we need for a reliable way to get device and brand/model information.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#57 Post by plinej »

Here's a dotpup of the sg_map executable I just compiled. This Pmount_Probedisk_Probepart.pup is to be used with sg_map.
Attachments
Pmount-Probedisk-Probepart.pup
(28.86 KiB) Downloaded 276 times
SG-map-1.21.pup
(49.74 KiB) Downloaded 243 times
Last edited by plinej on Mon 08 Jan 2007, 02:33, edited 5 times in total.

User avatar
peppyy
Posts: 443
Joined: Mon 27 Jun 2005, 23:49
Location: VT USA
Contact:

#58 Post by peppyy »

I am not sure if this helps but here are some results from sg_map

Ran with no usb attached

Code: Select all

sh-3.00# sg_map
Stopping because no sg devices found
with 2gb sandisk mini cruzer

Code: Select all

Strange, could not find device /dev/sda mapped to sg device??
again with same

Code: Select all

sh-3.00# sg_map
/dev/sg0  /dev/sda
unplugged

Code: Select all

sh-3.00# sg_map
Stopping because no sg devices found
with 1gb pny attache and 2gb micro

Code: Select all

sh-3.00# sg_map
Strange, could not find device /dev/sdb mapped to sg device??
/dev/sg0  /dev/sda
/dev/sg1  /dev/scd0
again with same

Code: Select all

sh-3.00# sg_map
/dev/sg0  /dev/sda
/dev/sg1  /dev/scd0
/dev/sg2  /dev/sdb
with attache unpluged

Code: Select all

sh-3.00# sg_map
/dev/sg2  /dev/sdb
This is on a thinkpad t22. with a single 1.1 port and usb hub.

I thoughtI was having problems with mut on some earlier machines but I now believe it is detection. that is a seperate problem though.
Puppy Linux...
It just works!

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#59 Post by plinej »

hmm, that's weird. sg_map seems to be working okay for me so far. If you download the new Pmount-Probedisk-Probepart.pup as well as SG_map and install them both you should still get all devices listed in pmount/probedisk but you won't get the brand/model information if sg_map doesn't detect your drive. All the drives are found in /proc/partitions and then the brand/model information will be found from sg_map.

My new probedisk wrapper script:

Code: Select all

#!/bin/sh

### wrapper script to fix probedisk issues with usb drives

if [ -d /tmp/probedisk ]; then
rm -r /tmp/probedisk
fi
if [ -f /tmp/probedisk ]; then
rm -f /tmp/probedisk
fi

if [ "`cat /proc/partitions | grep sd`" != "" ]; then
mkdir /tmp/probedisk
cat /proc/partitions | grep sd | sed -e 's/[0-9]//g' | sed -e 's/ //g' | sort -u > /tmp/probedisk/usbdevices  ### get current existing usb device names
sg_map -i | cut -b 11- | tr -s ' ' > /tmp/probedisk/scanbus
cat /tmp/probedisk/usbdevices | while read DEV
do
BRAND=`cat /tmp/probedisk/scanbus | grep /dev/$DEV | sed -e "s/\/dev\/$DEV //g" | sed -e 's/ /_/g'`
echo \/dev\/"$DEV"\|Direct-Access\|"$BRAND" >> /tmp/probedisk/probedisk  ### reorganize to output how original probedisk outputs
done
cat /tmp/probedisk/probedisk | sort -u > /tmp/probedisk/probedisk
fi

probedisk2 2>/dev/null | grep -v '/dev/sd'
if [ -f /tmp/probedisk/probedisk ]; then
cat /tmp/probedisk/probedisk
fi

rm -r /tmp/probedisk
Maybe I should add another cross reference search incase the brand/model info isn't found I could grep /var/log/messages or /proc/scsi (if only 1 usb drive is detected). I'll add that right now.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#60 Post by plinej »

Okay, download and install the 2 dotpups above (SG_map & Pmount_Probedisk_Probepart) and test pmount, probepart, and probedisk. My probedisk wrapper script is going to utilize sg_map to find the usb device names. If it fails and only one usb drive is found in /proc/partitions then the drive name will be found in /proc/scsi/scsi. If there are multiple usb drives and sg_map fails to get usb device names the script will grep through /var/log/messages. I would think this should work and the chance to fail should be minimal. With the probepart wrapper script in place you should be able to still see your device listed in pmount even if for some reason the drive information isn't found with the probedisk wrapper script.

newest probedisk wrapper script:

Code: Select all

#!/bin/sh

### wrapper script to fix probedisk issues with usb drives

if [ -d /tmp/probedisk ]; then
rm -r /tmp/probedisk
fi
if [ -f /tmp/probedisk ]; then
rm -f /tmp/probedisk
fi

if [ "`cat /proc/partitions | grep sd`" != "" ]; then
mkdir /tmp/probedisk
cat /proc/partitions | grep sd | sed -e 's/[0-9]//g' | sed -e 's/ //g' | sort -u > /tmp/probedisk/usbdevices  ### get current existing usb device names
sg_map -i | cut -b 11- | tr -s ' ' > /tmp/probedisk/scanbus
cat /tmp/probedisk/usbdevices | while read DEV
do
BRAND=`cat /tmp/probedisk/scanbus | grep /dev/$DEV | sed -e "s/\/dev\/$DEV //g" | sed -e 's/ /_/g'`
if [ "$BRAND" = "" ]; then
if [ "`cat /tmp/probedisk/usbdevices | wc -l | sed -e 's/ *//' | sed -e 's/ .*//g'`" = 1 ]; then
BRAND1=`cat /proc/scsi/scsi | grep Direct-Access -B 1 | grep -v Direct-Access | sed -n 1p | cut -f 2 -d ':' | tr -s ' ' | sed -e 's/Model//g' | sed 's/^ //g'`
BRAND2=`cat /proc/scsi/scsi | grep Direct-Access -B 1 | grep -v Direct-Access | sed -n 1p | cut -f 3 -d ':' | tr -s ' ' | sed -e 's/Rev//g' | sed 's/^ //g'`
else
BRAND1=`cat /var/log/messages | grep "SCSI device $DEV:" -B 10 | tail | grep 'Vendor:' | cut -f 5 -d ':' | sed -e 's/Model//g' | tr -s ' ' | sed 's/^ //g'`
BRAND2=`cat /var/log/messages | grep "SCSI device $DEV:" -B 10 | tail | grep 'Vendor:' | cut -f 6 -d ':' | sed -e 's/Rev//g' | tr -s ' ' | sed 's/^ //g'`
fi
BRAND="$BRAND1""$BRAND2"
fi
echo \/dev\/"$DEV"\|Direct-Access\|"$BRAND" >> /tmp/probedisk/probedisk  ### reorganize to output how original probedisk outputs
done
cat /tmp/probedisk/probedisk | sort -u > /tmp/probedisk/probedisk
fi

probedisk2 2>/dev/null | grep -v '/dev/sd'
if [ -f /tmp/probedisk/probedisk ]; then
cat /tmp/probedisk/probedisk
fi

rm -r /tmp/probedisk

User avatar
peppyy
Posts: 443
Joined: Mon 27 Jun 2005, 23:49
Location: VT USA
Contact:

#61 Post by peppyy »

Now I find no agreement between pmount and mut.
I have the following drives for the test

10gb HDA
had1 ext2 4gb,
hda2 linux swap 512mb
hda3 ext3 5gb

HDC toshiba dvd/cdrw

HDE Smart Memory card adapter on pcmcia with 128mb card

usb1 pny attache 1gb
usb2 sandisk mini cruser 2gb

There is no sr0, it is reading the cruser as such

Here is a screenshot
Image

I will be back tonight for the next update
Puppy Linux...
It just works!

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#62 Post by plinej »

What version of Puppy are you running? I see you have MUT 0.0.9b and your used and free numbers aren't populating on pmount. I would say you may want to update to a more recent version of Puppy if you want to use the dotpups I made. When you run sg_map run it like this:

sg_map -i

That will give you more information. Launch pmount from rxvt and see what errors popup, I'm guessing you are missing some necessary executables. Did you also download and install my updated Pmount-Probedisk-Probepart.pup that is several messages up? If you did install Pmount-Probedisk-Probepart.pup, make sure it is the version posted in the same message as the sg_map dotpup. I posted a couple of other versions previously.

I'll post a pic of how everything looks for me in Puppy 2.13 in a few minutes.
Last edited by plinej on Wed 03 Jan 2007, 20:25, edited 2 times in total.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#63 Post by plinej »

comparison pic:

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#64 Post by plinej »

As you can see sg_map -i reports a couple of devices that don't really exist on my system (sdc & sdd). For some reason that usb drive shows up three times in my /proc/scsi/scsi so my wrapper script just greps the line from sg_map for the usb devices that are reported in /proc/partitions so all that extra information isn't being piped into probedisk. I really think this should solve the probedisk/probepart usb issues.

User avatar
peppyy
Posts: 443
Joined: Mon 27 Jun 2005, 23:49
Location: VT USA
Contact:

#65 Post by peppyy »

I am running 2.0.1 on hda3. Since Puppy is my main os I tend to only upgrade every couple months. hda1 still has 1.0.9ce on it. Since thei is my main machine I should probably do my testing on a live cd instead of a hd install but I figure I can always fall back if I really mess up. Yes they are the most current also.

All my test machines at the moment have been adopted and I don't expect any new ones to come in real soon. The main reason I am so interested in this project is for mounting certain mp3 players like the rca lyra and such.
Puppy Linux...
It just works!

Post Reply