From 15ff79bf144cc8fe780bffdd7447dfbb5df604a8 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 24 May 2020 23:30:25 +0200 Subject: [PATCH] syscallcompat: warn when Getdents truncates data On CIFS mounts, unix.Getdents can return sudden ENOENT in the middle of data. This will not be reported as an error by user space tools, so return EIO instead. Also log it as a warning. https://github.com/rfjakob/gocryptfs/issues/483 --- internal/syscallcompat/getdents_linux.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/syscallcompat/getdents_linux.go b/internal/syscallcompat/getdents_linux.go index 6cfb033..2425326 100644 --- a/internal/syscallcompat/getdents_linux.go +++ b/internal/syscallcompat/getdents_linux.go @@ -42,6 +42,10 @@ func getdents(fd int) ([]fuse.DirEntry, error) { } continue } else if err != nil { + if smartBuf.Len() > 0 { + tlog.Warn.Printf("warning: unix.Getdents returned errno %d in the middle of data", err.(syscall.Errno)) + return nil, syscall.EIO + } return nil, err } if n == 0 {