All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] udev - make exec_callout() reusable
Date: Thu, 08 Jan 2004 18:33:55 +0000	[thread overview]
Message-ID: <20040108183355.GB2788@vrfy.org> (raw)

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

Here is a patch that switches exec_callout() to be reusable.
I want it to be callable in a different context.

thanks,
Kay

[-- Attachment #2: 03-exec-reuse.diff --]
[-- Type: text/plain, Size: 1524 bytes --]

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;

             reply	other threads:[~2004-01-08 18:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-08 18:33 Kay Sievers [this message]
2004-01-10  1:11 ` [PATCH] udev - make exec_callout() reusable Greg KH
2004-01-10  1:51 ` Kay Sievers
2004-01-10  3:54 ` 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=20040108183355.GB2788@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 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.