From 02b190f4c97758f7871d1301a68eb6a0bff2f365 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 8 Mar 2024 11:34:30 -0500 Subject: kernel: fs: Fix logic bug in initramfs code Return NULL if hdr is NULL, Before, if the file is not found, 0x200 would be returned instead of NULL. Signed-off-by: Ian Moffett --- sys/fs/initramfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sys/fs/initramfs.c') diff --git a/sys/fs/initramfs.c b/sys/fs/initramfs.c index c0eaa0c..dad3763 100644 --- a/sys/fs/initramfs.c +++ b/sys/fs/initramfs.c @@ -221,7 +221,7 @@ initramfs_open(const char *path) } hdr = initramfs_from_path((void *)initramfs, path); - return hdr_to_contents(hdr); + return (hdr == NULL) ? NULL : hdr_to_contents(hdr); } struct vfsops g_initramfs_ops = { -- cgit v1.2.3 From 735b519d0c5cf704a992972829ab7a36afa95685 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 15 Mar 2024 10:24:55 -0400 Subject: kernel: initramfs: Fix indent Signed-off-by: Ian Moffett --- sys/fs/initramfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sys/fs/initramfs.c') diff --git a/sys/fs/initramfs.c b/sys/fs/initramfs.c index dad3763..817e6a1 100644 --- a/sys/fs/initramfs.c +++ b/sys/fs/initramfs.c @@ -149,8 +149,8 @@ static char * get_module(const char *path, uint64_t *size) { for (uint64_t i = 0; i < mod_req.response->module_count; ++i) { if (strcmp(mod_req.response->modules[i]->path, path) == 0) { - *size = mod_req.response->modules[i]->size; - return mod_req.response->modules[i]->address; + *size = mod_req.response->modules[i]->size; + return mod_req.response->modules[i]->address; } } -- cgit v1.2.3 From 5338af63451bee4a6ff100ea926368875c6b0a9d Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 15 Mar 2024 11:58:56 -0400 Subject: kernel: initramfs: Fix vtype logic bug Signed-off-by: Ian Moffett --- sys/fs/initramfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sys/fs/initramfs.c') diff --git a/sys/fs/initramfs.c b/sys/fs/initramfs.c index 817e6a1..2a501a1 100644 --- a/sys/fs/initramfs.c +++ b/sys/fs/initramfs.c @@ -103,7 +103,7 @@ vop_vget(struct vnode *parent, const char *name, struct vnode **vp) return -ENOENT; } - if (hdr->type != TAR_TYPEFLAG_DIR) { + if (hdr->type == TAR_TYPEFLAG_DIR) { vtype = VDIR; } -- cgit v1.2.3 From 45547c3a0056ab5732c4ea1e01deee10749ecbcb Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 15 Mar 2024 12:06:40 -0400 Subject: kernel: vfs: Add fs capabilties Signed-off-by: Ian Moffett --- sys/fs/initramfs.c | 1 + sys/include/sys/mount.h | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'sys/fs/initramfs.c') diff --git a/sys/fs/initramfs.c b/sys/fs/initramfs.c index 2a501a1..6da0929 100644 --- a/sys/fs/initramfs.c +++ b/sys/fs/initramfs.c @@ -173,6 +173,7 @@ static int initramfs_init(struct fs_info *info) { initramfs = get_module("/boot/initramfs.tar", &initramfs_size); + info->caps = FSCAP_FULLPATH; if (initramfs == NULL) { panic("Failed to load initramfs\n"); diff --git a/sys/include/sys/mount.h b/sys/include/sys/mount.h index 3ac7ec7..209fa3e 100644 --- a/sys/include/sys/mount.h +++ b/sys/include/sys/mount.h @@ -33,6 +33,7 @@ #include #include #include +#include #define FS_NAME_MAX 16 /* Max length of FS type name including nul */ @@ -54,8 +55,14 @@ struct fs_info { char name[FS_NAME_MAX]; /* Filesystem type name */ struct vfsops *vfsops; /* Filesystem operations */ struct mount *mp_root; + uint16_t caps; }; +/* + * Filesystem capabilities + */ +#define FSCAP_FULLPATH __BIT(0) /* Requires full path per lookup */ + /* * Mount flags */ -- cgit v1.2.3