From d5de012a17f8dec476a3792875dcb5ef41ebf658 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Sun, 4 Dec 2022 03:43:21 -0500 Subject: [PATCH] btrfs-tree: translate item types for error messages Look up the name when filling in the what() field for the exception. Signed-off-by: Zygo Blaxell --- lib/btrfs-tree.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/btrfs-tree.cc b/lib/btrfs-tree.cc index 39960f8..2b2a1ea 100644 --- a/lib/btrfs-tree.cc +++ b/lib/btrfs-tree.cc @@ -77,14 +77,14 @@ namespace crucible { uint64_t BtrfsTreeItem::block_group_flags() const { - THROW_CHECK1(invalid_argument, m_type, m_type == BTRFS_BLOCK_GROUP_ITEM_KEY); + THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_BLOCK_GROUP_ITEM_KEY); return btrfs_get_member(&btrfs_block_group_item::flags, m_data); } uint64_t BtrfsTreeItem::block_group_used() const { - THROW_CHECK1(invalid_argument, m_type, m_type == BTRFS_BLOCK_GROUP_ITEM_KEY); + THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_BLOCK_GROUP_ITEM_KEY); return btrfs_get_member(&btrfs_block_group_item::used, m_data); } @@ -105,28 +105,28 @@ namespace crucible { uint64_t BtrfsTreeItem::dev_extent_chunk_offset() const { - THROW_CHECK1(invalid_argument, m_type, m_type == BTRFS_DEV_EXTENT_KEY); + THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_DEV_EXTENT_KEY); return btrfs_get_member(&btrfs_dev_extent::chunk_offset, m_data); } uint64_t BtrfsTreeItem::dev_extent_length() const { - THROW_CHECK1(invalid_argument, m_type, m_type == BTRFS_DEV_EXTENT_KEY); + THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_DEV_EXTENT_KEY); return btrfs_get_member(&btrfs_dev_extent::length, m_data); } uint64_t BtrfsTreeItem::dev_item_total_bytes() const { - THROW_CHECK1(invalid_argument, m_type, m_type == BTRFS_DEV_ITEM_KEY); + THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_DEV_ITEM_KEY); return btrfs_get_member(&btrfs_dev_item::total_bytes, m_data); } uint64_t BtrfsTreeItem::dev_item_bytes_used() const { - THROW_CHECK1(invalid_argument, m_type, m_type == BTRFS_DEV_ITEM_KEY); + THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_DEV_ITEM_KEY); return btrfs_get_member(&btrfs_dev_item::bytes_used, m_data); } @@ -134,14 +134,14 @@ namespace crucible { BtrfsTreeItem::inode_size() const { - THROW_CHECK1(invalid_argument, m_type, m_type == BTRFS_INODE_ITEM_KEY); + THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_INODE_ITEM_KEY); return btrfs_get_member(&btrfs_inode_item::size, m_data); } uint64_t BtrfsTreeItem::file_extent_logical_bytes() const { - THROW_CHECK1(invalid_argument, m_type, m_type == BTRFS_EXTENT_DATA_KEY); + THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_EXTENT_DATA_KEY); const auto file_extent_item_type = btrfs_get_member(&btrfs_file_extent_item::type, m_data); switch (file_extent_item_type) { case BTRFS_FILE_EXTENT_INLINE: @@ -157,7 +157,7 @@ namespace crucible { uint64_t BtrfsTreeItem::file_extent_offset() const { - THROW_CHECK1(invalid_argument, m_type, m_type == BTRFS_EXTENT_DATA_KEY); + THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_EXTENT_DATA_KEY); const auto file_extent_item_type = btrfs_get_member(&btrfs_file_extent_item::type, m_data); switch (file_extent_item_type) { case BTRFS_FILE_EXTENT_INLINE: @@ -173,14 +173,14 @@ namespace crucible { uint64_t BtrfsTreeItem::file_extent_generation() const { - THROW_CHECK1(invalid_argument, m_type, m_type == BTRFS_EXTENT_DATA_KEY); + THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_EXTENT_DATA_KEY); return btrfs_get_member(&btrfs_file_extent_item::generation, m_data); } uint64_t BtrfsTreeItem::file_extent_bytenr() const { - THROW_CHECK1(invalid_argument, m_type, m_type == BTRFS_EXTENT_DATA_KEY); + THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_EXTENT_DATA_KEY); auto file_extent_item_type = btrfs_get_member(&btrfs_file_extent_item::type, m_data); switch (file_extent_item_type) { case BTRFS_FILE_EXTENT_INLINE: @@ -196,14 +196,14 @@ namespace crucible { uint8_t BtrfsTreeItem::file_extent_type() const { - THROW_CHECK1(invalid_argument, m_type, m_type == BTRFS_EXTENT_DATA_KEY); + THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_EXTENT_DATA_KEY); return btrfs_get_member(&btrfs_file_extent_item::type, m_data); } btrfs_compression_type BtrfsTreeItem::file_extent_compression() const { - THROW_CHECK1(invalid_argument, m_type, m_type == BTRFS_EXTENT_DATA_KEY); + THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_EXTENT_DATA_KEY); return static_cast(btrfs_get_member(&btrfs_file_extent_item::compression, m_data)); }