mirror of
https://github.com/apache/nuttx.git
synced 2026-08-29 05:10:44 +00:00
fs/vfs: fix link() returning EXDEV instead of ENAMETOOLONG
When inode_find() for path2 fails due to ENAMETOOLONG (or ELOOP), the else branch incorrectly falls through to the EXDEV check based on whether target is a mountpoint. This causes link() to report EXDEV for overly long path2, violating POSIX which requires ENAMETOOLONG in this case. Fix by propagating the original inode_find() error code when it is not ENOENT or ENOTDIR (i.e., not a simple "path does not exist" condition). Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
This commit is contained in:
parent
152ebca599
commit
fa7865f109
1 changed files with 12 additions and 1 deletions
|
|
@ -180,12 +180,23 @@ int link(FAR const char *path1, FAR const char *path2)
|
|||
|
||||
else
|
||||
{
|
||||
/* If inode_find for path2 failed for a reason other than "path does
|
||||
* not exist" (e.g. ENAMETOOLONG, ELOOP), propagate that error
|
||||
* directly instead of falling through to the EXDEV check.
|
||||
*/
|
||||
|
||||
if (ret != -ENOENT && ret != -ENOTDIR)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_newinode;
|
||||
}
|
||||
|
||||
/* Cannot link between pseudofs and other mountpoints */
|
||||
|
||||
if (INODE_IS_MOUNTPT(target))
|
||||
{
|
||||
errcode = EXDEV;
|
||||
goto errout_with_target;
|
||||
goto errout_with_newinode;
|
||||
}
|
||||
|
||||
/* Create an inode in the pseudo-filesystem at this path. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue