summaryrefslogtreecommitdiff
path: root/src/kernel/vfs
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/vfs')
-rw-r--r--src/kernel/vfs/mount.c9
-rw-r--r--src/kernel/vfs/mount.h2
-rw-r--r--src/kernel/vfs/request.c6
-rw-r--r--src/kernel/vfs/request.h15
4 files changed, 14 insertions, 18 deletions
diff --git a/src/kernel/vfs/mount.c b/src/kernel/vfs/mount.c
index de2d708..aa73acb 100644
--- a/src/kernel/vfs/mount.c
+++ b/src/kernel/vfs/mount.c
@@ -9,8 +9,15 @@ struct vfs_mount *vfs_mount_seed(void) {
return mount_root;
}
-void vfs_mount_root_register(const char *path, struct vfs_backend *backend) {
+void vfs_root_register(const char *path, void (*accept)(struct vfs_request *)) {
+ struct vfs_backend *backend = kmalloc(sizeof *backend);
struct vfs_mount *mount = kmalloc(sizeof *mount);
+ *backend = (struct vfs_backend) {
+ .is_user = false,
+ .potential_handlers = 1,
+ .refcount = 1,
+ .kern.accept = accept,
+ };
*mount = (struct vfs_mount){
.prev = mount_root,
.prefix = path,
diff --git a/src/kernel/vfs/mount.h b/src/kernel/vfs/mount.h
index bcd3460..6efdaa7 100644
--- a/src/kernel/vfs/mount.h
+++ b/src/kernel/vfs/mount.h
@@ -21,4 +21,4 @@ struct vfs_mount *vfs_mount_resolve(
/** Decrements the reference count, potentially freeing the mount. */
void vfs_mount_remref(struct vfs_mount *mnt);
-void vfs_mount_root_register(const char *path, struct vfs_backend *backend);
+void vfs_root_register(const char *path, void (*accept)(struct vfs_request *));
diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c
index 959b051..8559b23 100644
--- a/src/kernel/vfs/request.c
+++ b/src/kernel/vfs/request.c
@@ -7,6 +7,8 @@
#include <kernel/vfs/request.h>
#include <shared/mem.h>
+static void vfs_backend_user_accept(struct vfs_request *req);
+
void vfsreq_create(struct vfs_request req_) {
struct vfs_request *req;
if (req_.caller) {
@@ -90,7 +92,7 @@ void vfs_backend_tryaccept(struct vfs_backend *backend) {
}
}
-void vfs_backend_user_accept(struct vfs_request *req) {
+static void vfs_backend_user_accept(struct vfs_request *req) {
struct process *handler;
struct fs_wait_response res = {0};
struct virt_cpy_error cpyerr;
@@ -148,5 +150,5 @@ void vfs_backend_refdown(struct vfs_backend *b) {
if (--(b->refcount) > 0) return;
assert(!b->queue);
- if (b->heap) kfree(b);
+ kfree(b);
}
diff --git a/src/kernel/vfs/request.h b/src/kernel/vfs/request.h
index 7c991f4..4e309b0 100644
--- a/src/kernel/vfs/request.h
+++ b/src/kernel/vfs/request.h
@@ -1,25 +1,21 @@
#pragma once
-#include <camellia/flags.h>
#include <camellia/types.h>
-#include <kernel/proc.h>
#include <stdbool.h>
#include <stddef.h>
// describes something which can act as an access function
struct vfs_backend {
- size_t refcount;
/* references:
* struct vfs_mount
* struct vfs_request
* struct process
* struct handle
*/
- bool heap;
+ size_t refcount;
size_t potential_handlers; // 0 - orphaned
struct vfs_request *queue;
bool is_user;
-
union {
struct {
struct process *handler;
@@ -71,14 +67,5 @@ static inline void vfsreq_finish_short(struct vfs_request *req, long ret) {
/** Try to accept an enqueued request */
void vfs_backend_tryaccept(struct vfs_backend *);
-void vfs_backend_user_accept(struct vfs_request *req);
void vfs_backend_refdown(struct vfs_backend *);
-
-
-#define BACKEND_KERN(accept) ((struct vfs_backend){\
- .is_user = false, \
- .heap = false, \
- .potential_handlers = 1, \
- .refcount = 1, \
- .kern.accept = accept})