当前位置: 首页>>代码示例>>Golang>>正文


Golang Req.RespondRwalk方法代码示例

本文整理汇总了Golang中github.com/lionkov/go9p/p/srv.Req.RespondRwalk方法的典型用法代码示例。如果您正苦于以下问题:Golang Req.RespondRwalk方法的具体用法?Golang Req.RespondRwalk怎么用?Golang Req.RespondRwalk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/lionkov/go9p/p/srv.Req的用法示例。


在下文中一共展示了Req.RespondRwalk方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Walk

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([]p.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])
}
开发者ID:rjkroege,项目名称:go9p,代码行数:37,代码来源:ufs.go

示例2: Walk

// BUG(mbucc) does not fully implement spec when fid = newfid.
// From http://plan9.bell-labs.com/magic/man2html/5/walk:
//	If newfid is the same as fid, the above discussion applies, with the
//	obvious difference that if the walk changes the state of newfid, it
//	also changes the state of fid; and if newfid is unaffected, then fid
//	is also unaffected.
//
func (u *VuFs) Walk(req *srv.Req) {
	fid := req.Fid.Aux.(*Fid)
	tc := req.Tc

	_, err := os.Stat(fid.path)
	if err != nil {
		req.RespondError(toError(err))
		return
	}

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

	newfid := req.Newfid.Aux.(*Fid)
	wqids := make([]p.Qid, len(tc.Wname))
	path := fid.path
	i := 0

	// Ensure execute permission on the walk root.
	st, err := os.Stat(path)
	if err != nil {
		req.RespondError(srv.Enoent)
		return
	}
	f, err := dir2Dir(path, st, req.Conn.Srv.Upool)
	if err != nil {
		req.RespondError(toError(err))
		return
	}
	if !CheckPerm(f, req.Fid.User, p.DMEXEC) {
		req.RespondError(srv.Eperm)
		return
	}

	for ; i < len(tc.Wname); i++ {

		var newpath string

		// Don't allow client to dotdot out of the file system root.
		if tc.Wname[i] == ".." {
			if path == u.Root {
				continue
			} else {
				newpath = path[:strings.LastIndex(path, "/")]
				if newpath == u.Root {
					continue
				}
			}
		} else {
			newpath = path + "/" + tc.Wname[i]
		}

		st, err := os.Stat(newpath)
		if err != nil {
			if i == 0 {
				req.RespondError(srv.Enoent)
				return
			}

			break
		}

		wqids[i] = *dir2Qid(st)

		if (wqids[i].Type & p.QTDIR) > 0 {
			f, err := dir2Dir(newpath, st, req.Conn.Srv.Upool)
			if err != nil {
				req.RespondError(toError(err))
				return
			}
			if !CheckPerm(f, req.Fid.User, p.DMEXEC) {
				req.RespondError(srv.Eperm)
				return
			}
		}

		path = newpath
	}

	newfid.path = path
	req.RespondRwalk(wqids[0:i])
}
开发者ID:postfix,项目名称:vufs,代码行数:90,代码来源:vufs.go


注:本文中的github.com/lionkov/go9p/p/srv.Req.RespondRwalk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。