1.2.3.1
The use of EACCES leads to slightly confusing error messages in downstream consumers, so prefer EROFS to better articulate what's actually happening. While here, use O_RDWR to mask the open flags while testing for non-RO access. This is at least encouraged by POSIX with their suggestion that "O_RDONLY | O_WRONLY == O_RDWR".