aboutsummaryrefslogtreecommitdiff
path: root/kernel/fs/namev.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/fs/namev.c')
-rw-r--r--kernel/fs/namev.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/kernel/fs/namev.c b/kernel/fs/namev.c
index 5146165..dd44450 100644
--- a/kernel/fs/namev.c
+++ b/kernel/fs/namev.c
@@ -232,11 +232,23 @@ long namev_dir(vnode_t *base, const char *path, vnode_t **res_vnode,
vref(dir);
// Tokenize the path
- char *token = NULL;
+ const char *token = NULL;
size_t len = 0;
+
while ((token = namev_tokenize(&path, &len)) && len > 0)
{
- if (path == NULL || *path == '\0' || (*path == '/' && *(path + 1) == '\0'))
+ if (path == NULL || *path == '\0')
+ {
+ break;
+ }
+
+ // Check if the whole path is a sequence of '/' then a null
+ int index = 0;
+ while (path[index] == '/')
+ {
+ index++;
+ }
+ if (path[index] == '\0')
{
break;
}
@@ -259,16 +271,9 @@ long namev_dir(vnode_t *base, const char *path, vnode_t **res_vnode,
return err;
}
- *res_vnode = dir;
- *name = token;
- *namelen = len;
-
// Reduce refcount and move to the next token
- if (next)
- {
- vput(&dir);
- dir = next;
- }
+ vput(&dir);
+ dir = next;
}
// Check if it's a directory
@@ -278,11 +283,10 @@ long namev_dir(vnode_t *base, const char *path, vnode_t **res_vnode,
return -ENOTDIR;
}
- // Assign the basename
+ // Assign the ret vars
*res_vnode = dir;
*name = token;
*namelen = len;
-
return 0;
}
/*