]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: topology: probe diskseq
authorThomas Weißschuh <thomas@t-8ch.de>
Wed, 28 Dec 2022 01:47:08 +0000 (01:47 +0000)
committerThomas Weißschuh <thomas@t-8ch.de>
Wed, 28 Dec 2022 12:34:20 +0000 (12:34 +0000)
libblkid/docs/libblkid-sections.txt
libblkid/samples/topology.c
libblkid/src/blkid.h.in
libblkid/src/libblkid.sym
libblkid/src/topology/ioctl.c
libblkid/src/topology/sysfs.c
libblkid/src/topology/topology.c
libblkid/src/topology/topology.h
tests/expected/blkid/topology-disk
tests/expected/blkid/topology-partition
tests/ts/blkid/topology

index d54cf66e0fbcae87ae905f0d933a4e38a9144e52..92970025321292f0a56647f5fd329185c8952090 100644 (file)
@@ -151,6 +151,7 @@ blkid_probe_enable_topology
 blkid_probe_get_topology
 blkid_topology_get_alignment_offset
 blkid_topology_get_dax
+blkid_topology_get_diskseq
 blkid_topology_get_logical_sector_size
 blkid_topology_get_minimum_io_size
 blkid_topology_get_optimal_io_size
index 7d21567d5408198365a51ff9f5179bf5ad815533..8dfb9c5bb23e695795304312edf47a4571fcb1c6 100644 (file)
@@ -11,6 +11,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <inttypes.h>
 
 #include <blkid.h>
 
@@ -53,6 +54,8 @@ int main(int argc, char *argv[])
                                blkid_topology_get_physical_sector_size(tp));
                printf("\tdax support          : %lu\n",
                                blkid_topology_get_dax(tp));
+               printf("\tdiskseq              : %"PRId64"\n",
+                               blkid_topology_get_diskseq(tp));
        }
 
        /*
index 6132cb8a1acf91866eac3fb2243eabdf93897772..c232d72fd17170a400a504794f624f5744ce2acd 100644 (file)
@@ -333,6 +333,8 @@ extern unsigned long blkid_topology_get_physical_sector_size(blkid_topology tp)
                        __ul_attribute__((nonnull));
 extern unsigned long blkid_topology_get_dax(blkid_topology tp)
                        __ul_attribute__((nonnull));
+extern uint64_t blkid_topology_get_diskseq(blkid_topology tp)
+                       __ul_attribute__((nonnull));
 
 /*
  * partitions probing
index 366f2c0c04fa72c3f48c12e6f8fff932eb251c59..775b0246cacb4681fe95e12669ad22630c03d4bb 100644 (file)
@@ -183,3 +183,7 @@ BLKID_2_37 {
        blkid_probe_set_hint;
        blkid_probe_reset_hints;
 } BLKID_2_36;
+
+BLKID_2_39 {
+       blkid_topology_get_diskseq;
+} BLKID_2_37;
index 3aba09e4fc27e77e1d7458c0986a01691319d509..0603eb912702ab8a84d615129fda20aa5e52acec 100644 (file)
@@ -33,7 +33,8 @@ static struct topology_val {
        { BLKALIGNOFF, NULL, blkid_topology_set_alignment_offset },
        { BLKIOMIN, blkid_topology_set_minimum_io_size },
        { BLKIOOPT, blkid_topology_set_optimal_io_size },
-       { BLKPBSZGET, blkid_topology_set_physical_sector_size }
+       { BLKPBSZGET, blkid_topology_set_physical_sector_size },
+       { BLKGETDISKSEQ, blkid_topology_set_diskseq },
        /* we read BLKSSZGET in topology.c */
 };
 
