- return 0;
-}
-
-int udev_db_lookup_name(const char *name, char *devpath, size_t len)
-{
- char dbpath[PATH_MAX];
- DIR *dir;
- int found = 0;
-
- strlcpy(dbpath, udev_root, sizeof(dbpath));
- strlcat(dbpath, "/"DB_DIR, sizeof(dbpath));
- dir = opendir(dbpath);
- if (dir == NULL) {
- info("no udev_db available '%s': %s", dbpath, strerror(errno));
- return -1;
- }
-
- while (!found) {
- struct dirent *ent;
- char filename[PATH_SIZE];
- char nodename[PATH_SIZE];
- char *bufline;
- char *buf;
- size_t bufsize;
- size_t cur;
- size_t count;
-
- ent = readdir(dir);
- if (ent == NULL || ent->d_name[0] == '\0')
- break;
- if (ent->d_name[0] == '.')
- continue;
-
- snprintf(filename, sizeof(filename), "%s/%s", dbpath, ent->d_name);
- filename[sizeof(filename)-1] = '\0';
- dbg("looking at '%s'", filename);
-
- if (file_map(filename, &buf, &bufsize) != 0) {
- err("unable to read db file '%s': %s", filename, strerror(errno));
- continue;
- }
-
- cur = 0;
- while (cur < bufsize && !found) {
- count = buf_get_line(buf, bufsize, cur);
- bufline = &buf[cur];
- cur += count+1;
-
- switch(bufline[0]) {
- case 'N':
- case 'S':
- if (count > sizeof(nodename))
- count = sizeof(nodename);
- memcpy(nodename, &bufline[2], count-2);
- nodename[count-2] = '\0';
- dbg("compare '%s' '%s'", nodename, name);
- if (strcmp(nodename, name) == 0) {
- db_file_to_devpath(ent->d_name, devpath, len);
- found = 1;
- }
- break;
- default:
- continue;
- }
- }
- file_unmap(buf, bufsize);
- }
+ name_index(udev->dev->devpath, udev->name, 0);
+ list_for_each_entry(name_loop, &udev->symlink_list, node)
+ name_index(udev->dev->devpath, name_loop->name, 0);