- udev_device_get_devlinks(device, print_record_devlinks_cb, NULL);
- udev_device_get_properties(device, print_record_properties_cb, NULL);
- printf("\n");
-}
-
-static int export_all_cb(struct udev_device *device, void *data)
-{
- if (udev_device_get_devname(device) != NULL)
- print_record(device);
- return 0;
-}
-
-static struct udev_device *lookup_device_by_name(struct udev *udev, const char *name)
-{
- struct udev_device *udev_device = NULL;
- LIST_HEAD(name_list);
- int count;
- struct name_entry *device;
-
- count = udev_db_get_devices_by_name(udev, name, &name_list);
- if (count <= 0)
- goto out;
-
- info(udev, "found %i devices for '%s'\n", count, name);
-
- /* select the device that matches */
- list_for_each_entry(device, &name_list, node) {
- struct udevice *udevice_loop;
- char filename[UTIL_PATH_SIZE];
- struct stat statbuf;
-
- udevice_loop = udev_device_init(udev);
- if (udevice_loop == NULL)
- break;
- if (udev_db_get_device(udevice_loop, device->name) != 0)
- goto next;
- info(udev, "found db entry '%s'\n", device->name);
- /* make sure, we don't get a link of a different device */
- util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename));
- util_strlcat(filename, "/", sizeof(filename));
- util_strlcat(filename, name, sizeof(filename));
- if (stat(filename, &statbuf) != 0)
- goto next;
- if (major(udevice_loop->devt) > 0 && udevice_loop->devt != statbuf.st_rdev) {
- info(udev, "skip '%s', dev_t doesn't match\n", udevice_loop->name);
- goto next;
- }
- util_strlcpy(filename, udev_get_sys_path(udev), sizeof(filename));
- util_strlcat(filename, udevice_loop->dev->devpath, sizeof(filename));
- udev_device = udev_device_new_from_syspath(udev, filename);
- udev_device_cleanup(udevice_loop);
- break;
-next:
- udev_device_cleanup(udevice_loop);
- }
-out:
- name_list_cleanup(udev, &name_list);
- return udev_device;
-}