]> git.hungrycats.org Git - bees/commitdiff
fs: add a ntoa function for chunk types
authorZygo Blaxell <bees@furryterror.org>
Mon, 27 Jan 2025 05:42:39 +0000 (00:42 -0500)
committerZygo Blaxell <bees@furryterror.org>
Fri, 7 Feb 2025 03:42:15 +0000 (22:42 -0500)
Signed-off-by: Zygo Blaxell <bees@furryterror.org>
include/crucible/fs.h
lib/fs.cc

index 35616810af31dc72b0a113310d1b35dd2c83f115..9c843d8f7b969ee6e474a7cffb6f4100584e1f85 100644 (file)
@@ -206,6 +206,7 @@ namespace crucible {
        ostream & operator<<(ostream &os, const btrfs_ioctl_search_key &key);
        ostream & operator<<(ostream &os, const BtrfsIoctlSearchKey &key);
 
+       string btrfs_chunk_type_ntoa(uint64_t type);
        string btrfs_search_type_ntoa(unsigned type);
        string btrfs_search_objectid_ntoa(uint64_t objectid);
        string btrfs_compress_type_ntoa(uint8_t type);
index 8c8226cfd64555da0036d2b6503776d7f1bc2339..dc20318796e1c6acfd9c35c3f478e0564ecfa907 100644 (file)
--- a/lib/fs.cc
+++ b/lib/fs.cc
@@ -881,6 +881,26 @@ namespace crucible {
                }
        }
 
+       string
+       btrfs_chunk_type_ntoa(uint64_t type)
+       {
+               static const bits_ntoa_table table[] = {
+                       NTOA_TABLE_ENTRY_BITS(BTRFS_BLOCK_GROUP_DATA),
+                       NTOA_TABLE_ENTRY_BITS(BTRFS_BLOCK_GROUP_METADATA),
+                       NTOA_TABLE_ENTRY_BITS(BTRFS_BLOCK_GROUP_SYSTEM),
+                       NTOA_TABLE_ENTRY_BITS(BTRFS_BLOCK_GROUP_DUP),
+                       NTOA_TABLE_ENTRY_BITS(BTRFS_BLOCK_GROUP_RAID0),
+                       NTOA_TABLE_ENTRY_BITS(BTRFS_BLOCK_GROUP_RAID1),
+                       NTOA_TABLE_ENTRY_BITS(BTRFS_BLOCK_GROUP_RAID10),
+                       NTOA_TABLE_ENTRY_BITS(BTRFS_BLOCK_GROUP_RAID1C3),
+                       NTOA_TABLE_ENTRY_BITS(BTRFS_BLOCK_GROUP_RAID1C4),
+                       NTOA_TABLE_ENTRY_BITS(BTRFS_BLOCK_GROUP_RAID5),
+                       NTOA_TABLE_ENTRY_BITS(BTRFS_BLOCK_GROUP_RAID6),
+                       NTOA_TABLE_ENTRY_END()
+               };
+               return bits_ntoa(type, table);
+       }
+
        string
        btrfs_search_type_ntoa(unsigned type)
        {