From: Yu Watanabe Date: Thu, 7 Mar 2019 05:43:33 +0000 (+0900) Subject: udevadm trigger: make --action option support all possible actions X-Git-Tag: v242-rc1~183^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dcee4a134c9e41a54b640bb7fdbb608c9826c792;p=thirdparty%2Fsystemd.git udevadm trigger: make --action option support all possible actions This also make udevadm abort operations if invalid action is specified. --- diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c index 63ceaaf957f..b5e5f091ca0 100644 --- a/src/udev/udevadm-trigger.c +++ b/src/udev/udevadm-trigger.c @@ -7,6 +7,7 @@ #include "sd-event.h" #include "device-enumerator-private.h" +#include "device-private.h" #include "fd-util.h" #include "fileio.h" #include "path-util.h" @@ -199,11 +200,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 (STR_IN_SET(optarg, "add", "remove", "change")) - action = optarg; - else - log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown action '%s'", optarg); + if (device_action_from_string(optarg) < 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown action '%s'", optarg); + action = optarg; break; case 's': r = sd_device_enumerator_add_match_subsystem(e, optarg, true);