summaryrefslogtreecommitdiff
path: root/src/udev/udevadm-util.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-08-17 22:57:04 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-08-17 23:22:26 +0900
commit6de7fa875977c156c0e2c09df23544ec008c6ed9 (patch)
treeaef96868104ddc41b4e12f6b97ac9797113b372f /src/udev/udevadm-util.c
parentd1429d8f788c9028cff65d8c552872fd59ecc34a (diff)
downloadsystemd-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.c19
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;
+}