RFC: cleaner version of test.block
I propose the following version of test.block. I think the code's easier to read than the one using "cut", and it removes the dependency on stuff outside of bash.
Also, running the call to udev backgrounded makes the whole scan take 1 second, rather than 1 second for each entry.
Chris
#!/bin/sh
#
# test.block - run udev(8) on each block device in /sys/block
SYSFSDIR=/sys # change this for a nonstand sysfs mount point
BIN=./udev # location of your udev binary
export ACTIONd # 'add' or 'remove'
for i in ${SYSFSDIR}/block/*; do
# add each drive
export DEVPATH=${i#${SYSFSDIR}}
$BIN block & # add each partition, on each device
for j in $i/*; do
if [ -f $j/dev ]; then
export DEVPATH=${j#${SYSFSDIR}}
$BIN block &
fi
done
done-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations Here's your chance to show off your extensive product knowledge We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 6 lines · Chris Friesen
I propose the following version of test.block. I think the code's easier to read than the one using "cut", and it removes the dependency on stuff outside of bash.
Also, running the call to udev backgrounded makes the whole scan take 1 second, rather than 1 second for each entry.
I did not test it, but if it works as advertised I think it is an improvement.
Robert Love
-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations Here's your chance to show off your extensive product knowledge We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 4 lines · Chris Friesen
I propose the following version of test.block. I think the code's easier to read than the one using "cut", and it removes the dependency on stuff outside of bash.
Looks good, care to make a patch against the 004 release?
Quoted 2 lines
Also, running the call to udev backgrounded makes the whole scan take 1 second, rather than 1 second for each entry.
The 004 release fixes that problem, so you don't have to run udev in the background.
On some basic tests (test.tty) with debugging turned off (comment out the DEBUG=true in the Makefile) all tty device nodes are created in less than .5 seconds. So I think we are ok as far as time goes now :)
thanks,
greg k-h
-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations Here's your chance to show off your extensive product knowledge We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 6 lines · * Chris Friesen ([email protected]) wrote:
I propose the following version of test.block. I think the code's easier to read than the one using "cut", and it removes the dependency on stuff outside of bash.
Also, running the call to udev backgrounded makes the whole scan take 1 second, rather than 1 second for each entry.
[snip]
One thing to take note of here, is that adding additional bash dependencies makes it harder to use on embedded devices, which generally use dash, busybox ash, or similar. (hotplug is another project that suffers from this, but that can be remedied by using diethotplug) --
Chris Larson - kergoth at handhelds dot org
Embedded Linux Developer - clarson at ti dot com
OpenZaurus Project Maintainer - http://openzaurus.org/
-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations Here's your chance to show off your extensive product knowledge We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 5 lines · Chris Larson
Quoted 4 lines · * Chris Friesen ([email protected]) wrote:
I propose the following version of test.block. I think the code's easier to read than the one using "cut", and it removes the dependency on stuff outside of bash.
Quoted 8 lines
Quoted 2 lines
Also, running the call to udev backgrounded makes the whole scan take 1 second, rather than 1 second for each entry.
[snip]
One thing to take note of here, is that adding additional bash dependencies makes it harder to use on embedded devices, which generally use dash, busybox ash, or similar. (hotplug is another project that suffers from this, but that can be remedied by using diethotplug)
Yes, but this is just a test script. And this is also one reason why udev is linked statically...
thanks,
greg k-h
-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations Here's your chance to show off your extensive product knowledge We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 6 lines · Greg KH
Quoted 2 lines · Chris Friesen
I propose the following version of test.block. I think the code's easier to read than the one using "cut", and it removes the dependency on stuff outside of bash.
Looks good, care to make a patch against the 004 release?
I've attached a patch against 005 for both the block and tty scripts. I didn't bother running udev backgrounded, since as you say, the new code runs a lot faster.
Chris
# This is a BitKeeper generated patch for the following project:
# Project Name: udev
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.133 -> 1.135 # test.block 1.11 -> 1.12 # test.tty 1.3 -> 1.4
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/10/22 [email protected] 1.84.1.1
# cleaning up the test script # -------------------------------------------- # 03/10/22 [email protected] 1.134 # Merge bk://kernel.bkbits.net/gregkh/udev/ # into doug.mackenzie.net:/home/chris/hacking/udev # -------------------------------------------- # 03/10/23 [email protected] 1.135 # cleaning up test script # -------------------------------------------- # diff -Nru a/test.block b/test.block --- a/test.block Thu Oct 23 00:25:14 2003 +++ b/test.block Thu Oct 23 00:25:14 2003 @@ -16,14 +16,13 @@
for i in ${SYSFSDIR}/block/*; do
# add each drive
- export DEVPATH="/"`echo $i | cut --delimiter='/' --fields=3-`
+ export DEVPATH=${i#${SYSFSDIR}}
$BIN block # add each partition, on each device
for j in $i/*; do
if [ -f $j/dev ]; then
- export DEVPATH="/"`echo $j | \
- cut --delimiter='/' --fields=3-`
+ export DEVPATH=${j#${SYSFSDIR}}
$BIN block
fi
done
diff -Nru a/test.tty b/test.tty
--- a/test.tty Thu Oct 23 00:25:14 2003
+++ b/test.tty Thu Oct 23 00:25:14 2003
@@ -15,6 +15,6 @@
export ACTION=$1 # 'add' or 'remove' for i in ${SYSFSDIR}/class/tty/*; do
- export DEVPATH="/"echo $i | cut --delimiter='/' --fields=3-
+ export DEVPATH=${i#${SYSFSDIR}}
$BIN tty
done
Quoted 7 lines · Chris Friesen
Quoted 5 lines · Greg KH
Quoted 3 lines · Chris Friesen
I propose the following version of test.block. I think the code's easier to read than the one using "cut", and it removes the dependency on stuff outside of bash.
Quoted 5 lines
Quoted 1 line
Looks good, care to make a patch against the 004 release?
I've attached a patch against 005 for both the block and tty scripts. I didn't bother running udev backgrounded, since as you say, the new code runs a lot faster.
Sorry for the delay, but I've included your patch in the 006 release.
thanks,
greg k-h
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel