Unifying External Interrupt System (#51)
[lunaix-os.git] / lunaix-os / kernel / fs / path_walk.c
index e1b11578145ed1f47d1ddd12cdf7246cf8207247..84e04d0e9bb0eed8ae229e7818f259951b24ead3 100644 (file)
@@ -6,6 +6,7 @@
 #include <klibc/string.h>
 
 #define VFS_SYMLINK_DEPTH 16
+#define VFS_SYMLINK_MAXLEN 512
 
 extern struct lru_zone *dnode_lru, *inode_lru;
 
@@ -31,7 +32,7 @@ __vfs_walk(struct v_dnode* start,
         } else {
             start = vfs_sysroot;
             if (!vfs_sysroot->mnt) {
-                panick("vfs: no root");
+                fail("vfs: no root");
             }
         }
 
@@ -119,21 +120,28 @@ __vfs_walk(struct v_dnode* start,
         current_level = dnode;
         current_inode = current_level->inode;
 
-        if ((current_inode->itype & F_MSLNK) &&
+        assert(current_inode);
+        
+        if (check_symlink_node(current_inode) &&
             !(walk_options & VFS_WALK_NOFOLLOW)) {
             const char* link;
+            struct v_inode_ops* iops;
 
-            if (!current_inode->ops->read_symlink) {
+            iops = current_inode->ops;
+
+            if (!iops->read_symlink) {
                 errno = ENOTSUP;
                 goto error;
             }
 
             lock_inode(current_inode);
-            if ((errno =
-                   current_inode->ops->read_symlink(current_inode, &link))) {
+
+            errno = iops->read_symlink(current_inode, &link);
+            if ((errno < 0)) {
                 unlock_inode(current_inode);
                 goto error;
             }
+
             unlock_inode(current_inode);
 
             errno = __vfs_walk(current_level->parent,