fs_open: add ioctl checkflag

fixed open error when driver not implement write

Signed-off-by: xucheng5 <xucheng5@xiaomi.com>
This commit is contained in:
xucheng5 2023-05-16 19:04:44 +08:00 committed by Xiang Xiao
parent a59673b526
commit f1287a9996

View File

@ -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;
}