From 5500d8a54f5db24d94e12019020d7ee26872efc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 6 Jan 2009 21:17:47 +0000 Subject: [PATCH] * All file descriptors that only refer to a mount now keep the mount, ie. they won't call put_mount() before they are freed. Internally, this causes them to grab a reference to the mount's root vnode. * This fixes bug #3262. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28850 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/fs/vfs.cpp | 44 ++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index 63061d4e79..ec4081013c 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -6450,24 +6450,23 @@ index_dir_open(dev_t mountID, bool kernel) if (!HAS_FS_MOUNT_CALL(mount, open_index_dir)) { status = EOPNOTSUPP; - goto out; + goto error; } status = FS_MOUNT_CALL(mount, open_index_dir, &cookie); if (status < B_OK) - goto out; + goto error; // get fd for the index directory status = get_new_fd(FDTYPE_INDEX_DIR, mount, NULL, cookie, 0, kernel); - if (status >= 0) - goto out; + if (status < 0) { + // something went wrong + FS_MOUNT_CALL(mount, close_index_dir, cookie); + FS_MOUNT_CALL(mount, free_index_dir_cookie, cookie); - // something went wrong - FS_MOUNT_CALL(mount, close_index_dir, cookie); - FS_MOUNT_CALL(mount, free_index_dir_cookie, cookie); - -out: - put_mount(mount); +error: + put_mount(mount); + } return status; } @@ -6493,8 +6492,7 @@ index_dir_free_fd(struct file_descriptor *descriptor) if (mount != NULL) { FS_MOUNT_CALL(mount, free_index_dir_cookie, descriptor->cookie); - // ToDo: find a replacement ref_count object - perhaps the root dir? - //put_vnode(vnode); + put_mount(mount); } } @@ -6644,25 +6642,24 @@ query_open(dev_t device, const char *query, uint32 flags, if (!HAS_FS_MOUNT_CALL(mount, open_query)) { status = EOPNOTSUPP; - goto out; + goto error; } status = FS_MOUNT_CALL(mount, open_query, query, flags, port, token, &cookie); if (status < B_OK) - goto out; + goto error; // get fd for the index directory status = get_new_fd(FDTYPE_QUERY, mount, NULL, cookie, 0, kernel); - if (status >= 0) - goto out; + if (status < 0) { + // something went wrong + FS_MOUNT_CALL(mount, close_query, cookie); + FS_MOUNT_CALL(mount, free_query_cookie, cookie); - // something went wrong - FS_MOUNT_CALL(mount, close_query, cookie); - FS_MOUNT_CALL(mount, free_query_cookie, cookie); - -out: - put_mount(mount); +error: + put_mount(mount); + } return status; } @@ -6688,8 +6685,7 @@ query_free_fd(struct file_descriptor *descriptor) if (mount != NULL) { FS_MOUNT_CALL(mount, free_query_cookie, descriptor->cookie); - // ToDo: find a replacement ref_count object - perhaps the root dir? - //put_vnode(vnode); + put_mount(mount); } }