udevd: add --verbose option to log also to stdout
This commit is contained in:
parent
b52a01ee39
commit
9e8fe79b8e
5
udevd.8
5
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
|
||||
|
|
20
udevd.c
20
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);
|
||||
|
|
|
@ -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>
|
||||
|
@ -47,6 +48,12 @@
|
|||
<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>
|
||||
|
|
Loading…
Reference in a new issue