We will now plug your new filesystem into the vfs kernel interface. This will be simply to put the corresponding information in files seen at the beginning. The first step will be to add our new vnode type into sys/vnode.h. In the vtagtype enum we will add our tag type at the end.
enum vtagtype { VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_MSDOSFS, VT_LFS, VT_LOFS, VT_FDESC, VT_PORTAL, VT_NULL, VT_UMAP, VT_KERNFS, VT_PROCFS, VT_AFS, VT_ISOFS, VT_UNION, VT_ADOSFS, VT_EXT2FS, VT_NCPFS, VT_VFS, VT_XFS, VT_MYFS };
#define MOUNT_XFS "xfs" /* xfs */ #define MOUNT_MYFS "myfs" /* MYFS The future best filesystem in the world */
/* * Types of memory to be allocated */ #define M_FREE 0 /* should be on free list */ ... #define M_MYFSNODE 73 /* myfs vnode private part */
... #ifdef MYFS # include <ufs/myfs/myfs_extern.h> #endif ... /* * Set up the filesystem operations for vnodes. * The types are defined in mount.h. */ #ifdef MYFS extern struct vfsops myfs_vfsops; #endif ... /* * Set up the filesystem operations for vnodes. */ static struct vfsconf vfsconflist[] = { ... /* my filesystem */ #ifdef MYFS { &myfs_vfsops, MOUNT_MYFS, 18, 0, MNT_LOCAL, myfs_mountroot, NULL }, #endif ... }; /* * vfs_opv_descs enumerates the list of vnode classes, each with it's own * vnode operation vector. It is consulted at system boot to build operation * vectors. It is NULL terminated. */ extern struct vnodeopv_desc myfs_vnodeop_opv_desc; ... struct vnodeopv_desc *vfs_opv_descs[] = { &sync_vnodeop_opv_desc, #ifdef SRSFS &srsfs_vnodeop_opv_desc, #endif NULL };This is simple. All you need to do is to insert your structures into the needed vectors. Beware to not forget a part or the system will crash at the first access of your filesystem. All this part is explained in the comments, this will normally not cause any problems.