nametransform: better error code on invalid diriv length

go-fuse translates errors unknown to it into "function not
implemented", which is wrong in this case.
This commit is contained in:
Jakob Unterwurzacher 2016-10-07 22:36:29 +02:00
parent 45dfc90a2f
commit 53257f4ee5

View File

@ -1,7 +1,6 @@
package nametransform package nametransform
import ( import (
"errors"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -26,6 +25,7 @@ const (
func ReadDirIV(dir string) (iv []byte, err error) { func ReadDirIV(dir string) (iv []byte, err error) {
fd, err := os.Open(filepath.Join(dir, DirIVFilename)) fd, err := os.Open(filepath.Join(dir, DirIVFilename))
if err != nil { if err != nil {
// Note: getting errors here is normal because of concurrent deletes.
return nil, err return nil, err
} }
defer fd.Close() defer fd.Close()
@ -59,7 +59,7 @@ func fdReadDirIV(fd *os.File) (iv []byte, err error) {
iv = iv[0:n] iv = iv[0:n]
if len(iv) != DirIVLen { 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", DirIVLen, len(iv))
return nil, errors.New("invalid iv length") return nil, syscall.EINVAL
} }
return iv, nil return iv, nil
} }