diff --git a/cmd/mount/handle.go b/cmd/mount/handle.go index 7b7b6c010..c3293acc3 100644 --- a/cmd/mount/handle.go +++ b/cmd/mount/handle.go @@ -25,15 +25,13 @@ var _ fusefs.HandleReader = (*FileHandle)(nil) func (fh *FileHandle) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) (err error) { var n int defer log.Trace(fh, "len=%d, offset=%d", req.Size, req.Offset)("read=%d, err=%v", &n, &err) - data := make([]byte, req.Size) + data := resp.Data[:req.Size] n, err = fh.Handle.ReadAt(data, req.Offset) + resp.Data = data[:n] if err == io.EOF { err = nil - } else if err != nil { - return translateError(err) } - resp.Data = data[:n] - return nil + return translateError(err) } // Check interface satisfied