Skip to contentSkip to conversation

udev - make exec_callout() reusable

PATCH Applied Kay Sievers 2 participants 4 messages Jan 8, 2004 – Jan 10, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 udev - make exec_callout() reusable

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

thanks,
Kay

namedev.c +6 -6
diff -Nru a/namedev.c b/namedev.c
@@ -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;
Applied
#1 lore raw
Quoted 2 lines · Kay Sievers

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

Care to hint about what context that would be? :)

Applied, thanks.

greg k-h

-------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#2 lore raw
In reply to Kay Sievers
Quoted 5 lines · Greg KH
Quoted 2 lines · Kay Sievers

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

Care to hint about what context that would be? :)

Oh, I dropped the idea. I wanted that some keys are evaluated by a external program, some sort of a tricky callout.
While thinking about it, the idea for dropping all the explicit methods came up. The callout method converted to only a PROGRAM= key combinable with every other key seems the cleaner solution.

But we never know. Maybe some day we need a free callable exec :)

Kay

-------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#3 lore raw
In reply to Kay Sievers
Quoted 9 lines · Kay Sievers
Quoted 5 lines · Greg KH
Quoted 2 lines · Kay Sievers

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

Care to hint about what context that would be? :)

Oh, I dropped the idea. I wanted that some keys are evaluated by a external program, some sort of a tricky callout.

Ah, ok, Pat came and talked to me about something like that today (the author of the scsi-id program.) I was curious as to what you were thinking.

Quoted 5 lines

While thinking about it, the idea for dropping all the explicit methods came up. The callout method converted to only a PROGRAM= key combinable with every other key seems the cleaner solution.

But we never know. Maybe some day we need a free callable exec :)

Heh, I agree. It is nice code to have around :)

greg k-h

-------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel