mount: removed unnecessary byte slice allocation for reads
Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com>
This commit is contained in:
parent
ae6874170f
commit
d0eb884262
1 changed files with 3 additions and 5 deletions
|
@ -25,15 +25,13 @@ var _ fusefs.HandleReader = (*FileHandle)(nil)
|
||||||
func (fh *FileHandle) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) (err error) {
|
func (fh *FileHandle) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) (err error) {
|
||||||
var n int
|
var n int
|
||||||
defer log.Trace(fh, "len=%d, offset=%d", req.Size, req.Offset)("read=%d, err=%v", &n, &err)
|
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)
|
n, err = fh.Handle.ReadAt(data, req.Offset)
|
||||||
|
resp.Data = data[:n]
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
err = nil
|
err = nil
|
||||||
} else if err != nil {
|
|
||||||
return translateError(err)
|
|
||||||
}
|
}
|
||||||
resp.Data = data[:n]
|
return translateError(err)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check interface satisfied
|
// Check interface satisfied
|
||||||
|
|
Loading…
Reference in a new issue