fs: Change inode_checkflags to static function

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2023-10-22 13:51:53 +08:00 committed by Petro Karashchenko
parent 66db15437d
commit d84aba8a42
2 changed files with 44 additions and 54 deletions

View File

@ -167,16 +167,6 @@ int inode_lock(void);
void inode_unlock(void);
/****************************************************************************
* Name: inode_checkflags
*
* Description:
* Check if the access described by 'oflags' is supported on 'inode'
*
****************************************************************************/
int inode_checkflags(FAR struct inode *inode, int oflags);
/****************************************************************************
* Name: inode_search
*

View File

@ -43,6 +43,50 @@
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: inode_checkflags
*
* Description:
* Check if the access described by 'oflags' is supported on 'inode'
*
* inode_checkflags() is an internal NuttX interface and should not be
* called from applications.
*
* Input Parameters:
* inode - The inode to check
* oflags - open flags.
*
* Returned Value:
* Zero (OK) is returned on success. On failure, a negated errno value is
* returned.
*
****************************************************************************/
static 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 (ops == NULL)
{
return -ENXIO;
}
if (((oflags & O_RDOK) != 0 && !ops->read && !ops->ioctl) ||
((oflags & O_WROK) != 0 && !ops->write && !ops->ioctl))
{
return -EACCES;
}
else
{
return OK;
}
}
/****************************************************************************
* Name: file_vopen
****************************************************************************/
@ -275,50 +319,6 @@ static int nx_vopen(FAR struct tcb_s *tcb,
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: inode_checkflags
*
* Description:
* Check if the access described by 'oflags' is supported on 'inode'
*
* inode_checkflags() is an internal NuttX interface and should not be
* called from applications.
*
* Input Parameters:
* inode - The inode to check
* oflags - open flags.
*
* Returned Value:
* Zero (OK) is returned on success. On failure, a negated errno value is
* returned.
*
****************************************************************************/
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 (ops == NULL)
{
return -ENXIO;
}
if (((oflags & O_RDOK) != 0 && !ops->read && !ops->ioctl) ||
((oflags & O_WROK) != 0 && !ops->write && !ops->ioctl))
{
return -EACCES;
}
else
{
return OK;
}
}
/****************************************************************************
* Name: file_open
*