mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
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:
parent
1924a96064
commit
6161c73639
39 changed files with 73 additions and 75 deletions
|
|
@ -802,7 +802,7 @@ static ssize_t fat_read(FAR struct file *filep, FAR char *buffer,
|
|||
|
||||
/* Check if the file was opened with read access */
|
||||
|
||||
if ((ff->ff_oflags & O_RDOK) == 0)
|
||||
if ((ff->ff_oflags & O_RDONLY) == 0)
|
||||
{
|
||||
ret = -EACCES;
|
||||
goto errout_with_lock;
|
||||
|
|
@ -1020,7 +1020,7 @@ static ssize_t fat_write(FAR struct file *filep, FAR const char *buffer,
|
|||
|
||||
/* Check if the file was opened for write access */
|
||||
|
||||
if ((ff->ff_oflags & O_WROK) == 0)
|
||||
if ((ff->ff_oflags & O_WRONLY) == 0)
|
||||
{
|
||||
ret = -EACCES;
|
||||
goto errout_with_lock;
|
||||
|
|
@ -2289,7 +2289,7 @@ static int fat_truncate(FAR struct file *filep, off_t length)
|
|||
|
||||
/* Check if the file was opened for write access */
|
||||
|
||||
if ((ff->ff_oflags & O_WROK) == 0)
|
||||
if ((ff->ff_oflags & O_WRONLY) == 0)
|
||||
{
|
||||
ret = -EACCES;
|
||||
goto errout_with_lock;
|
||||
|
|
|
|||
|
|
@ -516,7 +516,7 @@ static ssize_t hostfs_write(FAR struct file *filep, const char *buffer,
|
|||
* write flags.
|
||||
*/
|
||||
|
||||
if ((hf->oflags & O_WROK) == 0)
|
||||
if ((hf->oflags & O_WRONLY) == 0)
|
||||
{
|
||||
ret = -EACCES;
|
||||
goto errout_with_lock;
|
||||
|
|
|
|||
|
|
@ -113,12 +113,12 @@ int fs_open_amode(int oflags)
|
|||
{
|
||||
int amode = 0;
|
||||
|
||||
if ((oflags & O_RDOK) != 0)
|
||||
if ((oflags & O_RDONLY) != 0)
|
||||
{
|
||||
amode |= R_OK;
|
||||
}
|
||||
|
||||
if ((oflags & O_WROK) != 0)
|
||||
if ((oflags & O_WRONLY) != 0)
|
||||
{
|
||||
amode |= W_OK;
|
||||
}
|
||||
|
|
@ -285,9 +285,9 @@ int inode_checkopenperm(FAR struct inode *inode, int oflags)
|
|||
return -ENXIO;
|
||||
}
|
||||
|
||||
if (((oflags & O_RDOK) != 0 &&
|
||||
if (((oflags & O_RDONLY) != 0 &&
|
||||
!ops->readv && !ops->read && !ops->ioctl) ||
|
||||
((oflags & O_WROK) != 0 &&
|
||||
((oflags & O_WRONLY) != 0 &&
|
||||
!ops->writev && !ops->write && !ops->ioctl))
|
||||
{
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -138,14 +138,14 @@ static int file_mmap_(FAR struct file *filep, FAR void *start,
|
|||
}
|
||||
|
||||
if ((flags & MAP_SHARED) &&
|
||||
(filep->f_oflags & O_WROK) == 0 && prot == PROT_WRITE)
|
||||
(filep->f_oflags & O_WRONLY) == 0 && prot == PROT_WRITE)
|
||||
{
|
||||
ferr("ERROR: Unsupported options for read-only file descriptor,"
|
||||
"prot=%x flags=%04x\n", prot, flags);
|
||||
return -EACCES;
|
||||
}
|
||||
|
||||
if ((filep->f_oflags & O_RDOK) == 0)
|
||||
if ((filep->f_oflags & O_RDONLY) == 0)
|
||||
{
|
||||
ferr("ERROR: File descriptor does not have read permission\n");
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -706,7 +706,7 @@ static inline int nxffs_rdopen(FAR struct nxffs_volume_s *volume,
|
|||
* Limitation: Files cannot be open both for reading and writing.
|
||||
*/
|
||||
|
||||
if ((ofile->oflags & O_WROK) != 0)
|
||||
if ((ofile->oflags & O_WRONLY) != 0)
|
||||
{
|
||||
ferr("ERROR: File is open for writing\n");
|
||||
ret = -ENOSYS;
|
||||
|
|
@ -740,7 +740,7 @@ static inline int nxffs_rdopen(FAR struct nxffs_volume_s *volume,
|
|||
/* Initialize the open file state structure */
|
||||
|
||||
ofile->crefs = 1;
|
||||
ofile->oflags = O_RDOK;
|
||||
ofile->oflags = O_RDONLY;
|
||||
|
||||
/* Find the file on this volume associated with this file name */
|
||||
|
||||
|
|
@ -1013,22 +1013,22 @@ int nxffs_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* extension is supported.
|
||||
*/
|
||||
|
||||
switch (oflags & (O_WROK | O_RDOK))
|
||||
switch (oflags & (O_WRONLY | O_RDONLY))
|
||||
{
|
||||
case 0:
|
||||
default:
|
||||
ferr("ERROR: One of O_WRONLY/O_RDONLY must be provided\n");
|
||||
return -EINVAL;
|
||||
|
||||
case O_WROK:
|
||||
case O_WRONLY:
|
||||
ret = nxffs_wropen(volume, relpath, oflags, &ofile);
|
||||
break;
|
||||
|
||||
case O_RDOK:
|
||||
case O_RDONLY:
|
||||
ret = nxffs_rdopen(volume, relpath, &ofile);
|
||||
break;
|
||||
|
||||
case O_WROK | O_RDOK:
|
||||
case O_WRONLY | O_RDONLY:
|
||||
ferr("ERROR: O_RDWR is not supported\n");
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
|
@ -1156,7 +1156,7 @@ int nxffs_close(FAR struct file *filep)
|
|||
|
||||
/* Handle special finalization of the write operation. */
|
||||
|
||||
if ((ofile->oflags & O_WROK) != 0)
|
||||
if ((ofile->oflags & O_WRONLY) != 0)
|
||||
{
|
||||
ret = nxffs_wrclose(volume, (FAR struct nxffs_wrfile_s *)ofile);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ ssize_t nxffs_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
|
|||
|
||||
/* Check if the file was opened with read access */
|
||||
|
||||
if ((ofile->oflags & O_RDOK) == 0)
|
||||
if ((ofile->oflags & O_RDONLY) == 0)
|
||||
{
|
||||
ferr("ERROR: File not open for read access\n");
|
||||
ret = -EACCES;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ int nxffs_truncate(FAR struct file *filep, off_t length)
|
|||
|
||||
/* Check if the file was opened with write access */
|
||||
|
||||
if ((wrfile->ofile.oflags & O_WROK) == 0)
|
||||
if ((wrfile->ofile.oflags & O_WRONLY) == 0)
|
||||
{
|
||||
ferr("ERROR: File not open for write access\n");
|
||||
ret = -EACCES;
|
||||
|
|
|
|||
|
|
@ -545,7 +545,7 @@ ssize_t nxffs_write(FAR struct file *filep, FAR const char *buffer,
|
|||
|
||||
/* Check if the file was opened with write access */
|
||||
|
||||
if ((wrfile->ofile.oflags & O_WROK) == 0)
|
||||
if ((wrfile->ofile.oflags & O_WRONLY) == 0)
|
||||
{
|
||||
ferr("ERROR: File not open for write access\n");
|
||||
ret = -EACCES;
|
||||
|
|
|
|||
|
|
@ -553,7 +553,7 @@ static ssize_t rpmsgfs_write(FAR struct file *filep, const char *buffer,
|
|||
* write flags.
|
||||
*/
|
||||
|
||||
if ((hf->oflags & O_WROK) == 0)
|
||||
if ((hf->oflags & O_WRONLY) == 0)
|
||||
{
|
||||
ret = -EACCES;
|
||||
goto errout_with_lock;
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ static int smartfs_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* is writeable. O_TRUNC without write access is ignored.
|
||||
*/
|
||||
|
||||
if ((oflags & (O_TRUNC | O_WROK)) == (O_TRUNC | O_WROK))
|
||||
if ((oflags & (O_TRUNC | O_WRONLY)) == (O_TRUNC | O_WRONLY))
|
||||
{
|
||||
/* Truncate the file as part of the open */
|
||||
|
||||
|
|
@ -693,7 +693,7 @@ static ssize_t smartfs_write(FAR struct file *filep, FAR const char *buffer,
|
|||
* write flags.
|
||||
*/
|
||||
|
||||
if ((sf->oflags & O_WROK) == 0)
|
||||
if ((sf->oflags & O_WRONLY) == 0)
|
||||
{
|
||||
ret = -EACCES;
|
||||
goto errout_with_lock;
|
||||
|
|
@ -1223,7 +1223,7 @@ static int smartfs_truncate(FAR struct file *filep, off_t length)
|
|||
* write flags.
|
||||
*/
|
||||
|
||||
if ((sf->oflags & O_WROK) == 0)
|
||||
if ((sf->oflags & O_WRONLY) == 0)
|
||||
{
|
||||
ret = -EACCES;
|
||||
goto errout_with_lock;
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@ static int spiffs_open(FAR struct file *filep, FAR const char *relpath,
|
|||
*/
|
||||
|
||||
offset = 0;
|
||||
if ((oflags & (O_APPEND | O_WROK)) == (O_APPEND | O_WROK))
|
||||
if ((oflags & (O_APPEND | O_WRONLY)) == (O_APPEND | O_WRONLY))
|
||||
{
|
||||
offset = fobj->size == SPIFFS_UNDEFINED_LEN ? 0 : fobj->size;
|
||||
}
|
||||
|
|
@ -629,7 +629,7 @@ static ssize_t spiffs_write(FAR struct file *filep, FAR const char *buffer,
|
|||
|
||||
/* Verify that the file was opened with write access */
|
||||
|
||||
if ((fobj->oflags & O_WROK) == 0)
|
||||
if ((fobj->oflags & O_WRONLY) == 0)
|
||||
{
|
||||
ret = -EACCES;
|
||||
goto errout_with_lock;
|
||||
|
|
|
|||
|
|
@ -1255,7 +1255,7 @@ int inotify_init1(int flags)
|
|||
goto exit_set_errno;
|
||||
}
|
||||
|
||||
ret = file_allocate_from_inode(&g_inotify_inode, O_RDOK | flags,
|
||||
ret = file_allocate_from_inode(&g_inotify_inode, O_RDONLY | flags,
|
||||
0, dev, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
|
@ -1349,7 +1349,7 @@ void notify_open(FAR const char *path, int oflags)
|
|||
|
||||
void notify_close(FAR const char *path, int oflags)
|
||||
{
|
||||
if (oflags & O_WROK)
|
||||
if (oflags & O_WRONLY)
|
||||
{
|
||||
notify_queue_path_event(path, IN_CLOSE_WRITE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ static int file_vopen(FAR struct file *filep, FAR const char *path,
|
|||
|
||||
#ifdef CONFIG_BCH_DEVICE_READONLY
|
||||
oflags &= ~O_RDWR;
|
||||
oflags |= O_RDOK;
|
||||
oflags |= O_RDONLY;
|
||||
#endif
|
||||
|
||||
ret = block_proxy(filep, path, oflags);
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ ssize_t file_readv(FAR struct file *filep,
|
|||
|
||||
/* Was this file opened for read access? */
|
||||
|
||||
if ((filep->f_oflags & O_RDOK) == 0)
|
||||
if ((filep->f_oflags & O_RDONLY) == 0)
|
||||
{
|
||||
/* No.. File is not read-able */
|
||||
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ int signalfd(int fd, FAR const sigset_t *mask, int flags)
|
|||
|
||||
nxmutex_init(&dev->mutex);
|
||||
|
||||
fd = file_allocate_from_inode(&g_signalfd_inode, O_RDOK | flags,
|
||||
fd = file_allocate_from_inode(&g_signalfd_inode, O_RDONLY | flags,
|
||||
0, dev, 0);
|
||||
if (fd < 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ int file_truncate(FAR struct file *filep, off_t length)
|
|||
|
||||
/* Was this file opened for write access? */
|
||||
|
||||
if ((filep->f_oflags & O_WROK) == 0)
|
||||
if ((filep->f_oflags & O_WRONLY) == 0)
|
||||
{
|
||||
fwarn("WARNING: Cannot truncate a file opened read-only\n");
|
||||
return -EINVAL;
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ ssize_t file_writev(FAR struct file *filep,
|
|||
|
||||
/* Was this file opened for write access? */
|
||||
|
||||
if ((filep->f_oflags & O_WROK) == 0)
|
||||
if ((filep->f_oflags & O_WRONLY) == 0)
|
||||
{
|
||||
return -EACCES;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue