mirror of
https://github.com/systemd/systemd.git
synced 2024-11-23 10:13:34 +08:00
udevadm: add --ping option to 'control' command
This exposes `udev_ctrl_send_ping()`.
This commit is contained in:
parent
3797776e11
commit
a82340cc03
@ -419,6 +419,13 @@
|
||||
same time.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--ping</option></term>
|
||||
<listitem>
|
||||
<para>Send a ping message to systemd-udevd and wait for the reply. This may be useful to check that
|
||||
systemd-udevd daemon is running.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>-t</option></term>
|
||||
<term><option>--timeout=</option><replaceable>seconds</replaceable></term>
|
||||
|
@ -40,6 +40,7 @@ static int help(void) {
|
||||
" -R --reload Reload rules and databases\n"
|
||||
" -p --property=KEY=VALUE Set a global property for all events\n"
|
||||
" -m --children-max=N Maximum number of children\n"
|
||||
" --ping Wait for udev to respond to a ping message\n"
|
||||
" -t --timeout=SECONDS Maximum time to block for a reply\n"
|
||||
, program_invocation_short_name);
|
||||
|
||||
@ -51,19 +52,24 @@ int control_main(int argc, char *argv[], void *userdata) {
|
||||
usec_t timeout = 60 * USEC_PER_SEC;
|
||||
int c, r;
|
||||
|
||||
enum {
|
||||
ARG_PING = 0x100,
|
||||
};
|
||||
|
||||
static const struct option options[] = {
|
||||
{ "exit", no_argument, NULL, 'e' },
|
||||
{ "log-priority", required_argument, NULL, 'l' },
|
||||
{ "stop-exec-queue", no_argument, NULL, 's' },
|
||||
{ "start-exec-queue", no_argument, NULL, 'S' },
|
||||
{ "reload", no_argument, NULL, 'R' },
|
||||
{ "reload-rules", no_argument, NULL, 'R' }, /* alias for -R */
|
||||
{ "property", required_argument, NULL, 'p' },
|
||||
{ "env", required_argument, NULL, 'p' }, /* alias for -p */
|
||||
{ "children-max", required_argument, NULL, 'm' },
|
||||
{ "timeout", required_argument, NULL, 't' },
|
||||
{ "version", no_argument, NULL, 'V' },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "exit", no_argument, NULL, 'e' },
|
||||
{ "log-priority", required_argument, NULL, 'l' },
|
||||
{ "stop-exec-queue", no_argument, NULL, 's' },
|
||||
{ "start-exec-queue", no_argument, NULL, 'S' },
|
||||
{ "reload", no_argument, NULL, 'R' },
|
||||
{ "reload-rules", no_argument, NULL, 'R' }, /* alias for -R */
|
||||
{ "property", required_argument, NULL, 'p' },
|
||||
{ "env", required_argument, NULL, 'p' }, /* alias for -p */
|
||||
{ "children-max", required_argument, NULL, 'm' },
|
||||
{ "ping", no_argument, NULL, ARG_PING },
|
||||
{ "timeout", required_argument, NULL, 't' },
|
||||
{ "version", no_argument, NULL, 'V' },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{}
|
||||
};
|
||||
|
||||
@ -135,6 +141,11 @@ int control_main(int argc, char *argv[], void *userdata) {
|
||||
return r;
|
||||
break;
|
||||
}
|
||||
case ARG_PING:
|
||||
r = udev_ctrl_send_ping(uctrl, timeout);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to connect to udev daemon: %m");
|
||||
break;
|
||||
case 't':
|
||||
r = parse_sec(optarg, &timeout);
|
||||
if (r < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user