diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-06-29 16:22:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-29 16:22:22 +0200 |
commit | 3b88d21e9b73aca6c8890605fa5cc09e4928e5fc (patch) | |
tree | 810c6094358a26e7a248889c63c3bf7ea488f705 | |
parent | 0f4143f0f224158dd411555409a915923e4d8a99 (diff) | |
parent | 7ce7278217774e8383a0b4ecf396a4cb03bb3a87 (diff) | |
download | systemd-3b88d21e9b73aca6c8890605fa5cc09e4928e5fc.tar.gz systemd-3b88d21e9b73aca6c8890605fa5cc09e4928e5fc.tar.bz2 systemd-3b88d21e9b73aca6c8890605fa5cc09e4928e5fc.zip |
Merge pull request #12908 from yuwata/udevadm-completion-action
udevadm: support special value 'help' for --action option
-rw-r--r-- | man/udevadm.xml | 9 | ||||
-rw-r--r-- | shell-completion/bash/udevadm | 4 | ||||
-rw-r--r-- | src/libsystemd/sd-device/device-private.c | 4 | ||||
-rw-r--r-- | src/libsystemd/sd-device/device-private.h | 1 | ||||
-rw-r--r-- | src/udev/udevadm-test.c | 7 | ||||
-rw-r--r-- | src/udev/udevadm-trigger.c | 6 |
6 files changed, 24 insertions, 7 deletions
diff --git a/man/udevadm.xml b/man/udevadm.xml index 396d418f83..d12c39b765 100644 --- a/man/udevadm.xml +++ b/man/udevadm.xml @@ -228,7 +228,9 @@ <para>Type of event to be triggered. Possible actions are <literal>add</literal>, <literal>remove</literal>, <literal>change</literal>, <literal>move</literal>, <literal>online</literal>, <literal>offline</literal>, <literal>bind</literal>, - and <literal>unbind</literal>. The default value is <literal>change</literal>.</para> + and <literal>unbind</literal>. Also, the special value <literal>help</literal> can be used + to list the possible actions. The default value is <literal>change</literal>. + </para> </listitem> </varlistentry> <varlistentry> @@ -524,9 +526,10 @@ <variablelist> <varlistentry> <term><option>-a</option></term> - <term><option>--action=<replaceable>string</replaceable></option></term> + <term><option>--action=<replaceable>ACTION</replaceable></option></term> <listitem> - <para>The action string.</para> + <para>The action string. The special value <literal>help</literal> may be used to list + known values.</para> </listitem> </varlistentry> <varlistentry> diff --git a/shell-completion/bash/udevadm b/shell-completion/bash/udevadm index c151a41978..cb12c25538 100644 --- a/shell-completion/bash/udevadm +++ b/shell-completion/bash/udevadm @@ -119,7 +119,7 @@ _udevadm() { comps='devices subsystems' ;; -c|--action) - comps='add change remove bind unbind' + comps=$( udevadm trigger --action help ) ;; -y|--sysname-match|-b|--parent-match) comps=$( __get_all_sysdevs ) @@ -196,7 +196,7 @@ _udevadm() { if __contains_word "$prev" ${OPTS[TEST]}; then case $prev in -a|--action) - comps='add change remove bind unbind' + comps=$( udevadm test --action help ) ;; -N|--resolve-names) comps='early late never' diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c index 731b0ed0a7..16f8627bdb 100644 --- a/src/libsystemd/sd-device/device-private.c +++ b/src/libsystemd/sd-device/device-private.c @@ -998,3 +998,7 @@ static const char* const device_action_table[_DEVICE_ACTION_MAX] = { }; DEFINE_STRING_TABLE_LOOKUP(device_action, DeviceAction); + +void dump_device_action_table(void) { + DUMP_STRING_TABLE(device_action, DeviceAction, _DEVICE_ACTION_MAX); +} diff --git a/src/libsystemd/sd-device/device-private.h b/src/libsystemd/sd-device/device-private.h index 9696f9c02d..2bde53e969 100644 --- a/src/libsystemd/sd-device/device-private.h +++ b/src/libsystemd/sd-device/device-private.h @@ -75,3 +75,4 @@ static inline int device_read_db(sd_device *device) { DeviceAction device_action_from_string(const char *s) _pure_; const char *device_action_to_string(DeviceAction a) _const_; +void dump_device_action_table(void); diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c index 8124951422..7ad9993f09 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 f14010a2d0..77d95e513f 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); |