From 6d22bd87f0d9505721dfa0ec5ae94f39a1691526 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 29 Jun 2019 04:03:06 +0900 Subject: [PATCH] udevadm: support special value 'help' for --action option --- man/udevadm.xml | 9 ++++++--- src/udev/udevadm-test.c | 7 ++++++- src/udev/udevadm-trigger.c | 6 +++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/man/udevadm.xml b/man/udevadm.xml index 396d418..d12c39b 100644 --- a/man/udevadm.xml +++ b/man/udevadm.xml @@ -228,7 +228,9 @@ Type of event to be triggered. Possible actions are add, remove, change, move, online, offline, bind, - and unbind. The default value is change. + and unbind. Also, the special value help can be used + to list the possible actions. The default value is change. + @@ -524,9 +526,10 @@ - + - The action string. + The action string. The special value help may be used to list + known values. diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c index 8124951..7ad9993 100644 --- a/src/udev/udevadm-test.c +++ b/src/udev/udevadm-test.c @@ -33,7 +33,7 @@ static int help(void) { "Test an event run.\n\n" " -h --help Show this help\n" " -V --version Show package version\n" - " -a --action=ACTION Set action string\n" + " -a --action=ACTION|help Set action string\n" " -N --resolve-names=early|late|never When to resolve names\n" , program_invocation_short_name); @@ -56,6 +56,11 @@ static int parse_argv(int argc, char *argv[]) { case 'a': { DeviceAction a; + if (streq(optarg, "help")) { + dump_device_action_table(); + return 0; + } + a = device_action_from_string(optarg); if (a < 0) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c index f14010a..77d95e5 100644 --- a/src/udev/udevadm-trigger.c +++ b/src/udev/udevadm-trigger.c @@ -115,7 +115,7 @@ static int help(void) { " -t --type= Type of events to trigger\n" " devices sysfs devices (default)\n" " subsystems sysfs subsystems and drivers\n" - " -c --action=ACTION Event action value, default is \"change\"\n" + " -c --action=ACTION|help Event action value, default is \"change\"\n" " -s --subsystem-match=SUBSYSTEM Trigger devices from a matching subsystem\n" " -S --subsystem-nomatch=SUBSYSTEM Exclude devices from a matching subsystem\n" " -a --attr-match=FILE[=VALUE] Trigger devices with a matching attribute\n" @@ -205,6 +205,10 @@ int trigger_main(int argc, char *argv[], void *userdata) { return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown type --type=%s", optarg); break; case 'c': + if (streq(optarg, "help")) { + dump_device_action_table(); + return 0; + } if (device_action_from_string(optarg) < 0) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown action '%s'", optarg); -- 2.7.4