summaryrefslogtreecommitdiffstats
path: root/back/cmd/authfs/authfs.go
diff options
context:
space:
mode:
Diffstat (limited to 'back/cmd/authfs/authfs.go')
-rw-r--r--back/cmd/authfs/authfs.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/back/cmd/authfs/authfs.go b/back/cmd/authfs/authfs.go
index 71e5128..bf6e340 100644
--- a/back/cmd/authfs/authfs.go
+++ b/back/cmd/authfs/authfs.go
@@ -12,6 +12,7 @@ import (
type File interface {
Qid() (p9.QID, error)
+ Open(mode p9.Mode) error
// TODO
}
@@ -121,3 +122,35 @@ func (fs *Authfs) attach(fid p9.FID, f File) error {
fs.files[fid] = f
return nil
}
+
+func (fs *Authfs) Rclunk(fid p9.FID) error {
+ fs.mu.Lock()
+ defer fs.mu.Unlock()
+
+ if _, exists := fs.files[fid]; !exists {
+ return ErrFidNotExist
+ }
+ delete(fs.files, fid)
+ return nil
+}
+
+func (fs *Authfs) Ropen(fid p9.FID, mode p9.Mode) (p9.QID, error) {
+ f, err := fs.getFile(fid)
+ if err != nil {
+ return p9.QID{}, err
+ }
+ if err := f.Open(mode); err != nil {
+ return p9.QID{}, err
+ }
+ return f.Qid()
+}
+
+func (fs *Authfs) getFile(fid p9.FID) (File, error) {
+ fs.mu.Lock()
+ defer fs.mu.Unlock()
+ f, exists := fs.files[fid]
+ if !exists {
+ return nil, ErrFidNotExist
+ }
+ return f, nil
+}