summaryrefslogtreecommitdiff
path: root/src/init/fs/misc.c
diff options
context:
space:
mode:
authordzwdz2022-06-29 21:52:15 +0200
committerdzwdz2022-06-29 21:52:15 +0200
commitbf4cbc830d78774ac00d9501c45e8b84d0ae9ae7 (patch)
treef302f92badf74dade9e724e37f85d1ee2dd99833 /src/init/fs/misc.c
parent43de6a4d8ead1e609828ef34ad1957d34c94ee6a (diff)
kernel/vfs: add the OPEN_CREATE flag
Diffstat (limited to 'src/init/fs/misc.c')
-rw-r--r--src/init/fs/misc.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/init/fs/misc.c b/src/init/fs/misc.c
index f4965d5..914cfb2 100644
--- a/src/init/fs/misc.c
+++ b/src/init/fs/misc.c
@@ -105,10 +105,10 @@ void fs_passthru(const char *prefix) {
memcpy(tmp, buf, res.len);
memcpy(buf, prefix, prefix_len);
memcpy(buf + prefix_len, tmp, res.len);
- ret = _syscall_open(buf, res.len + prefix_len);
+ ret = _syscall_open(buf, res.len + prefix_len, res.flags);
} else ret = -1;
} else {
- ret = _syscall_open(buf, res.len);
+ ret = _syscall_open(buf, res.len, res.flags);
}
_syscall_fs_respond(NULL, ret);
break;
@@ -147,7 +147,7 @@ void fs_dir_inject(const char *path) {
}
if (hid < 0) _syscall_fs_respond(NULL, -2); // we ran out of handles
- ret = _syscall_open(buf, res.len); /* errors handled in inject handler */
+ ret = _syscall_open(buf, res.len, res.flags); /* errors handled in inject handler */
handles[hid].delegate = ret;
handles[hid].inject = NULL;
handles[hid].taken = true;
@@ -155,9 +155,12 @@ void fs_dir_inject(const char *path) {
if (buf[res.len - 1] == '/' &&
res.len < path_len && !memcmp(path, buf, res.len)) {
handles[hid].inject = path + res.len;
+
+ /* if we're making up the opened directory, disallow create */
+ if (ret < 0 && (res.flags & OPEN_CREATE)) hid = ret;
} else {
/* not injecting, don't allow opening nonexistent stuff */
- if (ret < 0) _syscall_fs_respond(NULL, ret);
+ if (ret < 0) hid = ret;
}
_syscall_fs_respond(NULL, hid);
break;