From f25b4c81baab4ffa34282cf51d2aa07d0d7fe085 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Wed, 20 Nov 2024 10:15:53 -0500 Subject: [PATCH] btrfs-tree: add root refs and extent flags fields Lazily filling in accessor methods for btrfs objects as needed by bees. Signed-off-by: Zygo Blaxell --- include/crucible/btrfs-tree.h | 2 ++ lib/btrfs-tree.cc | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/crucible/btrfs-tree.h b/include/crucible/btrfs-tree.h index 44241da..1c67b25 100644 --- a/include/crucible/btrfs-tree.h +++ b/include/crucible/btrfs-tree.h @@ -64,11 +64,13 @@ namespace crucible { /// @{ Extent items (EXTENT_ITEM) uint64_t extent_begin() const; uint64_t extent_end() const; + uint64_t extent_flags() const; uint64_t extent_generation() const; /// @} /// @{ Root items uint64_t root_flags() const; + uint64_t root_refs() const; /// @} /// @{ Root backref items. diff --git a/lib/btrfs-tree.cc b/lib/btrfs-tree.cc index d597d68..14073cb 100644 --- a/lib/btrfs-tree.cc +++ b/lib/btrfs-tree.cc @@ -22,6 +22,13 @@ namespace crucible { return m_objectid + m_offset; } + uint64_t + BtrfsTreeItem::extent_flags() const + { + THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_EXTENT_ITEM_KEY); + return btrfs_get_member(&btrfs_extent_item::flags, m_data); + } + uint64_t BtrfsTreeItem::extent_generation() const { @@ -61,6 +68,13 @@ namespace crucible { return btrfs_get_member(&btrfs_root_item::flags, m_data); } + uint64_t + BtrfsTreeItem::root_refs() const + { + THROW_CHECK1(invalid_argument, btrfs_search_type_ntoa(m_type), m_type == BTRFS_ROOT_ITEM_KEY); + return btrfs_get_member(&btrfs_root_item::refs, m_data); + } + ostream & operator<<(ostream &os, const BtrfsTreeItem &bti) {