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 return -fuse.EROFS
case vfs.ENOSYS: case vfs.ENOSYS:
return -fuse.ENOSYS return -fuse.ENOSYS
case vfs.EPERM:
return -fuse.EPERM
} }
fs.Errorf(nil, "IO error: %v", err) fs.Errorf(nil, "IO error: %v", err)
return -fuse.EIO return -fuse.EIO

View File

@ -85,7 +85,9 @@ func translateError(err error) error {
case vfs.EROFS: case vfs.EROFS:
return fuse.Errno(syscall.EROFS) return fuse.Errno(syscall.EROFS)
case vfs.ENOSYS: case vfs.ENOSYS:
return fuse.Errno(syscall.ENOSYS) return fuse.ENOSYS
case vfs.EPERM:
return fuse.EPERM
} }
return err 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) rdwrMode := flags & (os.O_RDONLY | os.O_WRONLY | os.O_RDWR)
if rdwrMode != os.O_RDONLY { if rdwrMode != os.O_RDONLY {
fs.Errorf(d, "Can only open directories read only") fs.Errorf(d, "Can only open directories read only")
return nil, os.ErrPermission return nil, EPERM
} }
return newDirHandle(d), nil return newDirHandle(d), nil
} }

View File

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

View File

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