Virtual file system

VFS supplies the common filesystem interface used by pathname lookup, file descriptors, mounts, and filesystem implementations. Most of its common implementation is in sys/kern/vfs_*.c. Filesystem-specific operations are implemented elsewhere, including under sys/fs and sys/ufs.

The central objects are a mount, which represents a mounted filesystem, and a vnode, which represents a filesystem object through a common interface. A name, an open file description, and a vnode are related but different objects with different ownership rules.

Finding the implementation

Source map

Source

Responsibility

sys/sys/vnode.h

Vnode layout, flags, reference interfaces, and operation-vector types.

sys/sys/mount.h

Mount state and filesystem-level operations.

sys/sys/namei.h

Pathname-lookup state, flags, and ownership interfaces.

sys/kern/vfs_lookup.c, vfs_cache.c

Path traversal, name caching, and the fast lookup path.

sys/kern/vfs_subr.c, vfs_hash.c

Vnode lifecycle, mount busying, and vnode identity helpers.

sys/kern/vfs_mount.c, vfs_mountroot.c

Mount creation, unmounting, references, and root mounting.

sys/kern/vfs_vnops.c, vfs_syscalls.c

Common vnode I/O helpers and syscall-facing operations.

sys/kern/vfs_bio.c, vfs_cluster.c

Buffer-cache operations and clustered I/O.

sys/kern/vnode_if.src

Source descriptions for generated vnode-operation interfaces.

The API references in this topic select the kern XML project, just as the separate Scheduling topic does. A reading topic need not have its own extraction project.

File-backed mappings connect to Virtual memory through the vnode pager. Blocking lookup, I/O, and unmount operations also interact with Scheduling, but VFS’s resource ownership remains separate from the scheduler’s thread-state bookkeeping.