The time now is Sat 25 May 2013, 11:20
All times are UTC - 4 |
| Author |
Message |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 6866 Location: Perth, Western Australia
|
Posted: Sat 16 Jun 2007, 10:18 Post subject:
|
|
Okay, I think I fixed probedisk...
| Description |
|

Download |
| Filename |
probedisk4-1.gz |
| Filesize |
527 Bytes |
| Downloaded |
339 Time(s) |
|
|
Back to top
|
|
 |
pakt

Joined: 04 Jun 2005 Posts: 1089 Location: Sweden
|
Posted: Sat 16 Jun 2007, 11:13 Post subject:
|
|
Same hardware as earlier:
| Quote: | # ./probepart-bk3
/dev/hdb1|vfat|2040192
/dev/hdb2|ext2|2008124
/dev/sr0|iso9660|0
/dev/sda1|vfat|249824
#
# ./probedisk4-1
/dev/hdb|disk|KINGSTON
/dev/sr0|cdrom|TSSTcorpCD/DVDW SH-W162C
/dev/sda|Direct-Access|SanDisk Cruzer Mini
# |
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 
|
|
Back to top
|
|
 |
GuestToo
Puppy Master
Joined: 04 May 2005 Posts: 4078
|
Posted: Sat 16 Jun 2007, 11:32 Post subject:
|
|
busybox's expr has a range of -2147483648 to 2147483647
bash's $((...)) has a range of -9223372036854775808 to 9223372036854775807, and the syntax is better looking, to my eye anyway
bc has arbitrary (unlimited) precision
i don't know about busybox's dc ... i think it switches from integers to floating point, and integer mode can't be forced using 0k ... busybox's dc has differences from the real dc, a script that was written using the real dc would probably not work with busybox's dc and vice versa
$((...)) also seems to work in busybox's ash, at least when ash is executed from a bash shell:
# ash
BusyBox v1.01 (2006.08.20-09:28+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
# echo $((3+4))
7
#
i'm not sure if bash is intercepting the $((...)) syntax before it gets to the ash shell or not ... i wouldn't think bash should do that
your script using $((...)) would look something like this:
[ $BSIZE ] && SIZE=$(($BSIZE/1024)) #KB
[ "$SUNITS" = "" ] && SIZE=$(($SIZE*2)) #512 byte blocks.
[ "$SUNITS" = '-m' ] && SIZE=$(($SIZE/1024)) #MB
your script using bc would look something like this:
[ $BSIZE ] && SIZE=`echo "$BSIZE/1024"|bc` #KB
[ "$SUNITS" = "" ] && SIZE=`echo "$SIZE*2"|bc` #512 byte blocks.
[ "$SUNITS" = '-m' ] && SIZE=`echo "$SIZE/1024"|bc` #MB
also, your script prints sizes in mb for -m, 512 byte blocks for $1="" ... any other parameter will print the size in 1k blocks ... i assume that's what you intended
|
|
Back to top
|
|
 |
John Doe
Joined: 01 Aug 2005 Posts: 1689 Location: Michigan, US
|
Posted: Sat 16 Jun 2007, 14:49 Post subject:
HFS/HFSPlus support Subject description: Probepart/MUT/Pmount Tangent... |
|
Yesterday another Intel-Mac user arrived.
I recall Barry modified 'libhardware' to enable NTFS recognition. Could the same be done for HFS and HFS+? Thereby enabling it to show up in probepart. Which would only leave some tiny modification to MUT and PMOUNT to enable mounting (example).
GUIDs (couldn't figure out which one is plain HFS):
| Code: | | Hierarchical File System (HFS+) partition 48465300-0000-11AA-AA11-00306543ECAC |
reference:
http://developer.apple.com/technotes/tn2006/tn2166.html#SECADVICE
http://en.wikipedia.org/wiki/GUID_Partition_Table
Here is the line for modules.dep for the zdrive and the squash, I put it right after hfs.ko:
| Code: | | /lib/modules/2.6.18.1/kernel/fs/hfsplus/hfsplus.ko: |
mut.tcl would be something like this at around line 285 (right after 'set results ""' in grab_fs_vol):
| Code: | if {$fs == "hfs"} {set fs "hfs"}
if {$fs == "hfsplus"} {set fs "hfsplus"} |
pmount would be something like this at around line 20 (right after 'FSTYPE="$1"'):
| Code: | [ "$FSTYPE" = "HFS" ] && FSTYPE="hfs"
[ "$FSTYPE" = "HFSPlus" ] && FSTYPE="hfsplus" |
Also the respective kernel module would need loaded.
| Code: | modprobe hfs
modprobe hfsplus |
That's about it I think. I have the modules in my zdrive and one hfs+ partition, so I could test the new scrips and libhardware if you upload it here.
*Edit- THat wasn't it, one other thought I forgot. Saving and booting could be a possible after that.
Last edited by John Doe on Sat 16 Jun 2007, 14:57; edited 1 time in total
|
|
Back to top
|
|
 |
Dougal

Joined: 19 Oct 2005 Posts: 2505 Location: Hell more grotesque than any medieval woodcut
|
Posted: Sat 16 Jun 2007, 14:50 Post subject:
|
|
Oops… I just read Barry's blog.
When I posted that probepart script I made some last-minute change and must have had a typo. I discovered it later but since no-one complained I assumed the script I posted didn't have that modification.
Here're my latest versions of the script, in case they are of any help.
| Description |
|

Download |
| Filename |
probaprt-probedisk-test-scsi.tar.gz |
| Filesize |
1.94 KB |
| Downloaded |
295 Time(s) |
_________________ What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind
|
|
Back to top
|
|
 |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 6866 Location: Perth, Western Australia
|
Posted: Sat 16 Jun 2007, 21:22 Post subject:
|
|
Heh heh, Jesse may be making all of this history with his "mutt on steroids":
http://www.puppyos.net/forum/?1181868790
(the word "mutt" is slang for a dog, actually a mixed-breed: http://en.wikipedia.org/wiki/Mixed-breed_dog , which kind of describes the multiple-nature of his new MUT -- hey Jess, why not call it "Mutt"?!)
|
|
Back to top
|
|
 |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 6866 Location: Perth, Western Australia
|
Posted: Sat 16 Jun 2007, 21:37 Post subject:
|
|
G2, thanks for that advice about $((...)). Yes, where I have the SIZE in bytes there is potential trouble using expr. I've modified the script.
|
|
Back to top
|
|
 |
jeffrey
Joined: 16 Jan 2006 Posts: 162 Location: Christchurch, New Zealand
|
Posted: Sun 17 Jun 2007, 19:52 Post subject:
awk is a powerful tool too... |
|
Just as an aside, you can often replace several commands with awk.
For example,
| Code: |
ALLDRVS="`grep -E '^ .*[^0-9]$|^ .*mmcblk[0-9]$' /proc/partitions | tr -s ' ' | cut -f 5 -d ' ' | tr '\n' ' '`"
|
could probably be replaced with
| Code: |
ALLDRVS=`awk 'NR>2 && $4~/[^0-9]$|mmcblk[0-9]$/ {print $4}' /proc/partitions`
|
Which means IF the line number is greater than 2 (ie skip the header) AND (field 4 is EITHER a string ending in something other than a digit OR the string "mmcblk" followed by a digit) THEN print field 4.
If you really need ALLDRVS to be on one line use
| Code: |
ALLDRVS=`awk 'NR>2 && $4~/.*[^0-9]$|mmcblk[0-9]$/ {printf "%s ",$4}' /proc/partitions`
|
Similarly, the following code
| Code: |
ALLDRVS="`grep -E ' hd| scd| sd| mmc| sr' /proc/diskstats | tr -s ' ' | cut -f 4 -d ' ' | grep -vE 'hd.*[0-9]$|sd.*[0-9]$' | tr '\n' ' '`"
|
could be replaced by
| Code: |
ALLDRVS=`awk '$3~/^hd.*[^0-9]$|^scd|^sd.*[^0-9]$|^mmc|^sr/ {print $3}' /proc/diskstats`
|
As you can guess, I quite like awk...
|
|
Back to top
|
|
 |
PaulBx1
Joined: 16 Jun 2006 Posts: 2308 Location: Wyoming, USA
|
Posted: Mon 18 Jun 2007, 00:58 Post subject:
|
|
| Quote: | | Heh heh, Jesse may be making all of this history with his "mutt on steroids" |
Maybe as far as MUT and pmount are concerned, but there are a lot of other scripts that use probedisk and probepart, so keep on plugging away at it...
|
|
Back to top
|
|
 |
Jesse
Joined: 08 May 2005 Posts: 465 Location: Auckland, NZ
|
Posted: Mon 18 Jun 2007, 01:59 Post subject:
|
|
Hi,
The new mutt will be able to simulate probepart and probedisk through a symlink to the mutt executable, like how busybox does multiple cli apps. If you're not sure what I'm saying there then consider it as another script candidate, but its a compiled binary (from c code).
Its currently working, it does probedisk and probepart, but there are some internal aspects still to tidy up before its ready for alpha/beta testing.
Jesse
|
|
Back to top
|
|
 |
Jesse
Joined: 08 May 2005 Posts: 465 Location: Auckland, NZ
|
Posted: Mon 18 Jun 2007, 20:09 Post subject:
|
|
Hi Barry,
I was just checkining out your probepart-bk3,
there is a minor glitch in it, to do with detecting superfloppy format and/or media change.
I recently discovered this in the new mutt, and fixed it there, I'd seen it previously but not realised what was going on.
The problem comes about when the user swaps the media, e.g. usb compact flash is swapped for another compact flash.
The problem can show as an incorrect size for the device, incorect partition name, or as a really confusing diferent filesystem name.
The good news is that on a second execution of the script the hardware is detected/reported correctly.
The problem comes about because the media has been changed and the kernel has not re-read the partition table from the device to update kernel interfaces like /proc/partitions.
Examples: I have a 256Mb CF that was once an ext3 superfloppy, but then I partitioned it to a 256MB part of vfat. I also have a 32MB CF of superfloppy vfat.
(start with 32MB)
sh-3.00# ./probepart-bk3 | grep sdb
/dev/sdb|vfat|62592
(swap to 256MB)
sh-3.00# ./probepart-bk3 | grep sdb
/dev/sdb|ext3|510464
sh-3.00# ./probepart-bk3 | grep sdb
/dev/sdb1|vfat|509992
(back to 32MB)
sh-3.00# ./probepart-bk3 | grep sdb
/dev/sdb1|none|509992
sh-3.00# ./probepart-bk3 | grep sdb
/dev/sdb|vfat|62592
Jesse
|
|
Back to top
|
|
 |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 6866 Location: Perth, Western Australia
|
Posted: Mon 18 Jun 2007, 22:07 Post subject:
|
|
Jesse, so do you mean if probepart is run too soon after a usb drive is changed, it can read /proc/partitions before it has properly updated?
/proc/partitions is not a normal file, we can't read its modify date. How to work around this problem? ...how did you do it in mutt?
I suppose it could be read twice, with one or two second delay, then check that they are identical -- this could be in a while-loop.
|
|
Back to top
|
|
 |
jeffrey
Joined: 16 Jan 2006 Posts: 162 Location: Christchurch, New Zealand
|
Posted: Mon 18 Jun 2007, 23:12 Post subject:
|
|
I don't understand what happens in Puppy when a device is added, but /sbin/hotplug may be called which may create a short-lived 'loading' file via the /etc/hotplug/firmware.agent script, although I couldn't spot one by running "find /sys /proc -name loading" in a loop while plugging a USB drive in.
When a device is plugged in I'd expect /var/log/messages to be updated so perhaps as a rough solution you could check whether its timestamp is the same as the current time.
(Just a few poor thoughts - not very clean I'm afraid...)
|
|
Back to top
|
|
 |
Jesse
Joined: 08 May 2005 Posts: 465 Location: Auckland, NZ
|
Posted: Tue 19 Jun 2007, 03:05 Post subject:
|
|
Hi,
In mutt, I use an ioctl to ask the kernel to update its info about the mbr of each drive/device, and I read the partition table direct from the MBR.
But it seems to be possible by reading the first sector and attempting to find the filesystem on the drive, which can be scripted for.
I have just done a quick update to your script and it works for me, I tried to optimise out the duplicate fs scans but guessfs_type is needed for both scans.
Attached is my updates to probepart-bk3, you might want to add comments to it?
sh-3.00# ./probepart-bk3 | grep sdb
/dev/sdb|vfat|62592
sh-3.00# ./probepart-bk3 | grep sdb
/dev/sdb1|vfat|509992
sh-3.00# ./probepart-bk3 | grep sdb
/dev/sdb|vfat|62592
Jesse
| Description |
|

Download |
| Filename |
probepart-bk3.tar.gz |
| Filesize |
1.1 KB |
| Downloaded |
261 Time(s) |
|
|
Back to top
|
|
 |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 6866 Location: Perth, Western Australia
|
Posted: Tue 19 Jun 2007, 07:41 Post subject:
|
|
Jesse, I don't quite understand the mods to the script.
1.
What is the effect of just reading and dumping the first 512 bytes of the drive/partition? Does that serve as a wake-up to the kernel?
2.
why do you have to call guess-fstype on both prescan and normal loops?
It would seem 1. and 2. are related somehow.
Apart from the above, note that the case-structure is only entered for drives that do not have partitions. But, isn't this updating problem generic?
In other words, the reading of the first 512 bytes needs to be in a separate case-structure? Like this:
| Code: | if [ ! $SIZE ];then
[ "`echo "$PARTITIONS" | grep "$ONEDEV"`" != "" ] && continue
#must be a device without partitions...
SIZE=0
DEVICE="$ONEDEV"
case $DEVICE in
hd*)
[ "`cat /proc/ide/$DEVICE/media`" = "cdrom" ] && FSTYPE="iso9660"
;;
scd*|sr*) #usb,sata,scsi cd/dvd drive.
FSTYPE="iso9660"
;;
esac
#for hd* or sd* superfloppy, determine size...
if [ "$PASS" == "normal" -a "$FSTYPE" = "unknown" ];then
BSIZE=`disktype /dev/$DEVICE 2>/dev/null | grep '^Block device' | cut -f 2 -d '(' | cut -f 1 -d ' '`
[ $BSIZE ] && SIZE=$(($BSIZE/1024)) #KB
fi
fi
if [ "$FSTYPE" = "unknown" -a "$PASS" = "prescan" ];then
case $DEVICE in
sd*|hd*)
#force a read of the partition/device mbr/boot block in case it has changed
dd if=/dev/$DEVICE of=/dev/null bs=512 count=1 2>&1 > /dev/null
;;
esac
fi
|
|
|
Back to top
|
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|