diff options
author | Jakob Unterwurzacher | 2016-11-06 14:09:34 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2016-11-06 14:09:34 +0100 |
commit | df1e3a10c45cefb393a350f75ebf3fbb8117ef2f (patch) | |
tree | 23fcebf5021d1a2e662846c7ef0813cda29f169e /internal/nametransform/diriv.go | |
parent | d15122d3d6b67d42617ed9950ce5273d0dba64fd (diff) |
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.
Diffstat (limited to 'internal/nametransform/diriv.go')
-rw-r--r-- | internal/nametransform/diriv.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/internal/nametransform/diriv.go b/internal/nametransform/diriv.go index f8734db..72c8e7c 100644 --- a/internal/nametransform/diriv.go +++ b/internal/nametransform/diriv.go @@ -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 |