This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new f1287a9996 fs_open: add ioctl checkflag
f1287a9996 is described below
commit f1287a9996fa935ae99d19e55482aa5ecc71c2b5
Author: xucheng5 <[email protected]>
AuthorDate: Tue May 16 19:04:44 2023 +0800
fs_open: add ioctl checkflag
fixed open error when driver not implement write
Signed-off-by: xucheng5 <[email protected]>
---
fs/vfs/fs_open.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c
index d5c0e6a362..6051d9ae80 100644
--- a/fs/vfs/fs_open.c
+++ b/fs/vfs/fs_open.c
@@ -297,18 +297,20 @@ static int nx_vopen(FAR struct tcb_s *tcb,
int inode_checkflags(FAR struct inode *inode, int oflags)
{
+ FAR const struct file_operations *ops = inode->u.i_ops;
+
if (INODE_IS_PSEUDODIR(inode))
{
return OK;
}
- if (inode->u.i_ops == NULL)
+ if (ops == NULL)
{
return -ENXIO;
}
- if (((oflags & O_RDOK) != 0 && !inode->u.i_ops->read) ||
- ((oflags & O_WROK) != 0 && !inode->u.i_ops->write))
+ if (((oflags & O_RDOK) != 0 && !ops->read && !ops->ioctl) ||
+ ((oflags & O_WROK) != 0 && !ops->write && !ops->ioctl))
{
return -EACCES;
}