summaryrefslogtreecommitdiff
path: root/internal/fusefrontend/file.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2019-10-06 19:36:04 +0200
committerJakob Unterwurzacher2019-10-06 19:37:51 +0200
commit43265940fa2d43ebea8edb00373aa4d6718e2ea7 (patch)
tree6427c63e2c4a451192d2f39cda4a105e4ebe291d /internal/fusefrontend/file.go
parentb3c88f573f4c1b269e78dd7d1dbd6de73d477694 (diff)
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.
Diffstat (limited to 'internal/fusefrontend/file.go')
-rw-r--r--internal/fusefrontend/file.go8
1 files changed, 7 insertions, 1 deletions
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