summaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-09-21 20:11:58 -0400
committerIan Moffett <ian@osmora.org>2025-09-21 20:11:58 -0400
commit2df3bcd48260e3038cc3a84d244e3814c8debc0e (patch)
tree51df25367ff90af32b4367d06280132bc8989828 /src/sys
parent9116f57c6220e6d4de9e8ecc5c10c7c3003387cc (diff)
kern: vfs: Add support for image-like paths
Typically filesystems are tree-like, however certain filesystems in the form of images have fixed paths baked into them. This optimizes handling so there isn't a need to unpack it into a rootfs/tmpfs Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/include/sys/mount.h15
-rw-r--r--src/sys/os/vfs_mount.c2
-rw-r--r--src/sys/os/vfs_namei.c29
3 files changed, 45 insertions, 1 deletions
diff --git a/src/sys/include/sys/mount.h b/src/sys/include/sys/mount.h
index c93eb2b..c9f686c 100644
--- a/src/sys/include/sys/mount.h
+++ b/src/sys/include/sys/mount.h
@@ -48,6 +48,7 @@
#define MOUNT_INITRD "initrd" /* Initial ramdisk */
/* Forward declarations */
+struct fs_info;
struct vfsops;
struct mount;
@@ -58,11 +59,13 @@ extern struct vfsops g_omar_vfsops;
* Represents a mountpoint
*
* @vp: Vnode of mount
+ * @fs: The filesystem backing this mountpoint
* @name: Mountname
* @link: TAILQ link
*/
struct mount {
struct vnode *vp;
+ struct fs_info *fs;
char name[FSNAME_MAX];
TAILQ_ENTRY(mount) link;
};
@@ -98,15 +101,27 @@ struct mount_args {
*
* @name: Filesystem type name
* @vfsops: VFS operations vector
+ * @attr: Attribute mask that may be set by fs
* @refcount: Mount count of this type
+ *
+ * XXX: The attributes mask is set by the filesystem and
+ * intended as an optimization to provide a way for
+ * filesystems set flags to modify behavior during
+ * things like the lookup stage.
*/
struct fs_info {
char name[FSNAME_MAX];
const struct vfsops *vfsops;
+ uint16_t attr;
int refcount;
};
/*
+ * Filesystem attributes mask
+ */
+#define FS_ATTR_IMAGE BIT (0) /* Is an image kind e.g., OSMORA OMAR */
+
+/*
* VFS operations vector
*
* @init: Initialize the filesystem
diff --git a/src/sys/os/vfs_mount.c b/src/sys/os/vfs_mount.c
index 8f09096..034b324 100644
--- a/src/sys/os/vfs_mount.c
+++ b/src/sys/os/vfs_mount.c
@@ -228,7 +228,7 @@ mount(struct mount_args *margs, uint32_t flags)
return error;
}
- /* The filesystem should give us its vnode */
+ mpp->fs = fip;
mpp->vp = margs->vp_res;
return 0;
}
diff --git a/src/sys/os/vfs_namei.c b/src/sys/os/vfs_namei.c
index 8727965..18d35f2 100644
--- a/src/sys/os/vfs_namei.c
+++ b/src/sys/os/vfs_namei.c
@@ -43,6 +43,10 @@ int
namei(struct nameidata *ndp)
{
struct mount *mp = NULL;
+ struct vnode *vp;
+ struct vop *vops;
+ struct vop_lookup_args lookup;
+ struct fs_info *fip;
char namebuf[NAME_MAX];
const char *p, *pcur;
size_t len, i = 0;
@@ -63,6 +67,31 @@ namei(struct nameidata *ndp)
return error;
}
+ vp = mp->vp;
+ fip = mp->fs;
+
+ if ((vops = vp->vops) == NULL) {
+ printf("namei: failed to get vops\n");
+ return -EIO;
+ }
+
+ /* We need vops->lookup() */
+ if (vops->lookup == NULL) {
+ printf("namei: vops does not have lookup op\n");
+ return -EIO;
+ }
+
+ /*
+ * If this is an image we are looking up, then throw
+ * a path right at it.
+ */
+ if (ISSET(fip->attr, FS_ATTR_IMAGE)) {
+ lookup.name = ndp->path;
+ lookup.dirvp = mp->vp;
+ lookup.vpp = &vp;
+ return vops->lookup(&lookup);
+ }
+
printf("namei: f: %s\n", ndp->path);
printf("namei: d: /\n", ndp->path);