use global udev_log variable instead of parameter in run_program

This commit is contained in:
Kay Sievers 2007-07-14 20:43:43 +02:00
parent 4110664d4f
commit fb819f5554
6 changed files with 11 additions and 12 deletions

View 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);
}
}
}

2
udev.h
View File

@ -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

View 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)

View 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;

View File

@ -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;
}

View 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);
}
}
}