chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
udevadm: fix short options in getopt()
[elogind.git]
/
udev
/
udevadm-info.c
diff --git
a/udev/udevadm-info.c
b/udev/udevadm-info.c
index 2ffce27ed71a76a04e171801dd0982d8a7e10235..9bd60c724334502b86fd574316375fd5188dcb10 100644
(file)
--- a/
udev/udevadm-info.c
+++ b/
udev/udevadm-info.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 2004-200
8
Kay Sievers <kay.sievers@vrfy.org>
+ * Copyright (C) 2004-200
9
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
*
* 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
@@
-60,7
+60,7
@@
static void print_all_attributes(struct udev_device *device, const char *key)
value = udev_device_get_sysattr_value(device, dent->d_name);
if (value == NULL)
continue;
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);
/* skip nonprintable attributes */
len = strlen(value);
@@
-142,18
+142,6
@@
static void print_record(struct udev_device *device)
if (i != 0)
printf("L: %i\n", i);
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);
-
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(device)) {
len = strlen(udev_get_dev_path(udev_device_get_udev(device)));
printf("S: %s\n", &udev_list_entry_get_name(list_entry)[len+1]);
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(device)) {
len = strlen(udev_get_dev_path(udev_device_get_udev(device)));
printf("S: %s\n", &udev_list_entry_get_name(list_entry)[len+1]);
@@
-221,7
+209,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' },
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' },
{ "attribute-walk", no_argument, NULL, 'a' },
{ "export-db", no_argument, NULL, 'e' },
{ "root", no_argument, NULL, 'r' },
@@
-250,11
+238,11
@@
int udevadm_info(struct udev *udev, int argc, char *argv[])
QUERY_ALL,
} query = QUERY_NONE;
QUERY_ALL,
} query = QUERY_NONE;
-
while (1
) {
+
for (;;
) {
int option;
struct stat statbuf;
int option;
struct stat statbuf;
- option = getopt_long(argc, argv, "aed:n:p:q:
:rxP
Vh", options, NULL);
+ option = getopt_long(argc, argv, "aed:n:p:q:
rxP:
Vh", options, NULL);
if (option == -1)
break;
if (option == -1)
break;
@@
-317,7
+305,7
@@
int udevadm_info(struct udev *udev, int argc, char *argv[])
break;
case 'q':
action = ACTION_QUERY;
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;
query = QUERY_PROPERTY;
} else if (strcmp(optarg, "name") == 0) {
query = QUERY_NAME;
@@
-388,23
+376,24
@@
int udevadm_info(struct udev *udev, int argc, char *argv[])
}
switch(query) {
}
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 {
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;
}
break;
+ }
case QUERY_SYMLINK:
list_entry = udev_device_get_devlinks_list_entry(device);
while (list_entry != NULL) {
case QUERY_SYMLINK:
list_entry = udev_device_get_devlinks_list_entry(device);
while (list_entry != NULL) {