mirror of
https://github.com/apache/nuttx.git
synced 2026-09-08 18:06:33 +00:00
fs/inode: propagate inode search errors
inode_reserve() previously continued processing all negative return values from inode_search(). Only -ENOENT indicates that the target inode is absent and creation may continue. Propagate other search errors through the existing cleanup path to avoid continuing inode creation with invalid insertion metadata. Assisted-by: GitHub Copilot Signed-off-by: Megha Rajput <i.meghar.2408@gmail.com>
This commit is contained in:
parent
784c6519de
commit
c5619cb3fe
1 changed files with 8 additions and 2 deletions
|
|
@ -53,6 +53,7 @@ static ino_t g_ino;
|
|||
static int inode_namelen(FAR const char *name)
|
||||
{
|
||||
FAR const char *tmp = name;
|
||||
|
||||
while (*tmp && *tmp != '/')
|
||||
{
|
||||
tmp++;
|
||||
|
|
@ -210,13 +211,17 @@ int inode_reserve(FAR const char *path,
|
|||
SETUP_SEARCH(&desc, path, false);
|
||||
|
||||
ret = inode_search(&desc);
|
||||
if (ret >= 0)
|
||||
if (ret != -ENOENT)
|
||||
{
|
||||
/* It is an error if the node already exists in the tree (or if it
|
||||
* lies within a mountpoint, we don't distinguish here).
|
||||
*/
|
||||
|
||||
ret = -EEXIST;
|
||||
if (ret >= 0)
|
||||
{
|
||||
ret = -EEXIST;
|
||||
}
|
||||
|
||||
goto errout_with_search;
|
||||
}
|
||||
|
||||
|
|
@ -249,6 +254,7 @@ int inode_reserve(FAR const char *path,
|
|||
*/
|
||||
|
||||
FAR const char *nextname = inode_nextname(name);
|
||||
|
||||
if (*nextname != '\0')
|
||||
{
|
||||
/* Insert an operationless node */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue