From mboxrd@z Thu Jan 1 00:00:00 1970 From: Darren Salt Date: Tue, 17 Feb 2004 01:25:20 +0000 Subject: Re: udev patch for attributes with trailing spaces in the values Message-Id: <4C81E83018%linux@youmustbejoking.demon.co.uk> MIME-Version: 1 Content-Type: multipart/mixed; boundary="80524971--667826619--567694585" List-Id: References: <200401301014.51387.meaton@vasco.com> In-Reply-To: <200401301014.51387.meaton@vasco.com> To: linux-hotplug@vger.kernel.org This message is in MIME format which your mailer apparently does not support. You either require a newer version of your software which supports MIME, or a separate MIME decoding utility. Alternatively, ask the sender of this message to resend it in a different format. --80524971--667826619--567694585 Content-Type: text/plain; charset=us-ascii I demand that Kay Sievers may or may not have written... > On Fri, Jan 30, 2004 at 10:14:51AM +1000, Mark Eaton wrote: >> 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... >> diff -Nru udev-015-orig/namedev.c udev-015/namedev.c >> --- udev-015-orig/namedev.c 2004-01-23 09:28:36.000000000 +1000 >> +++ udev-015/namedev.c 2004-01-30 08:59:10.000000000 +1000 >> @@ -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. -- | 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. --80524971--667826619--567694585 Content-Type: text/plain; charset=iso-8859-1; name="trailing-space.patch" Content-Disposition: attachment; filename="trailing-space.patch" Content-Transfer-Encoding: quoted-printable --- udev-016/namedev.c~ 2004-01-31 15:36:18.000000000 +0000 +++ udev-016/namedev.c 2004-02-11 15:09:06.000000000 +0000 @@ -422,9 +422,9 @@ return -ENODEV; =20 label_found: - c =3D tmpattr->value + strlen(tmpattr->value)-1; - if (*c =3D=3D '\n') - *c =3D 0x00; + c =3D tmpattr->value + strlen(tmpattr->value); + while (--c >=3D tmpattr->value && isspace (*c)) + *c =3D 0; dbg("compare attribute '%s' value '%s' with '%s'", pair->file, tmpattr->value, pair->value); if (strcmp_pattern(pair->value, tmpattr->value) !=3D 0) --80524971--667826619--567694585-- ------------------------------------------------------- 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=1356&alloc_id=3438&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