summaryrefslogtreecommitdiff
path: root/src/kernel/vfs
diff options
context:
space:
mode:
authordzwdz2022-08-04 23:06:57 +0200
committerdzwdz2022-08-04 23:06:57 +0200
commitce00d1677d7a419b427e7f11963eee982a55a231 (patch)
tree2662c3861226f6909b83d57ff8b6ac3b2ba5ec8d /src/kernel/vfs
parent26dc784103914b9d6ba36e0a96fa4b3af977626f (diff)
do some simple TODOs, organize the rest; general code maintainance
Diffstat (limited to 'src/kernel/vfs')
-rw-r--r--src/kernel/vfs/mount.c31
-rw-r--r--src/kernel/vfs/path.h3
-rw-r--r--src/kernel/vfs/request.c3
3 files changed, 18 insertions, 19 deletions
diff --git a/src/kernel/vfs/mount.c b/src/kernel/vfs/mount.c
index 77cc14b..de2d708 100644
--- a/src/kernel/vfs/mount.c
+++ b/src/kernel/vfs/mount.c
@@ -3,13 +3,25 @@
#include <kernel/vfs/mount.h>
#include <shared/mem.h>
-// TODO not the place where this should be done
static struct vfs_mount *mount_root = NULL;
struct vfs_mount *vfs_mount_seed(void) {
return mount_root;
}
+void vfs_mount_root_register(const char *path, struct vfs_backend *backend) {
+ struct vfs_mount *mount = kmalloc(sizeof *mount);
+ *mount = (struct vfs_mount){
+ .prev = mount_root,
+ .prefix = path,
+ .prefix_len = strlen(path),
+ .backend = backend,
+ .refs = 1,
+ };
+ mount_root = mount;
+}
+
+
struct vfs_mount *vfs_mount_resolve(
struct vfs_mount *top, const char *path, size_t path_len)
{
@@ -20,9 +32,8 @@ struct vfs_mount *vfs_mount_resolve(
continue;
/* ensure that there's no garbage after the match
- * recognize that e.g. /thisasdf doesn't get recognized as mounted under
- * /this */
-
+ * e.g. don't recognize /thisasdf as mounted under /this */
+
if (top->prefix_len == path_len) // can't happen if prefix == path
break;
if (path[top->prefix_len] == '/')
@@ -45,15 +56,3 @@ void vfs_mount_remref(struct vfs_mount *mnt) {
if (prev) vfs_mount_remref(prev);
}
-
-void vfs_mount_root_register(const char *path, struct vfs_backend *backend) {
- struct vfs_mount *mount = kmalloc(sizeof *mount);
- *mount = (struct vfs_mount){
- .prev = mount_root,
- .prefix = path,
- .prefix_len = strlen(path),
- .backend = backend,
- .refs = 1,
- };
- mount_root = mount;
-}
diff --git a/src/kernel/vfs/path.h b/src/kernel/vfs/path.h
index 8efa0d4..7484619 100644
--- a/src/kernel/vfs/path.h
+++ b/src/kernel/vfs/path.h
@@ -1,8 +1,7 @@
#pragma once
+#include <camellia/path.h>
#include <stddef.h>
-#define PATH_MAX 512
-
/** Reduce a path to its simplest form.
*
* @return length of the string in *out, always less than len. Negative if the path was invalid.
diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c
index d942fba..6883faa 100644
--- a/src/kernel/vfs/request.c
+++ b/src/kernel/vfs/request.c
@@ -114,7 +114,8 @@ void vfs_backend_user_accept(struct vfs_request *req) {
assert(req && req->backend && req->backend->user.handler);
handler = req->backend->user.handler;
assert(handler->state == PS_WAITS4REQUEST);
- assert(handler->handled_req == NULL);
+ if (handler->handled_req)
+ panic_unimplemented();
// the virt_cpy calls aren't present in all kernel backends
// it's a way to tell apart kernel and user backends apart