]> git.hungrycats.org Git - bees/commitdiff
btrfs-tree: add chunk items: length and type
authorZygo Blaxell <bees@furryterror.org>
Sun, 1 Jan 2023 01:15:12 +0000 (20:15 -0500)
committerZygo Blaxell <bees@furryterror.org>
Thu, 5 Jan 2023 06:10:17 +0000 (01:10 -0500)
Signed-off-by: Zygo Blaxell <bees@furryterror.org>
include/crucible/btrfs-tree.h
lib/btrfs-tree.cc

index f11c6eac9c5b650b30490c1033127382f45d404a..44241da85244e044a3f304abad674b8bd0d27ee7 100644 (file)
@@ -33,6 +33,11 @@ namespace crucible {
                uint64_t block_group_used() const;
                /// @}
 
+               /// @{ Chunk items
+               uint64_t chunk_length() const;
+               uint64_t chunk_type() const;
+               /// @}
+
                /// @{ Dev extent items (physical byte ranges)
                uint64_t dev_extent_chunk_offset() const;
                uint64_t dev_extent_length() const;
index 48a7450954332a64b5cb5e449df3eb4749b92bd0..39960f82172bbcd0dc71d98329d347e6ad102625 100644 (file)
@@ -88,6 +88,20 @@ namespace crucible {
                return btrfs_get_member(&btrfs_block_group_item::used, m_data);
        }
 
+       uint64_t
+       BtrfsTreeItem::chunk_length() const
+       {
+               THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_CHUNK_ITEM_KEY);
+               return btrfs_get_member(&btrfs_chunk::length, m_data);
+       }
+
+       uint64_t
+       BtrfsTreeItem::chunk_type() const
+       {
+               THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_CHUNK_ITEM_KEY);
+               return btrfs_get_member(&btrfs_chunk::type, m_data);
+       }
+
        uint64_t
        BtrfsTreeItem::dev_extent_chunk_offset() const
        {