Esempio n. 1
0
func (tag *Tag) Write(fid *Fid, data []byte, offset uint64) error {
	req := tag.reqAlloc()
	req.fid = fid
	err := ixp.PackTwrite(req.Tc, fid.Fid, offset, uint32(len(data)), data)
	if err != nil {
		return err
	}

	return tag.clnt.Rpcnb(req)
}
Esempio n. 2
0
// 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 := ixp.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
}