mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-26 10:03:40 +03:00
udevd: use getopt_long()
This commit is contained in:
parent
adc8e4b91e
commit
b52a01ee39
5
udevd.8
5
udevd.8
@ -14,7 +14,7 @@
|
|||||||
udevd \- event managing daemon
|
udevd \- event managing daemon
|
||||||
.SH "SYNOPSIS"
|
.SH "SYNOPSIS"
|
||||||
.HP 6
|
.HP 6
|
||||||
\fBudevd\fR [\fB\-\-daemon\fR]
|
\fBudevd\fR [\fB\-\-daemon\fR] [\fB\-\-help\fR]
|
||||||
.HP 20
|
.HP 20
|
||||||
\fBudevcontrol \fR\fB\fIcommand\fR\fR
|
\fBudevcontrol \fR\fB\fIcommand\fR\fR
|
||||||
.SH "DESCRIPTION"
|
.SH "DESCRIPTION"
|
||||||
@ -25,6 +25,9 @@ udevd listens to kernel uevents and passes the incoming events to udev. It ensur
|
|||||||
\fB\-\-daemon\fR
|
\fB\-\-daemon\fR
|
||||||
Detach and run in the background.
|
Detach and run in the background.
|
||||||
.TP 3n
|
.TP 3n
|
||||||
|
\fB\-\-help\fR
|
||||||
|
Print usage.
|
||||||
|
.TP 3n
|
||||||
\fBlog_priority=\fR\fB\fIvalue\fR\fR
|
\fBlog_priority=\fR\fB\fIvalue\fR\fR
|
||||||
udevcontrol can dynamically set the log level of udevd. Valid values are the numerical syslog priorities or their textual representations:
|
udevcontrol can dynamically set the log level of udevd. Valid values are the numerical syslog priorities or their textual representations:
|
||||||
\fBerr\fR,
|
\fBerr\fR,
|
||||||
|
27
udevd.c
27
udevd.c
@ -29,6 +29,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -76,6 +77,7 @@ void log_message(int priority, const char *format, ...)
|
|||||||
vsyslog(priority, format, args);
|
vsyslog(priority, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void asmlinkage udev_event_sig_handler(int signum)
|
static void asmlinkage udev_event_sig_handler(int signum)
|
||||||
@ -916,7 +918,12 @@ int main(int argc, char *argv[], char *envp[])
|
|||||||
fd_set readfds;
|
fd_set readfds;
|
||||||
const char *value;
|
const char *value;
|
||||||
int daemonize = 0;
|
int daemonize = 0;
|
||||||
int i;
|
int option;
|
||||||
|
static const struct option options[] = {
|
||||||
|
{ "daemon", 0, NULL, 'd' },
|
||||||
|
{ "help", 0, NULL, 'h' },
|
||||||
|
{}
|
||||||
|
};
|
||||||
int rc = 1;
|
int rc = 1;
|
||||||
int maxfd;
|
int maxfd;
|
||||||
|
|
||||||
@ -926,16 +933,20 @@ int main(int argc, char *argv[], char *envp[])
|
|||||||
dbg("version %s", UDEV_VERSION);
|
dbg("version %s", UDEV_VERSION);
|
||||||
|
|
||||||
/* parse commandline options */
|
/* parse commandline options */
|
||||||
for (i = 1 ; i < argc; i++) {
|
while (1) {
|
||||||
char *arg = argv[i];
|
option = getopt_long(argc, argv, "dtvh", options, NULL);
|
||||||
if (strcmp(arg, "--daemon") == 0 || strcmp(arg, "-d") == 0)
|
if (option == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
switch (option) {
|
||||||
|
case 'd':
|
||||||
daemonize = 1;
|
daemonize = 1;
|
||||||
else if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) {
|
break;
|
||||||
|
case 'h':
|
||||||
printf("Usage: udevd [--help] [--daemon]\n");
|
printf("Usage: udevd [--help] [--daemon]\n");
|
||||||
goto exit;
|
goto exit;
|
||||||
} else {
|
default:
|
||||||
fprintf(stderr, "unrecognized option '%s'\n", arg);
|
goto exit;
|
||||||
err("unrecognized option '%s'\n", arg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>udevd</command>
|
<command>udevd</command>
|
||||||
<arg><option>--daemon</option></arg>
|
<arg><option>--daemon</option></arg>
|
||||||
|
<arg><option>--help</option></arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>udevcontrol <replaceable>command</replaceable></command>
|
<command>udevcontrol <replaceable>command</replaceable></command>
|
||||||
@ -46,6 +47,12 @@
|
|||||||
<para>Detach and run in the background.</para>
|
<para>Detach and run in the background.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--help</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Print usage.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>log_priority=<replaceable>value</replaceable></option></term>
|
<term><option>log_priority=<replaceable>value</replaceable></option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user