udev patch for attributes with trailing spaces in the values
The following patch strips off spaces that are often contained at the end of SYSFS_ attributes. (ie lots of printers etc do this).
I'm not sure if this should actually be added to udev but I would be curious to hear peoples thoughts as I find it extremly annoying and pointless to have to hexdump the sysfs values to check if there are trailing spaces to write the various rules.
--
Mark Eaton
Senior Software Engineer
VASCO The Authentication Company
+67 3511 5404
+67 (0) 403 384 886
[email protected]
namedev.c +4 -1
@@ -427,7 +427,10 @@ label_found: c = tmpattr->value +strlen (tmpattr->value)-1 ;if (*c =='\n' ) - *c =0x00 ; + *c-- =0x00 ; +while (*c ==' ' ) + *c-- =0x00 ; +dbg ("compare attribute '%s' value '%s' with '%s'" , pair->file, tmpattr->value, pair->value);if (strcmp_pattern (pair->value, tmpattr->value) !=0 )
Quoted 6 lines · Mark Eaton
The following patch strips off spaces that are often contained at the end of
SYSFS_attributes. (ie lots of printers etc do this).
I'm not sure if this should actually be added to udev but I would be curious to hear peoples thoughts as I find it extremly annoying and pointless to have to hexdump the sysfs values to check if there are trailing spaces to write the various rules.
You may use udevinfo that prints the ready formated attribute for you or use the pattern matching if you don't want to count the number of spaces. :)
namedev.c line 430
Quoted 9 lines
diff -Nru
udev-015-orig/namedev.cudev-015/namedev.cnamedev.c +1
-1@@ -427,7 +427,10 @@ label_found: c = tmpattr->value +strlen (tmpattr->value)-1 ;if (*c ='\n' ) - *c =0x00 ; + *c-- =0x00 ;
Huh, what if the value is only the '\n'?
namedev.c line 432
Quoted 2 lines
namedev.c +2
-0+while (*c =' ' ) + *c-- =0x00 ;
thanks,
Kay
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
I demand that Kay Sievers may or may not have written...
Quoted 11 lines · Mark Eaton
Quoted 6 lines
The following patch strips off spaces that are often contained at the end of
SYSFS_attributes. (ie lots of printers etc do this). I'm not sure if this should actually be added to udev but I would be curious to hear peoples thoughts as I find it extremly annoying and pointless to have to hexdump the sysfs values to check if there are trailing spaces to write the various rules.You may use udevinfo that prints the ready formated attribute for you or use the pattern matching if you don't want to count the number of spaces. :)
I recently hit this problem when adding a device name (mainly "because I can") for a CF card reader. Initially, I wasn't aware that there /were/ any trailing spaces (and I hadn't noticed udevinfo), then I looked again and went hexdumping...
Quoted 11 lines
namedev.c 2004-01-30 08:59:10.000000000 +1000 line 430
Quoted 9 lines
diff -Nru
udev-015-orig/namedev.cudev-015/namedev.cnamedev.c 2004-01-30 08:59:10.000000000 +1000 renamed from namedev.c 2004-01-23 09:28:36.000000000 +1000 +1
-1@@ -427,7 +427,10 @@ label_found: c = tmpattr->value + strlen(tmpattr->value)-1; if (*c == '\n') - *c = 0x00; + *c-- = 0x00;Huh, what if the value is only the '\n'?
Fun and games, of course ;-)
My independently-written version is attached.
Signature · 6 lines
| Darren Salt | nr. Ashington, | d youmustbejoking,demon,co,uk | Debian, | Northumberland | s zap,tartarus,org | RISC OS | Toon Army | @ | When replying, "news"->"ds", "cu"->"co.uk", and validate By protracting life, we do not deduct one jot from the duration of death.
namedev.c renamed from namedev.c~ +3 -3
@@ -422,9 +422,9 @@return -ENODEV ; label_found: - c = tmpattr->value +strlen (tmpattr->value)-1 ; -if (*c =='\n' ) - *c =0x00 ; + c = tmpattr->value +strlen (tmpattr->value); +while (--c >= tmpattr->value &&isspace (*c)) + *c =0 ;dbg ("compare attribute '%s' value '%s' with '%s'" , pair->file, tmpattr->value, pair->value);if (strcmp_pattern (pair->value, tmpattr->value) !=0 )