-
- util_strlcpy(device, udev_get_sys_path(udev), sizeof(device));
- util_strlcat(device, ent->d_name, sizeof(device));
- util_path_decode(device);
- name_list_add(udev, name_list, device, 0);
- count++;
- }
- closedir(dir);
-out:
- return count;
-}
-
-static int update_link(struct udev_device *dev, const char *slink, int test)
-{
- struct udev *udev = udev_device_get_udev(dev);
- LIST_HEAD(name_list);
- struct name_entry *device;
- char target[UTIL_PATH_SIZE] = "";
- int count;
- int priority = 0;
- int rc = 0;
-
- info(udev, "update symlink '%s' of '%s'\n", slink, udev_device_get_syspath(dev));
-
- count = get_devices_by_name(udev, slink, &name_list);
- info(udev, "found %i devices with name '%s'\n", count, slink);
-
- /* if we don't have a reference, delete it */
- if (count <= 0) {
- info(udev, "no reference left, remove '%s'\n", slink);
- if (!test) {
- unlink(slink);
- delete_path(udev, slink);
- }
- goto out;
- }
-
- /* find the device with the highest priority */
- list_for_each_entry(device, &name_list, node) {
- struct udev_device *dev_db;
- const char *devnode;
-
- info(udev, "found '%s' for '%s'\n", device->name, slink);
-
- /* did we find ourself? we win, if we have the same priority */
- if (strcmp(udev_device_get_syspath(dev), device->name) == 0) {
- info(udev, "compare (our own) priority of '%s' %i >= %i\n",
- udev_device_get_devpath(dev), udev_device_get_devlink_priority(dev), priority);
- if (strcmp(udev_device_get_devnode(dev), slink) == 0) {
- info(udev, "'%s' is our device node, database inconsistent, skip link update\n",
- udev_device_get_devnode(dev));
- } else if (target[0] == '\0' || udev_device_get_devlink_priority(dev) >= priority) {
- priority = udev_device_get_devlink_priority(dev);
- util_strlcpy(target, udev_device_get_devnode(dev), sizeof(target));
- }