From f412eaa60a80a46dd325d9a2b59eb8996ee1a015 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Thu, 5 Mar 2015 19:58:20 -0600 Subject: [PATCH] Filter out EOF errors in ReadFile. --- file_system.go | 3 ++- samples/memfs/fs.go | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/file_system.go b/file_system.go index 56ccac2..33f7a79 100644 --- a/file_system.go +++ b/file_system.go @@ -694,7 +694,8 @@ type ReadFileRequest struct { } type ReadFileResponse struct { - // The data read. + // The data read. If this is less than the requested size, it indicates EOF. + // An error should not be returned in this case. Data []byte } diff --git a/samples/memfs/fs.go b/samples/memfs/fs.go index 7f35c27..62c1d18 100644 --- a/samples/memfs/fs.go +++ b/samples/memfs/fs.go @@ -16,6 +16,7 @@ package memfs import ( "fmt" + "io" "os" "time" @@ -497,6 +498,11 @@ func (fs *memFS) ReadFile( n, err := inode.ReadAt(resp.Data, req.Offset) resp.Data = resp.Data[:n] + // Don't return EOF errors; we just indicate EOF to fuse using a short read. + if err == io.EOF { + err = nil + } + return }