diff --git a/headers/os/drivers/fs_interface.h b/headers/os/drivers/fs_interface.h index e81cea9341..a758c79b48 100644 --- a/headers/os/drivers/fs_interface.h +++ b/headers/os/drivers/fs_interface.h @@ -309,6 +309,7 @@ extern status_t publish_vnode(fs_volume *volume, ino_t vnodeID, extern status_t get_vnode(fs_volume *volume, ino_t vnodeID, void **_privateNode); extern status_t put_vnode(fs_volume *volume, ino_t vnodeID); +extern status_t acquire_vnode(fs_volume *volume, ino_t vnodeID); extern status_t remove_vnode(fs_volume *volume, ino_t vnodeID); extern status_t unremove_vnode(fs_volume *volume, ino_t vnodeID); extern status_t get_vnode_removed(fs_volume *volume, ino_t vnodeID, diff --git a/headers/private/fs_shell/fssh_api_wrapper.h b/headers/private/fs_shell/fssh_api_wrapper.h index 8da598137a..ed09b3cf52 100644 --- a/headers/private/fs_shell/fssh_api_wrapper.h +++ b/headers/private/fs_shell/fssh_api_wrapper.h @@ -905,6 +905,7 @@ #define publish_vnode fssh_publish_vnode #define get_vnode fssh_get_vnode #define put_vnode fssh_put_vnode +#define acquire_vnode fssh_acquire_vnode #define remove_vnode fssh_remove_vnode #define unremove_vnode fssh_unremove_vnode #define get_vnode_removed fssh_get_vnode_removed diff --git a/headers/private/fs_shell/fssh_fs_interface.h b/headers/private/fs_shell/fssh_fs_interface.h index 47231f5c71..d4d406c9c8 100644 --- a/headers/private/fs_shell/fssh_fs_interface.h +++ b/headers/private/fs_shell/fssh_fs_interface.h @@ -347,6 +347,8 @@ extern fssh_status_t fssh_get_vnode(fssh_fs_volume *volume, fssh_vnode_id vnodeID, void **_privateNode); extern fssh_status_t fssh_put_vnode(fssh_fs_volume *volume, fssh_vnode_id vnodeID); +extern fssh_status_t fssh_acquire_vnode(fssh_fs_volume *volume, + fssh_vnode_id vnodeID); extern fssh_status_t fssh_remove_vnode(fssh_fs_volume *volume, fssh_vnode_id vnodeID); extern fssh_status_t fssh_unremove_vnode(fssh_fs_volume *volume, diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index f34ad6338e..e191c3332b 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -3193,6 +3193,23 @@ get_vnode(fs_volume *volume, ino_t vnodeID, void **_fsNode) } +extern "C" status_t +acquire_vnode(fs_volume *volume, ino_t vnodeID) +{ + struct vnode *vnode; + + mutex_lock(&sVnodeMutex); + vnode = lookup_vnode(volume->id, vnodeID); + mutex_unlock(&sVnodeMutex); + + if (vnode == NULL) + return B_BAD_VALUE; + + inc_vnode_ref_count(vnode); + return B_OK; +} + + extern "C" status_t put_vnode(fs_volume *volume, ino_t vnodeID) { @@ -3202,9 +3219,10 @@ put_vnode(fs_volume *volume, ino_t vnodeID) vnode = lookup_vnode(volume->id, vnodeID); mutex_unlock(&sVnodeMutex); - if (vnode) - dec_vnode_ref_count(vnode, false, true); + if (vnode == NULL) + return B_BAD_VALUE; + dec_vnode_ref_count(vnode, false, true); return B_OK; } diff --git a/src/tools/fs_shell/vfs.cpp b/src/tools/fs_shell/vfs.cpp index 795491d15e..aba2b88a2a 100644 --- a/src/tools/fs_shell/vfs.cpp +++ b/src/tools/fs_shell/vfs.cpp @@ -2017,6 +2017,23 @@ fssh_get_vnode(fssh_fs_volume *volume, fssh_vnode_id vnodeID, void **fsNode) } +extern "C" fssh_status_t +fssh_acquire_vnode(fssh_fs_volume *volume, fssh_vnode_id vnodeID) +{ + struct vnode *vnode; + + fssh_mutex_lock(&sVnodeMutex); + vnode = lookup_vnode(volume->id, vnodeID); + fssh_mutex_unlock(&sVnodeMutex); + + if (vnode == NULL) + return FSSH_B_BAD_VALUE; + + inc_vnode_ref_count(vnode); + return FSSH_B_OK; +} + + extern "C" fssh_status_t fssh_put_vnode(fssh_fs_volume *volume, fssh_vnode_id vnodeID) { @@ -2026,9 +2043,10 @@ fssh_put_vnode(fssh_fs_volume *volume, fssh_vnode_id vnodeID) vnode = lookup_vnode(volume->id, vnodeID); fssh_mutex_unlock(&sVnodeMutex); - if (vnode) - dec_vnode_ref_count(vnode, true); + if (vnode == NULL) + return FSSH_B_BAD_VALUE; + dec_vnode_ref_count(vnode, true); return FSSH_B_OK; }