]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: (bcachefs) adapt to major.minor version
authorThomas Weißschuh <thomas@t-8ch.de>
Sun, 9 Jul 2023 18:03:57 +0000 (20:03 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Tue, 11 Jul 2023 19:23:35 +0000 (21:23 +0200)
The version superblock field has been split into a major and minor
version part in the upstream code.
Adapt libblkid to it.

Link: https://lore.kernel.org/linux-bcachefs/20230709171551.2349961-11-kent.overstreet@linux.dev/
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
libblkid/src/superblocks/bcache.c
tests/expected/blkid/low-probe-bcachefs
tests/expected/blkid/low-probe-bcachefs-2

index bf7fed01fe46f3e695037529bb126ddb34bc41cf..1a0c124d374f0c4fa222f0b3d198d93c1619d604 100644 (file)
@@ -149,6 +149,9 @@ struct bcachefs_super_block {
 #define BCACHEFS_SB_FIELDS_OFF offsetof(struct bcachefs_super_block, _start)
 /* tag value for members field */
 #define BCACHEFS_SB_FIELD_TYPE_MEMBERS 1
+/* version splitting helpers */
+#define BCH_VERSION_MAJOR(_v)           ((uint16_t) ((_v) >> 10))
+#define BCH_VERSION_MINOR(_v)           ((uint16_t) ((_v) & ~(~0U << 10)))
 
 #define BYTES(f) ((((uint64_t) le32_to_cpu((f)->u64s)) * 8))
 
@@ -300,6 +303,7 @@ static int probe_bcachefs(blkid_probe pr, const struct blkid_idmag *mag)
        struct bcachefs_super_block *bcs;
        const unsigned char *sb, *sb_end;
        uint64_t sb_size, blocksize;
+       uint16_t version;
 
        bcs = blkid_probe_get_sb(pr, mag, struct bcachefs_super_block);
        if (!bcs)
@@ -325,7 +329,10 @@ static int probe_bcachefs(blkid_probe pr, const struct blkid_idmag *mag)
 
        blkid_probe_set_uuid(pr, bcs->user_uuid);
        blkid_probe_set_label(pr, bcs->label, sizeof(bcs->label));
-       blkid_probe_sprintf_version(pr, "%d", le16_to_cpu(bcs->version));
+       version = le16_to_cpu(bcs->version);
+       blkid_probe_sprintf_version(pr, "%"PRIu16".%"PRIu16,
+                                   BCH_VERSION_MAJOR(version),
+                                   BCH_VERSION_MINOR(version));
        blocksize = le16_to_cpu(bcs->block_size);
        blkid_probe_set_block_size(pr, blocksize * BCACHEFS_SECTOR_SIZE);
        blkid_probe_set_fsblocksize(pr, blocksize * BCACHEFS_SECTOR_SIZE);
index 70fddbee8e338e40d2f417e42c690cbb5c3591a1..510ec89448620d049e11c330853e4cbca3a70be1 100644 (file)
@@ -9,4 +9,4 @@ ID_FS_UUID=46bd306f-80ad-4cd0-af4f-147e7d85f393
 ID_FS_UUID_ENC=46bd306f-80ad-4cd0-af4f-147e7d85f393
 ID_FS_UUID_SUB=72a60ede-4cb6-4374-aa70-cb38a50af5ef
 ID_FS_UUID_SUB_ENC=72a60ede-4cb6-4374-aa70-cb38a50af5ef
-ID_FS_VERSION=13
+ID_FS_VERSION=0.13
index 4a6d664c098fed3eb75c7c50a7196ed7efe6268a..b6e220ea0a606323e9d3011236c0f71718f00a9a 100644 (file)
@@ -9,4 +9,4 @@ ID_FS_UUID=4fa11b1e-75e6-4210-9167-34e1769c0fe1
 ID_FS_UUID_ENC=4fa11b1e-75e6-4210-9167-34e1769c0fe1
 ID_FS_UUID_SUB=0a3643b7-c515-47f8-a0ea-91fc38d043d1
 ID_FS_UUID_SUB_ENC=0a3643b7-c515-47f8-a0ea-91fc38d043d1
-ID_FS_VERSION=26
+ID_FS_VERSION=0.26