linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] callout part selector tweak
Date: Thu, 11 Mar 2004 00:15:02 +0000	[thread overview]
Message-ID: <20040311001502.GB31657@vrfy.org> (raw)

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

Martin Schwenke <martin@meltin.net> asked for this feature and posted a
patch:

 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
 "giveme the second and later words"."


Here is the actual version with tests and a few words in the man page.

thanks,
Kay

[-- Attachment #2: 02-result-selector-plus.patch --]
[-- Type: text/plain, Size: 1942 bytes --]

===== namedev.c 1.128 vs edited =====
--- 1.128/namedev.c	Thu Mar 11 00:55:33 2004
+++ edited/namedev.c	Thu Mar 11 00:56:32 2004
@@ -190,6 +190,7 @@
 	int i;
 	char c;
 	char *spos;
+	char *rest;
 	int slen;
 	struct sysfs_attribute *tmpattr;
 
@@ -244,7 +245,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--;
@@ -255,7 +256,10 @@
 					dbg("requested part of result string not found");
 					break;
 				}
-				strfieldcpymax(temp2, spos, slen+1);
+				if (rest[0] == '+')
+					strfieldcpy(temp2, spos);
+				else
+					strfieldcpymax(temp2, spos, slen+1);
 				strfieldcatmax(string, temp2, maxsize);
 				dbg("substitute part of result string '%s'", temp2);
 			} else {
===== udev.8 1.52 vs edited =====
--- 1.52/udev.8	Wed Mar 10 21:04:30 2004
+++ edited/udev.8	Thu Mar 11 01:06:56 2004
@@ -253,7 +253,10 @@
 .br
 A single part of the string, separated by a space character
 may be selected by specifying the part number as a attribute:
-.BI %c{ part }
+.BI %c{ N }
+If the number is followed by the + char this part plus
+all remaining parts of the result string are substituted:
+.BI %c{ N+ }
 .TP
 .BI %s{ filename }
 The content of a sysfs attribute.
===== test/udev-test.pl 1.43 vs edited =====
--- 1.43/test/udev-test.pl	Thu Mar 11 00:55:33 2004
+++ edited/test/udev-test.pl	Thu Mar 11 00:56:35 2004
@@ -307,6 +307,15 @@
 EOF
 	},
 	{
+		desc     => "program result substitution (numbered part of+)",
+		subsys   => "block",
+		devpath  => "block/sda/sda3",
+		expected => "link3" ,
+		conf     => <<EOF
+BUS="scsi", PROGRAM="/bin/echo -n node link1 link2 link3 link4", RESULT="node *", NAME="%c{1}", SYMLINK="%c{2+}"
+EOF
+	},
+	{
 		desc     => "invalid program for device with no bus",
 		subsys   => "tty",
 		devpath  => "class/tty/console",

             reply	other threads:[~2004-03-11  0:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-11  0:15 Kay Sievers [this message]
2004-03-11  1:42 ` [PATCH] callout part selector tweak Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040311001502.GB31657@vrfy.org \
    --to=kay.sievers@vrfy.org \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).