aboutsummaryrefslogtreecommitdiff
path: root/sys/include
diff options
context:
space:
mode:
Diffstat (limited to 'sys/include')
-rw-r--r--sys/include/fs/initramfs.h37
-rw-r--r--sys/include/sys/mount.h84
-rw-r--r--sys/include/sys/namei.h44
-rw-r--r--sys/include/sys/vnode.h74
4 files changed, 239 insertions, 0 deletions
diff --git a/sys/include/fs/initramfs.h b/sys/include/fs/initramfs.h
new file mode 100644
index 0000000..897079c
--- /dev/null
+++ b/sys/include/fs/initramfs.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _INITRAMFS_H_
+#define _INITRAMFS_H_
+
+#include <sys/vnode.h>
+
+extern const struct vops g_initramfs_vops;
+
+#endif /* _INITRAMFS_H_ */
diff --git a/sys/include/sys/mount.h b/sys/include/sys/mount.h
new file mode 100644
index 0000000..e46cda9
--- /dev/null
+++ b/sys/include/sys/mount.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_MOUNT_H_
+#define _SYS_MOUNT_H_
+
+#include <sys/types.h>
+#include <sys/queue.h>
+#include <sys/namei.h>
+#include <sys/vnode.h>
+#include <sys/spinlock.h>
+
+#if defined(_KERNEL)
+
+#define FS_NAME_MAX 16 /* Length of fs name including nul */
+
+/*
+ * Filesystem types.
+ */
+#define MOUNT_RAMFS "initramfs"
+
+struct vfsops;
+struct mount;
+
+/* Mount list */
+typedef TAILQ_HEAD(, mount) mountlist_t;
+extern mountlist_t g_mountlist;
+
+/* Filesystem operations */
+extern const struct vfsops g_initramfs_vfsops;
+
+struct mount {
+ struct spinlock lock;
+ struct vnode *vp;
+ const struct vfsops *mnt_ops;
+ void *data;
+ TAILQ_ENTRY(mount) mnt_list;
+};
+
+struct fs_info {
+ char name[FS_NAME_MAX]; /* FS Type name */
+ const struct vfsops *vfsops; /* Operations vector */
+ int flags; /* Flags for this filesystem */
+ int refcount; /* Mount count of this type */
+};
+
+struct vfsops {
+ int(*init)(struct fs_info *fip);
+ int(*mount)(struct mount *mp, const char *path, void *data,
+ struct nameidata *ndp);
+};
+
+void vfs_init(void);
+struct mount *vfs_alloc_mount(struct vnode *vp, struct fs_info *fip);
+struct fs_info *vfs_byname(const char *name);
+
+#endif /* _KERNEL */
+#endif /* _SYS_MOUNT_H_ */
diff --git a/sys/include/sys/namei.h b/sys/include/sys/namei.h
new file mode 100644
index 0000000..bd3c0db
--- /dev/null
+++ b/sys/include/sys/namei.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_NAMEI_H_
+#define _SYS_NAMEI_H_
+
+#include <sys/types.h>
+#include <sys/vnode.h>
+
+struct nameidata {
+ const char *path; /* Pathname */
+ uint32_t flags;
+ struct vnode *vp; /* Vnode result */
+};
+
+int namei(struct nameidata *ndp);
+
+#endif /* !_SYS_NAMEI_H_ */
diff --git a/sys/include/sys/vnode.h b/sys/include/sys/vnode.h
new file mode 100644
index 0000000..1caf2cb
--- /dev/null
+++ b/sys/include/sys/vnode.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_VNODE_H_
+#define _SYS_VNODE_H_
+
+#include <sys/sio.h>
+
+#if defined(_KERNEL)
+
+struct vops;
+
+struct vnode {
+ int type;
+ int flags;
+ void *data;
+ const struct vops *vops;
+};
+
+/* Vnode type flags */
+#define VNON 0x00 /* Uninitialized */
+#define VREG 0x01 /* Regular file */
+#define VDIR 0x02 /* Directory */
+#define VCHR 0x03 /* Character device */
+#define VBLK 0x04 /* Block device */
+
+struct vop_lookup_args {
+ const char *name; /* Current path component */
+ struct vnode *dirvp; /* Directory vnode */
+ struct vnode **vpp; /* Result vnode */
+};
+
+struct vops {
+ int(*lookup)(struct vop_lookup_args *args);
+ int(*read)(struct vnode *vp, struct sio_txn *sio);
+ int(*reclaim)(struct vnode *vp);
+};
+
+extern struct vnode *g_root_vnode;
+
+int vfs_alloc_vnode(struct vnode **res, int type);
+int vfs_release_vnode(struct vnode *vp);
+
+int vfs_vop_lookup(struct vnode *vp, struct vop_lookup_args *args);
+int vfs_vop_read(struct vnode *vp, struct sio_txn *sio);
+
+#endif /* _KERNEL */
+#endif /* !_SYS_VNODE_H_ */