]> 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>
Sat, 25 Nov 2023 11:05:15 +0000 (12:05 +0100)
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>
(cherry picked from commit 8beea162ce1c2f5a7565044b68434efbb96f0697)

libblkid/src/superblocks/bcache.c
tests/expected/blkid/low-probe-bcachefs
tests/expected/blkid/low-probe-bcachefs-2

index 28ac4b52be3983dbc2ed926f37cb5eed844e4ef1..9581aba49d09e16f289f9c6b117c9c02b8e57e5f 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <stddef.h>
 #include <stdio.h>
+#include <inttypes.h>
 
 #include "superblocks.h"
 #include "crc32c.h"
@@ -159,6 +160,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))
 
@@ -301,6 +305,7 @@ static int probe_bcachefs(blkid_probe pr, const struct blkid_idmag *mag)
        struct bcachefs_super_block *bcs;
        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)
@@ -333,7 +338,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