X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udevinfo.c;h=3f47add87cd6f7197ec2d81dc5603bbf56564d3a;hb=9c6ad9fbbac82e517f5e748ddbe166f96f120afe;hp=5445b0fcc13e0ad1e6463a9b8439490e0afada35;hpb=492e76c9c1108a28eae356cc8bd7955ccf234980;p=elogind.git diff --git a/udevinfo.c b/udevinfo.c index 5445b0fcc..3f47add87 100644 --- a/udevinfo.c +++ b/udevinfo.c @@ -104,6 +104,10 @@ static int print_device_chain(const char *devpath) { struct sysfs_device *dev; + dev = sysfs_device_get(devpath); + if (dev == NULL) + return -1; + 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" @@ -112,10 +116,6 @@ static int print_device_chain(const char *devpath) "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); @@ -190,7 +190,7 @@ int main(int argc, char *argv[], char *envp[]) { "attribute-walk", 0, NULL, 'a' }, { "export-db", 0, NULL, 'e' }, { "root", 0, NULL, 'r' }, - { "version", 0, NULL, 'V' }, + { "version", 0, NULL, 1 }, /* -V outputs braindead format */ { "help", 0, NULL, 'h' }, {} }; @@ -290,6 +290,9 @@ int main(int argc, char *argv[], char *envp[]) case 'e': export_db(export_record); goto exit; + case 1: + printf("%s\n", UDEV_VERSION); + goto exit; case 'V': printf("udevinfo, version %s\n", UDEV_VERSION); goto exit; @@ -308,7 +311,6 @@ int main(int argc, char *argv[], char *envp[]) " --root prepend to query result or print udev_root\n" " --attribute-walk print all SYSFS_attributes along the device chain\n" " --export-db export the content of the udev database\n" - " --verision print udev version\n" " --help print this text\n" "\n"); goto exit; @@ -377,7 +379,11 @@ int main(int argc, char *argv[], char *envp[]) break; case ACTION_ATTRIBUTE_WALK: if (path[0] != '\0') { - print_device_chain(path); + if (print_device_chain(path) != 0) { + fprintf(stderr, "device not found\n"); + rc = 4; + goto exit; + } } else if (name[0] != '\0') { char devpath[PATH_SIZE]; @@ -386,7 +392,11 @@ int main(int argc, char *argv[], char *envp[]) rc = 4; goto exit; } - print_device_chain(devpath); + if (print_device_chain(devpath) != 0) { + fprintf(stderr, "device not found\n"); + rc = 4; + goto exit; + } } else { fprintf(stderr, "attribute walk needs --path or node --name specified\n"); rc = 5;