X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/d57ee3ae693448387e3022fdd07bd741b2db818a..a36758a5018f6a3792c164cd2a313d4f61b7111e:/lunaix-os/kernel/fs/path_walk.c diff --git a/lunaix-os/kernel/fs/path_walk.c b/lunaix-os/kernel/fs/path_walk.c index 0ffbabb..a0331e7 100644 --- a/lunaix-os/kernel/fs/path_walk.c +++ b/lunaix-os/kernel/fs/path_walk.c @@ -21,7 +21,7 @@ __vfs_walk(struct v_dnode* start, int i = 0, j = 0; if (depth >= VFS_SYMLINK_DEPTH) { - return ENAMETOOLONG; + return ELOOP; } if (path[0] == VFS_PATH_DELIM || !start) { @@ -33,9 +33,14 @@ __vfs_walk(struct v_dnode* start, panick("vfs: no root"); } } - i++; + + if (path[0] == VFS_PATH_DELIM) { + i++; + } } + assert(start); + struct v_dnode* dnode; struct v_inode* current_inode; struct v_dnode* current_level = start; @@ -43,7 +48,7 @@ __vfs_walk(struct v_dnode* start, struct hstr name = HSTR(fname_buffer, 0); char current = path[i++], lookahead; - while (current && current_level) { + while (current) { lookahead = path[i++]; if (current != VFS_PATH_DELIM) { if (j >= VFS_NAME_MAXLEN - 1) { @@ -69,9 +74,7 @@ __vfs_walk(struct v_dnode* start, if (!lookahead && (walk_options & VFS_WALK_PARENT)) { if (component) { - component->hash = name.hash; - component->len = j; - strcpy(component->value, fname_buffer); + hstrcpy(component, &name); } break; } @@ -103,7 +106,7 @@ __vfs_walk(struct v_dnode* start, } // reposition the resolved subtree pointed by symlink - vfs_dcache_rehash(current_level->parent, dnode); + // vfs_dcache_rehash(current_level->parent, dnode); current_level = dnode; current_inode = dnode->inode; }