From 5b37c4cf86db20762af9fe23224bec313a35ca43 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 8 Jul 2024 14:38:22 +0200 Subject: [PATCH] mount-tool: show diskseq in --list output Let's expose the diskseq a bit more prominently. --- src/mount/mount-tool.c | 18 +++++++++++++++++- test/units/TEST-74-AUX-UTILS.mount.sh | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c index 1c11cdd5f86..d43db8ffd13 100644 --- a/src/mount/mount-tool.c +++ b/src/mount/mount-tool.c @@ -1412,6 +1412,7 @@ static int discover_device(void) { static int list_devices(void) { enum { COLUMN_NODE, + COLUMN_DISKSEQ, COLUMN_PATH, COLUMN_MODEL, COLUMN_WWN, @@ -1437,7 +1438,7 @@ static int list_devices(void) { if (r < 0) return log_error_errno(r, "Failed to add property match: %m"); - table = table_new("node", "path", "model", "wwn", "fstype", "label", "uuid"); + table = table_new("node", "diskseq", "path", "model", "wwn", "fstype", "label", "uuid"); if (!table) return log_oom(); @@ -1460,6 +1461,21 @@ static int list_devices(void) { (void) sd_device_get_devname(d, &x); break; + case COLUMN_DISKSEQ: { + uint64_t ds; + + r = sd_device_get_diskseq(d, &ds); + if (r < 0) { + log_debug_errno(r, "Failed to get diskseq of block device, ignoring: %m"); + r = table_add_cell(table, NULL, TABLE_EMPTY, NULL); + } else + r = table_add_cell(table, NULL, TABLE_UINT64, &ds); + if (r < 0) + return table_log_add_error(r); + + continue; + } + case COLUMN_PATH: (void) sd_device_get_property_value(d, "ID_PATH", &x); break; diff --git a/test/units/TEST-74-AUX-UTILS.mount.sh b/test/units/TEST-74-AUX-UTILS.mount.sh index d440a7c667d..89a391d48e1 100755 --- a/test/units/TEST-74-AUX-UTILS.mount.sh +++ b/test/units/TEST-74-AUX-UTILS.mount.sh @@ -146,7 +146,7 @@ test -e /run/media/system/simple.img/foo.bar # systemd-mount --list and systemd-umount require the loopback block device is initialized by udevd. udevadm settle --timeout 30 assert_in "/dev/loop.* ext4 +sd-mount-test" "$(systemd-mount --list --full)" -LOOP_AUTO=$(systemd-mount --list --full --no-legend | awk '$6 == "sd-mount-test" { print $1 }') +LOOP_AUTO=$(systemd-mount --list --full --no-legend | awk '$7 == "sd-mount-test" { print $1 }') LOOP_AUTO_DEVPATH=$(udevadm info --query property --property DEVPATH --value "$LOOP_AUTO") systemd-umount "$WORK_DIR/simple.img" # Wait for 'change' uevent for the device with DISK_MEDIA_CHANGE=1. -- 2.47.3