sd-device: set driver subsystem if the sd_device object is generated from nulstr

Otherwise, the sd_device object cannot read correct udev database file.
This commit is contained in:
Yu Watanabe
2021-06-05 17:58:53 +09:00
parent 33f2de7b64
commit e5ca293fcd
3 changed files with 10 additions and 1 deletions
@@ -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);
@@ -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;
+1 -1
View 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;