Esempio n. 1
0
func (sfs *NopSrv) Walk(req *go9p.SrvReq) {
	fid := req.Fid.Aux.(Dispatcher)
	tc := req.Tc

	if sfs.Debuglevel > 0 {
		log.Printf("walk %s %s", fid, tc.Wname)
	}

	if req.Newfid.Aux == nil {
		req.Newfid.Aux = fid.Clone()
	}

	if len(tc.Wname) == 0 {
		w := make([]go9p.Qid, 0)
		req.RespondRwalk(w)
	} else {
		nfid, err := fid.Walk(req, tc.Wname[0])
		if err != nil {
			req.RespondError(toError(err))
			return
		}
		req.Newfid.Aux = nfid
		w := []go9p.Qid{*Qid(nfid)}
		req.RespondRwalk(w)
	}
}
Esempio n. 2
0
File: p9.go Progetto: flynn/bake
func (fs *fileSystem) Walk(req *go9p.SrvReq) {
	// Stat the file.
	aux := req.Fid.Aux.(*Aux)
	if err := aux.stat(); err != nil {
		req.RespondError(err)
		return
	}

	// Create a new file handle, if necessary.
	if req.Newfid.Aux == nil {
		req.Newfid.Aux = &Aux{rootID: aux.rootID}
	}

	nfid := req.Newfid.Aux.(*Aux)
	wqids := make([]go9p.Qid, 0, len(req.Tc.Wname))
	newPath := aux.path

	// Append actual files after the root.
	for i, name := range req.Tc.Wname {
		// If we have no root then the first segment is the root ID.
		if nfid.rootID == "" {
			nfid.rootID = name
			if root := (*FileSystem)(fs).Root(nfid.rootID); root == nil {
				req.RespondError(go9p.Enoent)
				return
			}
			wqids = append(wqids, *newRootQid(nfid.rootID))
			continue
		}

		// Otherwise we're already walking a root so continue to traverse the files.
		p := newPath + "/" + name
		st, err := os.Lstat(p)
		if err != nil {
			if i == 0 {
				req.RespondError(go9p.Enoent)
				return
			}
			break
		}

		wqids = append(wqids, *newQid(st))
		newPath = p
	}

	nfid.path = newPath
	req.RespondRwalk(wqids)
}