func (tag *Tag) Write(fid *Fid, data []byte, offset uint64) error { req := tag.reqAlloc() req.fid = fid err := p.PackTwrite(req.Tc, fid.Fid, offset, uint32(len(data)), data) if err != nil { return err } return tag.clnt.Rpcnb(req) }
// Write up to len(data) bytes starting from offset. Returns the // number of bytes written, or an Error. func (clnt *Clnt) Write(fid *Fid, data []byte, offset uint64) (int, error) { if uint32(len(data)) > fid.Iounit { data = data[0:fid.Iounit] } tc := clnt.NewFcall() err := p.PackTwrite(tc, fid.Fid, offset, uint32(len(data)), data) if err != nil { return 0, err } rc, err := clnt.Rpc(tc) if err != nil { return 0, err } return int(rc.Count), nil }