diff options
-rw-r--r-- | cmd/btrfs-dbg/main.go | 2 | ||||
-rw-r--r-- | cmd/btrfs-fsck/pass1.go | 2 | ||||
-rw-r--r-- | pkg/btrfs/types_btree.go | 5 | ||||
-rw-r--r-- | pkg/btrfsmisc/print_tree.go | 4 |
4 files changed, 9 insertions, 4 deletions
diff --git a/cmd/btrfs-dbg/main.go b/cmd/btrfs-dbg/main.go index 9033421..9536126 100644 --- a/cmd/btrfs-dbg/main.go +++ b/cmd/btrfs-dbg/main.go @@ -52,7 +52,7 @@ func Main(imgfilename string) (err error) { if err != nil { return err } - fmt.Printf("superblock checksum: %x\n", sum) + fmt.Printf("superblock checksum: %v\n", sum) spew.Dump(superblocks[0].Data) syschunks, err := superblocks[0].Data.ParseSysChunkArray() diff --git a/cmd/btrfs-fsck/pass1.go b/cmd/btrfs-fsck/pass1.go index f880ac9..cf93b1b 100644 --- a/cmd/btrfs-fsck/pass1.go +++ b/cmd/btrfs-fsck/pass1.go @@ -311,7 +311,7 @@ func pass1WriteReconstructedChunks( for i, laddr := range sortedLAddrs { chunk := fsReconstructedChunks[laddr] for j, stripe := range chunk.Stripes { - fmt.Printf("Pass 1: chunk[%d].stripe[%d] = { laddr=0x%0x ⇒ { dev_id=%v, paddr=0x%0x }, size=0x%0x }\n", + fmt.Printf("Pass 1: chunks[%d].stripes[%d] = { laddr=0x%0x => { dev_id=%d, paddr=0x%0x }, size=0x%0x }\n", i, j, laddr, stripe.DeviceID, stripe.Offset, chunk.Size) } reconstructedNode.Data.BodyLeaf = append(reconstructedNode.Data.BodyLeaf, btrfs.Item{ 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) diff --git a/pkg/btrfsmisc/print_tree.go b/pkg/btrfsmisc/print_tree.go index 3211d1d..de216c2 100644 --- a/pkg/btrfsmisc/print_tree.go +++ b/pkg/btrfsmisc/print_tree.go @@ -277,11 +277,11 @@ func printHeaderInfo(node btrfs.Node) { node.Head.Flags, node.Head.BackrefRev) - fmt.Printf("checksum stored %x\n", node.Head.Checksum) + fmt.Printf("checksum stored %v\n", node.Head.Checksum) if calcSum, err := node.CalculateChecksum(); err != nil { fmt.Printf("checksum calced %v\n", err) } else { - fmt.Printf("checksum calced %x\n", calcSum) + fmt.Printf("checksum calced %v\n", calcSum) } fmt.Printf("fs uuid %s\n", node.Head.MetadataUUID) |