]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: set driver subsystem if the sd_device object is generated from nulstr
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 4 Jun 2021 08:18:25 +0000 (17:18 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 5 Jun 2021 08:58:53 +0000 (17:58 +0900)
Otherwise, the sd_device object cannot read correct udev database file.

src/libsystemd/sd-device/device-internal.h
src/libsystemd/sd-device/device-private.c
src/libsystemd/sd-device/sd-device.c

index 9844608157976fda5d86f5d809dc7f84bd1bdbb4..19dac5c21f09927994a04e6ffa6bdfd7ab4feca0 100644 (file)
@@ -108,5 +108,6 @@ int device_set_devname(sd_device *device, const char *devname);
 int device_set_devtype(sd_device *device, const char *devtype);
 int device_set_devnum(sd_device *device, const char *major, const char *minor);
 int device_set_subsystem(sd_device *device, const char *_subsystem);
+int device_set_drivers_subsystem(sd_device *device);
 int device_set_driver(sd_device *device, const char *_driver);
 int device_set_usec_initialized(sd_device *device, usec_t when);
index 3ede43f377586a07323400a398bc91e3cef28eef..3307bb9db61fdb646c29f4d6b2f7bca731aebac3 100644 (file)
@@ -382,12 +382,20 @@ void device_seal(sd_device *device) {
 }
 
 static int device_verify(sd_device *device) {
+        int r;
+
         assert(device);
 
         if (!device->devpath || !device->subsystem || device->action < 0 || device->seqnum == 0)
                 return log_device_debug_errno(device, SYNTHETIC_ERRNO(EINVAL),
                                               "sd-device: Device created from strv or nulstr lacks devpath, subsystem, action or seqnum.");
 
+        if (streq(device->subsystem, "drivers")) {
+                r = device_set_drivers_subsystem(device);
+                if (r < 0)
+                        return r;
+        }
+
         device->sealed = true;
 
         return 0;
index eff852c335f676358a4385ada8c6e0b0243a6f61..ecb4c429c771351d079b86d672172de79c483e2f 100644 (file)
@@ -779,7 +779,7 @@ int device_set_subsystem(sd_device *device, const char *_subsystem) {
         return free_and_replace(device->subsystem, subsystem);
 }
 
-static int device_set_drivers_subsystem(sd_device *device) {
+int device_set_drivers_subsystem(sd_device *device) {
         _cleanup_free_ char *subsystem = NULL;
         const char *syspath, *drivers, *p;
         int r;