Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 25 Oct 2014, 23:10
All times are UTC - 4
 Forum index » House Training » Bugs ( Submit bugs )
212,213b USB flash names not retained in Pmount, Univ Inst
Moderators: Flash, Ian, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 2 of 10 Posts_count   Goto page: Previous 1, 2, 3, 4, ..., 8, 9, 10 Next
Author Message
plinej

Joined: 13 Aug 2006
Posts: 1522

PostPosted: Fri 29 Dec 2006, 13:52    Post_subject:  

I was messing around with that new probepart and noticed it shows my ext3 partitions as ext2 so there's definitely a problem with this version.
Back to top
View user's profile Send_private_message 
pakt


Joined: 04 Jun 2005
Posts: 1089
Location: Sweden

PostPosted: Fri 29 Dec 2006, 14:41    Post_subject:  

PaulBx1 wrote:
Isn't there an ordinary shell command, or set of commands, that will yield the same information that probedisk does - only correctly? Rolling Eyes If so, we should just chuck probedisk and replace it with these commands in the scripts where probedisk is used.

The only thing I've been able to find that retains the USB mass storage device reference when removing/re-inserting them is
Quote:
# cat /proc/partitions

Perhaps that can be used in the pmount script somehow.

Paul

_________________
Testing Puppy since v0.9.2 - my desktop OS since v1.0.7
Running SlaxerPup-4.12 - Puppy with a Slackware 12.2 heart Cool
Back to top
View user's profile Send_private_message 
Gn2


Joined: 16 Oct 2006
Posts: 936
Location: virtual - Veni vidi, nihil est adpulerit

PostPosted: Fri 29 Dec 2006, 15:16    Post_subject:  

The really good way (cat /proc/partitions) works -
Reads all devices found, major & minor numbers, size in blocks.
If a hot-plug device such as a pen drive is plugged in- it is found.
Unplugging it is safe - IF not mounted (use df to confirm)
Process events are dynamic.
Use of cat may obviate running (tail) to find latest logged system messages.

But (tail) will output other data - & as we all know more tail is always nice.
Back to top
View user's profile Send_private_message 
plinej

Joined: 13 Aug 2006
Posts: 1522

PostPosted: Fri 29 Dec 2006, 15:37    Post_subject:  

I'm sure we can modify pmount with these other ideas. I'd look into it right now but have got another project going. 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.
Back to top
View user's profile Send_private_message 
PaulBx1

Joined: 16 Jun 2006
Posts: 2308
Location: Wyoming, USA

PostPosted: Fri 29 Dec 2006, 20:13    Post_subject:  

We can also look to see how MUT does it, since MUT keeps things straight.

This fix also needs to be put in Universal Installer, and anything else that uses probedisk or probepart.
Back to top
View user's profile Send_private_message 
plinej

Joined: 13 Aug 2006
Posts: 1522

PostPosted: Sat 30 Dec 2006, 02:25    Post_subject:  

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:

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:

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.

Edited_time_total
Back to top
View user's profile Send_private_message 
pakt


Joined: 04 Jun 2005
Posts: 1089
Location: Sweden

PostPosted: Sat 30 Dec 2006, 02:55    Post_subject:  

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. Wink

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. Cool

Paul

_________________
Testing Puppy since v0.9.2 - my desktop OS since v1.0.7
Running SlaxerPup-4.12 - Puppy with a Slackware 12.2 heart Cool
Back to top
View user's profile Send_private_message 
plinej

Joined: 13 Aug 2006
Posts: 1522

PostPosted: Sat 30 Dec 2006, 09:59    Post_subject:  

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:

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:

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.
Back to top
View user's profile Send_private_message 
PaulBx1

Joined: 16 Jun 2006
Posts: 2308
Location: Wyoming, USA

PostPosted: Sat 30 Dec 2006, 13:31    Post_subject:  

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:
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:
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:
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

Shocked

Maybe we ought to fix probedisk and probepart instead, rather than reworking all of these <sigh>
Back to top
View user's profile Send_private_message 
plinej

Joined: 13 Aug 2006
Posts: 1522

PostPosted: Sat 30 Dec 2006, 20:37    Post_subject:  

Is there a problem with probepart? I see the problem with probedisk. I think I can probably make a bash script to replace it.
Back to top
View user's profile Send_private_message 
plinej

Joined: 13 Aug 2006
Posts: 1522

PostPosted: Sat 30 Dec 2006, 21:21    Post_subject:  

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

Edited_times_total
Back to top
View user's profile Send_private_message 
plinej

Joined: 13 Aug 2006
Posts: 1522

PostPosted: Sat 30 Dec 2006, 21:31    Post_subject:  

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

Code:

#!/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

Edited_times_total
Back to top
View user's profile Send_private_message 
plinej

Joined: 13 Aug 2006
Posts: 1522

PostPosted: Sat 30 Dec 2006, 22:00    Post_subject:  

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
Back to top
View user's profile Send_private_message 
PaulBx1

Joined: 16 Jun 2006
Posts: 2308
Location: Wyoming, USA

PostPosted: Sun 31 Dec 2006, 00:34    Post_subject:  

Looks pretty darn close, between the "real" probedisk and your "virtual" probedisk. Smile 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! Embarassed

Edited_time_total
Back to top
View user's profile Send_private_message 
plinej

Joined: 13 Aug 2006
Posts: 1522

PostPosted: Sun 31 Dec 2006, 00:54    Post_subject:  

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:

#!/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
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 2 of 10 Posts_count   Goto page: Previous 1, 2, 3, 4, ..., 8, 9, 10 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » House Training » Bugs ( Submit bugs )
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1152s ][ Queries: 13 (0.0080s) ][ GZIP on ]