From 215aa95c8d8c85985c1dcc5a994ad164823b39e6 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Fri, 12 Aug 2022 00:30:14 +0200 Subject: vfs: OPEN_RO flag, read-only whitelist entries --- src/kernel/vfs/request.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/kernel/vfs/request.c') diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c index 82f4731..f4db0db 100644 --- a/src/kernel/vfs/request.c +++ b/src/kernel/vfs/request.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -19,9 +19,10 @@ void vfsreq_create(struct vfs_request req_) { req = kmalloc(sizeof *req); } memcpy(req, &req_, sizeof *req); + if (req->backend) req->backend->refcount++; - if (req->backend) - req->backend->refcount++; + if (req->type == VFSOP_OPEN && (req->flags & OPEN_RO)) + req->flags &= ~OPEN_CREATE; if (req->backend && req->backend->potential_handlers) { struct vfs_request **iter = &req->backend->queue; @@ -51,6 +52,7 @@ void vfsreq_finish(struct vfs_request *req, char __user *stored, long ret, backing->backend = req->backend; req->backend->refcount++; backing->file_id = stored; + backing->ro = req->flags & OPEN_RO; req->caller->handles[handle] = backing; } else { /* delegating - moving a handle to the caller */ -- cgit v1.2.3