Using the provided example noop FS:
package main
import (
"io"
"log"
"os"
"time"
"aqwari.net/net/styx"
)
type emptyDir struct{}
func (emptyDir) Readdir(n int) ([]os.FileInfo, error) { return nil, io.EOF }
func (emptyDir) Mode() os.FileMode { return os.ModeDir | 0777 }
func (emptyDir) IsDir() bool { return true }
func (emptyDir) ModTime() time.Time { return time.Now() }
func (emptyDir) Name() string { return "" }
func (emptyDir) Size() int64 { return 0 }
func (emptyDir) Sys() interface{} { return nil }
func main() {
// Run a file server that creates directories (and only directories)
// on-demand, as a client walks to them.
h := styx.HandlerFunc(func(s *styx.Session) {
for s.Next() {
switch t := s.Request().(type) {
case styx.Tstat:
t.Rstat(emptyDir{}, nil)
case styx.Twalk:
t.Rwalk(emptyDir{}, nil)
case styx.Topen:
t.Ropen(emptyDir{}, nil)
}
}
})
log.Fatal(styx.ListenAndServe(":564", h))
}
Running the following client command:
$ 9p -a localhost:564 stat a
9p: dirstat: rwalk did not find file
Perhaps my understanding of how this package works is incorrect, but I expected any sort of stat call to successfully return an empty dir.
I am guessing styx wants (either intentionally, or by accident) the file to be created first using Tcreate? But what about the scenario where you are starting up a server which already has some files pre-populated inside it?
Using the provided example noop FS:
Running the following client command:
Perhaps my understanding of how this package works is incorrect, but I expected any sort of stat call to successfully return an empty dir.
I am guessing styx wants (either intentionally, or by accident) the file to be created first using Tcreate? But what about the scenario where you are starting up a server which already has some files pre-populated inside it?