From 3c5d991b0323b33816e661e52da5d6f5402f47b5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Sun, 9 Jul 2023 20:03:57 +0200 Subject: [PATCH] libblkid: (bcachefs) adapt to major.minor version MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 (cherry picked from commit 8beea162ce1c2f5a7565044b68434efbb96f0697) --- libblkid/src/superblocks/bcache.c | 10 +++++++++- tests/expected/blkid/low-probe-bcachefs | 2 +- tests/expected/blkid/low-probe-bcachefs-2 | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libblkid/src/superblocks/bcache.c b/libblkid/src/superblocks/bcache.c index 28ac4b52be..9581aba49d 100644 --- a/libblkid/src/superblocks/bcache.c +++ b/libblkid/src/superblocks/bcache.c @@ -10,6 +10,7 @@ #include #include +#include #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); diff --git a/tests/expected/blkid/low-probe-bcachefs b/tests/expected/blkid/low-probe-bcachefs index 70fddbee8e..510ec89448 100644 --- a/tests/expected/blkid/low-probe-bcachefs +++ b/tests/expected/blkid/low-probe-bcachefs @@ -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 diff --git a/tests/expected/blkid/low-probe-bcachefs-2 b/tests/expected/blkid/low-probe-bcachefs-2 index 4a6d664c09..b6e220ea0a 100644 --- a/tests/expected/blkid/low-probe-bcachefs-2 +++ b/tests/expected/blkid/low-probe-bcachefs-2 @@ -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 -- 2.47.2