return 0;
}
+
+int udev_db_call_foreach(int (*handler_function)(struct udevice *udev))
+{
+ struct dirent *ent;
+ DIR *dir;
+ char filename[NAME_SIZE];
+ struct udevice db_udev;
+
+ dir = opendir(udev_db_path);
+ if (dir == NULL) {
+ dbg("unable to udev db '%s'", udev_db_path);
+ return -1;
+ }
+
+ while (1) {
+ ent = readdir(dir);
+ if (ent == NULL || ent->d_name[0] == '\0')
+ break;
+
+ if (ent->d_name[0] == '.')
+ continue;
+
+ snprintf(filename, NAME_SIZE, "%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) {
+ if (handler_function(&db_udev) != 0)
+ break;
+ }
+ }
+
+ closedir(dir);
+ return 0;
+}
extern int udev_db_get_device_by_devpath(struct udevice *dev, const char *devpath);
extern int udev_db_get_device_by_name(struct udevice *udev, const char *name);
+extern int udev_db_call_foreach(int (*handler_function)(struct udevice *udev));
#endif /* _UDEV_DB_H_ */
unique attributes to compose a rule.
.RB Needs " \-p " specified.
.TP
+.B \-d
+Print the relationship between the devpath and the node name for all devices
+currently available in the database.
+.TP
.B \-h
Print help text.
.SH "FILES"
return retval;
}
+static int print_dump(struct udevice *udev) {
+ printf("%s:%s/%s\n", udev->devpath, udev_root, udev->name);
+ return 0;
+}
+
static int process_options(int argc, char *argv[])
{
- static const char short_options[] = "an:p:q:rVh";
+ static const char short_options[] = "adn:p:q:rVh";
int option;
int retval = 1;
struct udevice udev;
attributes = 1;
break;
+ case 'd':
+ udev_db_call_foreach(print_dump);
+ exit(0);
+
case 'V':
printf("udevinfo, version %s\n", UDEV_VERSION);
exit(0);
"\n"
" -r print udev root\n"
" -a print all SYSFS_attributes along the device chain\n"
- " -s print all sysfs devices with major/minor, physical device and bus\n"
+ " -d print the relationship of devpath and the node name for all\n"
+ " devices available in the database\n"
" -V print udev version\n"
" -h print this help text\n"
"\n");