Skip to content

Getting rwalk did not find file for any Twalk call #31

Description

@zakkor

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions