diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-08-17 22:57:04 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-08-17 23:22:26 +0900 |
commit | 6de7fa875977c156c0e2c09df23544ec008c6ed9 (patch) | |
tree | aef96868104ddc41b4e12f6b97ac9797113b372f /src/udev/udevadm-util.c | |
parent | d1429d8f788c9028cff65d8c552872fd59ecc34a (diff) | |
download | systemd-6de7fa875977c156c0e2c09df23544ec008c6ed9.tar.gz |
udevadm: introduce parse_device_action() helper function
Diffstat (limited to 'src/udev/udevadm-util.c')
-rw-r--r-- | src/udev/udevadm-util.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/udev/udevadm-util.c b/src/udev/udevadm-util.c index 6be0e73560..9649e5a207 100644 --- a/src/udev/udevadm-util.c +++ b/src/udev/udevadm-util.c @@ -110,3 +110,22 @@ int find_device_with_action(const char *id, sd_device_action_t action, sd_device return device_new_from_synthetic_event(ret, id, device_action_to_string(action)); } + +int parse_device_action(const char *str, sd_device_action_t *action) { + sd_device_action_t a; + + assert(str); + assert(action); + + if (streq(str, "help")) { + dump_device_action_table(); + return 0; + } + + a = device_action_from_string(str); + if (a < 0) + return a; + + *action = a; + return 1; +} |