]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: (bcachefs) add support for sub-device labels
authorThomas Weißschuh <thomas@t-8ch.de>
Tue, 26 Sep 2023 07:43:35 +0000 (09:43 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Sat, 25 Nov 2023 11:06:48 +0000 (12:06 +0100)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
(cherry picked from commit da91337a8109beb461c889ffe32701d3cb95aee2)

libblkid/src/superblocks/bcache.c
tests/expected/blkid/low-probe-bcachefs-2
tests/ts/blkid/images-fs/bcachefs-2.img.xz

index 9581aba49d09e16f289f9c6b117c9c02b8e57e5f..d3afc41d90e33a6a8a32b2b35ac631e28733fcde 100644 (file)
@@ -89,6 +89,16 @@ struct bcachefs_sb_field_members {
        struct bcachefs_sb_member       members[];
 }  __attribute__((packed));
 
+struct bcachefs_sb_disk_group {
+       uint8_t         label[SB_LABEL_SIZE];
+       uint64_t        flags[2];
+} __attribute__((packed));
+
+struct bcachefs_sb_field_disk_groups {
+       struct bcachefs_sb_field        field;
+       struct bcachefs_sb_disk_group   disk_groups[];
+}  __attribute__((packed));
+
 enum bcachefs_sb_csum_type {
        BCACHEFS_SB_CSUM_TYPE_NONE = 0,
        BCACHEFS_SB_CSUM_TYPE_CRC32C = 1,
@@ -160,6 +170,8 @@ 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
+/* tag value for disk_groups field */
+#define BCACHEFS_SB_FIELD_TYPE_DISK_GROUPS 5
 /* version splitting helpers */
 #define BCH_VERSION_MAJOR(_v)           ((uint16_t) ((_v) >> 10))
 #define BCH_VERSION_MINOR(_v)           ((uint16_t) ((_v) & ~(~0U << 10)))
@@ -229,6 +241,22 @@ static void probe_bcachefs_sb_members(blkid_probe pr,
        blkid_probe_set_fssize(pr, sectors * BCACHEFS_SECTOR_SIZE);
 }
 
+static void probe_bcachefs_sb_disk_groups(blkid_probe pr,
+                                         const struct bcachefs_super_block *bcs,
+                                         const struct bcachefs_sb_field *field,
+                                         uint8_t dev_idx)
+{
+       struct bcachefs_sb_field_disk_groups *disk_groups =
+                       (struct bcachefs_sb_field_disk_groups *) field;
+
+       if (BYTES(field) != offsetof(typeof(*disk_groups), disk_groups[bcs->nr_devices]))
+               return;
+
+       blkid_probe_set_id_label(pr, "LABEL_SUB",
+                                disk_groups->disk_groups[dev_idx].label,
+                                sizeof(disk_groups->disk_groups[dev_idx].label));
+}
+
 static int is_within_range(void *start, uint64_t size, void *end)
 {
        ptrdiff_t diff;
@@ -268,6 +296,9 @@ static void probe_bcachefs_sb_fields(blkid_probe pr, const struct bcachefs_super
                if (type == BCACHEFS_SB_FIELD_TYPE_MEMBERS)
                        probe_bcachefs_sb_members(pr, bcs, field, bcs->dev_idx);
 
+               if (type == BCACHEFS_SB_FIELD_TYPE_DISK_GROUPS)
+                       probe_bcachefs_sb_disk_groups(pr, bcs, field, bcs->dev_idx);
+
                field_addr += BYTES(field);
        }
 }
index b6e220ea0a606323e9d3011236c0f71718f00a9a..8e10469cf82d3ae947550682f061b89463d1a81b 100644 (file)
@@ -3,10 +3,12 @@ ID_FS_FSBLOCKSIZE=512
 ID_FS_FSSIZE=4194304
 ID_FS_LABEL=Label
 ID_FS_LABEL_ENC=Label
+ID_FS_LABEL_SUB=Device_Label
+ID_FS_LABEL_SUB_ENC=Device\x20Label
 ID_FS_TYPE=bcachefs
 ID_FS_USAGE=filesystem
 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=0.26
+ID_FS_UUID_SUB=525fa857-174a-4d3f-be33-6fe60441de7c
+ID_FS_UUID_SUB_ENC=525fa857-174a-4d3f-be33-6fe60441de7c
+ID_FS_VERSION=0.24
index e796c974cbc90c349d649911e48804773b91f5d9..267df3f3ee36e0793c69bca5af2712560a55caf6 100644 (file)
Binary files a/tests/ts/blkid/images-fs/bcachefs-2.img.xz and b/tests/ts/blkid/images-fs/bcachefs-2.img.xz differ