From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Wed, 03 Mar 2004 22:58:59 +0000 Subject: Re: [PATCH] fix NAME="foo-%c{N}" gets a truncated name Message-Id: <1078354738.1168.51.camel@pim> List-Id: References: <20040303144334.A20521@beaverton.ibm.com> In-Reply-To: <20040303144334.A20521@beaverton.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org On Wed, 2004-03-03 at 23:43, Patrick Mansfield wrote: > Here is a fix and a new test for the problem Atul hit, where if we have a > NAME based on a result of the form: > > NAME="foo-%c{7}" > > udev truncates the name. Without any prefix (the foo- in this example), > the rule was working OK. > > === namedev.c 1.122 vs edited ==> --- 1.122/namedev.c Tue Mar 2 21:00:21 2004 > +++ edited/namedev.c Wed Mar 3 14:16:54 2004 > @@ -285,7 +285,7 @@ > dbg("requested part of result string not found"); > break; > } > - strnfieldcat(string, udev->program_result + spos, slen+1); > + strnfieldcat(string, udev->program_result + spos, maxsize); > dbg("substitute part of result string '%s'", pos); No, this doesn't work. The string part of the string is not \0 terminated, so we need to truncate after the computed length. BUS="scsi", PROGRAM="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL="sda3", NAME="my-%c{6}" TEST 24: lots of arguments and characters before %c{N} device 'block/sda/sda3' expecting node 'my-foo8' add: error udev-root/ `-- my-foo8 foo9 thanks, Kay ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&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