summaryrefslogtreecommitdiff
path: root/src/kernel/vfs/mount.c
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/mount.c
parent26dc784103914b9d6ba36e0a96fa4b3af977626f (diff)
do some simple TODOs, organize the rest; general code maintainance
Diffstat (limited to 'src/kernel/vfs/mount.c')
-rw-r--r--src/kernel/vfs/mount.c31
1 files changed, 15 insertions, 16 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;
-}