Exemple #1
0
func (f *NullFS) Walk(req *srv.Req) {
	tc := req.Tc

	if len(tc.Wname) > 1 && tc.Qid.Type != ninep.QTDIR {
		req.RespondError(ninep.ENOENT)
		return
	}

	// The most common case is walking from '.', so we initialize to '.' and fix it up
	// later if needed.
	if req.Newfid.Aux == nil {
		req.Newfid.Aux = &Fid{NullFile: NullFile{Name: ".", Qid: dirQids["."]}}
	}

	if len(tc.Wname) == 0 {
		req.RespondRwalk([]ninep.Qid{})
		return
	}

	if q, ok := dirQids[tc.Wname[0]]; !ok {
		req.RespondError(ninep.ENOENT)
	} else {
		req.Newfid.Aux.(*Fid).Name = tc.Wname[0]
		req.Newfid.Aux.(*Fid).Qid = q
		req.RespondRwalk([]ninep.Qid{*q})
	}
}
Exemple #2
0
func (*Ufs) Walk(req *srv.Req) {
	fid := req.Fid.Aux.(*Fid)
	tc := req.Tc

	err := fid.stat()
	if err != nil {
		req.RespondError(err)
		return
	}

	if req.Newfid.Aux == nil {
		req.Newfid.Aux = new(Fid)
	}

	nfid := req.Newfid.Aux.(*Fid)
	wqids := make([]ninep.Qid, len(tc.Wname))
	path := fid.path
	i := 0
	for ; i < len(tc.Wname); i++ {
		p := path + "/" + tc.Wname[i]
		st, err := os.Lstat(p)
		if err != nil {
			if i == 0 {
				req.RespondError(Enoent)
				return
			}

			break
		}

		wqids[i] = *dir2Qid(st)
		path = p
	}

	nfid.path = path
	req.RespondRwalk(wqids[0:i])
}