]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/device: use device_get_action()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 9 Mar 2019 01:28:11 +0000 (10:28 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 11 Mar 2019 18:49:53 +0000 (03:49 +0900)
src/core/device.c

index a979caf21ce5b289393dc098bf61175f990c26ce..506bf744788a2538902ded2e0f582097a989f353 100644 (file)
@@ -893,7 +893,8 @@ static void device_propagate_reload_by_sysfs(Manager *m, const char *sysfs) {
 
 static int device_dispatch_io(sd_device_monitor *monitor, sd_device *dev, void *userdata) {
         Manager *m = userdata;
-        const char *action, *sysfs;
+        DeviceAction action;
+        const char *sysfs;
         int r;
 
         assert(m);
@@ -905,19 +906,19 @@ static int device_dispatch_io(sd_device_monitor *monitor, sd_device *dev, void *
                 return 0;
         }
 
-        r = sd_device_get_property_value(dev, "ACTION", &action);
+        r = device_get_action(dev, &action);
         if (r < 0) {
-                log_device_error_errno(dev, r, "Failed to get udev action string: %m");
+                log_device_error_errno(dev, r, "Failed to get udev action: %m");
                 return 0;
         }
 
-        if (streq(action, "change"))
+        if (action == DEVICE_ACTION_CHANGE)
                 device_propagate_reload_by_sysfs(m, sysfs);
 
         /* A change event can signal that a device is becoming ready, in particular if
          * the device is using the SYSTEMD_READY logic in udev
          * so we need to reach the else block of the follwing if, even for change events */
-        if (streq(action, "remove"))  {
+        if (action == DEVICE_ACTION_REMOVE) {
                 r = swap_process_device_remove(m, dev);
                 if (r < 0)
                         log_device_warning_errno(dev, r, "Failed to process swap device remove event, ignoring: %m");