fs/fs_dup2: correct check before dup
Change-Id: I2387ab447f0d8ed9429960922a72de35b2730acb Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
f57ba35151
commit
554310bd78
|
@ -88,23 +88,30 @@ int file_dup2(FAR struct file *filep1, FAR struct file *filep2)
|
|||
* can maintain the correct open counts.
|
||||
*/
|
||||
|
||||
if (inode->u.i_ops && inode->u.i_ops->open)
|
||||
if (inode->u.i_ops)
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
if (INODE_IS_MOUNTPT(inode))
|
||||
{
|
||||
/* Dup the open file on the in the new file structure */
|
||||
|
||||
if (inode->u.i_mops->dup)
|
||||
{
|
||||
ret = inode->u.i_mops->dup(filep1, &temp);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* (Re-)open the pseudo file or device driver */
|
||||
|
||||
temp.f_priv = filep1->f_priv;
|
||||
|
||||
if (inode->u.i_ops->open)
|
||||
{
|
||||
ret = inode->u.i_ops->open(&temp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle open failures */
|
||||
|
||||
|
|
Loading…
Reference in New Issue