summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2006-09-19 17:07:25 +0200
committerKay Sievers <kay.sievers@suse.de>2006-09-19 17:07:25 +0200
commitbc2a89fad6a5935e241d2f50d5b4f620dc343233 (patch)
tree9ff34f155769eaa78f0606d7d073a7fac4d4ea7f
parent7b5206d60917aeb8d2438b4022b2755b4eb5f126 (diff)
udevinfo: print error in --attribute-walk
-rw-r--r--udevinfo.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/udevinfo.c b/udevinfo.c
index 5445b0fcc1..2832ea0ee3 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);
@@ -377,7 +377,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 +390,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;