From e0969623d49d3380349935dfc1c3b71d62f44906 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 21 Sep 2025 20:13:51 -0400 Subject: kern: omar: Implement image-like lookup VOP Signed-off-by: Ian Moffett --- src/sys/os/os_omar.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'src') 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 #include #include +#include #include #include #include @@ -166,9 +167,48 @@ 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 */ @@ -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 = { -- cgit v1.2.3