X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/f8bd95b7a13dfe54d800e2d7ecdb0329f0798289..270869139db617e29a35bb9ded41087bb702f9ac:/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 f3dc8dd..783d9b4 100644 --- a/lunaix-os/kernel/fs/path_walk.c +++ b/lunaix-os/kernel/fs/path_walk.c @@ -6,6 +6,7 @@ #include #define VFS_SYMLINK_DEPTH 16 +#define VFS_SYMLINK_MAXLEN 512 extern struct lru_zone *dnode_lru, *inode_lru; @@ -119,21 +120,28 @@ __vfs_walk(struct v_dnode* start, current_level = dnode; current_inode = current_level->inode; - if ((current_inode->itype & VFS_IFSYMLINK) && + 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, @@ -148,8 +156,6 @@ __vfs_walk(struct v_dnode* start, goto error; } - // reposition the resolved subtree pointed by symlink - // vfs_dcache_rehash(current_level->parent, dnode); current_level = dnode; current_inode = dnode->inode; } @@ -175,6 +181,11 @@ vfs_walk(struct v_dnode* start, struct hstr* component, int options) { + if (!path) { + *dentry = NULL; + return 0; + } + // allocate a file name stack for path walking and recursion to resolve // symlink char* name_buffer = valloc(2048);