vfs: add EPERM to errors

This commit is contained in:
Nick Craig-Wood 2017-10-31 15:33:08 +00:00
parent 190367d917
commit 8184ec4b70
5 changed files with 9 additions and 4 deletions

View File

@ -640,6 +640,8 @@ func translateError(err error) (errc int) {
return -fuse.EROFS
case vfs.ENOSYS:
return -fuse.ENOSYS
case vfs.EPERM:
return -fuse.EPERM
}
fs.Errorf(nil, "IO error: %v", err)
return -fuse.EIO

View File

@ -85,7 +85,9 @@ func translateError(err error) error {
case vfs.EROFS:
return fuse.Errno(syscall.EROFS)
case vfs.ENOSYS:
return fuse.Errno(syscall.ENOSYS)
return fuse.ENOSYS
case vfs.EPERM:
return fuse.EPERM
}
return err
}

View File

@ -311,7 +311,7 @@ func (d *Dir) Open(flags int) (fd Handle, err error) {
rdwrMode := flags & (os.O_RDONLY | os.O_WRONLY | os.O_RDWR)
if rdwrMode != os.O_RDONLY {
fs.Errorf(d, "Can only open directories read only")
return nil, os.ErrPermission
return nil, EPERM
}
return newDirHandle(d), nil
}

View File

@ -26,6 +26,7 @@ const (
var (
ENOENT = os.ErrNotExist
EEXIST = os.ErrExist
EPERM = os.ErrPermission
)
var errorNames = []string{

View File

@ -298,10 +298,10 @@ func (f *File) Open(flags int) (fd Handle, err error) {
read = false
case rdwrMode == os.O_RDWR:
fs.Errorf(f, "Can't open for Read and Write")
return nil, os.ErrPermission
return nil, EPERM
default:
fs.Errorf(f, "Can't figure out how to open with flags: 0x%X", flags)
return nil, os.ErrPermission
return nil, EPERM
}
if read {
fd, err = f.OpenRead()