From f1287a9996fa935ae99d19e55482aa5ecc71c2b5 Mon Sep 17 00:00:00 2001 From: xucheng5 Date: Tue, 16 May 2023 19:04:44 +0800 Subject: [PATCH] fs_open: add ioctl checkflag fixed open error when driver not implement write Signed-off-by: xucheng5 --- 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; }