linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] udev - switch callout part selector to {attribute}
@ 2004-02-17  1:11 Kay Sievers
  2004-02-17  1:33 ` Greg KH
  2004-02-29 16:05 ` Olaf Hering
  0 siblings, 2 replies; 3+ messages in thread
From: Kay Sievers @ 2004-02-17  1:11 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 334 bytes --]

Here we change the magic callout part number selector to the new
atribute syntax. The syntax to select the second part of the callout string:

 '%2c' is now '%c{2}'

I think it's more clear and we no longer misuse the length argument.

The old syntax is still supported, but we should remove it some
time in the future.


thanks,
Kay

[-- Attachment #2: 02-callout-part-as-attribute.patch --]
[-- Type: text/plain, Size: 3798 bytes --]

diff -Nru a/etc/udev/udev.rules.devfs b/etc/udev/udev.rules.devfs
--- a/etc/udev/udev.rules.devfs	Tue Feb 17 01:52:32 2004
+++ b/etc/udev/udev.rules.devfs	Tue Feb 17 01:52:32 2004
@@ -2,7 +2,7 @@
 # fields.  See the udev man page for a full description of them.
 
 # ide block devices
-BUS="ide", KERNEL="hd*", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", NAME="%k", SYMLINK="%1c %2c"
+BUS="ide", KERNEL="hd*", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", NAME="%k", SYMLINK="%c{1} %c{2}"
 
 # md block devices
 KERNEL="md[0-9]*", NAME="md/%n"
diff -Nru a/etc/udev/udev.rules.gentoo b/etc/udev/udev.rules.gentoo
--- a/etc/udev/udev.rules.gentoo	Tue Feb 17 01:52:32 2004
+++ b/etc/udev/udev.rules.gentoo	Tue Feb 17 01:52:32 2004
@@ -57,7 +57,7 @@
 
 # devfs-names for ide-devices (uncomment only one)
 #  /dev/ide/.../{disc,cd} and /dev/{cdroms,discs}/* type names
-BUS="ide", PROGRAM="/etc/udev/scripts/ide-devfs.sh %k %b %n", RESULT="hd*", NAME="%1c", SYMLINK="%2c %3c"
+BUS="ide", PROGRAM="/etc/udev/scripts/ide-devfs.sh %k %b %n", RESULT="hd*", NAME="%c{1}", SYMLINK="%c{2} %c{3}"
  
 # fb devices
 KERNEL="fb[0-9]*", NAME="fb/%n", SYMLINK="%k"
diff -Nru a/extras/ide-devfs.sh b/extras/ide-devfs.sh
--- a/extras/ide-devfs.sh	Tue Feb 17 01:52:32 2004
+++ b/extras/ide-devfs.sh	Tue Feb 17 01:52:32 2004
@@ -2,7 +2,7 @@
 
 # udev external PROGRAM script
 # return devfs-names for ide-devices
-# BUS="ide", KERNEL="hd*", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", NAME="%k", SYMLINK="%1c %2c"
+# BUS="ide", KERNEL="hd*", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", NAME="%k", SYMLINK="%c{1} %c{2}"
 
 HOST="${2%\.[0-9]}"
 TARGET="${2#[0-9]\.}"
diff -Nru a/extras/name_cdrom.pl b/extras/name_cdrom.pl
--- a/extras/name_cdrom.pl	Tue Feb 17 01:52:32 2004
+++ b/extras/name_cdrom.pl	Tue Feb 17 01:52:32 2004
@@ -2,7 +2,7 @@
 
 # a horribly funny script that shows how flexible udev can really be
 # This is to be executed by udev with the following rules:
-# KERNEL="[hs]d[a-z]", PROGRAM="name_cdrom.pl %M %m", NAME="%1c", SYMLINK="cdrom"
+# KERNEL="[hs]d[a-z]", PROGRAM="name_cdrom.pl %M %m", NAME="%c{1}", SYMLINK="cdrom"
 
 use strict;
 use warnings;
diff -Nru a/namedev.c b/namedev.c
--- a/namedev.c	Tue Feb 17 01:52:32 2004
+++ b/namedev.c	Tue Feb 17 01:52:32 2004
@@ -219,6 +219,7 @@
 	char *pos3;
 	char *attr;
 	int num;
+	int i;
 	char c;
 	struct sysfs_attribute *tmpattr;
 
@@ -270,11 +271,15 @@
 		case 'c':
 			if (strlen(udev->program_result) == 0)
 				break;
-			if (num > 0) {
+			/* get part part of the result string */
+			i = num; /* num syntax is deprecated and will be removed  */
+			if (attr != NULL)
+				i = atoi(attr);
+			if (i > 0) {
 				strncpy(temp1, udev->program_result, sizeof(temp1));
 				pos2 = temp1;
-				while (num) {
-					num--;
+				while (i) {
+					i--;
 					pos3 = strsep(&pos2, " ");
 					if (pos3 == NULL) {
 						dbg("requested part of result string not found");
diff -Nru a/test/udev-test.pl b/test/udev-test.pl
--- a/test/udev-test.pl	Tue Feb 17 01:52:32 2004
+++ b/test/udev-test.pl	Tue Feb 17 01:52:32 2004
@@ -194,16 +194,6 @@
 EOF
 	},
 	{
-		desc     => "select sysfs attribute by SYSFS{vendor}",
-		subsys   => "block",
-		devpath  => "block/sda",
-		expected => "disk-IBM-ESXS-sda" ,
-		conf     => <<EOF
-BUS="scsi", SYSFS{vendor}="IBM-ESXS", NAME="disk-%s{vendor}-%k"
-KERNEL="ttyUSB0", NAME="visor"
-EOF
-	},
-	{
 		desc     => "sustitution of sysfs value (%s{file})",
 		subsys   => "block",
 		devpath  => "block/sda",
@@ -250,7 +240,7 @@
 		devpath  => "block/sda/sda3",
 		expected => "link1" ,
 		conf     => <<EOF
-BUS="scsi", PROGRAM="/bin/echo -n node link1 link2", RESULT="node *", NAME="%1c", SYMLINK="%2c %3c"
+BUS="scsi", PROGRAM="/bin/echo -n node link1 link2", RESULT="node *", NAME="%c{1}", SYMLINK="%c{2} %c{3}"
 EOF
 	},
 	{

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

* Re: [PATCH] udev - switch callout part selector to {attribute}
  2004-02-17  1:11 [PATCH] udev - switch callout part selector to {attribute} Kay Sievers
@ 2004-02-17  1:33 ` Greg KH
  2004-02-29 16:05 ` Olaf Hering
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2004-02-17  1:33 UTC (permalink / raw)
  To: linux-hotplug

On Tue, Feb 17, 2004 at 02:11:52AM +0100, Kay Sievers wrote:
> Here we change the magic callout part number selector to the new
> atribute syntax. The syntax to select the second part of the callout string:
> 
>  '%2c' is now '%c{2}'
> 
> I think it's more clear and we no longer misuse the length argument.
> 
> The old syntax is still supported, but we should remove it some
> time in the future.

I agree, give us a release or two to warn people about it :)

Applied, thanks.

greg k-h


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id\x1356&alloc_id438&op=click
_______________________________________________
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] 3+ messages in thread

* Re: [PATCH] udev - switch callout part selector to {attribute}
  2004-02-17  1:11 [PATCH] udev - switch callout part selector to {attribute} Kay Sievers
  2004-02-17  1:33 ` Greg KH
@ 2004-02-29 16:05 ` Olaf Hering
  1 sibling, 0 replies; 3+ messages in thread
From: Olaf Hering @ 2004-02-29 16:05 UTC (permalink / raw)
  To: linux-hotplug

 On Tue, Feb 17, Kay Sievers wrote:

> Here we change the magic callout part number selector to the new
> atribute syntax. The syntax to select the second part of the callout string:
> 
>  '%2c' is now '%c{2}'

This changed the format requirements of the config file. I think it is
time to provide a simple version tag for the config files,
similar to /etc/pam/* or /proc/slabinfo.

-- 
USB is for mice, FireWire is for men!

sUse lINUX ag, n√úRNBERG


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id\x1356&alloc_id438&op=click
_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2004-02-29 16:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-17  1:11 [PATCH] udev - switch callout part selector to {attribute} Kay Sievers
2004-02-17  1:33 ` Greg KH
2004-02-29 16:05 ` Olaf Hering

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