chiark / gitweb /
use global udev_log variable instead of parameter in run_program
authorKay Sievers <kay.sievers@vrfy.org>
Sat, 14 Jul 2007 18:43:43 +0000 (20:43 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Sat, 14 Jul 2007 18:43:43 +0000 (20:43 +0200)
test-udev.c
udev.h
udev_rules.c
udev_utils_run.c
udevd.c
udevstart.c

index ba36015..f114609 100644 (file)
@@ -166,7 +166,7 @@ int main(int argc, char *argv[], char *envp[])
 
                                strlcpy(program, name_loop->name, sizeof(program));
                                udev_rules_apply_format(udev, program, sizeof(program));
-                               run_program(program, udev->dev->subsystem, NULL, 0, NULL, (udev_log_priority >= LOG_INFO));
+                               run_program(program, udev->dev->subsystem, NULL, 0, NULL);
                        }
                }
        }
diff --git a/udev.h b/udev.h
index baf58a8..c056835 100644 (file)
--- a/udev.h
+++ b/udev.h
@@ -169,6 +169,6 @@ extern size_t buf_get_line(const char *buf, size_t buflen, size_t cur);
 /* udev_utils_run.c */
 extern int pass_env_to_socket(const char *name, const char *devpath, const char *action);
 extern int run_program(const char *command, const char *subsystem,
-                      char *result, size_t ressize, size_t *reslen, int log);
+                      char *result, size_t ressize, size_t *reslen);
 
 #endif
index b2b4809..9483c2b 100644 (file)
@@ -190,7 +190,7 @@ static int import_program_into_env(struct udevice *udev, const char *program)
        char result[2048];
        size_t reslen;
 
-       if (run_program(program, udev->dev->subsystem, result, sizeof(result), &reslen, (udev_log_priority >= LOG_INFO)) != 0)
+       if (run_program(program, udev->dev->subsystem, result, sizeof(result), &reslen) != 0)
                return -1;
        return import_keys_into_env(udev, result, reslen);
 }
@@ -837,8 +837,7 @@ try_parent:
 
                strlcpy(program, key_val(rule, &rule->program), sizeof(program));
                udev_rules_apply_format(udev, program, sizeof(program));
-               if (run_program(program, udev->dev->subsystem, result, sizeof(result),
-                               NULL, (udev_log_priority >= LOG_INFO)) != 0) {
+               if (run_program(program, udev->dev->subsystem, result, sizeof(result), NULL) != 0) {
                        dbg("PROGRAM is false");
                        udev->program_result[0] = '\0';
                        if (rule->program.operation != KEY_OP_NOMATCH)
index 1a92cdd..69b54f4 100644 (file)
@@ -24,6 +24,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <ctype.h>
+#include <syslog.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <sys/wait.h>
@@ -69,9 +70,8 @@ int pass_env_to_socket(const char *sockname, const char *devpath, const char *ac
 }
 
 int run_program(const char *command, const char *subsystem,
-               char *result, size_t ressize, size_t *reslen, int log)
+               char *result, size_t ressize, size_t *reslen)
 {
-       int retval = 0;
        int status;
        int outpipe[2] = {-1, -1};
        int errpipe[2] = {-1, -1};
@@ -81,6 +81,7 @@ int run_program(const char *command, const char *subsystem,
        char *argv[(sizeof(arg) / 2) + 1];
        int devnull;
        int i;
+       int retval = 0;
 
        /* build argv from comand */
        strlcpy(arg, command, sizeof(arg));
@@ -109,13 +110,13 @@ int run_program(const char *command, const char *subsystem,
        info("'%s'", command);
 
        /* prepare pipes from child to parent */
-       if (result || log) {
+       if (result != NULL || udev_log_priority >= LOG_INFO) {
                if (pipe(outpipe) != 0) {
                        err("pipe failed: %s", strerror(errno));
                        return -1;
                }
        }
-       if (log) {
+       if (udev_log_priority >= LOG_INFO) {
                if (pipe(errpipe) != 0) {
                        err("pipe failed: %s", strerror(errno));
                        return -1;
diff --git a/udevd.c b/udevd.c
index afefb91..5ed8e38 100644 (file)
--- a/udevd.c
+++ b/udevd.c
@@ -147,8 +147,7 @@ static int udev_event_process(struct udevd_uevent_msg *msg)
 
                                strlcpy(program, name_loop->name, sizeof(program));
                                udev_rules_apply_format(udev, program, sizeof(program));
-                               if (run_program(program, udev->dev->subsystem, NULL, 0, NULL,
-                                               (udev_log_priority >= LOG_INFO)) != 0)
+                               if (run_program(program, udev->dev->subsystem, NULL, 0, NULL) != 0)
                                        if (!name_loop->ignore_error)
                                                retval = -1;
                        }
index 6af5860..1e67a06 100644 (file)
@@ -160,7 +160,7 @@ static int add_device(const char *devpath)
 
                                strlcpy(program, name_loop->name, sizeof(program));
                                udev_rules_apply_format(udev, program, sizeof(program));
-                               run_program(program, udev->dev->subsystem, NULL, 0, NULL, (udev_log_priority >= LOG_INFO));
+                               run_program(program, udev->dev->subsystem, NULL, 0, NULL);
                        }
                }
        }