summaryrefslogtreecommitdiff
path: root/pkg/btrfs
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/btrfs')
-rw-r--r--pkg/btrfs/crc32c.go5
-rw-r--r--pkg/btrfs/internal/uuid.go5
-rw-r--r--pkg/btrfs/types_btree.go6
-rw-r--r--pkg/btrfs/types_superblock.go6
4 files changed, 7 insertions, 15 deletions
diff --git a/pkg/btrfs/crc32c.go b/pkg/btrfs/crc32c.go
index 5e050cc..4ea4169 100644
--- a/pkg/btrfs/crc32c.go
+++ b/pkg/btrfs/crc32c.go
@@ -1,17 +1,12 @@
package btrfs
import (
- "bytes"
"encoding/binary"
"hash/crc32"
)
type CSum [0x20]byte
-func (a CSum) Equal(b CSum) bool {
- return bytes.Equal(a[:], b[:])
-}
-
func CRC32c(data []byte) CSum {
crc := crc32.Update(0, crc32.MakeTable(crc32.Castagnoli), data)
diff --git a/pkg/btrfs/internal/uuid.go b/pkg/btrfs/internal/uuid.go
index ff274d9..6169638 100644
--- a/pkg/btrfs/internal/uuid.go
+++ b/pkg/btrfs/internal/uuid.go
@@ -1,7 +1,6 @@
package internal
import (
- "bytes"
"encoding/hex"
"strings"
)
@@ -18,7 +17,3 @@ func (uuid UUID) String() string {
str[20:32],
}, "-")
}
-
-func (a UUID) Equal(b UUID) bool {
- return bytes.Equal(a[:], b[:])
-}
diff --git a/pkg/btrfs/types_btree.go b/pkg/btrfs/types_btree.go
index 96b069a..8db00e2 100644
--- a/pkg/btrfs/types_btree.go
+++ b/pkg/btrfs/types_btree.go
@@ -229,7 +229,7 @@ func (node Node) ValidateChecksum() error {
if err != nil {
return err
}
- if !calced.Equal(stored) {
+ if calced != stored {
return fmt.Errorf("node checksum mismatch: stored=%s calculated=%s",
stored, calced)
}
@@ -273,7 +273,7 @@ func (fs *FS) ReadNode(addr LogicalAddr) (util.Ref[LogicalAddr, Node], error) {
// sanity checking
- if !node.Head.MetadataUUID.Equal(sb.Data.EffectiveMetadataUUID()) {
+ if node.Head.MetadataUUID != sb.Data.EffectiveMetadataUUID() {
return ret, fmt.Errorf("btrfs.FS.ReadNode: node@%d: does not look like a node", addr)
}
@@ -284,7 +284,7 @@ func (fs *FS) ReadNode(addr LogicalAddr) (util.Ref[LogicalAddr, Node], error) {
stored := node.Head.Checksum
calced := CRC32c(nodeBuf[binstruct.StaticSize(CSum{}):])
- if !calced.Equal(stored) {
+ if calced != stored {
return ret, fmt.Errorf("btrfs.FS.ReadNode: node@%d: checksum mismatch: stored=%s calculated=%s",
addr, stored, calced)
}
diff --git a/pkg/btrfs/types_superblock.go b/pkg/btrfs/types_superblock.go
index ec8b497..9cd097b 100644
--- a/pkg/btrfs/types_superblock.go
+++ b/pkg/btrfs/types_superblock.go
@@ -83,7 +83,7 @@ func (sb Superblock) ValidateChecksum() error {
if err != nil {
return err
}
- if !calced.Equal(stored) {
+ if calced != stored {
return fmt.Errorf("superblock checksum mismatch: stored=%s calculated=%s",
stored, calced)
}
@@ -226,4 +226,6 @@ var incompatFlagNames = []string{
}
func (f IncompatFlags) Has(req IncompatFlags) bool { return f&req == req }
-func (f IncompatFlags) String() string { return util.BitfieldString(f, incompatFlagNames, util.HexLower) }
+func (f IncompatFlags) String() string {
+ return util.BitfieldString(f, incompatFlagNames, util.HexLower)
+}