diff options
Diffstat (limited to 'back/cmd/authfs/authfs.go')
| -rw-r--r-- | back/cmd/authfs/authfs.go | 20 |
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) } |