implement udev_device_new_from_subsystem_sysname

This commit is contained in:
illiliti
2020-07-16 22:53:23 +03:00
parent f9eeef168e
commit 09dbf27a07
2 changed files with 17 additions and 2 deletions

View File

@@ -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
* [ ] ???

View File

@@ -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;
}