include/fcntl.h: remove O_RDOK/O_WROK aliases

O_RDOK and O_WROK are non-standard aliases for O_RDONLY and O_WRONLY
respectively.  Having two names for the same flag creates confusion,
especially when aligning the flag values with Linux.  Remove the
aliases and replace all uses with the standard O_RDONLY/O_WRONLY.

No functional change — O_RDOK was defined as O_RDONLY and O_WROK as
O_WRONLY, so the replacement is a pure text substitution.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2026-06-24 13:49:16 +08:00 committed by Alan C. Assis
parent 1924a96064
commit 6161c73639
39 changed files with 73 additions and 75 deletions

View file

@ -102,7 +102,7 @@ int fclose(FAR FILE *stream)
/* If the stream was opened for writing, then flush the stream */
if ((stream->fs_oflags & O_WROK) != 0)
if ((stream->fs_oflags & O_WRONLY) != 0)
{
ret = lib_fflush(stream);
errcode = get_errno();

View file

@ -245,7 +245,7 @@ FAR FILE *fmemopen(FAR void *buf, size_t size, FAR const char *mode)
* by the size argument.
*/
if ((oflags & O_RDWR) == O_RDOK)
if ((oflags & O_RDWR) == O_RDONLY)
{
fmemopen_cookie->end = size;
}

View file

@ -229,7 +229,7 @@ int lib_mode2oflags(FAR const char *mode)
{
/* Open for read access */
oflags = O_RDOK | O_TEXT;
oflags = O_RDONLY | O_TEXT;
state = MODE_R;
}
else
@ -245,7 +245,7 @@ int lib_mode2oflags(FAR const char *mode)
{
/* Open for write access, truncating any existing file */
oflags = O_WROK | O_CREAT | O_TRUNC | O_TEXT;
oflags = O_WRONLY | O_CREAT | O_TRUNC | O_TEXT;
state = MODE_W;
}
else
@ -261,7 +261,7 @@ int lib_mode2oflags(FAR const char *mode)
{
/* Write to the end of the file */
oflags = O_WROK | O_CREAT | O_APPEND | O_TEXT;
oflags = O_WRONLY | O_CREAT | O_APPEND | O_TEXT;
state = MODE_A;
}
else

View file

@ -66,7 +66,7 @@ ssize_t lib_fflush_unlocked(FAR FILE *stream)
/* Return EBADF if the file is not opened for writing */
if ((stream->fs_oflags & O_WROK) == 0)
if ((stream->fs_oflags & O_WRONLY) == 0)
{
return -EBADF;
}

View file

@ -76,7 +76,7 @@ int lib_flushall_unlocked(FAR struct streamlist *list)
* the pending write data in the stream.
*/
if ((stream->fs_oflags & O_WROK) != 0)
if ((stream->fs_oflags & O_WRONLY) != 0)
{
/* Flush the writable FILE */
@ -129,7 +129,7 @@ int lib_flushall(FAR struct streamlist *list)
* the pending write data in the stream.
*/
if ((stream->fs_oflags & O_WROK) != 0)
if ((stream->fs_oflags & O_WRONLY) != 0)
{
/* Flush the writable FILE */

View file

@ -64,7 +64,7 @@ ssize_t lib_fread_unlocked(FAR void *ptr, size_t count, FAR FILE *stream)
_NX_SETERRNO(EBADF);
return ERROR;
}
else if ((stream->fs_oflags & O_RDOK) == 0)
else if ((stream->fs_oflags & O_RDONLY) == 0)
{
stream->fs_flags |= __FS_FLAG_ERROR;
_NX_SETERRNO(EBADF);

View file

@ -64,7 +64,7 @@ ssize_t lib_fwrite_unlocked(FAR const void *ptr, size_t count,
/* Check if write access is permitted */
if ((stream->fs_oflags & O_WROK) == 0)
if ((stream->fs_oflags & O_WRONLY) == 0)
{
set_errno(EBADF);
goto errout;

View file

@ -54,7 +54,7 @@ int ungetc(int c, FAR FILE *stream)
/* Stream must be open for read access */
if ((stream->fs_oflags & O_RDOK) == 0)
if ((stream->fs_oflags & O_RDONLY) == 0)
{
return EOF;
}

View file

@ -64,7 +64,7 @@ wint_t ungetwc_unlocked(wint_t wc, FAR FILE *f)
/* Stream must be open for read access */
if ((f->fs_oflags & O_RDOK) == 0)
if ((f->fs_oflags & O_RDONLY) == 0)
{
return WEOF;
}

View file

@ -70,7 +70,7 @@ int lib_wrflush_unlocked(FAR FILE *stream)
* that case.
*/
if ((stream->fs_oflags & O_WROK) == 0)
if ((stream->fs_oflags & O_WRONLY) == 0)
{
/* Report that the success was successful if we attempt to flush a
* read-only stream.