From a169e17d28ce89ab243685f00e8bb9b418fe3130 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 7 Jun 2022 01:34:15 -0600 Subject: fix em up --- pkg/btrfs/types_btree.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'pkg/btrfs') diff --git a/pkg/btrfs/types_btree.go b/pkg/btrfs/types_btree.go index 734c859..e58e33b 100644 --- a/pkg/btrfs/types_btree.go +++ b/pkg/btrfs/types_btree.go @@ -146,6 +146,11 @@ func (node Node) MarshalBinary() ([]byte, error) { return nil, fmt.Errorf("btrfs.Node.MarshalBinary: .Size must be greater than %d", binstruct.StaticSize(NodeHeader{})) } + if node.Head.Level > 0 { + node.Head.NumItems = uint32(len(node.BodyInternal)) + } else { + node.Head.NumItems = uint32(len(node.BodyLeaf)) + } buf := make([]byte, node.Size) -- cgit v1.2.3-2-g168b