From 76a7e1175a75231c8eff0a4c7d77ee020da94bcf Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Tue, 25 Jun 2024 15:13:45 -0700 Subject: [PATCH] fix index key to new uint8 size --- examples/xattridx/main.go | 9 +++++++-- scoutfs.go | 20 ++++++++++---------- scoutfsdefs.go | 5 +++-- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/examples/xattridx/main.go b/examples/xattridx/main.go index b40d92e..9c7c2ae 100644 --- a/examples/xattridx/main.go +++ b/examples/xattridx/main.go @@ -13,7 +13,7 @@ func main() { // flags mount path name mountPath := flag.String("mount", "", "mount path name") // flags index type uint64 - indexType := flag.Uint64("type", 0, "index type") + indexType := flag.Uint("type", 0, "index type") // flags index start uint64 indexStart := flag.Uint64("start", 0, "index start") // flags index end uint64 @@ -29,7 +29,12 @@ func main() { } defer f.Close() - idx := scoutfs.NewIndexSearch(f, *indexType, *indexStart, *indexEnd) + if *indexType > 255 { + log.Fatal("index type out of bounds") + } + itype := uint8(*indexType) + + idx := scoutfs.NewIndexSearch(f, itype, *indexStart, *indexEnd) for { ents, err := idx.Next() if err != nil { diff --git a/scoutfs.go b/scoutfs.go index badcbd9..131e5ab 100644 --- a/scoutfs.go +++ b/scoutfs.go @@ -1707,17 +1707,17 @@ const ( indexXattrBatch = 1024 ) -func NewIndexSearch(f *os.File, key, start, end uint64, opts ...IOption) *IndexSearch { +func NewIndexSearch(f *os.File, key uint8, start, end uint64, opts ...IOption) *IndexSearch { i := &IndexSearch{ f: f, pos: indexEntry{ - A: key, - B: start, + Major: key, + Minor: start, }, end: indexEntry{ - A: key, - B: end, - Ino: math.MaxUint64, + Major: key, + Minor: end, + Ino: math.MaxUint64, }, batch: indexXattrBatch, } @@ -1789,7 +1789,7 @@ func (i *IndexSearch) Next() ([]IndexEnt, error) { } inodes[i].Inode = e.Ino - inodes[i].Value = e.B + inodes[i].Value = e.Minor } i.pos = e.increment() @@ -1800,9 +1800,9 @@ func (i *IndexSearch) Next() ([]IndexEnt, error) { func (i indexEntry) increment() indexEntry { i.Ino++ if i.Ino == 0 { - i.B++ - if i.B == 0 { - i.A++ + i.Minor++ + if i.Minor == 0 { + i.Major++ } } return i diff --git a/scoutfsdefs.go b/scoutfsdefs.go index 27278c5..b280246 100644 --- a/scoutfsdefs.go +++ b/scoutfsdefs.go @@ -213,9 +213,10 @@ type getQuotaRules struct { Nr uint64 } type indexEntry struct { - A uint64 - B uint64 + Minor uint64 Ino uint64 + Major uint8 + X_pad [7]uint8 } type readXattrIndex struct { Flags uint64