- printf("P: %s\n", path);
- printf("N: %s\n", dev->name);
- printf("T: %c\n", dev->type);
- printf("M: %#o\n", dev->mode);
- printf("S: %s\n", dev->symlink);
- printf("O: %s\n", dev->owner);
- printf("G: %s\n", dev->group);
- printf("F: %s\n", dev->config_file);
- printf("L: %i\n", dev->config_line);
- printf("U: %li\n", dev->config_uptime);
- printf("\n");
+ struct sysfs_device *dev;
+
+ printf("\n"
+ "Udevinfo starts with the device specified by the devpath and then\n"
+ "walks up the chain of parent devices. It prints for every device\n"
+ "found, all possible attributes in the udev rules key format.\n"
+ "A rule to match, can be composed by the attributes of the device\n"
+ "and the attributes from one single parent device.\n"
+ "\n");
+
+ dev = sysfs_device_get(devpath);
+ if (dev == NULL)
+ return -1;
+
+ printf(" looking at device '%s':\n", dev->devpath);
+ printf(" KERNEL==\"%s\"\n", dev->kernel);
+ printf(" SUBSYSTEM==\"%s\"\n", dev->subsystem);
+ printf(" DRIVER==\"%s\"\n", dev->driver);
+ print_all_attributes(dev->devpath, "ATTR");
+
+ /* walk up the chain of devices */
+ while (1) {
+ dev = sysfs_device_get_parent(dev);
+ if (dev == NULL)
+ break;
+ printf(" looking at parent device '%s':\n", dev->devpath);
+ printf(" KERNELS==\"%s\"\n", dev->kernel);
+ printf(" SUBSYTEMS==\"%s\"\n", dev->subsystem);
+ printf(" DRIVERS==\"%s\"\n", dev->driver);
+
+ print_all_attributes(dev->devpath, "ATTRS");
+ }
+