- if (util_get_sys_subsystem(udev_device->udev, udev_device->devpath, subsystem, sizeof(subsystem)) < 2)
- return NULL;
- udev_device->subsystem = strdup(subsystem);
- return udev_device->subsystem;
+
+ /* read "subsytem" link */
+ if (util_get_sys_subsystem(udev_device->udev, udev_device->syspath, subsystem, sizeof(subsystem)) > 0) {
+ udev_device->subsystem = strdup(subsystem);
+ return udev_device->subsystem;
+ }
+
+ /* implicit names */
+ if (strncmp(udev_device->devpath, "/module/", 8) == 0) {
+ udev_device->subsystem = strdup("module");
+ return udev_device->subsystem;
+ }
+ if (strstr(udev_device->devpath, "/drivers/") != NULL) {
+ udev_device->subsystem = strdup("drivers");
+ return udev_device->subsystem;
+ }
+ if (strncmp(udev_device->devpath, "/subsystem/", 11) == 0 ||
+ strncmp(udev_device->devpath, "/class/", 7) == 0 ||
+ strncmp(udev_device->devpath, "/bus/", 5) == 0) {
+ udev_device->subsystem = strdup("subsystem");
+ return udev_device->subsystem;
+ }
+ return NULL;