func (fid *Fid) Wstat(d *plan9.Dir) error { b, err := d.Bytes() if err != nil { return err } tx := &plan9.Fcall{Type: plan9.Twstat, Fid: fid.fid, Stat: b} _, err = fid.c.rpc(tx) return err }
func (c *ClientConn) readdir(fc *plan9.Fcall, ref *fileRef) *plan9.Fcall { // if the call have an offset, return 0 // since all readdir call's will return the full directory if fc.Offset > 0 { fc.Count = 0 return fc } childs, err := c.explorer.ListDir(ref.Path) if err != nil { return c.unexpectedErr(fc, err) } tmpBuf := allocBuffer(int(c.iounit)) out := bytes.NewBuffer(tmpBuf[:0]) defer discardBuffer(tmpBuf) for _, id := range childs { stat, err := c.explorer.Stat(id.Path) if err != nil { return c.unexpectedErr(fc, err) } dir := plan9.Dir{ Qid: plan9.Qid{Type: uint8(stat.Type), Vers: stat.Version, Path: id.Path}, Mode: plan9.Perm(stat.Mode), Atime: stat.Atime, Mtime: stat.Mtime, Length: stat.Size, Uid: stat.Uname, Gid: stat.Gname, Name: stat.Name, } buf, err := dir.Bytes() if err != nil { return c.unexpectedErr(fc, err) } _, err = out.Write(buf) if err != nil { return c.unexpectedErr(fc, err) } } fc.Count = uint32(len(fc.Data)) fc.Data = out.Bytes() return fc }