summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_mount.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 909a618..02c7308 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -35,6 +35,7 @@
#include <os/mount.h>
#include <kern/vfs.h>
#include <lib/stdbool.h>
+#include <lib/string.h>
#include <vm/kalloc.h>
/*
@@ -114,3 +115,40 @@ mount(struct mount_args *margs)
spinlock_release(&mount_lock, false);
return 0;
}
+
+/*
+ * XXX: Currently we are looking up entries by the fstype.
+ * This must be updated to actual name-based lookups
+ * in future revisions of rv7
+ */
+int
+mount_lookup(const char *name, struct mount **mres)
+{
+ struct fs_info *fip;
+ struct mount *iter, *mount = NULL;
+
+ if (name == NULL || mres == NULL) {
+ return -EINVAL;
+ }
+
+ spinlock_acquire(&mount_lock, false);
+ TAILQ_FOREACH(iter, &mountlist, link) {
+ fip = iter->fip;
+ if (__likely(*name != *fip->name)) {
+ continue;
+ }
+
+ if (strcmp(fip->name, name) == 0) {
+ mount = iter;
+ break;
+ }
+ }
+
+ spinlock_release(&mount_lock, false);
+ if (mount == NULL) {
+ return -ENOENT;
+ }
+
+ *mres = mount;
+ return 0;
+}