VFSCONF(9)

✨ VFSCONF(9) ✨

okay bestie, welcome to vfconf β€” aka vfs configuration information, from the Kernel Developer's Manual πŸ’–

so like. this is the manual for vfsconf(9), which is the whole ~vibe infrastructure~ that lets the kernel know about file system types. it's giving very much "behind the scenes but make it essential" πŸ‘‘


🌸 SYNOPSIS 🌸

#include <sys/param.h>
#include <sys/mount.h>

int
vfs_register(struct vfsconf *vfc);

int
vfs_unregister(struct vfsconf *vfc);

int
vfs_modevent(module_t mod, int type, void *data);

like, that's the whole entrance exam right there 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

Every single file system type the kernel knows about has a vfsconf structure. That structure holds literally all the info you need to create a new mount of that file system type. no cap, it's the blueprint πŸŽ€

struct vfsconf {
        struct  vfsops *vfc_vfsops;     /* file system operations vector */
        char    vfc_name[MFSNAMELEN];   /* file system type name */
        int     vfc_typenum;            /* historic file system type number */
        int     vfc_refcount;           /* number mounted of this type */
        int     vfc_flags;              /* permanent flags */
        struct  vfsconf *vfc_next;      /* next in list */
};

so when a new file system gets mounted, mount(2) does a lookup of the vfsconf structure by its name. and if it's not already registered? it tries to load a kernel module for it. main character energy tbh.

The file system operations for the new mount point are taken from vfc_vfsops, and mnt_vfc in the mount structure is made to point directly at the vfsconf structure for the file system type. The file system type number comes from vfc_typenum, which was assigned back in vfs_register(), and the mount flags are taken from a mask of vfc_flags. Every single time a file system of a given type is mounted, vfc_refcount gets incremented. keeping count, periodt πŸ’…

vfs_register() β€” takes a new vfsconf structure and adds it to the list of existing file systems. If the type hasn't already been registered, it gets initialized by calling the vfs_init() function in the file system operations vector. vfs_register() also updates the oid's of any sysctl nodes for this file system type so they match the newly assigned type number. slay πŸ”₯

vfs_unregister() β€” unlinks vfc from the list of registered file system types, but only if there are currently no mounted instances. If the vfs_uninit() function in the file systems initialization vector is defined, it gets called. bye bestie πŸ‘‹

vfs_modevent() β€” this one is registered by VFS_SET() to handle the loading and unloading of file system kernel modules. In the case of MOD_LOAD, vfs_register() is called. In the case of MOD_UNLOAD, vfs_unregister() is called. iconic dispatcher behaviour ngl ✨


πŸ’œ RETURN VALUES πŸ’œ

  • vfs_register() β€” returns 0 if successful; otherwise, EEXIST is returned, indicating that the file system type has already been registered. (rude, but okay πŸ™ˆ)
  • vfs_unregister() β€” returns 0 if successful.
    • If no vfsconf entry can be found matching the name in vfc, EINVAL is returned.
    • If the reference count of mounted instances of the file system type is not zero, EBUSY is returned. (can't unlink what's still in use, babe πŸ’€)
    • If vfs_uninit() is called, any errors it returns will be returned by vfs_unregister().
  • vfs_modevent() β€” returns the result of the call to vfs_register() or vfs_unregister(), whatever the case. it's just the messenger fr fr

🌈 SEE ALSO 🌈

go read those too, they're all part of the same lore iykyk πŸ“š


πŸ‘‘ AUTHORS πŸ‘‘

This manual page was written by Chad David <davidc@acns.ab.ca>. thank you chad, we love you for this 🫢🌸


and that's the tea, bestie β€” this was the VFSCONF(9) page from the Kernel Developer's Manual, Debian edition, dated June 16, 2013. go mount something responsibly πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from