From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Mon, 08 Mar 2004 02:44:24 +0000 Subject: Re: [PATCH] namedev.c %c{N+} capability + buglet with SYMLINK Message-Id: <20040308024424.GA24782@vrfy.org> MIME-Version: 1 Content-Type: multipart/mixed; boundary="jRHKVT23PllUwdXP" List-Id: References: <16459.53560.188318.971393@martins.ozlabs.org> In-Reply-To: <16459.53560.188318.971393@martins.ozlabs.org> To: linux-hotplug@vger.kernel.org --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Mar 08, 2004 at 12:49:44PM +1100, Martin Schwenke wrote: > I want to be able to use naming callouts that follow a convention of > providing the canonical device name as the first word, and > aliases/symlinks as subsequent words. That is, my callout might > print: > > hdc cdrom bert ernie > > so the canonical name will be "hdc", and "cdrom, "bert" and "ernie" > will be aliases/symlinks. I can probably implement this is in > slightly gross fashion by having the result match against the number > spaces in the result, and then do the appropriate number of > substitutions. > > The following patch almost let's me have the following configuration: > > PROGRAM="/sbin/aliaser %b %k %n %M %m", RESULT="?*", NAME="%c{1}", SYMLINK="%c{2+}" > > allowing me to specify an arbitrary number of symlinks by saying "give > me the second and later words". I thought of implementing something > more complex (involving arbitrary ranges of words), but I think the > implementation below provides all the functionality that is needed. Nice idea, but the code you've patched is gone: http://linuxusb.bkbits.net:8080/udev/anno/namedev.c@1.125?nav=index.html|src/ Hey, it was too ugly and you try to make it more ugly :) Here is a patch for the current version, but there are more patches pending and we need to change it again. thanks, Kay --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="06-result-selector-plus.patch" ===== namedev.c 1.125 vs edited ===== --- 1.125/namedev.c Thu Mar 4 14:38:53 2004 +++ edited/namedev.c Mon Mar 8 03:22:43 2004 @@ -222,6 +222,7 @@ int i; char c; char *spos; + char *rest; int slen; struct sysfs_attribute *tmpattr; @@ -276,7 +277,7 @@ /* get part part of the result string */ i = 0; if (attr != NULL) - i = atoi(attr); + i = strtoul(attr, &rest, 10); if (i > 0) { foreach_strpart(udev->program_result, " \n\r", spos, slen) { i--; @@ -287,7 +288,10 @@ dbg("requested part of result string not found"); break; } - strnfieldcpy(temp2, spos, slen+1); + if (rest[0] == '+') + strfieldcpy(temp2, spos); + else + strnfieldcpy(temp2, spos, slen+1); strnfieldcat(string, temp2, maxsize); dbg("substitute part of result string '%s'", temp2); } else { ===== test/udev-test.pl 1.42 vs edited ===== --- 1.42/test/udev-test.pl Thu Mar 4 14:38:53 2004 +++ edited/test/udev-test.pl Mon Mar 8 03:24:57 2004 @@ -289,6 +289,15 @@ EOF }, { + desc => "program result substitution (numbered part of+)", + subsys => "block", + devpath => "block/sda/sda3", + expected => "link3" , + conf => < "invalid program for device with no bus", subsys => "tty", devpath => "class/tty/console", --jRHKVT23PllUwdXP-- ------------------------------------------------------- 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_id=1470&alloc_id=3638&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