]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevadm: show more fields of sd_device objects in "udevadm info"
authorLennart Poettering <lennart@poettering.net>
Mon, 4 Apr 2022 13:25:01 +0000 (15:25 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 4 Apr 2022 16:24:14 +0000 (18:24 +0200)
Let's make things easier to debug, and show a more comprehensive set of
fields, extending on the existing output syntax that starts with one
marker character followed by a colon and a space.

man/udevadm.xml
src/udev/udevadm-info.c

index e299a7587945146eda74689f68bbc4ad3dc40f3c..162287fa5f9a92c64426ccd04f74e0ce146e00ac 100644 (file)
               <entry><literal>P:</literal></entry>
               <entry>Device path in <filename>/sys/</filename></entry>
             </row>
+            <row>
+              <entry><literal>M:</literal></entry>
+              <entry>Device name in <filename>/sys/</filename> (i.e. the last component of <literal>P:</literal>)</entry>
+            </row>
+            <row>
+              <entry><literal>R:</literal></entry>
+              <entry>Device number in <filename>/sys/</filename> (i.e. the numeric suffix of the last component of <literal>P:</literal>)</entry>
+            </row>
+            <row>
+              <entry><literal>U:</literal></entry>
+              <entry>Kernel subsystem</entry>
+            </row>
+            <row>
+              <entry><literal>T:</literal></entry>
+              <entry>Kernel device type within subsystem</entry>
+            </row>
+            <row>
+              <entry><literal>D:</literal></entry>
+              <entry>Kernel device node major/minor</entry>
+            </row>
+            <row>
+              <entry><literal>I:</literal></entry>
+              <entry>Network interface index</entry>
+            </row>
             <row>
               <entry><literal>N:</literal></entry>
               <entry>Kernel device node name</entry>
               <entry><literal>S:</literal></entry>
               <entry>Device node symlink</entry>
             </row>
+            <row>
+              <entry><literal>Q:</literal></entry>
+              <entry>Block device sequence number (DISKSEQ)</entry>
+            </row>
+            <row>
+              <entry><literal>V:</literal></entry>
+              <entry>Attached driver</entry>
+            </row>
             <row>
               <entry><literal>E:</literal></entry>
               <entry>Device property</entry>
index a088c1727ce4b77a836cba081b71110ea4429c73..721c5665b396519e77604396ba853596dedbc7ca 100644 (file)
@@ -171,27 +171,61 @@ static int print_device_chain(sd_device *device) {
 }
 
 static int print_record(sd_device *device) {
-        const char *str, *val;
-        int i;
+        const char *str, *val, *subsys;
+        dev_t devnum;
+        uint64_t q;
+        int i, ifi;
 
         assert(device);
 
-        (void) sd_device_get_devpath(device, &str);
+        /* We don't show syspath here, because it's identical to devpath (modulo the "/sys" prefix).
+         *
+         * We don't show action/seqnum here because that only makes sense for records synthesized from
+         * uevents, not for those synthesized from database entries.
+         *
+         * We don't show sysattrs here, because they can be expensive and potentially issue expensive driver
+         * IO. */
+
+        assert_se(sd_device_get_devpath(device, &str) >= 0);
         printf("P: %s\n", str);
 
+        if (sd_device_get_sysname(device, &str) >= 0)
+                printf("M: %s\n", str);
+
+        if (sd_device_get_sysnum(device, &str) >= 0)
+                printf("R: %s\n", str);
+
+        if (sd_device_get_subsystem(device, &subsys) >= 0)
+                printf("U: %s\n", subsys);
+
+        if (sd_device_get_devtype(device, &str) >= 0)
+                printf("T: %s\n", str);
+
+        if (sd_device_get_devnum(device, &devnum) >= 0)
+                printf("D: %c %u:%u\n", streq_ptr(subsys, "block") ? 'b' : 'c', major(devnum), minor(devnum));
+
+        if (sd_device_get_ifindex(device, &ifi) >= 0)
+                printf("I: %i\n", ifi);
+
         if (sd_device_get_devname(device, &str) >= 0) {
                 assert_se(val = path_startswith(str, "/dev/"));
                 printf("N: %s\n", val);
-        }
 
-        if (device_get_devlink_priority(device, &i) >= 0)
-                printf("L: %i\n", i);
+                if (device_get_devlink_priority(device, &i) >= 0)
+                        printf("L: %i\n", i);
 
-        FOREACH_DEVICE_DEVLINK(device, str) {
-                assert_se(val = path_startswith(str, "/dev/"));
-                printf("S: %s\n", val);
+                FOREACH_DEVICE_DEVLINK(device, str) {
+                        assert_se(val = path_startswith(str, "/dev/"));
+                        printf("S: %s\n", val);
+                }
         }
 
+        if (sd_device_get_diskseq(device, &q) >= 0)
+                printf("Q: %" PRIu64 "\n", q);
+
+        if (sd_device_get_driver(device, &str) >= 0)
+                printf("V: %s\n", str);
+
         FOREACH_DEVICE_PROPERTY(device, str, val)
                 printf("E: %s=%s\n", str, val);