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

Please post any bugs you have found
Message
Author
plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#21 Post by plinej »

I definitely see the problem with probedisk. I'm about to go to bed but I think we could easily do some kind of workaround. We could use /var/log/messages and cross reference it with the devices listed in /proc/partitions. To get the usb info from /var/log/messages:

Code: Select all

cat /var/log/messages | grep Direct-Access -A 1 -B 1  | sed -e 's/.*kernel:/:/g'
This could give you your usb drives from /proc/partitions:

Code: Select all

cat /proc/partitions | grep sd | sed -e 's/[0-9]//g' | sed -e 's/ //g' | sort -u
I should be able to pound something out this weekend. I've got a couple of Christmas parties though so I'll only have time at night.
Last edited by plinej on Sat 30 Dec 2006, 07:06, edited 1 time in total.

User avatar
pakt
Posts: 1157
Joined: Sat 04 Jun 2005, 16:54
Location: Sweden

#22 Post by pakt »

plinej wrote:On a side note I've revised dougal's revised pmount to include a rox launcher and a couple of other minor things and sent it off to pakt.
I've done some testing and the 'merged' pmount seems to work well, even on the eBox. It is faster and now includes buttons to launch rox for mounted partitions, along with other small improvements. I have sent it off to Barry with the hope that he can include it in 2.13beta2. ;)

Just the obscure problem remains of not keeping track of more than one USB mass storage device reference, due to bugs in probepart/probedisk. Hopefully info from 'cat /proc/partitions' can be used in the script to solve that. 8)

Paul
Methinks Raspberry Pi were ideal for runnin' Puppy Linux

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

#23 Post by plinej »

I've got to get ready to leave but I was thinking about this probedisk thing and was curious if there's a way to use grep to find only the last example of a given variable from stdout? Or is there a way to use sed to replace a given variable but only the last example from stdout?

When I run:

Code: Select all

cat /var/log/messages | grep Direct-Access -A 1 -B 1  | sed -e 's/.*kernel:/:/g' | grep -v Direct-Access
I get several different outputs for sdb, sdc, etc... after unplugging and plugging back in my usb devices. I only want to find the last example of each device. I want to use the output from:

Code: Select all

cat /proc/partitions | grep sd | sed -e 's/[0-9]//g' | sed -e 's/ //g' | sort -u 
as variables to grep for the last appearance of given variable or use sed to replace that last appearance of given variable to /dev/sd(whatever) which can later be easily grepped for.

This way if I have 3 variables I could have an output of 6 lines (I would use grep -B 1 to view the line before with the vendor and model info) instead of having multiple extra lines that may cause conflicting or incorrect information.

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

#24 Post by PaulBx1 »

That "-A 1 -B 1" is not going to work very well if some other message comes in at the same time.

Here is what MUT uses:


Code: Select all

