implement udev_device_new_from_subsystem_sysname
This commit is contained in:
@@ -8,7 +8,7 @@ What Works
|
||||
* [x] xorg-server
|
||||
* [x] libinput
|
||||
* [ ] wlroots - partially works. someone reported that mouse doesn't work
|
||||
* [ ] weston - need implement udev_device_new_from_subsystem_sysname()
|
||||
* [ ] weston - should work. need test
|
||||
* [ ] kwin - fails to compile for odd reason
|
||||
* [ ] ???
|
||||
|
||||
|
||||
@@ -514,7 +514,22 @@ UDEV_EXPORT struct udev_device *udev_device_new_from_devnum(struct udev *udev, c
|
||||
|
||||
UDEV_EXPORT struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname)
|
||||
{
|
||||
// XXX NOT IMPLEMENTED
|
||||
char *fmt[] = { "/sys/bus/%s/devices/%s", "/sys/class/%s/%s", NULL };
|
||||
char path[PATH_MAX];
|
||||
int i;
|
||||
|
||||
if (!udev || !subsystem || !sysname) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; fmt[i]; i++) {
|
||||
snprintf(path, sizeof(path), fmt[i], subsystem, sysname);
|
||||
|
||||
if (access(path, R_OK)) {
|
||||
return udev_device_new_from_syspath(udev, path);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user