summaryrefslogtreecommitdiffstats
path: root/back/cmd/authfs/userdir.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2026-03-14 11:23:50 -0400
committerSam Anthony <sam@samanthony.xyz>2026-03-14 11:23:50 -0400
commit700096b078f6e16f2c5c967ea140f0b93e799986 (patch)
treee1d9965e9bf09ebe01a96d8faa6d2bc027e6984c /back/cmd/authfs/userdir.go
parent7d622695ae19e518fded6aa5fbf001dae4652211 (diff)
downloadbuth-harveyos.zip
authfs: rewrite with Harvey-OS/ninep, implement Rattachharveyos
Diffstat (limited to 'back/cmd/authfs/userdir.go')
-rw-r--r--back/cmd/authfs/userdir.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/back/cmd/authfs/userdir.go b/back/cmd/authfs/userdir.go
new file mode 100644
index 0000000..f7ef5a7
--- /dev/null
+++ b/back/cmd/authfs/userdir.go
@@ -0,0 +1,51 @@
+package main
+
+import (
+ "errors"
+ "fmt"
+ "io/fs"
+ "os"
+
+ p9 "github.com/Harvey-OS/ninep/protocol"
+
+ "git.samanthony.xyz/buth/back/qver"
+)
+
+type UsersDir struct {
+ path string
+ *qver.Version
+}
+
+func NewUsersDir(path string, rootVer *qver.Version) (*UsersDir, error) {
+ info, err := os.Stat(path)
+ if errors.Is(err, fs.ErrNotExist) {
+ if err := os.Mkdir(path, 0770); err != nil {
+ return nil, err
+ }
+ } else if err != nil {
+ return nil, err
+ } else if !info.IsDir() {
+ return nil, fmt.Errorf("%q is not a directory", path)
+ }
+
+ return &UsersDir{
+ path,
+ qver.New(qver.Parent(rootVer)),
+ }, nil
+}
+
+func (dir *UsersDir) Close() {
+ dir.Version.Close()
+}
+
+func (dir *UsersDir) Qid() (p9.QID, error) {
+ ver, err := dir.Version.Get()
+ if err != nil {
+ return p9.QID{}, err
+ }
+ return p9.QID{
+ Type: p9.QTDIR,
+ Version: ver,
+ Path: usersQidPath,
+ }, nil
+}