From 57eb330d16ee64951e5dcdf6726948610b72f471 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Tue, 19 May 2026 18:40:33 +0200 Subject: [PATCH] purge all 'store' vocabulary from code and comments --- fs/fs.go | 2 +- fs/memory.go | 2 +- fs/tree.go | 16 ++++++++-------- main.go | 2 +- server/server.go | 28 ++++++++++++++-------------- session/session.go | 12 ++++++------ 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/fs/fs.go b/fs/fs.go index 6bdf4f5..b931e4a 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -1,4 +1,4 @@ -// Package store defines storage interfaces and a filesystem-backed +// Package fs defines the file tree interfaces and implementation. // implementation used by the 9P server. package fs diff --git a/fs/memory.go b/fs/memory.go index 21e88ac..981e828 100644 --- a/fs/memory.go +++ b/fs/memory.go @@ -7,7 +7,7 @@ import ( "sync" ) -// MemoryStore is an in-memory key/value store implementing FileTree. +// MemoryTree is an in-memory key/value tree implementing FileTree. // Values are []byte blobs held in RAM; nothing is persisted to disk. // All operations are safe for concurrent use. type MemoryStore struct { diff --git a/fs/tree.go b/fs/tree.go index 323a474..80e451d 100644 --- a/fs/tree.go +++ b/fs/tree.go @@ -30,11 +30,11 @@ type Tree struct { // Option configures a Tree. type Option func(*Tree) -// WithReadOnly makes the store reject writes, creates, deletes, and renames. +// WithReadOnly makes the tree reject writes, creates, deletes, and renames. func WithReadOnly() Option { return func(d *Tree) { d.readOnly = true } } // WithIndex adds a synthetic read-only "idx" entry whose content is -// generated by calling fn with the store itself. +// generated by calling fn with the tree itself. func WithIndex(fn func(FileTree) ([]byte, error)) Option { return func(d *Tree) { d.indexFn = fn } } @@ -44,7 +44,7 @@ func WithResolver(fn func(dirs []string, name string) (string, error)) Option { return func(d *Tree) { d.resolveFn = fn } } -// WithLister overrides how the store lists its entries. +// WithLister overrides how the tree lists its entries. func WithLister(fn func(dirs []string) ([]os.DirEntry, error)) Option { return func(d *Tree) { d.listFn = fn } } @@ -110,7 +110,7 @@ func (d *Tree) Child(name string) *Tree { return d.children[name] } -// split checks if name routes to a child store. Returns (child, rest, true) +// split checks if name routes to a child tree. Returns (child, rest, true) // if a child handles this path, or (nil, "", false) otherwise. func (d *Tree) split(name string) (*Tree, string, bool) { if d.children == nil { @@ -289,7 +289,7 @@ func (d *Tree) Create(name string) error { return child.Create(rest) } if d.readOnly { - return fmt.Errorf("read-only store") + return fmt.Errorf("read-only tree") } if d.createFn != nil { return d.createFn(d.Tree, name, d.perm) @@ -306,7 +306,7 @@ func (d *Tree) Delete(name string) error { return child.Delete(rest) } if d.readOnly { - return fmt.Errorf("read-only store") + return fmt.Errorf("read-only tree") } if d.deleteFn != nil { return d.deleteFn(d.Tree, name) @@ -323,7 +323,7 @@ func (d *Tree) Rename(old, new string) error { return child.Rename(rest, new) } if d.readOnly { - return fmt.Errorf("read-only store") + return fmt.Errorf("read-only tree") } if d.renameFn != nil { return d.renameFn(d.Tree, old, new) @@ -359,7 +359,7 @@ func (d *Tree) MkdirAll(rel string) error { return child.MkdirAll(rest) } if d.readOnly { - return fmt.Errorf("read-only store") + return fmt.Errorf("read-only tree") } if len(d.Tree) == 0 { return fmt.Errorf("no backing directory") diff --git a/main.go b/main.go index 5721cb5..c14c5d6 100644 --- a/main.go +++ b/main.go @@ -320,7 +320,7 @@ func defaultTmpDir() string { return paths.DataDir() + "/tmp" } -// ToolIndex generates a tool index from a store's file listing. +// ToolIndex generates a tool index from a tree's file listing. func ToolIndex(s fs.FileTree) ([]byte, error) { entries, err := s.List() if err != nil { diff --git a/server/server.go b/server/server.go index e633fc0..537f19b 100644 --- a/server/server.go +++ b/server/server.go @@ -23,7 +23,7 @@ import ( "9fans.net/go/plan9" ) -// Re-export store types for use in server.go. +// Re-export fs types for use in server.go. type ( File = fs.File FileTree = fs.FileTree @@ -118,10 +118,10 @@ func New(cfg Config) *Server { // fsRoute maps a path prefix to its backing fs. type fsRoute struct { prefix string - store func() FileTree + tree func() FileTree } -// routes returns the route table for generic store-backed paths. +// routes returns the route table for the file tree namespace. func (s *Server) routes() []fsRoute { return []fsRoute{ {"/a/", func() FileTree { return s.agentStore }}, @@ -136,11 +136,11 @@ func (s *Server) routes() []fsRoute { } } -// route returns the store and entry name for a path, or nil if no route matches. +// route returns the tree and entry name for a path, or nil if no route matches. func (s *Server) route(path string) (FileTree, string) { for _, r := range s.routes() { if strings.HasPrefix(path, r.prefix) { - return r.store(), strings.TrimPrefix(path, r.prefix) + return r.tree(), strings.TrimPrefix(path, r.prefix) } } // Root-level files (e.g. /backends, /help). @@ -162,11 +162,11 @@ func (s *Server) openEntry(path string) (File, error) { return st.Open(name) } -// routeDir returns the store for a directory path (e.g. "/a" → agentStore). +// routeDir returns the tree for a directory path (e.g. "/a" → agentStore). func (s *Server) routeDir(path string) FileTree { for _, r := range s.routes() { if path+"/" == r.prefix { - return r.store() + return r.tree() } } return nil @@ -270,7 +270,7 @@ func (s *Server) checkPerm(uname, path string, mode uint8) error { -// readFile opens an entry in a store and reads it. +// readFile opens an entry in a tree and reads it. func readFile(s fs.FileTree, name string) ([]byte, error) { e, err := s.Open(name) if err != nil { @@ -279,7 +279,7 @@ func readFile(s fs.FileTree, name string) ([]byte, error) { return e.Read() } -// writeFile opens an entry in a store and writes to it. +// writeFile opens an entry in a tree and writes to it. func writeFile(s fs.FileTree, name string, data []byte) error { e, err := s.Open(name) if err != nil { @@ -288,7 +288,7 @@ func writeFile(s fs.FileTree, name string, data []byte) error { return e.Write(data) } -// readTimeout is the server-side deadline for all non-blocking store reads. +// readTimeout is the server-side deadline for all non-blocking reads. const readTimeout = 10 * time.Second // Serve handles a single 9P connection. Each request is dispatched to its own @@ -584,7 +584,7 @@ func (s *Server) create(cs *connState, fc *plan9.Fcall) *plan9.Fcall { newPath := pathJoin(f.path, fc.Name) if fc.Perm&plan9.DMDIR != 0 { - // mkdir: delegate to store if it supports MkdirAll. + // mkdir: delegate to tree if it supports MkdirAll. type dirCreator interface { MkdirAll(string) error } @@ -614,7 +614,7 @@ func (s *Server) create(cs *connState, fc *plan9.Fcall) *plan9.Fcall { return errFcall(fc, err.Error()) } } else if st, parentName := s.route(f.path); st != nil { - // Parent is a subdirectory within a store; create relative to it. + // Parent is a subdirectory within a tree; create relative to it. type subCreator interface { Create(string) error } @@ -916,7 +916,7 @@ func (s *Server) readDir(path string, offset uint64, count uint32) []byte { dirs = append(dirs, st) } } else if st := s.routeDir(path); st != nil { - // Top-level store directory (e.g. /a, /s, /m). + // Top-level tree directory (e.g. /a, /s, /m). entries, _ := st.List() for _, e := range entries { fpath := path + "/" + e.Name() @@ -928,7 +928,7 @@ func (s *Server) readDir(path string, offset uint64, count uint32) []byte { dirs = append(dirs, d) } } else if st, name := s.route(path); st != nil { - // Subdirectory within a store (e.g. /s/mysession, /s/mysession/t). + // Subdirectory within a tree (e.g. /s/mysession, /s/mysession/t). type dirLister interface { Readdir(string) ([]os.DirEntry, error) } diff --git a/session/session.go b/session/session.go index 512f2ba..d2bcb5e 100644 --- a/session/session.go +++ b/session/session.go @@ -93,7 +93,7 @@ var sessionStoreFiles = map[string]os.FileMode{ var sessionStoreOrder = []string{"new", "idx", "ls", "kill", "sh", "b", "bfg", "bbg", "cleanup"} -// FileMode returns the mode for a fixed session store file, +// FileMode returns the mode for a fixed session file, // or 0 and false if the name is not a fixed file. func FileMode(name string) (os.FileMode, bool) { m, ok := sessionStoreFiles[name] @@ -122,7 +122,7 @@ type ManagerConfig struct { // Manager manages session lifecycle and exposes sessions as a Tree. type Manager struct { - store *fs.Tree + tree *fs.Tree cfg ManagerConfig mu sync.RWMutex sessions map[string]*Session @@ -130,7 +130,7 @@ type Manager struct { } // Tree returns the Tree view of the session namespace. -func (s *Manager) Tree() *fs.Tree { return s.store } +func (s *Manager) Tree() *fs.Tree { return s.tree } // nextUname generates the next uname atomically. func (s *Manager) nextUname() string { return fmt.Sprintf("%d", s.nextUID.Add(1)) @@ -148,7 +148,7 @@ func NewManager(cfg ManagerConfig) *Manager { sessions: make(map[string]*Session), } ss.nextUID.Store(9999) - ss.store = fs.NewTree(nil, 0, + ss.tree = fs.NewTree(nil, 0, fs.WithStat(func(_ []string, name string) (os.FileInfo, error) { return ss.stat(name) }), fs.WithOpener(func(_ []string, name string) (fs.File, error) { return ss.openEntry(name) }), fs.WithLister(func(_ []string) ([]os.DirEntry, error) { return ss.list() }), @@ -307,7 +307,7 @@ func (s *Manager) openEntry(name string) (fs.File, error) { } rel := parts[2] if s.cfg.ToolTree == nil { - return nil, fmt.Errorf("%s: no tool store", name) + return nil, fmt.Errorf("%s: no tool tree", name) } // Apply per-session allowTools filtering on idx. if rel == "idx" && len(sess.AllowTools) > 0 { @@ -402,7 +402,7 @@ func (s *Manager) del(name string) error { if s.cfg.ToolTree != nil { return s.cfg.ToolTree.Delete(parts[2]) } - return fmt.Errorf("no tool store") + return fmt.Errorf("no tool tree") } // Session files are synthetic; allow rm -r to continue. return nil