refactor: improve on scrolling experience in lunaix console
[lunaix-os.git] / lunaix-os / kernel / fs / path_walk.c
index 0ffbabb84bb36fe1b763a6a2a23d6a69f9fffc41..c7d4ecb1e23f4a0914332928941515f8db8242b5 100644 (file)
@@ -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) {