+ if (warn) {
+ err("%%e is deprecated, will be removed and is unlikely to work correctly. Don't use it.");
+ warn = 0;
+ }
+
+ /* check if the device already owns a matching name */
+ udev_db = udev_device_init();
+ if (udev_db == NULL)
+ return -1;
+ if (udev_db_get_device(udev_db, devpath) == 0) {
+ struct name_entry *name_loop;
+ int devnum;
+
+ devnum = match_name_and_get_number(base, udev_db->name);
+ if (devnum >= 0) {
+ num = devnum;
+ dbg("device '%s', already has the node '%s' with num %u, use it", devpath, base, num);
+ goto out;
+ }
+ list_for_each_entry(name_loop, &udev_db->symlink_list, node) {
+ devnum = match_name_and_get_number(base, name_loop->name);
+ if (devnum >= 0) {
+ num = devnum;
+ dbg("device '%s', already has a symlink '%s' with num %u, use it", devpath, base, num);
+ goto out;
+ }
+ }
+ }
+
+ /* just search the database again and again until a free name is found */
+ strlcpy(filename, base, sizeof(filename));