linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] udev: cool test scripts
@ 2003-10-17 22:35 Robert Love
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Love @ 2003-10-17 22:35 UTC (permalink / raw)
  To: linux-hotplug

Hi, Greg.

I dunno if these are desired, but they are pretty useful to me.

This patch changes test.tty and test.block to add/remove each tty and
block device, respectively, on the system.  Great way to
populate/unpopulate udev rapidly.

Its just a simple for loop over the sysfs entries.

Patch is against udev-003.

	Robert Love


 test.block |   18 ++++++++++--------
 test.tty   |   18 ++++++++++--------
 2 files changed, 20 insertions(+), 16 deletions(-)

diff -urN udev-cvs/test.block udev/test.block
--- udev-cvs/test.block	2003-07-24 22:12:14.000000000 -0400
+++ udev/test.block	2003-10-17 18:30:07.314143640 -0400
@@ -1,10 +1,12 @@
-#!/bin/sh
-export ACTION­d
-#export ACTION=remove
+#! /bin/sh
+#
+# test.block - run udev(8) on each block device in /sys/block
 
-export DEVPATH=/block/hda
-export DEVPATH=/block/sda/sda1
-#export DEVPATH=/block/sda
+SYSFSDIR=/sys		# change this for a nonstand sysfs mount point
+BIN=./udev		# location of your udev binary
+export ACTION­d	# 'add' or 'remove'
 
-
-./udev block
+for i in ${SYSFSDIR}/block/*; do
+	export DEVPATH="/"`echo $i | cut --delimiter='/' --fields=3-`
+	$BIN block
+done
diff -urN udev-cvs/test.tty udev/test.tty
--- udev-cvs/test.tty	2003-07-23 15:32:19.000000000 -0400
+++ udev/test.tty	2003-10-17 18:28:25.808574832 -0400
@@ -1,10 +1,12 @@
-#!/bin/sh
-export ACTION­d
-#export ACTION=remove
-export DEVPATH=/devices/pci0/00:09.0/usb1/1-1/1-1.1/ttyUSB7
-export DEVPATH=/class/tty/ttyUSB0
-#export DEVPATH=/block/hda
+#! /bin/sh
+#
+# test.tty - run udev(8) on each tty device in /sys/class/tty
 
+SYSFSDIR=/sys		# change this for a nonstand sysfs mount point
+BIN=./udev		# location of your udev binary
+export ACTION­d	# 'add' or 'remove'
 
-#./udev block
-./udev tty
+for i in ${SYSFSDIR}/class/tty/*; do
+	export DEVPATH="/"`echo $i | cut --delimiter='/' --fields=3-`
+	$BIN tty
+done





-------------------------------------------------------
This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo
The Event For Linux Datacenter Solutions & Strategies in The Enterprise 
Linux in the Boardroom; in the Front Office; & in the Server Room 
http://www.enterpriselinuxforum.com
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] udev: cool test scripts
@ 2003-10-17 22:58 Greg KH
  2003-10-17 23:18 ` Robert Love
  2003-10-18  0:18 ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: Greg KH @ 2003-10-17 22:58 UTC (permalink / raw)
  To: linux-hotplug

On Fri, Oct 17, 2003 at 06:35:22PM -0400, Robert Love wrote:
> Hi, Greg.
> 
> I dunno if these are desired, but they are pretty useful to me.
> 
> This patch changes test.tty and test.block to add/remove each tty and
> block device, respectively, on the system.  Great way to
> populate/unpopulate udev rapidly.
> 
> Its just a simple for loop over the sysfs entries.

Nice, thanks for the patch, I've applied it.

But the test.block script doesn't catch any partitions on the block
devices :)

thanks,

greg k-h


-------------------------------------------------------
This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo
The Event For Linux Datacenter Solutions & Strategies in The Enterprise 
Linux in the Boardroom; in the Front Office; & in the Server Room 
http://www.enterpriselinuxforum.com
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] udev: cool test scripts
  2003-10-17 22:58 [patch] udev: cool test scripts Greg KH
@ 2003-10-17 23:18 ` Robert Love
  2003-10-18  0:18 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Robert Love @ 2003-10-17 23:18 UTC (permalink / raw)
  To: linux-hotplug

On Fri, 2003-10-17 at 18:58, Greg KH wrote:

> Nice, thanks for the patch, I've applied it.

Thanks.

> But the test.block script doesn't catch any partitions on the block
> devices :)

Never happy!  But for a fellow Gator...

        [19:07:52]root@phantasy:~/src/udev/udev# ./test.block
        [19:13:37]root@phantasy:~/src/udev/udev# ls /udev/hd*
        ls: /udev/hd*: No such file or directory
        [19:13:42]root@phantasy:~/src/udev/udev# ./test.block
        [19:13:53]root@phantasy:~/src/udev/udev# ls /udev/hd*
        /udev/hda   /udev/hda2  /udev/hda4  /udev/hda6  /udev/hdd
        /udev/hda1  /udev/hda3  /udev/hda5  /udev/hdc

test.block now recurses /sys/block, looking for partitions.  Should add
all drives and all partitions.

Patch is against 003 plus last patch.

	Robert Love


 test.block |   10 ++++++++++
 1 files changed, 10 insertions(+)

diff -urN udev-cvs/test.block udev/test.block
--- udev-cvs/test.block	2003-10-17 19:17:36.299032104 -0400
+++ udev/test.block	2003-10-17 19:18:16.672894344 -0400
@@ -7,6 +7,16 @@
 export ACTION­d	# 'add' or 'remove'
 
 for i in ${SYSFSDIR}/block/*; do
+	# add each drive
 	export DEVPATH="/"`echo $i | cut --delimiter='/' --fields=3-`
 	$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-`
+			$BIN block
+		fi
+	done
 done




-------------------------------------------------------
This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo
The Event For Linux Datacenter Solutions & Strategies in The Enterprise 
Linux in the Boardroom; in the Front Office; & in the Server Room 
http://www.enterpriselinuxforum.com
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] udev: cool test scripts
  2003-10-17 22:58 [patch] udev: cool test scripts Greg KH
  2003-10-17 23:18 ` Robert Love
@ 2003-10-18  0:18 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2003-10-18  0:18 UTC (permalink / raw)
  To: linux-hotplug

On Fri, Oct 17, 2003 at 07:18:48PM -0400, Robert Love wrote:
>         [19:07:52]root@phantasy:~/src/udev/udev# ./test.block
>         [19:13:37]root@phantasy:~/src/udev/udev# ls /udev/hd*
>         ls: /udev/hd*: No such file or directory
>         [19:13:42]root@phantasy:~/src/udev/udev# ./test.block
>         [19:13:53]root@phantasy:~/src/udev/udev# ls /udev/hd*
>         /udev/hda   /udev/hda2  /udev/hda4  /udev/hda6  /udev/hdd
>         /udev/hda1  /udev/hda3  /udev/hda5  /udev/hdc
> 
> test.block now recurses /sys/block, looking for partitions.  Should add
> all drives and all partitions.
> 
> Patch is against 003 plus last patch.

Very nice.  Applied, thanks.

greg k-h


-------------------------------------------------------
This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo
The Event For Linux Datacenter Solutions & Strategies in The Enterprise 
Linux in the Boardroom; in the Front Office; & in the Server Room 
http://www.enterpriselinuxforum.com
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-10-18  0:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-17 22:58 [patch] udev: cool test scripts Greg KH
2003-10-17 23:18 ` Robert Love
2003-10-18  0:18 ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2003-10-17 22:35 Robert Love

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).