diff --git a/src/libsystemd/sd-device/device-internal.h b/src/libsystemd/sd-device/device-internal.h index 9844608157..19dac5c21f 100644 --- a/src/libsystemd/sd-device/device-internal.h +++ b/src/libsystemd/sd-device/device-internal.h @@ -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); diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c index 3ede43f377..3307bb9db6 100644 --- a/src/libsystemd/sd-device/device-private.c +++ b/src/libsystemd/sd-device/device-private.c @@ -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; diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index eff852c335..ecb4c429c7 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -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;