summaryrefslogtreecommitdiff
path: root/udevinfo.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-03-29 16:12:41 +0100
committerKay Sievers <kay.sievers@vrfy.org>2008-03-29 16:12:41 +0100
commite7e194a088e984972d6a18c7f7a36a1e8f1f58e6 (patch)
tree1ab3ee39f9fa6679e3198411b3f15cb25b680743 /udevinfo.c
parentab815cae7f974ec77b2cd3861f01edf92269a88a (diff)
udevadm: info - resolve devpath if symlink is given
Diffstat (limited to 'udevinfo.c')
-rw-r--r--udevinfo.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/udevinfo.c b/udevinfo.c
index 948aaccc36..85899cfd9d 100644
--- a/udevinfo.c
+++ b/udevinfo.c
@@ -281,6 +281,7 @@ int udevinfo(int argc, char *argv[], char *envp[])
strlcpy(name, &optarg[strlen(udev_root)+1], sizeof(name));
else
strlcpy(name, optarg, sizeof(name));
+ remove_trailing_chars(name, '/');
dbg("name: %s", name);
break;
case 'p':
@@ -289,6 +290,27 @@ int udevinfo(int argc, char *argv[], char *envp[])
strlcpy(path, &optarg[strlen(sysfs_path)], sizeof(path));
else
strlcpy(path, optarg, sizeof(path));
+ remove_trailing_chars(path, '/');
+
+ /* possibly resolve to real devpath */
+ if (sysfs_resolve_link(path, sizeof(path)) != 0) {
+ char temp[PATH_SIZE];
+ char *pos;
+
+ /* also check if the parent is a link */
+ strlcpy(temp, path, sizeof(temp));
+ pos = strrchr(temp, '/');
+ if (pos != 0) {
+ char tail[PATH_SIZE];
+
+ strlcpy(tail, pos, sizeof(tail));
+ pos[0] = '\0';
+ if (sysfs_resolve_link(temp, sizeof(temp)) == 0) {
+ strlcpy(path, temp, sizeof(path));
+ strlcat(path, tail, sizeof(path));
+ }
+ }
+ }
dbg("path: %s", path);
break;
case 'q':