-/**
- * udevdb_init: initializes database
- * @init_flag: UDEVDB_INTERNAL - database stays in memory
- * UDEVDB_DEFAULT - database is written to a file
- */
-int udevdb_init(int init_flag)
-{
- if (init_flag != UDEVDB_DEFAULT && init_flag != UDEVDB_INTERNAL)
- return -EINVAL;
-
- udevdb = tdb_open(udev_db_filename, 0, init_flag, O_RDWR | O_CREAT, 0644);
- if (udevdb == NULL) {
- if (init_flag == UDEVDB_INTERNAL)
- dbg("unable to initialize in-memory database");
- else
- dbg("unable to initialize database at '%s'", udev_db_filename);
- return -EINVAL;
+ while (1) {
+ ent = readdir(dir);
+ if (ent == NULL || ent->d_name[0] == '\0')
+ break;
+
+ if (ent->d_name[0] == '.')
+ continue;
+
+ snprintf(filename, NAME_SIZE-1, "%s/%s", udev_db_path, ent->d_name);
+ filename[NAME_SIZE-1] = '\0';
+
+ memset(&db_udev, 0x00, sizeof(struct udevice));
+ if (parse_db_file(&db_udev, filename) == 0) {
+ char *pos;
+ int len;
+
+ if (strncmp(name, db_udev.name, NAME_SIZE) == 0) {
+ goto found;
+ }
+
+ foreach_strpart(db_udev.symlink, " ", pos, len) {
+ if (strncmp(name, pos, len) != 0)
+ continue;
+
+ if (len == strlen(name))
+ goto found;
+ }
+
+ }