All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: [udev] support arguments in callout exec
Date: Thu, 20 Nov 2003 01:42:50 +0000	[thread overview]
Message-ID: <marc-linux-hotplug-106929267025682@msgid-missing> (raw)

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

Hi,
here is argument support for CALLOUT exec:

CALLOUT, PROGRAM="/bin/echo -n xxx", BUS="usb", ID="xxx", NAME="webcam%n"

results in:

Nov 20 02:35:20 pim udev[30422]: get_major_minor: found major = 81, minor = 0
Nov 20 02:35:20 pim udev[30422]: exec_callout: callout to /bin/echo -n xxx
Nov 20 02:35:20 pim udev[30422]: exec_callout: callout returned 'xxx'
Nov 20 02:35:20 pim udev[30422]: get_attr: kernel number appended: 0

The feature is really nice, but the maximum argument count is hard coded to 8.
What do you think?

thanks,
Kay



09-namedev.c-callout-argument-support.diff
  namdev.c - support for argument in CALLOUT exec


[-- Attachment #2: 09-namedev.c-callout-argument-support.diff --]
[-- Type: text/plain, Size: 904 bytes --]

--- ../udev/namedev.c	2003-11-19 12:56:50.000000000 +0100
+++ namedev.c	2003-11-20 02:34:05.000000000 +0100
@@ -480,6 +480,9 @@
 	pid_t pid;
 	int value_set = 0;
 	char buffer[256];
+	char *prog;
+	char *args[8];
+	int i;
 
 	dbg("callout to %s\n", dev->exec_program);
 	retval = pipe(fds);
@@ -499,7 +502,14 @@
 		 */
 		close(STDOUT_FILENO);
 		dup(fds[1]);	/* dup write side of pipe to STDOUT */
-		retval = execve(dev->exec_program, main_argv, main_envp);
+		strcpy(buffer, dev->exec_program);
+		prog = strtok(buffer, " ");
+		for(i=1; i<=8; i++) {
+			args[i] = strtok(NULL, " ");
+			if (args[i] == NULL)
+				break;
+		}
+		retval = execve(prog, args, main_envp);
 		if (retval != 0) {
 			dbg("child execve failed");
 			exit(1);
@@ -528,6 +538,7 @@
 				strncpy(value, buffer, len);
 			}
 		}
+		dbg("callout returned '%s'", value);
 		close(fds[0]);
 		res = wait(&status);
 		if (res < 0) {

             reply	other threads:[~2003-11-20  1:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-20  1:42 Kay Sievers [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-11-20  0:47 [udev] support arguments in callout exec Arnd Bergmann
2003-11-20  2:59 ` Arnd Bergmann
2003-11-20  3:21 ` Kay Sievers
2003-11-20 12:31 ` Kay Sievers
2003-11-20 16:07 ` Kay Sievers
2003-11-20 17:31 ` Kay Sievers
2003-11-20 20:14 ` Arnd Bergmann
2003-11-21  6:50 ` Greg KH
2003-11-21  6:53 ` Greg KH
2003-11-22 18:14 ` 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=marc-linux-hotplug-106929267025682@msgid-missing \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.