From e2df52b7da463a14d7f5083d83c374760a8e1d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 8 Jun 2004 11:34:49 +0000 Subject: [PATCH] The symlink traversion didn't balance the ref_count of the starting vnode correctly when it entered the next recursion of vnode_path_to_vnode(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7854 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/fs/vfs.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/kernel/core/fs/vfs.cpp b/src/kernel/core/fs/vfs.cpp index 5f98debf3b..16c47fc78f 100755 --- a/src/kernel/core/fs/vfs.cpp +++ b/src/kernel/core/fs/vfs.cpp @@ -605,10 +605,10 @@ vnode_path_to_vnode(struct vnode *vnode, char *path, bool traverseLeafLink, status_t status = 0; int type = 0; - FUNCTION(("vnode_path_to_vnode(path = %s)\n", path)); + FUNCTION(("vnode_path_to_vnode(vnode = %p, path = %s)\n", vnode, path)); if (!path) - return EINVAL; + return B_BAD_VALUE; while (true) { struct vnode *nextVnode; @@ -632,12 +632,11 @@ vnode_path_to_vnode(struct vnode *vnode, char *path, bool traverseLeafLink, while (*nextPath == '/'); } - // See if the .. is at the root of a mount and move to the covered - // vnode so we pass the '..' parse to the underlying filesystem + // See if the '..' is at the root of a mount and move to the covered + // vnode so we pass the '..' path to the underlying filesystem if (!strcmp("..", path) && vnode->mount->root_vnode == vnode && vnode->mount->covers_vnode) { - nextVnode = vnode->mount->covers_vnode; inc_vnode_ref_count(nextVnode); put_vnode(vnode); @@ -718,6 +717,9 @@ vnode_path_to_vnode(struct vnode *vnode, char *path, bool traverseLeafLink, vnode = sRoot; inc_vnode_ref_count(vnode); } + inc_vnode_ref_count(vnode); + // balance the next recursion - we will decrement the ref_count + // of the vnode, no matter if we succeeded or not status = vnode_path_to_vnode(vnode, path, traverseLeafLink, count + 1, &nextVnode, _type); @@ -760,7 +762,7 @@ path_to_vnode(char *path, bool traverseLink, struct vnode **_vnode, bool kernel) FUNCTION(("path_to_vnode(path = \"%s\")\n", path)); if (!path) - return EINVAL; + return B_BAD_VALUE; // figure out if we need to start at root or at cwd if (*path == '/') {