From 43265940fa2d43ebea8edb00373aa4d6718e2ea7 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 6 Oct 2019 19:36:04 +0200 Subject: fusefrontend: print file hexdump on header error This should help debugging https://github.com/rfjakob/gocryptfs/issues/363 , but does no harm in normal operation as it only prints ciphertext to the log. --- internal/fusefrontend/file.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go index 50aa551..3313934 100644 --- a/internal/fusefrontend/file.go +++ b/internal/fusefrontend/file.go @@ -4,6 +4,7 @@ package fusefrontend import ( "bytes" + "encoding/hex" "fmt" "io" "log" @@ -158,7 +159,12 @@ func (f *File) doRead(dst []byte, off uint64, length uint64) ([]byte, fuse.Statu // Empty file return nil, fuse.OK } - tlog.Warn.Printf("doRead %d: corrupt header: %v", f.qIno.Ino, err) + buf := make([]byte, 100) + n, _ := f.fd.ReadAt(buf, 0) + buf = buf[:n] + hexdump := hex.EncodeToString(buf) + tlog.Warn.Printf("doRead %d: corrupt header: %v\nFile hexdump (%d bytes): %s", + f.qIno.Ino, err, n, hexdump) return nil, fuse.EIO } // Save into the file table -- cgit v1.2.3