From c4ba6ec269c9f202905562ba196d72c351a4e863 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Mon, 27 Jan 2025 00:42:39 -0500 Subject: [PATCH] fs: add a ntoa function for chunk types Signed-off-by: Zygo Blaxell --- include/crucible/fs.h | 1 + lib/fs.cc | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/crucible/fs.h b/include/crucible/fs.h index 3561681..9c843d8 100644 --- a/include/crucible/fs.h +++ b/include/crucible/fs.h @@ -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); diff --git a/lib/fs.cc b/lib/fs.cc index 8c8226c..dc20318 100644 --- 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) {