/*
- * udevinfo - fetches attributes for a device
+ * udevinfo.c - fetches attributes for a device
*
* Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
*
printf("N: %s\n", udev->name);
list_for_each_entry(name_loop, &udev->symlink_list, node)
printf("S: %s\n", name_loop->name);
+ list_for_each_entry(name_loop, &udev->env_list, node)
+ printf("E: %s\n", name_loop->name);
return 0;
}
return retval;
}
-static int print_dump(const char *devpath, const char *name) {
- printf("%s=%s/%s\n", devpath, udev_root, name);
- return 0;
+static void dump_names(void) {
+ LIST_HEAD(name_list);
+ struct name_entry *name_loop;
+
+ udev_db_get_all_entries(&name_list);
+ list_for_each_entry(name_loop, &name_list, node) {
+ struct udevice udev_db;
+
+ udev_init_device(&udev_db, NULL, NULL, NULL);
+ if (udev_db_get_device(&udev_db, name_loop->name) == 0)
+ printf("%s=%s/%s\n", udev_db.devpath, udev_root, udev_db.name);
+ udev_cleanup_device(&udev_db);
+ }
+ name_list_cleanup(&name_list);
}
int main(int argc, char *argv[], char *envp[])
break;
case 'd':
- udev_db_dump_names(print_dump);
+ dump_names();
goto exit;
case 'V':
}
retval = udev_db_get_device(&udev, pos);
if (retval != 0) {
- fprintf(stderr, "device not found in database\n");
+ fprintf(stderr, "no record for '%s' in database\n", pos);
goto exit;
}
goto print;
} else
pos = name;
- retval = udev_db_search_name(devpath, sizeof(devpath), pos);
+ retval = udev_db_lookup_name(pos, devpath, sizeof(devpath));
if (retval != 0) {
- fprintf(stderr, "device not found in database\n");
+ fprintf(stderr, "no record for '%s' in database\n", pos);
goto exit;
}
udev_db_get_device(&udev, devpath);
goto exit;
case QUERY_SYMLINK:
if (list_empty(&udev.symlink_list))
- break;
+ goto exit;
if (root)
list_for_each_entry(name_loop, &udev.symlink_list, node)
printf("%s/%s ", udev_root, name_loop->name);