index 745cd115aaf87cafbc0126707bee56e4ea78b9e5..fe13f940f12372b5a5271220b2412ccc265f6097 100644 (file)
@@ -38,6 +38,7 @@ static struct topology_val {
        { "queue/optimal_io_size", blkid_topology_set_optimal_io_size },
        { "queue/physical_block_size", blkid_topology_set_physical_sector_size },
        { "queue/dax", blkid_topology_set_dax },
+       { "diskseq", blkid_topology_set_diskseq },
 };
 
 static int probe_sysfs_tp(blkid_probe pr,
index d638c4c203fb1400e4d8121ceb3150198977f1a9..d34e7a0bbbc59752f2cd7aed728fd7eb53b78024 100644 (file)
@@ -68,6 +68,7 @@ struct blkid_struct_topology {
        unsigned long   logical_sector_size;
        unsigned long   physical_sector_size;
        unsigned long   dax;
+       uint64_t        diskseq;
 };
 
 /*
@@ -312,6 +313,14 @@ int blkid_topology_set_dax(blkid_probe pr, unsigned long val)
                        val);
 }
 
+int blkid_topology_set_diskseq(blkid_probe pr, uint64_t val)
+{
+       return topology_set_value(pr,
+                       "DISKSEQ",
+                       offsetof(struct blkid_struct_topology, diskseq),
+                       val);
+}
+
 /**
  * blkid_topology_get_alignment_offset:
  * @tp: topology
@@ -379,3 +388,16 @@ unsigned long blkid_topology_get_dax(blkid_topology tp)
 {
        return tp->dax;
 }
+
+/**
+ * blkid_topology_get_diskseq
+ * @tp: topology
+ *
+ * Returns: disk sequence number
+ *
+ * Since: 2.39
+ */
+uint64_t blkid_topology_get_diskseq(blkid_topology tp)
+{
+       return tp->diskseq;
+}
index 3e46af9ac5c3efacc21531c896d73613d23c97da..9810fe46b2782721e2087c054aae8ab4cd5758f6 100644 (file)
@@ -8,6 +8,7 @@ extern int blkid_topology_set_minimum_io_size(blkid_probe pr, unsigned long val)
 extern int blkid_topology_set_optimal_io_size(blkid_probe pr, unsigned long val);
 extern int blkid_topology_set_physical_sector_size(blkid_probe pr, unsigned long val);
 extern int blkid_topology_set_dax(blkid_probe pr, unsigned long val);
+extern int blkid_topology_set_diskseq(blkid_probe pr, uint64_t val);
 
 /*
  * topology probers
index 1c812b6ca1165bc72a89a220baa4c40ea0f95f88..c958c4c14dfd998c0478ab95186e95877a107095 100644 (file)
@@ -1,3 +1,4 @@
+ID_FS_DISKSEQ=S
 ID_IOLIMIT_LOGICAL_SECTOR_SIZE=512
 ID_IOLIMIT_MINIMUM_IO_SIZE=512
 ID_IOLIMIT_PHYSICAL_SECTOR_SIZE=512
index 1c812b6ca1165bc72a89a220baa4c40ea0f95f88..c958c4c14dfd998c0478ab95186e95877a107095 100644 (file)
@@ -1,3 +1,4 @@
+ID_FS_DISKSEQ=S
 ID_IOLIMIT_LOGICAL_SECTOR_SIZE=512
 ID_IOLIMIT_MINIMUM_IO_SIZE=512
 ID_IOLIMIT_PHYSICAL_SECTOR_SIZE=512
index 6dde1bc35abd40aa2eea113f7a2237a1633aa69b..fcf07247315ac8267e8b136be71b9645c7ddb133 100755 (executable)
@@ -36,6 +36,7 @@ echo -e 'label: dos\n- - - -' | "$TS_CMD_SFDISK" -q "$TS_LODEV"
 
 "$TS_CMD_BLKID" -i -o udev "$TS_LODEV" \
        2> "$TS_ERRLOG" \
+       | sed -E -e 's/^ID_FS_DISKSEQ=[[:digit:]]+$/ID_FS_DISKSEQ=S/' \
        | sort > "$TS_OUTPUT"
 
 ts_finalize_subtest
@@ -45,6 +46,7 @@ ts_init_subtest partition
 
 "$TS_CMD_BLKID" -i -o udev "$TS_LODEV"p1 \
        2> "$TS_ERRLOG" \
+       | sed -E -e 's/^ID_FS_DISKSEQ=[[:digit:]]+$/ID_FS_DISKSEQ=S/' \
        | sort > "$TS_OUTPUT"
 
 ts_finalize_subtest