summaryrefslogtreecommitdiff
path: root/src/kernel/vfs
diff options
context:
space:
mode:
authordzwdz2022-10-02 19:25:17 +0200
committerdzwdz2022-10-02 19:25:17 +0200
commit710e9b2b5c16f74f66420c66d12455ad518d42c7 (patch)
tree82b88cc07ef3f122512354d649af68584bd4da4d /src/kernel/vfs
parent503d9ff758f8b83295830bdfc8c2ea56837d25e5 (diff)
syscall/open: add the full suite of READ/WRITE flags
Diffstat (limited to 'src/kernel/vfs')
-rw-r--r--src/kernel/vfs/request.c11
-rw-r--r--src/kernel/vfs/request.h2
2 files changed, 10 insertions, 3 deletions
diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c
index 24d5dac..0a377d3 100644
--- a/src/kernel/vfs/request.c
+++ b/src/kernel/vfs/request.c
@@ -23,8 +23,12 @@ void vfsreq_create(struct vfs_request req_) {
memcpy(req, &req_, sizeof *req);
if (req->backend) req->backend->refcount++;
- if (req->type == VFSOP_OPEN && (req->flags & OPEN_RO))
- req->flags &= ~OPEN_CREATE;
+ if (req->type == VFSOP_OPEN && !(req->flags & OPEN_WRITE) && (req->flags & OPEN_CREATE)) {
+ vfsreq_finish_short(req, -EINVAL);
+ return;
+ }
+
+ // TODO if i add a handle field to vfs_request, check ->readable ->writeable here
if (req->backend && req->backend->potential_handlers) {
struct vfs_request **iter = &req->backend->queue;
@@ -47,7 +51,8 @@ void vfsreq_finish(struct vfs_request *req, char __user *stored, long ret,
h = handle_init(HANDLE_FILE);
h->backend = req->backend; req->backend->refcount++;
h->file_id = stored;
- h->ro = req->flags & OPEN_RO;
+ h->readable = OPEN_READABLE(req->flags);
+ h->writeable = OPEN_WRITEABLE(req->flags);
} else {
/* delegating - moving a handle to the caller */
assert(handler);
diff --git a/src/kernel/vfs/request.h b/src/kernel/vfs/request.h
index 4e309b0..db707d0 100644
--- a/src/kernel/vfs/request.h
+++ b/src/kernel/vfs/request.h
@@ -42,6 +42,8 @@ struct vfs_request {
size_t len;
} output;
+ // TODO why doesn't this just have a reference to the handle?
+
void __user *id; // handle.file.id
long offset;
int flags;