Skip to content

Commit

Permalink
fusefrontend: print file hexdump on header error
Browse files Browse the repository at this point in the history
This should help debugging #363 ,
but does no harm in normal operation as it only prints ciphertext to the log.
  • Loading branch information
rfjakob committed Oct 6, 2019
1 parent b3c88f5 commit 4326594
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/fusefrontend/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package fusefrontend

import (
"bytes"
"encoding/hex"
"fmt"
"io"
"log"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4326594

Please sign in to comment.