diff --git a/fs/inode/fs_inodereserve.c b/fs/inode/fs_inodereserve.c index 3082a523b97..1b3c970e7e1 100644 --- a/fs/inode/fs_inodereserve.c +++ b/fs/inode/fs_inodereserve.c @@ -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 */