summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sys/include/sys/fcntl.h1
-rw-r--r--src/sys/os/os_filedes.c13
2 files changed, 13 insertions, 1 deletions
diff --git a/src/sys/include/sys/fcntl.h b/src/sys/include/sys/fcntl.h
index 30d2ec4..1ab3e71 100644
--- a/src/sys/include/sys/fcntl.h
+++ b/src/sys/include/sys/fcntl.h
@@ -43,6 +43,7 @@
#define O_RDONLY 0x00
#define O_RDWR BIT(1)
#define O_WRONLY BIT(2)
+#define O_CREAT BIT(3)
/* File access mode flags */
#define O_ACCMODE (O_RDWR | O_WRONLY)
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 */
@@ -180,12 +182,21 @@ fd_open(const char *path, mode_t mode)
}
/*
+ * 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) {