summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sys/include/sys/mount.h11
-rw-r--r--src/sys/os/vfs_mount.c29
2 files changed, 40 insertions, 0 deletions
diff --git a/src/sys/include/sys/mount.h b/src/sys/include/sys/mount.h
index c2beb8d..0296b70 100644
--- a/src/sys/include/sys/mount.h
+++ b/src/sys/include/sys/mount.h
@@ -133,5 +133,16 @@ int mount(struct mount_args *margs, uint32_t flags);
*/
int mountlist_init(struct mountlist *mlp);
+/*
+ * Allocate a new mountpoint
+ *
+ * @name: The name to allocate mountpoint as
+ * @mp_res: Result pointer is written here
+ *
+ * Returns zero on success, otherwise a less than
+ * zero value to indicate failure.
+ */
+int mount_alloc(const char *name, struct mount **mp_res);
+
#endif /* !_KERNEL */
#endif /* !_SYS_MOUNT_H_ */
diff --git a/src/sys/os/vfs_mount.c b/src/sys/os/vfs_mount.c
index f1d7ffd..69aec10 100644
--- a/src/sys/os/vfs_mount.c
+++ b/src/sys/os/vfs_mount.c
@@ -29,6 +29,7 @@
#include <sys/types.h>
#include <sys/syslog.h>
+#include <sys/param.h>
#include <sys/errno.h>
#include <sys/cdefs.h>
#include <sys/mount.h>
@@ -41,6 +42,34 @@
*/
static struct mountlist root;
+
+/*
+ * Allocate a new mountpoint
+ */
+int
+mount_alloc(const char *name, struct mount **mp_res)
+{
+ struct mount *mp;
+ size_t len, slen;
+
+ if (mp_res == NULL || name == NULL) {
+ return -EINVAL;
+ }
+
+ mp = kalloc(sizeof(*mp));
+ if (mp == NULL) {
+ printf("mount_alloc: allocation failure\n");
+ return -ENOMEM;
+ }
+
+ slen = strlen(name);
+ len = MIN(sizeof(mp->name), slen);
+ memcpy(mp->name, name, len);
+
+ *mp_res = mp;
+ return 0;
+}
+
/*
* Mount a filesystem
*/