Esempio n. 1
0
func (tag *Tag) Read(fid *Fid, offset uint64, count uint32) error {
	req := tag.reqAlloc()
	req.fid = fid
	err := ixp.PackTread(req.Tc, fid.Fid, offset, count)
	if err != nil {
		return err
	}

	return tag.clnt.Rpcnb(req)
}
Esempio n. 2
0
// Reads count bytes starting from offset from the file associated with the fid.
// Returns a slice with the data read, if the operation was successful, or an
// Error.
func (clnt *Clnt) Read(fid *Fid, offset uint64, count uint32) ([]byte, error) {
	if count > fid.Iounit {
		count = fid.Iounit
	}

	tc := clnt.NewFcall()
	err := ixp.PackTread(tc, fid.Fid, offset, count)
	if err != nil {
		return nil, err
	}

	rc, err := clnt.Rpc(tc)
	if err != nil {
		return nil, err
	}

	return rc.Data, nil
}