sh-3.00# cd /usr/lib/mut
sh-3.00# grep -i "/proc" mut.tcl
        if {[file exists /proc/bus/usb/devices]} {
                set ::last_hotplug [file mtime /proc/bus/usb/devices]
                set fid [open "/proc/devices" r]
                set bd_fd [open "/proc/ide/$bus/$lun/$scan_me" r]
                set fid [open "/proc/diskstats" r]
                set fid [open "/proc/partitions" r]
                                        set  gl [split [glob "/proc/ide/ide*/$dev"] /]
                set fid [open "/proc/swaps" r]
                set fid [open "/proc/scsi/scsi" r]
                                set fid [open "/proc/scsi/usb-storage/$ctrlr" r]
        if {[file exists /proc/bus/usb/devices]} {
                set hotplug [file mtime /proc/bus/usb/devices]
array unset partitions ;                  # List of info from /proc/partitions
array unset mounteds ;                    # List of info from /proc/mounts
set grabdevs {fd hd sd scd sr} ;          # list of device types to scan in /proc/diskstats & /proc/partitions
array unset majorBus ;                    # block device info from /proc/devices
        if {[file exists /proc/bus/usb/devices]} {
That /proc/scsi/scsi gives a nice display of the device information:

Code: Select all

sh-3.00# cat /proc/scsi/scsi
Attached devices:
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: LEXAR    Model: JD FIREFLY       Rev: 3000
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi3 Channel: 00 Id: 00 Lun: 00
  Vendor: I-Stick2 Model: IntelligentStick Rev: 0.00
  Type:   Direct-Access                    ANSI SCSI revision: 02
The above "Model" is what shows up in the MUT display.

The /proc/bus/usb/devices might be useful too, although in my case the mfr info does not show in one of the devices:

Code: Select all

T:  Bus=01 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#=  6 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=3538 ProdID=0042 Rev= 1.00
S:  Product=USB Mass Storage Device
S:  SerialNumber=00000000000287
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr= 98mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=01(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=83(I) Atr=03(Int.) MxPS=  64 Ivl=8ms

T:  Bus=01 Lev=02 Prnt=02 Port=03 Cnt=02 Dev#=  5 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=05dc ProdID=a560 Rev=30.00
S:  Manufacturer=LEXAR MEDIA
S:  Product=JD FIREFLY
S:  SerialNumber=1069A701072609160706
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
All this kinda makes me wonder why we have pmount, when MUT works so well. :wink:

BTW, here are the list of things in 211 I found that use probedisk or probepart:
crypt-pupsave (our encryption utility)
/etc/rc.d/rc.shutdown
/usr/local/bin/mtoolsfmshell
/usr/sbin/cdburner-wizard-old
/usr/sbin/e2ore3.sh
/usr/sbin/grubconfig
/usr/sbin/importfrompuppy1
/usr/sbin/pmount
/usr/sbin/remasterpup2
/usr/sbin/Pdisk
/usr/sbin/burniso2cd
/usr/sbin/cdburner-wizard
/usr/sbin/puppyinstaller

:shock:

Maybe we ought to fix probedisk and probepart instead, rather than reworking all of these <sigh>

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

#25 Post by plinej »

Is there a problem with probepart? I see the problem with probedisk. I think I can probably make a bash script to replace it.

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

#26 Post by plinej »

What are the chances of a message coming in that would interrupt the usb information?
Just curious if it would really be a problem. I suppose I could try to work something else out but in the meantime try out the following code. I've got a script worked out that will output all of the usb information exactly how it is displayed in probedisk (only correctly) using my examples from above.

--edited--
see next post
Last edited by plinej on Sun 31 Dec 2006, 02:32, edited 2 times in total.

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

#27 Post by plinej »

We could go into /sbin/ and rename probedisk to probedisk2 and save the following code as /sbin/probedisk

Code: Select all

#!/bin/sh

if [ -d /tmp/probedisk ]; then
rm -r /tmp/probedisk
fi
mkdir /tmp/probedisk
probedisk2 | grep -v 'dev/sd' > /tmp/probedisk/probedisk
cat /proc/partitions | grep sd | sed -e 's/[0-9]//g' | sed -e 's/ //g' | sort -u > /tmp/probedisk/usbdevices
cat /tmp/probedisk/usbdevices | while read DEV
do
echo Vendor > /tmp/probedisk/"$DEV"
cat /var/log/messages | grep Direct-Access -A 1 -B 1  | sed -e 's/.*kernel:/:/g' | grep -v Direct-Access | sed '/^$/d' | sed '/^--/d' | grep "$DEV" -B 1 >> /tmp/probedisk/"$DEV"
NUMLINES=`cat /tmp/probedisk/"$DEV" | wc -l | sed -e 's/ *//' | sed -e 's/ .*//g'`
NUMLINES2=`expr "$NUMLINES" - 1`
while [ "`cat /tmp/probedisk/"$DEV" | sed -n "$NUMLINES2"p | grep Vendor`" = "" ]
do
NUMLINES2=`expr "$NUMLINES2" - 1`
done
VENDOR=`cat /tmp/probedisk/"$DEV" | sed -n ""$NUMLINES2"p" > /tmp/probedisk/"$DEV"-vendor`
BRAND=`cat /tmp/probedisk/"$DEV"-vendor | cut -f 3 -d ':' | sed -e 's/Model//g' | sed -e 's/ *//' | tr -s ' '`
NAME=`cat /tmp/probedisk/"$DEV"-vendor | cut -f 4 -d ':' | sed -e 's/Rev//g' | sed -e 's/ *//' | tr -s ' '`
echo \/dev\/"$DEV"\|Direct-Access\|"$BRAND""$NAME" >> /tmp/probedisk/probedisk
done
cat /tmp/probedisk/probedisk
rm -r /tmp/probedisk
Last edited by plinej on Sun 31 Dec 2006, 03:36, edited 3 times in total.

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

#28 Post by plinej »

Well it seems close. It works and then I remove a usb stick and then it loses the vendor info even though the info is still in the temp file. Still some more tweaking to be done.

--edit--

Ok, the above code has been modified and it seems to be working okay.

I'll think of a way to make sure the initial grep of information in /var/log/messages gets all necessary lines just incase of some off chance something is being piped into it at the same time.

--edit--

whoops, had to edit it again

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

#29 Post by PaulBx1 »

Looks pretty darn close, between the "real" probedisk and your "virtual" probedisk. :) However, there is a problem. The real one returns info on hda, the cdrom, etc. Don't you need to add that too?

Oh, another thing. Why are you still going to /var/log/messages? When /pro/scsi/scsi has the info? Maybe I am missing something, but it seems the system log is supposed to be consumed by human eyes, not a script. It is not deterministic enough for that.

probepart is broken as well as probedisk, although if it depends on the "virtual" probedisk, which you have fixed, maybe that will fix probepart too. Easy enough to check...

But I was thinking if probedisk and probepart are both rewritten, then Barry can toss that package he was using for them, since these two are the only things he is using from this package.

<later>
Never mind my comment about /var/log/messages. MUT uses it too! :oops:
Last edited by PaulBx1 on Sun 31 Dec 2006, 05:38, edited 1 time in total.

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

#30 Post by plinej »

Okay, this should work in all cases to get the usb information. Just incase the vendor info isn't found the original way I created an alternate way. I used /var/log/messages because it seemed to be the easiest way for me to come up with something. I didn't use /proc/scsi/scsi because I don't see where it shows you the actual device (i.e. sda). As for getting the hda & cdrom info the original probedisk seems to do that fine. Just rename probedisk to probedisk2 and copy this script as probedisk. After doing that all the necessary info should be displayed. Until someone wants to do a total re-write this will have to do. What's broken with probepart?

Code: Select all

#!/bin/sh

### a re-write for probedisk (usb portion)
### the original probedisk has problems with usb information
### http://www.murga-linux.com/puppy/viewtopic.php?t=13267
### Rename the original probedisk at /sbin/ to probedisk2
### save this script as /sbin/probedisk

if [ -d /tmp/probedisk ]; then
rm -r /tmp/probedisk
fi
mkdir /tmp/probedisk
cp /var/log/messages /tmp/probedisk
probedisk2 | grep -v 'dev/sd' > /tmp/probedisk/probedisk  ### use the original probedisk (renamed to probedisk2) to get all non-usb information
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
cat /tmp/probedisk/usbdevices | while read DEV
do
cat /tmp/probedisk/messages | grep Direct-Access -A 1 -B 1  | sed -e 's/.*kernel:/:/g' | grep -v Direct-Access | sed '/^$/d' | sed '/^--/d' | grep "$DEV" -B 1 > /tmp/probedisk/"$DEV" ### get necessary info from /tmp/probedisk/messages
NUMLINES=`cat /tmp/probedisk/"$DEV" | wc -l | sed -e 's/ *//' | sed -e 's/ .*//g'`
NUMLINES2=`expr "$NUMLINES" - 1`
if [ "`cat /tmp/probedisk/"$DEV" | grep Vendor`" != "" ]; then  ### just incase Vendor info isn't on designated line
while [ "`cat /tmp/probedisk/"$DEV" | sed -n ""$NUMLINES2"p" | grep Vendor`" = "" ]
do
NUMLINES2=`expr "$NUMLINES2" - 1`
done
fi
if [ "`cat /tmp/probedisk/"$DEV" | grep Vendor`" = "" ]; then  ### just incase Vendor info isn't in file we'll try to get it an alternate way
NUM=`cat /tmp/probedisk/messages | grep 'SCSI device "$DEV":' -n | cut -f 1 -d ':' | tail -n 1`  ### get last line in /tmp/probedisk/messages that contains 'SCSI device (your device)'
NUM2=`expr "$NUM" - 1`
while [ "`cat /tmp/probedisk/messages | sed -n ""$NUM2"p" | grep Vendor`" = "" ]
do
NUM2=`expr "NUM2" - 1`
done
VENDOR=`cat /tmp/probedisk/messages | sed -n ""$NUM2"p" | sed -e 's/.*kernel:/:/g'`
else
VENDOR=`cat /tmp/probedisk/"$DEV" | sed -n ""$NUMLINES2"p" > /tmp/probedisk/"$DEV"-vendor`
fi
BRAND=`cat /tmp/probedisk/"$DEV"-vendor | cut -f 3 -d ':' | sed -e 's/Model//g' | sed -e 's/ *//' | tr -s ' '`
NAME=`cat /tmp/probedisk/"$DEV"-vendor | cut -f 4 -d ':' | sed -e 's/Rev//g' | sed -e 's/ *//' | tr -s ' '`
echo \/dev\/"$DEV"\|Direct-Access\|"$BRAND""$NAME" >> /tmp/probedisk/probedisk  ### reorganize to output how original probedisk outputs
done
cat /tmp/probedisk/probedisk
rm -r /tmp/probedisk

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

#31 Post by PaulBx1 »

From my experiment earlier:

Code: Select all

sh-3.00# /root/probedisk
/dev/hdc|cdrom|MATSHITADVD-ROM SR-8175
/dev/hda|disk|IC25N020ATDA04-0
/dev/sda|Direct-Access|LEXAR    JD FIREFLY       
sh-3.00# /root/probepart
libcfdisk: unable to open /dev/sda
/dev/hdc|iso9660|0|MATSHITADVD-ROM SR-8175
/dev/hda1|vfat|36968337|Win95 FAT32 (LBA)
/dev/hda2|swap|2086560|Linux Swap 
Obviously probepart is looking for sda which is not there, however it may be thinking it's there by paying attention to probedisk! So maybe only probedisk needs fixing.

If you hadn't noticed my edit above, I found that MUT also uses /var/log/messages...

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

#32 Post by plinej »

Yeah, I think /var/log/messages is probably the easiest way to go. If I get bored I'll try and think up ways to get rid of probedisk alltogether but for now I think this script should solve the problem.

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

#33 Post by PaulBx1 »

Well, I tried it on 211 and it looked like it worked, sort of (although when I pulled one out, pmount acted like both flash drives were gone). I tried in 213 and nothing worked, I think because of mrxvt. Then going back to 211 it is even more broken:

Code: Select all

sh-3.00# probedisk
/dev/hdc|cdrom|MATSHITADVD-ROM SR-8175
/dev/hda|disk|IC25N020ATDA04-0
/dev/sda|Direct-Access|LEXAR JD FIREFLY 
/dev/sdb|Direct-Access|LEXAR JD FIREFLY 
MUT knows sda is the IntelligentStick.

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

#34 Post by plinej »

Weird, here's mine with the revised probedisk:

Code: Select all

sh-3.00# probedisk
/dev/hda|disk|IC25N080ATMR04-0
/dev/hdc|cdrom|HL-DT-ST DVD-RW GWA-4040N
/dev/sda|Direct-Access|WD 1600JB External 
/dev/sdb|Direct-Access|JetFlash TS1GJF110 
/dev/sdc|Direct-Access|GENERIC USB Storage-CFC 
I'm in 2.11 right now. I have audio and usb issues with the new kernel. Are you using the newest version of pmount and not the original 2.11 pmount? After going back into 2.11 you moved the revised probedisk into /sbin/?

After a while of taking out and re-inserting the usb drives MUT, pmount, and probedisk all show the same and correct information.

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

#35 Post by PaulBx1 »

Just using the 211 pmount. Now I recall it had problems <sigh> I will get the one in 213. However pmount should not affect the way probedisk works, right? That's still broken.

I followed your instructions for probedisk and probedisk2.

Did you try pulling and reinserting a flash drive? That's when mine went bad...

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

#36 Post by plinej »

Yeah, I pulled and re-inserted my usb drives and all the correct information was retained in probedisk.

User avatar
pakt
Posts: 1157
Joined: Sat 04 Jun 2005, 16:54
Location: Sweden

#37 Post by pakt »

Running 2.13b2 from my eBox right now (no pup_save file) and tried plinej's probedisk script. Seems to work okay. Here's an excerpt:

Code: Select all

sh-3.00# probedisk
/dev/hda|disk|CF-ATA
/dev/sda|Direct-Access|SanDisk Cruzer Mini 
/dev/sdb|Direct-Access|USB 2.0 Mobile Disk 
sh-3.00# 
sh-3.00# probedisk
/dev/hda|disk|CF-ATA
/dev/sdb|Direct-Access|USB 2.0 Mobile Disk 
sh-3.00# 
sh-3.00# probedisk
/dev/hda|disk|CF-ATA
/dev/sda|Direct-Access|SanDisk Cruzer Mini 
/dev/sdb|Direct-Access|USB 2.0 Mobile Disk 
sh-3.00#
Paul
Methinks Raspberry Pi were ideal for runnin' Puppy Linux

User avatar
pakt
Posts: 1157
Joined: Sat 04 Jun 2005, 16:54
Location: Sweden

#38 Post by pakt »

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
Methinks Raspberry Pi were ideal for runnin' Puppy Linux

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

#39 Post by plinej »

pakt,

Does the newly updated pmount do that too? If not, does the modified probedisk report back correctly when pmount doesn't?

User avatar
pakt
Posts: 1157
Joined: Sat 04 Jun 2005, 16:54
Location: Sweden

#40 Post by pakt »

plinej wrote:Does the newly updated pmount do that too?
Unfortunately, it does - no difference.
plinej wrote:If not, does the modified probedisk report back correctly when pmount doesn't?
Yes, probedisk gives the right results:
sh-3.00# probedisk
/dev/hda|disk|CF-ATA
/dev/sda|Direct-Access|SanDisk Cruzer Mini
/dev/sdb|Direct-Access|USB 2.0 Mobile Disk
sh-3.00#
sh-3.00# probedisk
/dev/hda|disk|CF-ATA
/dev/sdb|Direct-Access|USB 2.0 Mobile Disk
sh-3.00#
sh-3.00# probedisk
/dev/hda|disk|CF-ATA
/dev/sda|Direct-Access|SanDisk Cruzer Mini
/dev/sdb|Direct-Access|USB 2.0 Mobile Disk
sh-3.00#
Methinks Raspberry Pi were ideal for runnin' Puppy Linux

Post Reply