From 51c51c16bf4839940124695fbee65c152f6d29c5 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Sat, 14 Mar 2026 16:14:15 -0400 Subject: authfs: implement Qid() for Session and SessionsDir --- back/cmd/authfs/authfs.go | 7 ------- back/cmd/authfs/qid.go | 16 ++++++++++++++++ back/cmd/authfs/sess.go | 6 ++++++ back/cmd/authfs/sessdir.go | 14 ++++++++++++++ 4 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 back/cmd/authfs/qid.go diff --git a/back/cmd/authfs/authfs.go b/back/cmd/authfs/authfs.go index e2a8bf9..71e5128 100644 --- a/back/cmd/authfs/authfs.go +++ b/back/cmd/authfs/authfs.go @@ -10,13 +10,6 @@ import ( "git.samanthony.xyz/buth/back/auth" ) -const ( - _ uint64 = iota - rootQidPath - usersQidPath - sessionsQidPath -) - type File interface { Qid() (p9.QID, error) // TODO diff --git a/back/cmd/authfs/qid.go b/back/cmd/authfs/qid.go new file mode 100644 index 0000000..7c23240 --- /dev/null +++ b/back/cmd/authfs/qid.go @@ -0,0 +1,16 @@ +package main + +const ( + _ uint64 = iota + rootQidPath + usersQidPath + sessionsQidPath +) + +var nextQidPath uint64 = 99 + +func NextQidPath() uint64 { + p := nextQidPath + nextQidPath++ + return p +} diff --git a/back/cmd/authfs/sess.go b/back/cmd/authfs/sess.go index 138ea84..3d0cca3 100644 --- a/back/cmd/authfs/sess.go +++ b/back/cmd/authfs/sess.go @@ -4,12 +4,15 @@ import ( "sync/atomic" "time" + p9 "github.com/Harvey-OS/ninep/protocol" + "git.samanthony.xyz/buth/back/auth" ) type Session struct { auth.SessId auth.Uname + qid p9.QID timer *time.Timer dead *atomic.Bool } @@ -20,6 +23,7 @@ func NewSession(id auth.SessId, uname auth.Uname) *Session { return &Session{ id, uname, + p9.QID{Path: NextQidPath()}, timer, dead, } @@ -46,3 +50,5 @@ func (s *Session) Extend() bool { // already expired return false } + +func (s *Session) Qid() (p9.QID, error) { return s.qid, nil } diff --git a/back/cmd/authfs/sessdir.go b/back/cmd/authfs/sessdir.go index 186484f..eafc92f 100644 --- a/back/cmd/authfs/sessdir.go +++ b/back/cmd/authfs/sessdir.go @@ -3,6 +3,8 @@ package main import ( "sync" + p9 "github.com/Harvey-OS/ninep/protocol" + "git.samanthony.xyz/buth/back/auth" "git.samanthony.xyz/buth/back/qver" ) @@ -58,3 +60,15 @@ func (dir *SessionsDir) Kill(id auth.SessId) { dir.Version.Bump() } } + +func (dir *SessionsDir) 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: sessionsQidPath, + }, nil +} -- cgit v1.2.3