mirror of
https://github.com/systemd/systemd.git
synced 2024-12-26 03:22:00 +03:00
sd-device: properly support some corner case syspath
This commit is contained in:
parent
be247835c7
commit
0b859c9773
@ -439,6 +439,9 @@ _public_ int sd_device_new_from_subsystem_sysname(
|
||||
const char *subsys = memdupa_suffix0(sysname, sep - sysname);
|
||||
sep++;
|
||||
|
||||
if (streq(sep, "drivers")) /* If the sysname is "drivers", then it's the drivers directory itself that is meant. */
|
||||
r = device_strjoin_new("/sys/bus/", subsys, "/drivers", NULL, ret);
|
||||
else
|
||||
r = device_strjoin_new("/sys/bus/", subsys, "/drivers/", sep, ret);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@ -940,6 +943,8 @@ int device_set_drivers_subsystem(sd_device *device) {
|
||||
return r;
|
||||
|
||||
drivers = strstr(devpath, "/drivers/");
|
||||
if (!drivers)
|
||||
drivers = endswith(devpath, "/drivers");
|
||||
if (!drivers)
|
||||
return -EINVAL;
|
||||
|
||||
@ -986,11 +991,11 @@ _public_ int sd_device_get_subsystem(sd_device *device, const char **ret) {
|
||||
if (subsystem)
|
||||
r = device_set_subsystem(device, subsystem);
|
||||
/* use implicit names */
|
||||
else if (path_startswith(device->devpath, "/module/"))
|
||||
else if (!isempty(path_startswith(device->devpath, "/module/")))
|
||||
r = device_set_subsystem(device, "module");
|
||||
else if (strstr(syspath, "/drivers/"))
|
||||
else if (strstr(syspath, "/drivers/") || endswith(syspath, "/drivers"))
|
||||
r = device_set_drivers_subsystem(device);
|
||||
else if (PATH_STARTSWITH_SET(device->devpath, "/class/", "/bus/"))
|
||||
else if (!isempty(PATH_STARTSWITH_SET(device->devpath, "/class/", "/bus/")))
|
||||
r = device_set_subsystem(device, "subsystem");
|
||||
else {
|
||||
device->subsystem_set = true;
|
||||
|
Loading…
Reference in New Issue
Block a user