From 268e0484e24c3ecf9ec8df189a18cbbf36f81d1a Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 21 Oct 2017 17:43:21 +0200 Subject: [PATCH] Revert most of "fusefrontend: clamp oversized reads" We cannot return less data than requested to the kernel! From https://libfuse.github.io/doxygen/structfuse__operations.html: Read should return exactly the number of bytes requested except on EOF or error, otherwise the rest of the data will be substituted with zeroes. Reverts commit 3009ec9852316c3c696f77f476390ab5a6d8d6d7 minus the formatting improvements we want to keep. Fixes https://github.com/rfjakob/gocryptfs/issues/147 Reopens https://github.com/rfjakob/gocryptfs/issues/145 --- internal/fusefrontend/file.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go index be15280..f765eae 100644 --- a/internal/fusefrontend/file.go +++ b/internal/fusefrontend/file.go @@ -132,8 +132,6 @@ func (f *file) createHeader() (fileID []byte, err error) { return h.ID, err } -var oversizedReadWarn sync.Once - // doRead - read "length" plaintext bytes from plaintext offset "off" and append // to "dst". // Arguments "length" and "off" do not have to be block-aligned. @@ -144,16 +142,6 @@ var oversizedReadWarn sync.Once // Called by Read() for normal reading, // by Write() and Truncate() for Read-Modify-Write func (f *file) doRead(dst []byte, off uint64, length uint64) ([]byte, fuse.Status) { - // Our byte cache pools are sized acc. to MAX_KERNEL_WRITE, but the - // running kernel may have a higher limit set. Clamp to what we can - // handle. - if length > fuse.MAX_KERNEL_WRITE { - oversizedReadWarn.Do(func() { - tlog.Warn.Printf("doRead: truncating oversized read: %d to %d bytes", - length, fuse.MAX_KERNEL_WRITE) - }) - length = fuse.MAX_KERNEL_WRITE - } // Make sure we have the file ID. f.fileTableEntry.HeaderLock.RLock() if f.fileTableEntry.ID == nil {