fs/vfs: Avoid calling stat with oldrelpath twice in mountptrename
and return error directly if stat return failure Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
17ca45e8a3
commit
35d3365577
1 changed files with 15 additions and 8 deletions
|
@ -352,14 +352,6 @@ static int mountptrename(FAR const char *oldpath, FAR struct inode *oldinode,
|
|||
{
|
||||
struct stat buf;
|
||||
|
||||
#ifdef CONFIG_FS_NOTIFY
|
||||
ret = oldinode->u.i_mops->stat(oldinode, oldpath, &buf);
|
||||
if (ret >= 0)
|
||||
{
|
||||
oldisdir = S_ISDIR(buf.st_mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
next_subdir:
|
||||
ret = oldinode->u.i_mops->stat(oldinode, newrelpath, &buf);
|
||||
if (ret >= 0)
|
||||
|
@ -434,6 +426,9 @@ next_subdir:
|
|||
goto errout_with_newinode;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FS_NOTIFY
|
||||
oldisdir = S_ISDIR(buf.st_mode);
|
||||
#endif
|
||||
if (oldinode->u.i_mops->unlink)
|
||||
{
|
||||
/* Attempt to remove the file before doing the rename.
|
||||
|
@ -450,6 +445,18 @@ next_subdir:
|
|||
}
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_FS_NOTIFY
|
||||
else
|
||||
{
|
||||
ret = oldinode->u.i_mops->stat(oldinode, oldrelpath, &buf);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout_with_newinode;
|
||||
}
|
||||
|
||||
oldisdir = S_ISDIR(buf.st_mode);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Perform the rename operation using the relative paths at the common
|
||||
|
|
Loading…
Reference in a new issue