]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mount-tool: show diskseq in --list output
authorLennart Poettering <lennart@poettering.net>
Mon, 8 Jul 2024 12:38:22 +0000 (14:38 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 10 Jul 2024 07:35:31 +0000 (09:35 +0200)
Let's expose the diskseq a bit more prominently.

src/mount/mount-tool.c
test/units/TEST-74-AUX-UTILS.mount.sh

index 1c11cdd5f86d1800dce21fc79c0609f9878a0e58..d43db8ffd13f793e8dbf9bb9106185a34eba791d 100644 (file)
@@ -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;
index d440a7c667dab68370faa1bbce397d6d277c7f93..89a391d48e1e6e7d9e82ed31688fda2b4f8cbe89 100755 (executable)
@@ -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.