From a0e902598c9f5fbce55653f679e0ce91bc3369b7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 4 Apr 2022 15:25:01 +0200 Subject: [PATCH] udevadm: show more fields of sd_device objects in "udevadm info" 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 | 32 +++++++++++++++++++++++++ src/udev/udevadm-info.c | 52 ++++++++++++++++++++++++++++++++++------- 2 files changed, 75 insertions(+), 9 deletions(-) diff --git a/man/udevadm.xml b/man/udevadm.xml index e299a758794..162287fa5f9 100644 --- a/man/udevadm.xml +++ b/man/udevadm.xml @@ -227,6 +227,30 @@ P: Device path in /sys/ + + M: + Device name in /sys/ (i.e. the last component of P:) + + + R: + Device number in /sys/ (i.e. the numeric suffix of the last component of P:) + + + U: + Kernel subsystem + + + T: + Kernel device type within subsystem + + + D: + Kernel device node major/minor + + + I: + Network interface index + N: Kernel device node name @@ -239,6 +263,14 @@ S: Device node symlink + + Q: + Block device sequence number (DISKSEQ) + + + V: + Attached driver + E: Device property diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c index a088c1727ce..721c5665b39 100644 --- a/src/udev/udevadm-info.c +++ b/src/udev/udevadm-info.c @@ -171,26 +171,60 @@ 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); + + FOREACH_DEVICE_DEVLINK(device, str) { + assert_se(val = path_startswith(str, "/dev/")); + printf("S: %s\n", val); + } } - if (device_get_devlink_priority(device, &i) >= 0) - printf("L: %i\n", i); + if (sd_device_get_diskseq(device, &q) >= 0) + printf("Q: %" PRIu64 "\n", q); - FOREACH_DEVICE_DEVLINK(device, str) { - assert_se(val = path_startswith(str, "/dev/")); - printf("S: %s\n", val); - } + 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);