本文整理匯總了Golang中github.com/lionkov/go9p/p/srv.Req.RespondRwstat方法的典型用法代碼示例。如果您正苦於以下問題:Golang Req.RespondRwstat方法的具體用法?Golang Req.RespondRwstat怎麽用?Golang Req.RespondRwstat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/lionkov/go9p/p/srv.Req
的用法示例。
在下文中一共展示了Req.RespondRwstat方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Wstat
func (u *VuFs) Wstat(req *srv.Req) {
fid := req.Fid.Aux.(*Fid)
_, err := os.Stat(fid.path)
if err != nil {
req.RespondError(toError(err))
return
}
dir := &req.Tc.Dir
if dir.Mode != 0xFFFFFFFF {
mode := dir.Mode & 0777
e := os.Chmod(fid.path, os.FileMode(mode))
if e != nil {
req.RespondError(toError(e))
return
}
}
/*
// BUG(mbucc) implement chown
uid, gid := p.NOUID, p.NOUID
uid, err = lookup(dir.Uid, false)
if err != nil {
req.RespondError(err)
return
}
gid, err = lookup(dir.Gid, true)
if err != nil {
req.RespondError(err)
return
}
if uid != p.NOUID || gid != p.NOUID {
e := os.Chown(fid.path, int(uid), int(gid))
if e != nil {
req.RespondError(toError(e))
return
}
}
*/
if dir.Name != "" {
// If we path.Join dir.Name to / before adding it to
// the fid path, that ensures nobody gets to walk out of the
// root of this server.
newname := path.Join(path.Dir(fid.path), path.Join("/", dir.Name))
// absolute renaming. VuFs can do this, so let's support it.
// We'll allow an absolute path in the Name and, if it is,
// we will make it relative to root. This is a gigantic performance
// improvement in systems that allow it.
if filepath.IsAbs(dir.Name) {
newname = path.Join(fid.path, dir.Name)
}
err := syscall.Rename(fid.path, newname)
if err != nil {
req.RespondError(toError(err))
return
}
fid.path = newname
}
if dir.Length != 0xFFFFFFFFFFFFFFFF {
e := os.Truncate(fid.path, int64(dir.Length))
if e != nil {
req.RespondError(toError(e))
return
}
}
// If either mtime or atime need to be changed, then
// we must change both.
if dir.Mtime != ^uint32(0) || dir.Atime != ^uint32(0) {
mt, at := time.Unix(int64(dir.Mtime), 0), time.Unix(int64(dir.Atime), 0)
if cmt, cat := (dir.Mtime == ^uint32(0)), (dir.Atime == ^uint32(0)); cmt || cat {
st, e := os.Stat(fid.path)
if e != nil {
req.RespondError(toError(e))
return
}
switch cmt {
case true:
mt = st.ModTime()
default:
at = atime(st.Sys().(*syscall.Stat_t))
}
}
e := os.Chtimes(fid.path, at, mt)
if e != nil {
req.RespondError(toError(e))
return
}
}
req.RespondRwstat()
}
示例2: Wstat
//.........這裏部分代碼省略.........
return
}
}
uid, gid := p.NOUID, p.NOUID
if req.Conn.Dotu {
uid = dir.Uidnum
gid = dir.Gidnum
}
// Try to find local uid, gid by name.
if (dir.Uid != "" || dir.Gid != "") && !req.Conn.Dotu {
changed = true
uid, err = lookup(dir.Uid, false)
if err != nil {
req.RespondError(err)
return
}
// BUG(akumar): Lookup will never find gids
// corresponding to group names, because
// it only operates on user names.
gid, err = lookup(dir.Gid, true)
if err != nil {
req.RespondError(err)
return
}
}
if uid != p.NOUID || gid != p.NOUID {
changed = true
e := os.Chown(fid.path, int(uid), int(gid))
if e != nil {
req.RespondError(toError(e))
return
}
}
if dir.Name != "" {
changed = true
// If we path.Join dir.Name to / before adding it to
// the fid path, that ensures nobody gets to walk out of the
// root of this server.
newname := path.Join(path.Dir(fid.path), path.Join("/", dir.Name))
// absolute renaming. Ufs can do this, so let's support it.
// We'll allow an absolute path in the Name and, if it is,
// we will make it relative to root. This is a gigantic performance
// improvement in systems that allow it.
if filepath.IsAbs(dir.Name) {
newname = path.Join(u.Root, dir.Name)
}
err := syscall.Rename(fid.path, newname)
if err != nil {
req.RespondError(toError(err))
return
}
fid.path = newname
}
if dir.Length != 0xFFFFFFFFFFFFFFFF {
changed = true
e := os.Truncate(fid.path, int64(dir.Length))
if e != nil {
req.RespondError(toError(e))
return
}
}
// If either mtime or atime need to be changed, then
// we must change both.
if dir.Mtime != ^uint32(0) || dir.Atime != ^uint32(0) {
changed = true
mt, at := time.Unix(int64(dir.Mtime), 0), time.Unix(int64(dir.Atime), 0)
if cmt, cat := (dir.Mtime == ^uint32(0)), (dir.Atime == ^uint32(0)); cmt || cat {
st, e := os.Stat(fid.path)
if e != nil {
req.RespondError(toError(e))
return
}
switch cmt {
case true:
mt = st.ModTime()
default:
at = atime(st.Sys().(*syscall.Stat_t))
}
}
e := os.Chtimes(fid.path, at, mt)
if e != nil {
req.RespondError(toError(e))
return
}
}
if !changed && fid.file != nil {
fid.file.Sync()
}
req.RespondRwstat()
}