]> err.no Git - systemd/commitdiff
udevd: add --verbose option to log also to stdout
authorKay Sievers <kay.sievers@suse.de>
Fri, 8 Sep 2006 09:28:38 +0000 (11:28 +0200)
committerKay Sievers <kay.sievers@suse.de>
Fri, 8 Sep 2006 09:28:38 +0000 (11:28 +0200)
udevd.8
udevd.c
udevd.xml

diff --git a/udevd.8 b/udevd.8
index bb6d27fb41ebb88a3f96f3e5b3e077e1fe0d6f69..aef2090236b1cb80667e03a9df16dfce87fd3ce3 100644 (file)
--- a/udevd.8
+++ b/udevd.8
@@ -14,7 +14,7 @@
 udevd \- event managing daemon
 .SH "SYNOPSIS"
 .HP 6
-\fBudevd\fR [\fB\-\-daemon\fR] [\fB\-\-help\fR]
+\fBudevd\fR [\fB\-\-daemon\fR] [\fB\-\-verbose\fR] [\fB\-\-help\fR]
 .HP 20
 \fBudevcontrol \fR\fB\fIcommand\fR\fR
 .SH "DESCRIPTION"
@@ -25,6 +25,9 @@ udevd listens to kernel uevents and passes the incoming events to udev. It ensur
 \fB\-\-daemon\fR
 Detach and run in the background.
 .TP 3n
+\fB\-\-verbose\fR
+Print log messages to stdout.
+.TP 3n
 \fB\-\-help\fR
 Print usage.
 .TP 3n
diff --git a/udevd.c b/udevd.c
index df6e2228106173db10212ee025cb1184bb633f6b..eb632bd85242d32a29e772efcb30da7349c02a87 100644 (file)
--- 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);
index f0682ed00c3b8600d84b3936adc3c5864414bdae..cc2a1bcd22221e419e854f5e1e9f15d1fd925ed6 100644 (file)
--- a/udevd.xml
+++ b/udevd.xml
@@ -26,6 +26,7 @@
         <cmdsynopsis>
           <command>udevd</command>
           <arg><option>--daemon</option></arg>
+          <arg><option>--verbose</option></arg>
           <arg><option>--help</option></arg>
         </cmdsynopsis>
         <cmdsynopsis>
               <para>Detach and run in the background.</para>
             </listitem>
           </varlistentry>
+          <varlistentry>
+            <term><option>--verbose</option></term>
+            <listitem>
+              <para>Print log messages to stdout.</para>
+            </listitem>
+          </varlistentry>
           <varlistentry>
             <term><option>--help</option></term>
             <listitem>