- udev = udev_new();
- if (!udev) {
- log_error("Failed to allocate udev environment.");
- goto fail;
- }
-
- enumerator = udev_enumerate_new(udev);
- if (!enumerator) {
- log_error("Failed to allocate udev enumerator.");
- goto fail;
- }
-
- udev_enumerate_add_match_subsystem(enumerator, "graphics");
- udev_enumerate_add_match_tag(enumerator, seat);
-
- r = udev_enumerate_scan_devices(enumerator);
- if (r < 0) {
- log_error("Failed to enumerate devices.");
- goto fail;
- }
-
- first = udev_enumerate_get_list_entry(enumerator);
- udev_list_entry_foreach(item, first) {
- struct udev_device *d;
- const char *dn;
-
- d = udev_device_new_from_syspath(udev, udev_list_entry_get_name(item));
- if (!d)
- continue;
-
- dn = udev_device_get_devnode(d);
-
- if (dn) {
- device_node = strdup(dn);
- if (!device_node) {
- udev_device_unref(d);
- log_error("Out of memory.");
- goto fail;
- }
- }
-
- udev_device_unref(d);
-
- if (device_node)
- break;
- }
-
- if (!device_node) {
- log_error("Failed to find device node for seat %s.", seat);
- goto fail;
- }
-