From bf4cbc830d78774ac00d9501c45e8b84d0ae9ae7 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 29 Jun 2022 21:52:15 +0200 Subject: kernel/vfs: add the OPEN_CREATE flag --- src/init/fs/misc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/init/fs/misc.c') 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; -- cgit v1.2.3