if (stat(path_full, &statbuf) == 0)
goto found;
- strlcpy(path, "/class/", sizeof(path_full) - sysfs_len);
+ strlcpy(path, "/bus/", sizeof(path_full) - sysfs_len);
strlcat(path, id, sizeof(path_full) - sysfs_len);
if (stat(path_full, &statbuf) == 0)
goto found;
+ goto out;
- strlcpy(path, "/bus/", sizeof(path_full) - sysfs_len);
+ strlcpy(path, "/class/", sizeof(path_full) - sysfs_len);
strlcat(path, id, sizeof(path_full) - sysfs_len);
if (stat(path_full, &statbuf) == 0)
goto found;
- goto out;
}
if (strcmp(subsystem, "module") == 0) {
if (stat(path_full, &statbuf) == 0)
goto found;
- strlcpy(path, "/class/", sizeof(path_full) - sysfs_len);
+ strlcpy(path, "/bus/", sizeof(path_full) - sysfs_len);
strlcat(path, subsystem, sizeof(path_full) - sysfs_len);
- strlcat(path, "/", sizeof(path_full) - sysfs_len);
+ strlcat(path, "/devices/", sizeof(path_full) - sysfs_len);
strlcat(path, id, sizeof(path_full) - sysfs_len);
if (stat(path_full, &statbuf) == 0)
goto found;
- strlcpy(path, "/bus/", sizeof(path_full) - sysfs_len);
+ strlcpy(path, "/class/", sizeof(path_full) - sysfs_len);
strlcat(path, subsystem, sizeof(path_full) - sysfs_len);
- strlcat(path, "/devices/", sizeof(path_full) - sysfs_len);
+ strlcat(path, "/", sizeof(path_full) - sysfs_len);
strlcat(path, id, sizeof(path_full) - sysfs_len);
if (stat(path_full, &statbuf) == 0)
goto found;
out:
return 0;
-
found:
if (S_ISLNK(statbuf.st_mode))
sysfs_resolve_link(path, sizeof(path_full) - sysfs_len);