> By doing so we can relax check in inode_checkflags() to:
>
> int inode_checkflags(FAR struct inode *inode, int oflags)
> {
> if ((oflags == 0) ||
> (oflags & O_WROK) != 0 && !inode->u.i_ops->write)
> {
> return -EACCES;
> }
> else
> {
> return OK;
> }
> }
>
> No, this would be an error. This would break any file, filesystem, or
driver that really needs to support write-only behavior. In that case,
there is a write method and no read method.
This would be a major loss of functionality. These IOCTL-only drivers are
degenerate cases and perhaps for them you can cut corners. Bu, we need to
support all existing behavior for all VFS entities.
To permit opening with O_RDWR, some IOCTL drivers have dummy write methods
too. The loop driver again has:
/****************************************************************************
* Name: loop_write
****************************************************************************/
static ssize_t loop_write(FAR struct file *filep, FAR const char *buffer,
size_t len)
{
return len; /* Say that everything was written */
}