From 59abe1956c72576cbd9c362603b685e24e30ca41 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 17 Oct 2025 14:34:43 -0400 Subject: kern: filedesc: Add O_CREAT flag for fd_open() Add an O_CREAT flag to the ABI headers so that files can be created in the VFS. Signed-off-by: Ian Moffett --- src/sys/os/os_filedes.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/sys/os') diff --git a/src/sys/os/os_filedes.c b/src/sys/os/os_filedes.c index 95452af..ca56fc3 100644 --- a/src/sys/os/os_filedes.c +++ b/src/sys/os/os_filedes.c @@ -160,8 +160,10 @@ fd_open(const char *path, mode_t mode) { struct filedesc *fd; struct nameidata nd; + struct vop_create_args creat_args; struct proc *self = proc_self(); struct vnode *vp; + uint32_t namei_flags = 0; int error; /* We need the current proc */ @@ -179,13 +181,22 @@ fd_open(const char *path, mode_t mode) return error; } + /* + * If we are creating a new file, we'll need to + * get the parent vnode so that we can use the + * create vop. + */ + if (ISSET(mode, O_CREAT)) { + namei_flags |= NAMEI_CREATE; + } + /* * Now we try to do the lookup, we'll need * the vnode for file references to be * useful */ nd.path = path; - nd.flags = 0; + nd.flags = namei_flags; nd.vp_res = &vp; error = namei(&nd); if (error < 0) { -- cgit v1.2.3