mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
!include/fcntl.h: align open flags with Linux values
Align the NuttX open(2) flag constants with the Linux asm-generic values so that the FUSE wire protocol and other cross-platform interfaces work without conversion. All code that used '(flags & O_RDONLY)' as a bitmask check (always 0 now that O_RDONLY=0) has been updated to use '(flags & O_ACCMODE)' comparisons. The NUTTX_O_* constants in include/nuttx/fs/hostfs.h are updated to match, and the sim hostfs open flag mapping is fixed. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
9c381340c0
commit
9e141acab3
75 changed files with 239 additions and 213 deletions
|
|
@ -280,7 +280,7 @@ int aio_write(FAR struct aiocb *aiocbp)
|
|||
*/
|
||||
|
||||
flags = fcntl(aiocbp->aio_fildes, F_GETFL);
|
||||
if ((flags & O_WRONLY) == 0)
|
||||
if ((flags & O_ACCMODE) == O_RDONLY)
|
||||
{
|
||||
aiocbp->aio_result = -EBADF;
|
||||
return OK;
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ static int binfs_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* access is not permitted.
|
||||
*/
|
||||
|
||||
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -761,7 +761,7 @@ static int cromfs_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* access is not permitted.
|
||||
*/
|
||||
|
||||
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ static int fat_open(FAR struct file *filep, FAR const char *relpath,
|
|||
/* Check if the caller has sufficient privileges to open the file */
|
||||
|
||||
readonly = ((DIR_GETATTRIBUTES(direntry) & FATATTR_READONLY) != 0);
|
||||
if (((oflags & O_WRONLY) != 0) && readonly)
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY && readonly)
|
||||
{
|
||||
ret = -EACCES;
|
||||
goto errout_with_lock;
|
||||
|
|
@ -379,7 +379,7 @@ static int fat_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* the file.
|
||||
*/
|
||||
|
||||
if ((oflags & (O_APPEND | O_WRONLY)) == (O_APPEND | O_WRONLY))
|
||||
if ((oflags & O_APPEND) && (oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
off_t offset = fat_seek(filep, ff->ff_size, SEEK_SET);
|
||||
if (offset < 0)
|
||||
|
|
@ -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_RDONLY) == 0)
|
||||
if ((ff->ff_oflags & O_ACCMODE) == O_WRONLY)
|
||||
{
|
||||
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_WRONLY) == 0)
|
||||
if ((ff->ff_oflags & O_ACCMODE) == O_RDONLY)
|
||||
{
|
||||
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_WRONLY) == 0)
|
||||
if ((ff->ff_oflags & O_ACCMODE) == O_RDONLY)
|
||||
{
|
||||
ret = -EACCES;
|
||||
goto errout_with_lock;
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ static int hostfs_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* file.
|
||||
*/
|
||||
|
||||
if ((oflags & (O_APPEND | O_WRONLY)) == (O_APPEND | O_WRONLY))
|
||||
if ((oflags & O_APPEND) && (oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
ret = host_lseek(hf->fd, 0, 0, SEEK_END);
|
||||
if (ret >= 0)
|
||||
|
|
@ -516,7 +516,7 @@ static ssize_t hostfs_write(FAR struct file *filep, const char *buffer,
|
|||
* write flags.
|
||||
*/
|
||||
|
||||
if ((hf->oflags & O_WRONLY) == 0)
|
||||
if ((hf->oflags & O_ACCMODE) == O_RDONLY)
|
||||
{
|
||||
ret = -EACCES;
|
||||
goto errout_with_lock;
|
||||
|
|
|
|||
|
|
@ -111,19 +111,20 @@ int fs_checkmode(uid_t owner, gid_t group, mode_t mode, int amode)
|
|||
|
||||
int fs_open_amode(int oflags)
|
||||
{
|
||||
int amode = 0;
|
||||
|
||||
if ((oflags & O_RDONLY) != 0)
|
||||
switch (oflags & O_ACCMODE)
|
||||
{
|
||||
amode |= R_OK;
|
||||
}
|
||||
case O_RDONLY:
|
||||
return R_OK;
|
||||
|
||||
if ((oflags & O_WRONLY) != 0)
|
||||
{
|
||||
amode |= W_OK;
|
||||
}
|
||||
case O_WRONLY:
|
||||
return W_OK;
|
||||
|
||||
return amode;
|
||||
case O_RDWR:
|
||||
return R_OK | W_OK;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
@ -285,9 +286,9 @@ int inode_checkopenperm(FAR struct inode *inode, int oflags)
|
|||
return -ENXIO;
|
||||
}
|
||||
|
||||
if (((oflags & O_RDONLY) != 0 &&
|
||||
if (((oflags & O_ACCMODE) != O_WRONLY &&
|
||||
!ops->readv && !ops->read && !ops->ioctl) ||
|
||||
((oflags & O_WRONLY) != 0 &&
|
||||
((oflags & O_ACCMODE) != O_RDONLY &&
|
||||
!ops->writev && !ops->write && !ops->ioctl))
|
||||
{
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -287,14 +287,19 @@ static int littlefs_convert_oflags(int oflags)
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
if ((oflags & O_RDONLY) != 0)
|
||||
switch (oflags & O_ACCMODE)
|
||||
{
|
||||
ret |= LFS_O_RDONLY;
|
||||
}
|
||||
case O_RDONLY:
|
||||
ret |= LFS_O_RDONLY;
|
||||
break;
|
||||
|
||||
if ((oflags & O_WRONLY) != 0)
|
||||
{
|
||||
ret |= LFS_O_WRONLY;
|
||||
case O_WRONLY:
|
||||
ret |= LFS_O_WRONLY;
|
||||
break;
|
||||
|
||||
case O_RDWR:
|
||||
ret |= LFS_O_RDWR;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((oflags & O_CREAT) != 0)
|
||||
|
|
|
|||
|
|
@ -137,15 +137,15 @@ static int file_mmap_(FAR struct file *filep, FAR void *start,
|
|||
return -EBADF;
|
||||
}
|
||||
|
||||
if ((flags & MAP_SHARED) &&
|
||||
(filep->f_oflags & O_WRONLY) == 0 && (prot & PROT_WRITE))
|
||||
if ((flags & MAP_SHARED) && (prot & PROT_WRITE) &&
|
||||
(filep->f_oflags & O_ACCMODE) == O_RDONLY)
|
||||
{
|
||||
ferr("ERROR: Unsupported options for read-only file descriptor,"
|
||||
"prot=%x flags=%04x\n", prot, flags);
|
||||
return -EACCES;
|
||||
}
|
||||
|
||||
if ((filep->f_oflags & O_RDONLY) == 0)
|
||||
if ((filep->f_oflags & O_ACCMODE) == O_WRONLY)
|
||||
{
|
||||
ferr("ERROR: File descriptor does not have read permission\n");
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ static int mount_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* REVISIT: Write-able proc files could be quite useful.
|
||||
*/
|
||||
|
||||
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -581,7 +581,7 @@ static int nfs_fileopen(FAR struct nfsmount *nmp, FAR struct nfsnode *np,
|
|||
|
||||
/* Check if the caller has sufficient privileges to open the file */
|
||||
|
||||
if ((oflags & O_WRONLY) != 0)
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
/* Check if anyone has privileges to write to the file -- owner,
|
||||
* group, or other (we are probably "other" and may still not be
|
||||
|
|
@ -737,7 +737,7 @@ static int nfs_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* the file.
|
||||
*/
|
||||
|
||||
if ((oflags & (O_APPEND | O_WRONLY)) == (O_APPEND | O_WRONLY))
|
||||
if ((oflags & O_APPEND) && (oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
filep->f_pos = (off_t)np->n_size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_WRONLY) != 0)
|
||||
if ((ofile->oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
ferr("ERROR: File is open for writing\n");
|
||||
ret = -ENOSYS;
|
||||
|
|
@ -1013,9 +1013,8 @@ int nxffs_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* extension is supported.
|
||||
*/
|
||||
|
||||
switch (oflags & (O_WRONLY | O_RDONLY))
|
||||
switch (oflags & O_ACCMODE)
|
||||
{
|
||||
case 0:
|
||||
default:
|
||||
ferr("ERROR: One of O_WRONLY/O_RDONLY must be provided\n");
|
||||
return -EINVAL;
|
||||
|
|
@ -1028,7 +1027,7 @@ int nxffs_open(FAR struct file *filep, FAR const char *relpath,
|
|||
ret = nxffs_rdopen(volume, relpath, &ofile);
|
||||
break;
|
||||
|
||||
case O_WRONLY | O_RDONLY:
|
||||
case O_RDWR:
|
||||
ferr("ERROR: O_RDWR is not supported\n");
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
|
@ -1156,7 +1155,7 @@ int nxffs_close(FAR struct file *filep)
|
|||
|
||||
/* Handle special finalization of the write operation. */
|
||||
|
||||
if ((ofile->oflags & O_WRONLY) != 0)
|
||||
if ((ofile->oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
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_RDONLY) == 0)
|
||||
if ((ofile->oflags & O_ACCMODE) == O_WRONLY)
|
||||
{
|
||||
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_WRONLY) == 0)
|
||||
if ((wrfile->ofile.oflags & O_ACCMODE) == O_RDONLY)
|
||||
{
|
||||
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_WRONLY) == 0)
|
||||
if ((wrfile->ofile.oflags & O_ACCMODE) == O_RDONLY)
|
||||
{
|
||||
ferr("ERROR: File not open for write access\n");
|
||||
ret = -EACCES;
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ static int cpuload_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* REVISIT: Write-able proc files could be quite useful.
|
||||
*/
|
||||
|
||||
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ static int critmon_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* REVISIT: Write-able proc files could be quite useful.
|
||||
*/
|
||||
|
||||
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ static int fdt_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* REVISIT: Write-able proc files could be quite useful.
|
||||
*/
|
||||
|
||||
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ static int iobinfo_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* REVISIT: Write-able proc files could be quite useful.
|
||||
*/
|
||||
|
||||
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ static int tcbinfo_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* REVISIT: Write-able proc files could be quite useful.
|
||||
*/
|
||||
|
||||
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ static int uptime_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* REVISIT: Write-able proc files could be quite useful.
|
||||
*/
|
||||
|
||||
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ static int version_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* REVISIT: Write-able proc files could be quite useful.
|
||||
*/
|
||||
|
||||
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -168,8 +168,8 @@ static int skel_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* can not be permitted.
|
||||
*/
|
||||
|
||||
if (((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0) &&
|
||||
(skel_procfsoperations.write == NULL))
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY &&
|
||||
skel_procfsoperations.write == NULL)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ static int romfs_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* access is not permitted.
|
||||
*/
|
||||
|
||||
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
ret = -EACCES;
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ static int rpmsgfs_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* file.
|
||||
*/
|
||||
|
||||
if ((oflags & (O_APPEND | O_WRONLY)) == (O_APPEND | O_WRONLY))
|
||||
if ((oflags & O_APPEND) && (oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
ret = rpmsgfs_client_lseek(fs->handle, hf->fd, 0, SEEK_END);
|
||||
if (ret >= 0)
|
||||
|
|
@ -553,7 +553,7 @@ static ssize_t rpmsgfs_write(FAR struct file *filep, const char *buffer,
|
|||
* write flags.
|
||||
*/
|
||||
|
||||
if ((hf->oflags & O_WRONLY) == 0)
|
||||
if ((hf->oflags & O_ACCMODE) == O_RDONLY)
|
||||
{
|
||||
ret = -EACCES;
|
||||
goto errout_with_lock;
|
||||
|
|
|
|||
|
|
@ -113,8 +113,8 @@ static int file_shm_open(FAR struct file *shm, FAR const char *name,
|
|||
}
|
||||
|
||||
#ifdef CONFIG_PSEUDOFS_ATTRIBUTES
|
||||
if (((oflags & O_WRONLY) && !(inode->i_mode & S_IWUSR)) ||
|
||||
((oflags & O_RDONLY) && !(inode->i_mode & S_IRUSR))
|
||||
if (((oflags & O_ACCMODE) != O_RDONLY && !(inode->i_mode & S_IWUSR)) ||
|
||||
((oflags & O_ACCMODE) != O_WRONLY && !(inode->i_mode & S_IRUSR)))
|
||||
{
|
||||
ret = -EACCES;
|
||||
inode_release(inode);
|
||||
|
|
|
|||
|
|
@ -351,8 +351,8 @@ static int smartfs_open(FAR struct file *filep, FAR const char *relpath,
|
|||
* REVISIT: Write-able proc files could be quite useful.
|
||||
*/
|
||||
|
||||
if (((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0) &&
|
||||
(g_smartfs_procfs_operations.write == NULL))
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY &&
|
||||
g_smartfs_procfs_operations.write == NULL)
|
||||
{
|
||||
ferr("ERROR: Only O_RDONLY supported\n");
|
||||
return -EACCES;
|
||||
|
|
|
|||
|
|
@ -693,7 +693,7 @@ static ssize_t smartfs_write(FAR struct file *filep, FAR const char *buffer,
|
|||
* write flags.
|
||||
*/
|
||||
|
||||
if ((sf->oflags & O_WRONLY) == 0)
|
||||
if ((sf->oflags & O_ACCMODE) == O_RDONLY)
|
||||
{
|
||||
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_WRONLY) == 0)
|
||||
if ((sf->oflags & O_ACCMODE) == O_RDONLY)
|
||||
{
|
||||
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_WRONLY)) == (O_APPEND | O_WRONLY))
|
||||
if ((oflags & O_APPEND) && (oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
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_WRONLY) == 0)
|
||||
if ((fobj->oflags & O_ACCMODE) == O_RDONLY)
|
||||
{
|
||||
ret = -EACCES;
|
||||
goto errout_with_lock;
|
||||
|
|
|
|||
|
|
@ -371,7 +371,7 @@ ssize_t spiffs_fobj_read(FAR struct spiffs_s *fs,
|
|||
|
||||
/* Make sure that read access is supported */
|
||||
|
||||
if ((fobj->oflags & O_RDONLY) == 0)
|
||||
if ((fobj->oflags & O_ACCMODE) == O_WRONLY)
|
||||
{
|
||||
return -EACCES;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1679,7 +1679,7 @@ static int tmpfs_open(FAR struct file *filep, FAR const char *relpath,
|
|||
*/
|
||||
|
||||
offset = 0;
|
||||
if ((oflags & (O_APPEND | O_WRONLY)) == (O_APPEND | O_WRONLY))
|
||||
if ((oflags & O_APPEND) && (oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
offset = tfo->tfo_size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_WRONLY)
|
||||
if ((oflags & O_ACCMODE) != O_RDONLY)
|
||||
{
|
||||
notify_queue_path_event(path, IN_CLOSE_WRITE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ static int file_vopen(FAR struct file *filep, FAR const char *path,
|
|||
FS_PROFILE_STOP(start_time, g_fs_profile.total_open_time,
|
||||
g_fs_profile.opens);
|
||||
|
||||
if (ret == -EISDIR && ((oflags & O_WRONLY) == 0))
|
||||
if (ret == -EISDIR && (oflags & O_ACCMODE) == O_RDONLY)
|
||||
{
|
||||
ret = dir_allocate(filep, desc.relpath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ ssize_t file_readv(FAR struct file *filep,
|
|||
|
||||
/* Was this file opened for read access? */
|
||||
|
||||
if ((filep->f_oflags & O_RDONLY) == 0)
|
||||
if ((filep->f_oflags & O_ACCMODE) == O_WRONLY)
|
||||
{
|
||||
/* No.. File is not read-able */
|
||||
|
||||
|
|
|
|||
|
|
@ -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_WRONLY) == 0)
|
||||
if ((filep->f_oflags & O_ACCMODE) == O_RDONLY)
|
||||
{
|
||||
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_WRONLY) == 0)
|
||||
if ((filep->f_oflags & O_ACCMODE) == O_RDONLY)
|
||||
{
|
||||
return -EACCES;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue