purge all 'store' vocabulary from code and comments

This commit is contained in:
Levi Neely 2026-05-19 18:40:33 +02:00
parent 038dc4b0bf
commit 57eb330d16
6 changed files with 31 additions and 31 deletions

View File

@ -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. // implementation used by the 9P server.
package fs package fs

View File

@ -7,7 +7,7 @@ import (
"sync" "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. // Values are []byte blobs held in RAM; nothing is persisted to disk.
// All operations are safe for concurrent use. // All operations are safe for concurrent use.
type MemoryStore struct { type MemoryStore struct {

View File

@ -30,11 +30,11 @@ type Tree struct {
// Option configures a Tree. // Option configures a Tree.
type Option func(*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 } } func WithReadOnly() Option { return func(d *Tree) { d.readOnly = true } }
// WithIndex adds a synthetic read-only "idx" entry whose content is // 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 { func WithIndex(fn func(FileTree) ([]byte, error)) Option {
return func(d *Tree) { d.indexFn = fn } 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 } 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 { func WithLister(fn func(dirs []string) ([]os.DirEntry, error)) Option {
return func(d *Tree) { d.listFn = fn } return func(d *Tree) { d.listFn = fn }
} }
@ -110,7 +110,7 @@ func (d *Tree) Child(name string) *Tree {
return d.children[name] 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. // if a child handles this path, or (nil, "", false) otherwise.
func (d *Tree) split(name string) (*Tree, string, bool) { func (d *Tree) split(name string) (*Tree, string, bool) {
if d.children == nil { if d.children == nil {
@ -289,7 +289,7 @@ func (d *Tree) Create(name string) error {
return child.Create(rest) return child.Create(rest)
} }
if d.readOnly { if d.readOnly {
return fmt.Errorf("read-only store") return fmt.Errorf("read-only tree")
} }
if d.createFn != nil { if d.createFn != nil {
return d.createFn(d.Tree, name, d.perm) return d.createFn(d.Tree, name, d.perm)
@ -306,7 +306,7 @@ func (d *Tree) Delete(name string) error {
return child.Delete(rest) return child.Delete(rest)
} }
if d.readOnly { if d.readOnly {
return fmt.Errorf("read-only store") return fmt.Errorf("read-only tree")
} }
if d.deleteFn != nil { if d.deleteFn != nil {
return d.deleteFn(d.Tree, name) return d.deleteFn(d.Tree, name)
@ -323,7 +323,7 @@ func (d *Tree) Rename(old, new string) error {
return child.Rename(rest, new) return child.Rename(rest, new)
} }
if d.readOnly { if d.readOnly {
return fmt.Errorf("read-only store") return fmt.Errorf("read-only tree")
} }
if d.renameFn != nil { if d.renameFn != nil {
return d.renameFn(d.Tree, old, new) return d.renameFn(d.Tree, old, new)
@ -359,7 +359,7 @@ func (d *Tree) MkdirAll(rel string) error {
return child.MkdirAll(rest) return child.MkdirAll(rest)
} }
if d.readOnly { if d.readOnly {
return fmt.Errorf("read-only store") return fmt.Errorf("read-only tree")
} }
if len(d.Tree) == 0 { if len(d.Tree) == 0 {
return fmt.Errorf("no backing directory") return fmt.Errorf("no backing directory")

View File

@ -320,7 +320,7 @@ func defaultTmpDir() string {
return paths.DataDir() + "/tmp" 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) { func ToolIndex(s fs.FileTree) ([]byte, error) {
entries, err := s.List() entries, err := s.List()
if err != nil { if err != nil {

View File

@ -23,7 +23,7 @@ import (
"9fans.net/go/plan9" "9fans.net/go/plan9"
) )
// Re-export store types for use in server.go. // Re-export fs types for use in server.go.
type ( type (
File = fs.File File = fs.File
FileTree = fs.FileTree FileTree = fs.FileTree
@ -118,10 +118,10 @@ func New(cfg Config) *Server {
// fsRoute maps a path prefix to its backing fs. // fsRoute maps a path prefix to its backing fs.
type fsRoute struct { type fsRoute struct {
prefix string 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 { func (s *Server) routes() []fsRoute {
return []fsRoute{ return []fsRoute{
{"/a/", func() FileTree { return s.agentStore }}, {"/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) { func (s *Server) route(path string) (FileTree, string) {
for _, r := range s.routes() { for _, r := range s.routes() {
if strings.HasPrefix(path, r.prefix) { 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). // Root-level files (e.g. /backends, /help).
@ -162,11 +162,11 @@ func (s *Server) openEntry(path string) (File, error) {
return st.Open(name) 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 { func (s *Server) routeDir(path string) FileTree {
for _, r := range s.routes() { for _, r := range s.routes() {
if path+"/" == r.prefix { if path+"/" == r.prefix {
return r.store() return r.tree()
} }
} }
return nil 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) { func readFile(s fs.FileTree, name string) ([]byte, error) {
e, err := s.Open(name) e, err := s.Open(name)
if err != nil { if err != nil {
@ -279,7 +279,7 @@ func readFile(s fs.FileTree, name string) ([]byte, error) {
return e.Read() 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 { func writeFile(s fs.FileTree, name string, data []byte) error {
e, err := s.Open(name) e, err := s.Open(name)
if err != nil { if err != nil {
@ -288,7 +288,7 @@ func writeFile(s fs.FileTree, name string, data []byte) error {
return e.Write(data) 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 const readTimeout = 10 * time.Second
// Serve handles a single 9P connection. Each request is dispatched to its own // 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) newPath := pathJoin(f.path, fc.Name)
if fc.Perm&plan9.DMDIR != 0 { 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 { type dirCreator interface {
MkdirAll(string) error MkdirAll(string) error
} }
@ -614,7 +614,7 @@ func (s *Server) create(cs *connState, fc *plan9.Fcall) *plan9.Fcall {
return errFcall(fc, err.Error()) return errFcall(fc, err.Error())
} }
} else if st, parentName := s.route(f.path); st != nil { } 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 { type subCreator interface {
Create(string) error Create(string) error
} }
@ -916,7 +916,7 @@ func (s *Server) readDir(path string, offset uint64, count uint32) []byte {
dirs = append(dirs, st) dirs = append(dirs, st)
} }
} else if st := s.routeDir(path); st != nil { } 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() entries, _ := st.List()
for _, e := range entries { for _, e := range entries {
fpath := path + "/" + e.Name() fpath := path + "/" + e.Name()
@ -928,7 +928,7 @@ func (s *Server) readDir(path string, offset uint64, count uint32) []byte {
dirs = append(dirs, d) dirs = append(dirs, d)
} }
} else if st, name := s.route(path); st != nil { } 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 { type dirLister interface {
Readdir(string) ([]os.DirEntry, error) Readdir(string) ([]os.DirEntry, error)
} }

View File

@ -93,7 +93,7 @@ var sessionStoreFiles = map[string]os.FileMode{
var sessionStoreOrder = []string{"new", "idx", "ls", "kill", "sh", "b", "bfg", "bbg", "cleanup"} 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. // or 0 and false if the name is not a fixed file.
func FileMode(name string) (os.FileMode, bool) { func FileMode(name string) (os.FileMode, bool) {
m, ok := sessionStoreFiles[name] m, ok := sessionStoreFiles[name]
@ -122,7 +122,7 @@ type ManagerConfig struct {
// Manager manages session lifecycle and exposes sessions as a Tree. // Manager manages session lifecycle and exposes sessions as a Tree.
type Manager struct { type Manager struct {
store *fs.Tree tree *fs.Tree
cfg ManagerConfig cfg ManagerConfig
mu sync.RWMutex mu sync.RWMutex
sessions map[string]*Session sessions map[string]*Session
@ -130,7 +130,7 @@ type Manager struct {
} }
// Tree returns the Tree view of the session namespace. // 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. // nextUname generates the next uname atomically.
func (s *Manager) nextUname() string { func (s *Manager) nextUname() string {
return fmt.Sprintf("%d", s.nextUID.Add(1)) return fmt.Sprintf("%d", s.nextUID.Add(1))
@ -148,7 +148,7 @@ func NewManager(cfg ManagerConfig) *Manager {
sessions: make(map[string]*Session), sessions: make(map[string]*Session),
} }
ss.nextUID.Store(9999) 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.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.WithOpener(func(_ []string, name string) (fs.File, error) { return ss.openEntry(name) }),
fs.WithLister(func(_ []string) ([]os.DirEntry, error) { return ss.list() }), 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] rel := parts[2]
if s.cfg.ToolTree == nil { 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. // Apply per-session allowTools filtering on idx.
if rel == "idx" && len(sess.AllowTools) > 0 { if rel == "idx" && len(sess.AllowTools) > 0 {
@ -402,7 +402,7 @@ func (s *Manager) del(name string) error {
if s.cfg.ToolTree != nil { if s.cfg.ToolTree != nil {
return s.cfg.ToolTree.Delete(parts[2]) 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. // Session files are synthetic; allow rm -r to continue.
return nil return nil