From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Thu, 08 Jan 2004 18:33:55 +0000 Subject: [PATCH] udev - make exec_callout() reusable Message-Id: <20040108183355.GB2788@vrfy.org> MIME-Version: 1 Content-Type: multipart/mixed; boundary="aM3YZ0Iwxop3KEKx" List-Id: To: linux-hotplug@vger.kernel.org --aM3YZ0Iwxop3KEKx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Here is a patch that switches exec_callout() to be reusable. I want it to be callable in a different context. thanks, Kay --aM3YZ0Iwxop3KEKx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="03-exec-reuse.diff" diff -Nru a/namedev.c b/namedev.c --- a/namedev.c Thu Jan 8 19:05:25 2004 +++ b/namedev.c Thu Jan 8 19:05:25 2004 @@ -298,7 +298,7 @@ return; /* here to prevent compiler warning... */ } -static int exec_callout(struct config_device *dev, char *value, int len) +static int exec_program(char *path, char *value, int len) { int retval; int res; @@ -311,7 +311,7 @@ char *args[CALLOUT_MAXARG]; int i; - dbg("callout to '%s'", dev->exec_program); + dbg("callout to '%s'", path); retval = pipe(fds); if (retval != 0) { dbg("pipe failed"); @@ -327,9 +327,9 @@ /* child */ close(STDOUT_FILENO); dup(fds[1]); /* dup write side of pipe to STDOUT */ - if (strchr(dev->exec_program, ' ')) { + if (strchr(path, ' ')) { /* callout with arguments */ - pos = dev->exec_program; + pos = path; for (i=0; i < CALLOUT_MAXARG-1; i++) { args[i] = strsep(&pos, " "); if (args[i] == NULL) @@ -341,7 +341,7 @@ } retval = execve(args[0], args, main_envp); } else { - retval = execve(dev->exec_program, main_argv, main_envp); + retval = execve(path, main_argv, main_envp); } if (retval != 0) { dbg("child execve failed"); @@ -407,7 +407,7 @@ /* substitute anything that needs to be in the program name */ apply_format(udev, dev->exec_program); - if (exec_callout(dev, udev->callout_value, NAME_SIZE)) + if (exec_program(dev->exec_program, udev->callout_value, NAME_SIZE)) continue; if (strcmp_pattern(dev->id, udev->callout_value) != 0) continue; --aM3YZ0Iwxop3KEKx-- ------------------------------------------------------- This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html _______________________________________________ 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