nametransform: nicer error message on empty gocryptfs.diriv

Old:

	Nov 06 13:34:38 brikett gocryptfs[16228]: ReadDirIVAt: Read failed: EOF
	Nov 06 13:34:38 brikett gocryptfs[16228]: go-fuse: can't convert error type: EOF

New:

	Nov 06 14:08:43 brikett gocryptfs[17361]: ReadDirIVAt: wanted 16 bytes, got 0. Returning EINVAL.
This commit is contained in:
Jakob Unterwurzacher 2016-11-06 14:09:34 +01:00
parent d15122d3d6
commit df1e3a10c4
1 changed files with 3 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package nametransform
import (
"io"
"io/ioutil"
"os"
"path/filepath"
@ -52,13 +53,13 @@ func fdReadDirIV(fd *os.File) (iv []byte, err error) {
// make the buffer 1 byte bigger than necessary.
iv = make([]byte, DirIVLen+1)
n, err := fd.Read(iv)
if err != nil {
if err != nil && err != io.EOF {
tlog.Warn.Printf("ReadDirIVAt: Read failed: %v", err)
return nil, err
}
iv = iv[0:n]
if len(iv) != DirIVLen {
tlog.Warn.Printf("ReadDirIVAt: wanted %d bytes, got %d", DirIVLen, len(iv))
tlog.Warn.Printf("ReadDirIVAt: wanted %d bytes, got %d. Returning EINVAL.", DirIVLen, len(iv))
return nil, syscall.EINVAL
}
return iv, nil