/*
- * Copyright (C) 2004-2008 Kay Sievers <kay.sievers@vrfy.org>
+ * Copyright (C) 2004-2009 Kay Sievers <kay.sievers@vrfy.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
value = udev_device_get_sysattr_value(device, dent->d_name);
if (value == NULL)
continue;
- dbg(udev, "attr '%s'='%s'(%zi)\n", dent->d_name, value, len);
+ dbg(udev, "attr '%s'='%s'\n", dent->d_name, value);
/* skip nonprintable attributes */
len = strlen(value);
if (i != 0)
printf("L: %i\n", i);
- i = udev_device_get_num_fake_partitions(device);
- if (i != 0)
- printf("A:%u\n", i);
-
- i = udev_device_get_ignore_remove(device);
- if (i != 0)
- printf("R:%u\n", i);
-
i = udev_device_get_watch_handle(device);
if (i >= 0)
- printf("W:%u\n", i);
+ printf("W: %u\n", i);
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(device)) {
len = strlen(udev_get_dev_path(udev_device_get_udev(device)));
static const struct option options[] = {
{ "name", required_argument, NULL, 'n' },
{ "path", required_argument, NULL, 'p' },
- { "query", optional_argument, NULL, 'q' },
+ { "query", required_argument, NULL, 'q' },
{ "attribute-walk", no_argument, NULL, 'a' },
{ "export-db", no_argument, NULL, 'e' },
{ "root", no_argument, NULL, 'r' },
int option;
struct stat statbuf;
- option = getopt_long(argc, argv, "aed:n:p:q::rxPVh", options, NULL);
+ option = getopt_long(argc, argv, "aed:n:p:q:rxPVh", options, NULL);
if (option == -1)
break;
break;
case 'q':
action = ACTION_QUERY;
- if (optarg == NULL || strcmp(optarg, "property") == 0 || strcmp(optarg, "env") == 0) {
+ if (strcmp(optarg, "property") == 0 || strcmp(optarg, "env") == 0) {
query = QUERY_PROPERTY;
} else if (strcmp(optarg, "name") == 0) {
query = QUERY_NAME;
}
switch(query) {
- case QUERY_NAME:
+ case QUERY_NAME: {
+ const char *node = udev_device_get_devnode(device);
+
+ if (node == NULL) {
+ fprintf(stderr, "no device node found\n");
+ rc = 5;
+ goto exit;
+ }
+
if (root) {
printf("%s\n", udev_device_get_devnode(device));
} else {
- size_t len;
- const char *node;
-
- len = strlen(udev_get_dev_path(udev));
- node = udev_device_get_devnode(device);
- if (node == NULL) {
- fprintf(stderr, "no device node found\n");
- rc = 5;
- goto exit;
- }
- printf("%s\n", &udev_device_get_devnode(device)[len+1]);
+ size_t len = strlen(udev_get_dev_path(udev));
+
+ printf("%s\n", &udev_device_get_devnode(device)[len+1]);
}
break;
+ }
case QUERY_SYMLINK:
list_entry = udev_device_get_devlinks_list_entry(device);
while (list_entry != NULL) {