summaryrefslogtreecommitdiff
path: root/udevd.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2006-09-08 11:28:38 +0200
committerKay Sievers <kay.sievers@suse.de>2006-09-08 11:28:38 +0200
commit9e8fe79b8e84177fc9479d6c6af039b7402d52d3 (patch)
treed727f05e473849ca83e7cdde0ea2fad0634be965 /udevd.c
parentb52a01ee39dad3b04aaa7e3af7435f062d3e887f (diff)
udevd: add --verbose option to log also to stdout
Diffstat (limited to 'udevd.c')
-rw-r--r--udevd.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/udevd.c b/udevd.c
index df6e222810..eb632bd852 100644
--- a/udevd.c
+++ b/udevd.c
@@ -45,6 +45,8 @@
#include "udevd.h"
#include "udev_selinux.h"
+static int verbose;
+
static struct udev_rules rules;
static int udevd_sock = -1;
static int uevent_netlink_sock = -1;
@@ -76,6 +78,13 @@ void log_message(int priority, const char *format, ...)
va_start(args, format);
vsyslog(priority, format, args);
va_end(args);
+
+ if (verbose) {
+ va_start(args, format);
+ vprintf(format, args);
+ va_end(args);
+ printf("\n");
+ }
}
#endif
@@ -921,6 +930,7 @@ int main(int argc, char *argv[], char *envp[])
int option;
static const struct option options[] = {
{ "daemon", 0, NULL, 'd' },
+ { "verbose", 0, NULL, 'v' },
{ "help", 0, NULL, 'h' },
{}
};
@@ -942,8 +952,13 @@ int main(int argc, char *argv[], char *envp[])
case 'd':
daemonize = 1;
break;
+ case 'v':
+ verbose = 1;
+ if (udev_log_priority < LOG_INFO)
+ udev_log_priority = LOG_INFO;
+ break;
case 'h':
- printf("Usage: udevd [--help] [--daemon]\n");
+ printf("Usage: udevd [--help] [--daemon] [--verbose]\n");
goto exit;
default:
goto exit;
@@ -1006,7 +1021,8 @@ int main(int argc, char *argv[], char *envp[])
fd = open("/dev/null", O_RDWR);
if (fd >= 0) {
dup2(fd, STDIN_FILENO);
- dup2(fd, STDOUT_FILENO);
+ if (!verbose)
+ dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
if (fd > STDERR_FILENO)
close(fd);