diff options
author | Ian Moffett <ian@osmora.org> | 2025-10-07 12:38:22 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-10-07 12:38:22 -0400 |
commit | eb2c3f0f8b2e50adc3f5e008d72c32a8a3059569 (patch) | |
tree | 11ada1ef8f6ab77016ff24200057587436e0ebb2 /src/sys/include/os | |
parent | a612e3237157e3141634951dc63048eab295e1e9 (diff) |
os: vnode: Add refcounts to vnodes
Keep track of how many referencing are on a vnode so one isn't freed
early while another object is still using it.
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys/include/os')
-rw-r--r-- | src/sys/include/os/vnode.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/sys/include/os/vnode.h b/src/sys/include/os/vnode.h index ed98206..354c73c 100644 --- a/src/sys/include/os/vnode.h +++ b/src/sys/include/os/vnode.h @@ -31,6 +31,7 @@ #define _OS_VNODE_H_ 1 #include <sys/types.h> +#include <sys/atomic.h> /* Forward declarations */ struct vnode; @@ -82,16 +83,20 @@ struct vop { * [V] Set up by VFS * [F/V]: Both F and V * + * @refcount: How many objects have a reference * @type: Vnode type [F/V] * @vops: Vnode operations hooks [F] * @data: Filesystem specific data [F] */ struct vnode { + int refcount; vtype_t type; struct vop *vops; void *data; }; +#define vnode_ref(VP) (atomic_inc_int(&(VP)->refcount)) + /* * Allocate a new vnode * |