- printf("P: %s\n", udev->devpath);
- printf("N: %s\n", udev->name);
- printf("S: %s\n", udev->symlink);
- 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_name);
+ printf(" SUBSYSTEM==\"%s\"\n", dev->subsystem);
+ print_all_attributes(dev->devpath);
+
+ /* 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(" ID==\"%s\"\n", dev->kernel_name);
+ printf(" BUS==\"%s\"\n", dev->subsystem);
+ printf(" DRIVER==\"%s\"\n", dev->driver);
+
+ print_all_attributes(dev->devpath);
+ }
+