commit fa7dc51876530daa2bced6c3f8c7ff87b4e1fd0c
parent f59d503daf49e212bc1cdaa3f0d644b676f33487
Author: Matsuda Kenji <info@mtkn.jp>
Date: Thu, 19 Oct 2023 11:51:42 +0900
add Stat() for AuthFile
Diffstat:
| M | auth.go | | | 23 | +++++++++++++++++------ |
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/auth.go b/auth.go
@@ -1,8 +1,8 @@
package lib9p
import (
- "errors"
"io"
+ "io/fs"
)
type AuthFile struct {
@@ -15,9 +15,21 @@ type AuthFile struct {
}
func (af *AuthFile) Stat() (*FileInfo, error) {
- return nil, errors.New("auth file")
+ if af.Qid.Type&QTAUTH == 0 {
+ panic("QTAUTH bit not set")
+ }
+ s := Stat{
+ Qid: af.Qid,
+ Mode: fs.ModeAppend | fs.ModeExclusive | fs.ModeTemporary, // TODO: right?
+ Name: "auth",
+ Uid: af.Uname,
+ Gid: af.Uname,
+ Muid: af.Uname,
+ }
+
+ return &FileInfo{Stat: s}, nil
}
-func (af *AuthFile) Close() error { return nil }
-func (af *AuthFile) Read(p []byte) (int, error) { return af.R.Read(p) }
-func (af *AuthFile) Write(p []byte) (int, error) { return af.W.Write(p) }
-\ No newline at end of file
+func (af *AuthFile) Close() error { return nil }
+func (af *AuthFile) Read(p []byte) (int, error) { return af.R.Read(p) }
+func (af *AuthFile) Write(p []byte) (int, error) { return af.W.Write(p) }