]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: always pass random UUID on triggering uevent 36514/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 25 Feb 2025 18:33:16 +0000 (03:33 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 26 Feb 2025 09:07:51 +0000 (18:07 +0900)
Then, this makes sd_device_trigger() a simple wrapper of
sd_device_trigger_with_uuid().

src/libsystemd/sd-device/sd-device.c

index ac441a7f3852fe6e300e79f333fe7dbbe28637e3..181a9256dd2df44949d2c0068c1e8f2c40665bd1 100644 (file)
@@ -2692,16 +2692,7 @@ _public_ int sd_device_set_sysattr_valuef(sd_device *device, const char *sysattr
 }
 
 _public_ int sd_device_trigger(sd_device *device, sd_device_action_t action) {
-        const char *s;
-
-        assert_return(device, -EINVAL);
-
-        s = device_action_to_string(action);
-        if (!s)
-                return -EINVAL;
-
-        /* This uses the simple no-UUID interface of kernel < 4.13 */
-        return sd_device_set_sysattr_value(device, "uevent", s);
+        return sd_device_trigger_with_uuid(device, action, NULL);
 }
 
 _public_ int sd_device_trigger_with_uuid(
@@ -2715,10 +2706,6 @@ _public_ int sd_device_trigger_with_uuid(
 
         assert_return(device, -EINVAL);
 
-        /* If no one wants to know the UUID, use the simple interface from pre-4.13 times */
-        if (!ret_uuid)
-                return sd_device_trigger(device, action);
-
         s = device_action_to_string(action);
         if (!s)
                 return -EINVAL;
@@ -2733,7 +2720,8 @@ _public_ int sd_device_trigger_with_uuid(
         if (r < 0)
                 return r;
 
-        *ret_uuid = u;
+        if (ret_uuid)
+                *ret_uuid = u;
         return 0;
 }