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:
parent
a59673b526
commit
f1287a9996
1 changed files with 5 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue