One option, conforming standard, would be that you just always give O_RDWR
(same flags as what linux devices have), but then when calling read/write you
check if the pointer is non-null. If the driver doesn't define read or write,
those operations are allowed on the device, but act as no-op.
If you can't think of anything useful to do with read() or write(),
thenthis has been historically handled is by including a dummy read
method in the driver that just returns zero (EOF). For example, the
loop driver:
/****************************************************************************
* Name: loop_read
****************************************************************************/
static ssize_t loop_read(FAR struct file *filep, FAR char *buffer,
size_t len)
{
return 0; /* Return EOF */
}
*
*