summaryrefslogtreecommitdiff
path: root/src/kernel/vfs/request.c
diff options
context:
space:
mode:
authordzwdz2023-01-25 20:16:22 +0100
committerdzwdz2023-01-25 20:16:22 +0100
commit17bfb0ef0a48330b1d54e61fe3c30d83528d2d90 (patch)
treeb3d4aed1f408edcb17fe5c86fccaeacaa2a5a48a /src/kernel/vfs/request.c
parent2ad6ee8ed15d1bf898645a16dbc06991a3c1425e (diff)
style: typedef structs, shorter namespaces
I've wanted to do this for a while, and since I've just had a relatively large refactor commit (pcpy), this is as good of a time as any. Typedefing structs was mostly inspired by Plan 9's coding style. It makes some lines of code much shorter at basically no expense. Everything related to userland kept old-style struct definitions, so as not to force that style onto other people. I also considered changing SCREAMING_ENUM_FIELDS to NicerLookingCamelcase, but I didn't, just in case that'd be confusing.
Diffstat (limited to 'src/kernel/vfs/request.c')
-rw-r--r--src/kernel/vfs/request.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c
index c98913a..7e5877d 100644
--- a/src/kernel/vfs/request.c
+++ b/src/kernel/vfs/request.c
@@ -7,12 +7,12 @@
#include <kernel/vfs/request.h>
#include <shared/mem.h>
-static void vfs_backend_user_accept(struct vfs_request *req);
+static void vfs_backend_user_accept(VfsReq *req);
-void vfsreq_create(struct vfs_request req_) {
- struct vfs_request *req;
+void vfsreq_create(VfsReq req_) {
+ VfsReq *req;
if (req_.caller) {
- process_transition(req_.caller, PS_WAITS4FS);
+ proc_setstate(req_.caller, PS_WAITS4FS);
if (!req_.caller->reqslot)
req_.caller->reqslot = kmalloc(sizeof *req);
req = req_.caller->reqslot;
@@ -34,7 +34,7 @@ void vfsreq_create(struct vfs_request req_) {
// TODO if i add a handle field to vfs_request, check ->readable ->writeable here
if (req->backend && req->backend->provhcnt) {
- struct vfs_request **iter = &req->backend->queue;
+ VfsReq **iter = &req->backend->queue;
while (*iter != NULL) // find free spot in queue
iter = &(*iter)->queue_next;
*iter = req;
@@ -44,11 +44,11 @@ void vfsreq_create(struct vfs_request req_) {
}
}
-void vfsreq_finish(struct vfs_request *req, char __user *stored, long ret,
- int flags, struct process *handler)
+void vfsreq_finish(VfsReq *req, char __user *stored, long ret,
+ int flags, Proc *handler)
{
if (req->type == VFSOP_OPEN && ret >= 0) {
- struct handle *h;
+ Handle *h;
if (!(flags & FSR_DELEGATE)) {
/* default behavior - create a new handle for the file, wrap the id */
h = handle_init(HANDLE_FILE);
@@ -60,14 +60,14 @@ void vfsreq_finish(struct vfs_request *req, char __user *stored, long ret,
} else {
/* delegating - moving a handle to the caller */
assert(handler);
- h = process_handle_take(handler, ret);
+ h = proc_hid_take(handler, ret);
// TODO don't ignore OPEN_RO
}
if (h) {
// TODO write tests for caller getting killed while opening a file
if (!req->caller) panic_unimplemented();
- ret = process_handle_put(req->caller, h);
+ ret = proc_handle_put(req->caller, h);
if (ret < 0) ret = -EMFILE;
} else {
ret = -1;
@@ -83,14 +83,14 @@ void vfsreq_finish(struct vfs_request *req, char __user *stored, long ret,
if (req->caller) {
assert(req->caller->state == PS_WAITS4FS);
regs_savereturn(&req->caller->regs, ret);
- process_transition(req->caller, PS_RUNNING);
+ proc_setstate(req->caller, PS_RUNNING);
} else {
kfree(req);
}
}
-void vfs_backend_tryaccept(struct vfs_backend *backend) {
- struct vfs_request *req = backend->queue;
+void vfs_backend_tryaccept(VfsBackend *backend) {
+ VfsReq *req = backend->queue;
if (!req) return;
if (backend->is_user && !backend->user.handler) return;
@@ -103,8 +103,8 @@ void vfs_backend_tryaccept(struct vfs_backend *backend) {
}
}
-static void vfs_backend_user_accept(struct vfs_request *req) {
- struct process *handler;
+static void vfs_backend_user_accept(VfsReq *req) {
+ Proc *handler;
struct ufs_request res = {0};
int len;
@@ -143,26 +143,26 @@ static void vfs_backend_user_accept(struct vfs_request *req) {
panic_unimplemented();
}
- struct handle *h;
- handle_t hid = process_handle_init(handler, HANDLE_FS_REQ, &h);
+ Handle *h;
+ hid_t hid = proc_handle_init(handler, HANDLE_FS_REQ, &h);
if (hid < 0) panic_unimplemented();
h->req = req;
- process_transition(handler, PS_RUNNING);
+ proc_setstate(handler, PS_RUNNING);
regs_savereturn(&handler->regs, hid);
req->backend->user.handler = NULL;
return;
}
-void vfs_backend_refdown(struct vfs_backend *b, bool use) {
+void vfs_backend_refdown(VfsBackend *b, bool use) {
size_t *field = use ? &b->usehcnt : &b->provhcnt;
assert(b);
assert(0 < *field);
*field -= 1;
if (b->provhcnt == 0 && use == false) {
- struct vfs_request *q = b->queue;
+ VfsReq *q = b->queue;
while (q) {
- struct vfs_request *q2 = q->queue_next;
+ VfsReq *q2 = q->queue_next;
vfsreq_finish_short(q, -1);
q = q2;
}
@@ -173,11 +173,11 @@ void vfs_backend_refdown(struct vfs_backend *b, bool use) {
b->kern.cleanup(b);
}
if (b->is_user && b->user.handler) {
- struct process *p = b->user.handler;
+ Proc *p = b->user.handler;
b->user.handler = NULL;
assert(p->state == PS_WAITS4REQUEST);
regs_savereturn(&p->regs, -EPIPE);
- process_transition(p, PS_RUNNING);
+ proc_setstate(p, PS_RUNNING);
}
}
if (b->usehcnt == 0 && b->provhcnt == 0) {