vfs: Make OpenFile and friends return EINVAL if O_RDONLY and O_TRUNC

Before this change Open("name", os.O_RDONLY|os.O_TRUNC) would have
truncated the file.  This is what Linux does, but is counterintuitive.
POSIX states this is undefined, so return an error in this case
instead.  This preserves the invariant O_RDONLY => file is not
changed.
This commit is contained in:
Nick Craig-Wood
2018-02-23 22:39:28 +00:00
parent 3282fd26af
commit 54deb01f00
7 changed files with 107 additions and 88 deletions

View File

@@ -91,6 +91,8 @@ func translateError(err error) error {
return fuse.Errno(syscall.EROFS)
case vfs.ENOSYS:
return fuse.ENOSYS
case vfs.EINVAL:
return fuse.Errno(syscall.EINVAL)
}
return err
}