From 63d3b78538e2e40bd199ee771bcdf9413e542319 Mon Sep 17 00:00:00 2001 From: axtloss Date: Sat, 17 Feb 2024 19:07:53 +0100 Subject: Multithread fsverify --- core/storage.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'core/storage.go') diff --git a/core/storage.go b/core/storage.go index 8334271..d3dc3da 100644 --- a/core/storage.go +++ b/core/storage.go @@ -2,13 +2,13 @@ package core import ( "bufio" + "bytes" "encoding/binary" "encoding/json" "fmt" + bolt "go.etcd.io/bbolt" "io" "os" - - bolt "go.etcd.io/bbolt" ) type Header struct { @@ -141,6 +141,8 @@ func ReadDB(partition string) (string, error) { db := make([]byte, header.TableSize*header.TableUnit) n, err := io.ReadFull(reader, db) if err != nil { + fmt.Println("failed reading db") + fmt.Println(header.TableSize * header.TableUnit) return "", err } if n != header.TableSize*header.TableUnit { @@ -195,3 +197,14 @@ func GetNode(checksum string, db *bolt.DB) (Node, error) { } return node, err } + +func CopyByteArea(start int, end int, reader *bytes.Reader) ([]byte, error) { + bytes := make([]byte, end-start) + n, err := reader.ReadAt(bytes, int64(start)) + if err != nil { + return nil, err + } else if n != end-start { + return nil, fmt.Errorf("Unable to read requested size. Got %d, expected %d", n, end-start) + } + return bytes, nil +} -- cgit v1.2.3