From 17bfb0ef0a48330b1d54e61fe3c30d83528d2d90 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 25 Jan 2023 20:16:22 +0100 Subject: 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. --- src/kernel/vfs/request.h | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src/kernel/vfs/request.h') diff --git a/src/kernel/vfs/request.h b/src/kernel/vfs/request.h index 4d7fa01..182202c 100644 --- a/src/kernel/vfs/request.h +++ b/src/kernel/vfs/request.h @@ -1,38 +1,38 @@ #pragma once -#include +#include #include #include -// describes something which can act as an access function -struct vfs_backend { +/* describes something which can act as an access function */ +struct VfsBackend { /* amount of using references - * struct vfs_mount - * struct vfs_request - * struct handle + * VfsMount + * VfsReq + * Handle * once it reaches 0, it'll never increase */ - size_t usehcnt; /* struct vfs_mount */ + size_t usehcnt; /* VfsMount */ /* amount of providing references - * struct process + * Proc * 0 - orphaned, will never increase */ size_t provhcnt; - struct vfs_request *queue; + VfsReq *queue; bool is_user; union { struct { - struct process *handler; + Proc *handler; } user; struct { - void (*accept)(struct vfs_request *); - void (*cleanup)(struct vfs_backend *); + void (*accept)(VfsReq *); + void (*cleanup)(VfsBackend *); void *data; } kern; }; }; -// describes an in-process vfs call -struct vfs_request { - enum vfs_operation type; +/* describes an in-progress vfs call */ +struct VfsReq { + enum vfs_op type; struct { bool kern; // if false: use .buf ; if true: use .buf_kern union { @@ -54,26 +54,26 @@ struct vfs_request { /* if caller != NULL, owned by it - don't free, the allocation will be reused * if caller == NULL, free on finish */ - struct process *caller; - struct vfs_backend *backend; + Proc *caller; + VfsBackend *backend; - struct vfs_request *queue_next; - struct vfs_request *postqueue_next; /* used by kernel backends */ + VfsReq *queue_next; + VfsReq *postqueue_next; /* used by kernel backends */ /* only one of these queues is in use at a given moment, they could * be merged into a single field */ }; /** Assigns the vfs_request to the caller, and dispatches the call */ -void vfsreq_create(struct vfs_request); -void vfsreq_finish(struct vfs_request*, char __user *stored, long ret, int flags, struct process *handler); +void vfsreq_create(VfsReq); +void vfsreq_finish(VfsReq*, char __user *stored, long ret, int flags, Proc *handler); -static inline void vfsreq_finish_short(struct vfs_request *req, long ret) { +static inline void vfsreq_finish_short(VfsReq *req, long ret) { vfsreq_finish(req, (void __user *)ret, ret, 0, NULL); } /** Try to accept an enqueued request */ -void vfs_backend_tryaccept(struct vfs_backend *); +void vfs_backend_tryaccept(VfsBackend *); // TODO the bool arg is confusing. maybe this should just be a function // that verified the refcount and potentially frees the backend -void vfs_backend_refdown(struct vfs_backend *, bool use); +void vfs_backend_refdown(VfsBackend *, bool use); -- cgit v1.2.3