From 93c729aefb2596c14bbe135b0126d964342ab77b Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 17 Oct 2025 12:37:49 -0400 Subject: kern: vfs: Add 'create' virtual file operation The create VOP allows the caller to create a node within the parent directory of a filesystem represented by a vnode. Signed-off-by: Ian Moffett --- src/sys/include/os/vnode.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/sys/include/os') diff --git a/src/sys/include/os/vnode.h b/src/sys/include/os/vnode.h index 1bef1e2..628ba68 100644 --- a/src/sys/include/os/vnode.h +++ b/src/sys/include/os/vnode.h @@ -32,6 +32,7 @@ #include #include +#include /* Forward declarations */ struct vnode; @@ -82,6 +83,16 @@ struct vop_rw_data { struct vnode *vp; }; +/* + * Arguments to create an entry within a + * filesystem + * + * @ndp: Path component to create + */ +struct vop_create_args { + struct nameidata *ndp; +}; + /* * Represents operations that can be performed on * a specific vnode. These are implemented as callbacks @@ -89,6 +100,7 @@ struct vop_rw_data { struct vop { int(*lookup)(struct vop_lookup_args *args); int(*reclaim)(struct vnode *vp, int flags); + int(*create)(struct vop_create_args *args); ssize_t(*write)(struct vop_rw_data *data); ssize_t(*read)(struct vop_rw_data *data); }; @@ -176,4 +188,16 @@ ssize_t vop_read(struct vnode *vp, char *data, off_t off, size_t len); */ int vop_reclaim(struct vnode *vp, int flags); +/* + * Create a node within a specific filesystem or + * directory + * + * @vp: Vnode of parent directory + * @ndp: Namei descriptor of path component + * + * Returns zero on success, otherwise a less than zero + * value on failure. + */ +int vop_create(struct vnode *vp, struct nameidata *ndp); + #endif /* !_OS_VNODE_H_ */ -- cgit v1.2.3