mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-30 23:21:08 +03:00
udevadm: info - resolve devpath if symlink is given
This commit is contained in:
parent
ab815cae7f
commit
e7e194a088
@ -37,7 +37,7 @@ static size_t devpath_to_db_path(const char *devpath, char *filename, size_t len
|
|||||||
{
|
{
|
||||||
size_t start;
|
size_t start;
|
||||||
|
|
||||||
/* add location of db files */
|
/* translate to location of db file */
|
||||||
strlcpy(filename, udev_root, len);
|
strlcpy(filename, udev_root, len);
|
||||||
start = strlcat(filename, "/"DB_DIR"/", len);
|
start = strlcat(filename, "/"DB_DIR"/", len);
|
||||||
strlcat(filename, devpath, len);
|
strlcat(filename, devpath, len);
|
||||||
|
22
udevinfo.c
22
udevinfo.c
@ -281,6 +281,7 @@ int udevinfo(int argc, char *argv[], char *envp[])
|
|||||||
strlcpy(name, &optarg[strlen(udev_root)+1], sizeof(name));
|
strlcpy(name, &optarg[strlen(udev_root)+1], sizeof(name));
|
||||||
else
|
else
|
||||||
strlcpy(name, optarg, sizeof(name));
|
strlcpy(name, optarg, sizeof(name));
|
||||||
|
remove_trailing_chars(name, '/');
|
||||||
dbg("name: %s", name);
|
dbg("name: %s", name);
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
@ -289,6 +290,27 @@ int udevinfo(int argc, char *argv[], char *envp[])
|
|||||||
strlcpy(path, &optarg[strlen(sysfs_path)], sizeof(path));
|
strlcpy(path, &optarg[strlen(sysfs_path)], sizeof(path));
|
||||||
else
|
else
|
||||||
strlcpy(path, optarg, sizeof(path));
|
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);
|
dbg("path: %s", path);
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
|
Loading…
Reference in New Issue
Block a user