chiark / gitweb /
[PATCH] make udevinfo's -r option also workimg for symlink queries
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Wed, 10 Nov 2004 09:19:39 +0000 (10:19 +0100)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 05:21:20 +0000 (22:21 -0700)
[kay@pim udev.kay]$ ./udevinfo -r -q symlink -p /class/video4linux/video0
/dev/camera0 /dev/kamera0 /dev/videocam0 /dev/webcam0

[kay@pim udev.kay]$ ./udevinfo -q symlink -p /class/video4linux/video0
camera0 kamera0 videocam0 webcam0

udevinfo.8
udevinfo.c

index 599a0033f877caad10c6ae95b59feac160015680..bbcc3d8f4904721a6fa9be9c09656acca6654f6f 100644 (file)
@@ -19,9 +19,10 @@ Print the version information.
 .B \-r
 Print the
 .B udev_root
-directory. When used in conjunction with a query for the node name, the
+directory. When used in conjunction with a query for the node name or the
+symlink names, the
 .B udev_root
-will be prepended.
+will be prepended to query result.
 .TP
 .BI \-q " query_type"
 Query the database for specified value of a created device node or network
index 8fab86ca8c95e9bd80a088181bc660b9d5c93b53..290a09e880aee1dc7c95c03417fab4ee39e4eea6 100644 (file)
@@ -266,7 +266,7 @@ static int process_options(void)
        int root = 0;
        int attributes = 0;
        enum query_type query = NONE;
-       char result[NAME_SIZE] = "";
+       char result[1024] = "";
        char path[NAME_SIZE] = "";
        char name[NAME_SIZE] = "";
        char temp[NAME_SIZE];
@@ -401,7 +401,20 @@ print:
                        break;
 
                case SYMLINK:
-                       strfieldcpy(result, udev.symlink);
+                       if (root) {
+                               int slen;
+                               char *spos;
+                               char slink[NAME_SIZE];
+
+                               pos = result;
+                               foreach_strpart(udev.symlink, " \n\r", spos, slen) {
+                                       strncpy(slink, spos, slen);
+                                       slink[slen] = '\0';
+                                       pos += sprintf(pos, "%s/%s ", udev_root, slink);
+                               }
+                       } else {
+                               strfieldcpy(result, udev.symlink);
+                       }
                        break;
 
                case PATH: