1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

udevadm: info - accept --query without a value and print properties

This commit is contained in:
Kay Sievers 2009-06-07 02:39:54 +02:00
parent 80381823bc
commit 0254b2118f
2 changed files with 17 additions and 24 deletions

View File

@ -221,7 +221,7 @@ int udevadm_info(struct udev *udev, int argc, char *argv[])
static const struct option options[] = {
{ "name", required_argument, NULL, 'n' },
{ "path", required_argument, NULL, 'p' },
{ "query", required_argument, NULL, 'q' },
{ "query", optional_argument, NULL, 'q' },
{ "attribute-walk", no_argument, NULL, 'a' },
{ "export-db", no_argument, NULL, 'e' },
{ "root", no_argument, NULL, 'r' },
@ -246,7 +246,7 @@ int udevadm_info(struct udev *udev, int argc, char *argv[])
QUERY_NAME,
QUERY_PATH,
QUERY_SYMLINK,
QUERY_ENV,
QUERY_PROPERTY,
QUERY_ALL,
} query = QUERY_NONE;
@ -254,7 +254,7 @@ int udevadm_info(struct udev *udev, int argc, char *argv[])
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;
@ -317,29 +317,22 @@ int udevadm_info(struct udev *udev, int argc, char *argv[])
break;
case 'q':
action = ACTION_QUERY;
if (strcmp(optarg, "name") == 0) {
if (optarg == NULL || strcmp(optarg, "property") == 0 || strcmp(optarg, "env") == 0) {
query = QUERY_PROPERTY;
} else if (strcmp(optarg, "name") == 0) {
query = QUERY_NAME;
break;
}
if (strcmp(optarg, "symlink") == 0) {
} else if (strcmp(optarg, "symlink") == 0) {
query = QUERY_SYMLINK;
break;
}
if (strcmp(optarg, "path") == 0) {
} else if (strcmp(optarg, "path") == 0) {
query = QUERY_PATH;
break;
}
if (strcmp(optarg, "env") == 0) {
query = QUERY_ENV;
break;
}
if (strcmp(optarg, "all") == 0) {
} else if (strcmp(optarg, "all") == 0) {
query = QUERY_ALL;
break;
} else {
fprintf(stderr, "unknown query type\n");
rc = 3;
goto exit;
}
fprintf(stderr, "unknown query type\n");
rc = 3;
goto exit;
break;
case 'r':
if (action == ACTION_NONE)
action = ACTION_ROOT;
@ -370,7 +363,7 @@ int udevadm_info(struct udev *udev, int argc, char *argv[])
" name name of device node\n"
" symlink pointing to node\n"
" path sys device path\n"
" env the device related imported environment\n"
" property the device properties\n"
" all all values\n"
" --path=<syspath> sys device path used for query or attribute walk\n"
" --name=<name> node or symlink name used for query or attribute walk\n"
@ -432,7 +425,7 @@ int udevadm_info(struct udev *udev, int argc, char *argv[])
case QUERY_PATH:
printf("%s\n", udev_device_get_devpath(device));
goto exit;
case QUERY_ENV:
case QUERY_PROPERTY:
list_entry = udev_device_get_properties_list_entry(device);
while (list_entry != NULL) {
printf("%s=%s\n", udev_list_entry_get_name(list_entry), udev_list_entry_get_value(list_entry));

View File

@ -90,7 +90,7 @@
<option>--path</option> or <option>--name</option> to identify the specified
device. Valid queries are:
<command>name</command>, <command>symlink</command>, <command>path</command>,
<command>env</command>, <command>all</command>.</para>
<command>property</command>, <command>all</command>.</para>
</listitem>
</varlistentry>
<varlistentry>