diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-01-13 07:44:38 +0900 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-01-18 16:10:01 +0100 |
commit | a82340cc0312e2a946ac5c797fa57e98fe613ce7 (patch) | |
tree | 08609279dd863658caca06b33b930835651c4f7c /src/udev/udevadm-control.c | |
parent | 3797776e11d2a242517c3a20a953b5d0e80384f8 (diff) | |
download | systemd-a82340cc0312e2a946ac5c797fa57e98fe613ce7.tar.gz |
udevadm: add --ping option to 'control' command
This exposes `udev_ctrl_send_ping()`.
Diffstat (limited to 'src/udev/udevadm-control.c')
-rw-r--r-- | src/udev/udevadm-control.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/udev/udevadm-control.c b/src/udev/udevadm-control.c index 4cd3eba1bc..7cfc4c929d 100644 --- a/src/udev/udevadm-control.c +++ b/src/udev/udevadm-control.c @@ -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) |