mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
fs/vfs/symlink: fix the inode information update outside of lock
For re-enter case, the inode information may unlock with not filled, and get by other user. that lead to the error behavior. Especially SMP scene. Signed-off-by: buxiasen <buxiasen@xiaomi.com>
This commit is contained in:
+9
-5
@@ -146,6 +146,15 @@ int symlink(FAR const char *path1, FAR const char *path2)
|
|||||||
|
|
||||||
inode_lock();
|
inode_lock();
|
||||||
ret = inode_reserve(path2, 0777, &inode);
|
ret = inode_reserve(path2, 0777, &inode);
|
||||||
|
|
||||||
|
if (ret >= 0)
|
||||||
|
{
|
||||||
|
/* Initialize the inode */
|
||||||
|
|
||||||
|
INODE_SET_SOFTLINK(inode);
|
||||||
|
inode->u.i_link = newpath2;
|
||||||
|
}
|
||||||
|
|
||||||
inode_unlock();
|
inode_unlock();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@@ -153,11 +162,6 @@ int symlink(FAR const char *path1, FAR const char *path2)
|
|||||||
errcode = -ret;
|
errcode = -ret;
|
||||||
goto errout_with_search;
|
goto errout_with_search;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the inode */
|
|
||||||
|
|
||||||
INODE_SET_SOFTLINK(inode);
|
|
||||||
inode->u.i_link = newpath2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Symbolic link successfully created */
|
/* Symbolic link successfully created */
|
||||||
|
|||||||
Reference in New Issue
Block a user