+ /* check if the device already owns a matching name */
+ udev_init_device(&udev_db, NULL, NULL, NULL);
+ 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));