summaryrefslogtreecommitdiffstats
path: root/back/cmd/authfs/authfs.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2026-03-14 20:01:34 -0400
committerSam Anthony <sam@samanthony.xyz>2026-03-14 20:01:34 -0400
commit3f16c6b240108bca18be0d1941f6dda1f1fc2d51 (patch)
treee74054e695e2b411343eb1d36f717a8edba82b47 /back/cmd/authfs/authfs.go
parentcab80e76783c416960b06d98058eeba8d4c254fb (diff)
downloadbuth-mockup.zip
authfs.RootDir: implement Dir interfacemockup
Diffstat (limited to 'back/cmd/authfs/authfs.go')
-rw-r--r--back/cmd/authfs/authfs.go20
1 files changed, 6 insertions, 14 deletions
diff --git a/back/cmd/authfs/authfs.go b/back/cmd/authfs/authfs.go
index da2637c..7d04179 100644
--- a/back/cmd/authfs/authfs.go
+++ b/back/cmd/authfs/authfs.go
@@ -29,23 +29,17 @@ type Dir interface {
// Authfs is the root p9.NineServer.
type Authfs struct {
*RootDir
- *UsersDir
- *SessionsDir
-
mu sync.Mutex // guards below
files map[p9.FID]File
}
func NewAuthfs(rootPath string) (*Authfs, error) {
- root := NewRootDir()
- users, err := NewUsersDir(rootPath, root.Version)
+ root, err := NewRootDir(rootPath)
if err != nil {
return nil, err
}
return &Authfs{
root,
- users,
- NewSessionsDir(root.Version),
sync.Mutex{},
make(map[p9.FID]File),
}, nil
@@ -53,8 +47,6 @@ func NewAuthfs(rootPath string) (*Authfs, error) {
func (fs *Authfs) Close() {
fs.RootDir.Close()
- fs.UsersDir.Close()
- fs.SessionsDir.Close()
}
func (fs *Authfs) Rversion(msize p9.MaxSize, version string) (p9.MaxSize, string, error) {
@@ -83,15 +75,15 @@ func (fs *Authfs) Rattach(fid, afid p9.FID, uname, aname string) (p9.QID, error)
case "":
f = fs.RootDir
case "users":
- f = fs.UsersDir
+ f = fs.RootDir.UsersDir
case "sessions":
- f = fs.SessionsDir
+ f = fs.RootDir.SessionsDir
default:
return p9.QID{}, ErrFileNotExist
}
case "/users/":
- f, err = fs.UsersDir.Walk(file)
+ f, err = fs.RootDir.UsersDir.Walk(file)
if err != nil {
return p9.QID{}, err
}
@@ -101,7 +93,7 @@ func (fs *Authfs) Rattach(fid, afid p9.FID, uname, aname string) (p9.QID, error)
if err != nil {
return p9.QID{}, err
}
- f, ok = fs.SessionsDir.Get(sessid)
+ f, ok = fs.RootDir.SessionsDir.Get(sessid)
if !ok {
return p9.QID{}, ErrFileNotExist
}
@@ -227,7 +219,7 @@ func (fs *Authfs) Rread(fid p9.FID, off p9.Offset, n p9.Count) ([]byte, error) {
func (fs *Authfs) Rwrite(fid p9.FID, off p9.Offset, b []byte) (p9.Count, error) {
f, ok := fs.getFile(fid)
if !ok {
- return nil, ErrFidNotExist
+ return 0, ErrFidNotExist
}
return f.Write(off, b)
}