chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rules: suse - use NAME for mapper/control
[elogind.git]
/
udev
/
udevadm-info.c
diff --git
a/udev/udevadm-info.c
b/udev/udevadm-info.c
index db11a289b249574ccd169a071cecc743e27c66e3..519dc4a45bf586fe27d96cacfe72c3fc98f0201d 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
@@
-25,6
+25,7
@@
#include <dirent.h>
#include <errno.h>
#include <getopt.h>
#include <dirent.h>
#include <errno.h>
#include <getopt.h>
+#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
@@
-40,7
+41,6
@@
static void print_all_attributes(struct udev_device *device, const char *key)
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
struct stat statbuf;
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
struct stat statbuf;
- char filename[UTIL_PATH_SIZE];
const char *value;
size_t len;
const char *value;
size_t len;
@@
-52,8
+52,7
@@
static void print_all_attributes(struct udev_device *device, const char *key)
if (strcmp(dent->d_name, "dev") == 0)
continue;
if (strcmp(dent->d_name, "dev") == 0)
continue;
- util_strscpyl(filename, sizeof(filename), udev_device_get_syspath(device), "/", dent->d_name, NULL);
- if (lstat(filename, &statbuf) != 0)
+ if (fstatat(dirfd(dir), dent->d_name, &statbuf, AT_SYMLINK_NOFOLLOW) != 0)
continue;
if (S_ISLNK(statbuf.st_mode))
continue;
continue;
if (S_ISLNK(statbuf.st_mode))
continue;
@@
-145,15
+144,15
@@
static void print_record(struct udev_device *device)
i = udev_device_get_num_fake_partitions(device);
if (i != 0)
i = udev_device_get_num_fake_partitions(device);
if (i != 0)
- printf("A:%u\n", i);
+ printf("A:
%u\n", i);
i = udev_device_get_ignore_remove(device);
if (i != 0)
i = udev_device_get_ignore_remove(device);
if (i != 0)
- printf("R:%u\n", i);
+ printf("R:
%u\n", i);
i = udev_device_get_watch_handle(device);
if (i >= 0)
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)));
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(device)) {
len = strlen(udev_get_dev_path(udev_device_get_udev(device)));
@@
-247,7
+246,7
@@
int udevadm_info(struct udev *udev, int argc, char *argv[])
QUERY_NAME,
QUERY_PATH,
QUERY_SYMLINK,
QUERY_NAME,
QUERY_PATH,
QUERY_SYMLINK,
- QUERY_
ENV
,
+ QUERY_
PROPERTY
,
QUERY_ALL,
} query = QUERY_NONE;
QUERY_ALL,
} query = QUERY_NONE;
@@
-318,29
+317,22
@@
int udevadm_info(struct udev *udev, int argc, char *argv[])
break;
case 'q':
action = ACTION_QUERY;
break;
case 'q':
action = ACTION_QUERY;
- if (strcmp(optarg, "name") == 0) {
+ if (strcmp(optarg, "property") == 0 || strcmp(optarg, "env") == 0) {
+ query = QUERY_PROPERTY;
+ } else if (strcmp(optarg, "name") == 0) {
query = QUERY_NAME;
query = QUERY_NAME;
- break;
- }
- if (strcmp(optarg, "symlink") == 0) {
+ } else if (strcmp(optarg, "symlink") == 0) {
query = QUERY_SYMLINK;
query = QUERY_SYMLINK;
- break;
- }
- if (strcmp(optarg, "path") == 0) {
+ } else if (strcmp(optarg, "path") == 0) {
query = QUERY_PATH;
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;
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;
case 'r':
if (action == ACTION_NONE)
action = ACTION_ROOT;
@@
-371,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"
" 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"
" 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"
@@
-433,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_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));
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));