From 095a7d841532784712684844f93fa242017fae69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Sun, 18 Oct 2009 22:58:29 +0000 Subject: [PATCH] using chroot with a mount point wrongly exposed the mount point name: we now avoid resolving the volume root in case we hit the IO context root. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33645 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/fs/vfs.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index 517782a3ac..7033e2fbba 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -2640,22 +2640,24 @@ dir_vnode_to_path(struct vnode* vnode, char* buffer, size_t bufferSize, int32 maxLevel = 256; int32 length; status_t status; + struct io_context* ioContext = get_current_io_context(kernel); // we don't use get_vnode() here because this call is more // efficient and does all we need from get_vnode() inc_vnode_ref_count(vnode); - - // resolve a volume root to its mount point - struct vnode* mountPoint = resolve_volume_root_to_mount_point(vnode); - if (mountPoint) { - put_vnode(vnode); - vnode = mountPoint; + + if (vnode != ioContext->root) { + // we don't hit the IO context root + // resolve a volume root to its mount point + struct vnode* mountPoint = resolve_volume_root_to_mount_point(vnode); + if (mountPoint) { + put_vnode(vnode); + vnode = mountPoint; + } } path[--insert] = '\0'; - struct io_context* ioContext = get_current_io_context(kernel); - while (true) { // the name buffer is also used for fs_read_dir() char nameBuffer[sizeof(struct dirent) + B_FILE_NAME_LENGTH]; @@ -2678,12 +2680,16 @@ dir_vnode_to_path(struct vnode* vnode, char* buffer, size_t bufferSize, status = get_vnode_name(vnode, parentVnode, (struct dirent*)nameBuffer, sizeof(nameBuffer), ioContext); - // resolve a volume root to its mount point - mountPoint = resolve_volume_root_to_mount_point(parentVnode); - if (mountPoint) { - put_vnode(parentVnode); - parentVnode = mountPoint; - parentID = parentVnode->id; + if (vnode != ioContext->root) { + // we don't hit the IO context root + // resolve a volume root to its mount point + struct vnode* mountPoint + = resolve_volume_root_to_mount_point(parentVnode); + if (mountPoint) { + put_vnode(parentVnode); + parentVnode = mountPoint; + parentID = parentVnode->id; + } } bool hitRoot = (parentVnode == vnode);