diff options
author | Ian Moffett <ian@osmora.org> | 2025-09-21 20:13:51 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-09-21 20:13:51 -0400 |
commit | e0969623d49d3380349935dfc1c3b71d62f44906 (patch) | |
tree | fd528b17d2c1ba4b66fd9c44d32b349c276e7efd /src/sys/os | |
parent | 31361caa155591ae3e40008e8b7d748e84df50dd (diff) |
kern: omar: Implement image-like lookup VOP
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys/os')
-rw-r--r-- | src/sys/os/os_omar.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/sys/os/os_omar.c b/src/sys/os/os_omar.c index a75642f..48c745b 100644 --- a/src/sys/os/os_omar.c +++ b/src/sys/os/os_omar.c @@ -35,6 +35,7 @@ #include <sys/mount.h> #include <sys/panic.h> #include <sys/syslog.h> +#include <os/kalloc.h> #include <os/omar.h> #include <string.h> #include <stdbool.h> @@ -166,10 +167,49 @@ initrd_init(struct fs_info *fip) panic("initrd: could not find '%s'\n", INITRD_PATH); } + /* This is an image */ + fip->attr |= FS_ATTR_IMAGE; return 0; } /* + * Lookup a file within the initrd + */ +static int +initrd_lookup(struct vop_lookup_args *args) +{ + struct initrd_node np; + struct vnode *vp; + int error; + + if (args->vpp == NULL) { + return -EINVAL; + } + + /* Path must start with '/' */ + if (*args->name++ != '/') { + return -ENOENT; + } + + /* Get the actual file */ + error = initrd_get_file(args->name, &np); + if (error < 0) { + return error; + } + + /* Grab a vnode */ + error = vfs_valloc(&vp, VTYPE_FILE, 0); + if (error < 0) { + return error; + } + + vp->data = kalloc(sizeof(np)); + memcpy(vp->data, &np, sizeof(np)); + *args->vpp = vp; + return error; +} + +/* * Mount the initrd */ static int @@ -223,7 +263,7 @@ initrd_open(const char *path, char **res) } static struct vop omar_vops = { - .lookup = NULL + .lookup = initrd_lookup }; struct vfsops g_omar_vfsops = { |