torvalds/linux
Filesystems
Purpose
fs/ contains both the VFS (Virtual File System) abstraction and the in-tree implementations of every supported file system. The VFS is the indirection layer that translates read, write, open, stat, mount, etc., into per-filesystem operations.
Directory layout
fs/
├── Kconfig, Kconfig.binfmt, Makefile
├── inode.c, dcache.c, namei.c, namespace.c, super.c, file.c, file_table.c
├── open.c, read_write.c, splice.c, sync.c, fcntl.c, ioctl.c, stat.c, statfs.c
├── attr.c, xattr.c, posix_acl.c
├── pipe.c, fifo.c, anon_inodes.c, eventfd.c, timerfd.c, signalfd.c
├── select.c, poll.c (in include/), epoll/ (separate? check)
├── exec.c (in fs/), binfmt_elf.c, binfmt_misc.c, binfmt_script.c, binfmt_flat.c
├── inotify/, fsnotify/, dnotify/, fanotify/ # Notification frameworks
├── locks.c, mbcache.c, drop_caches.c, fs-writeback.c, dax.c
├── ext2/ ext4/ xfs/ btrfs/ f2fs/ bcachefs/ ntfs3/ udf/ romfs/ ramfs/ cramfs/ jfs/ erofs/ orangefs/ ubifs/ jffs2/ adfs/ affs/ befs/ bfs/ qnx4/ qnx6/ omfs/ minix/ coda/ exfat/ fat/
├── proc/ sysfs/ tracefs/ debugfs/ pstore/ efivarfs/ configfs/ resctrl/ cachefiles/
├── tmpfs (under mm/shmem.c, but UAPI lives in fs)
├── nfs/ nfsd/ nfs_common/ lockd/ nls/ exportfs/ # NFS client/server
├── smb/ ksmbd/ cifs (within smb/) # SMB client + Samba in-kernel
├── ceph/ # Ceph client
├── 9p/ # 9P (used by virtio-9p)
├── fuse/ # FUSE: user-space filesystem framework
├── overlayfs/ # Stackable overlayfs
├── autofs/ # autofs auto-mounter
├── netfs/, fscache/ # Network-FS cache framework
├── kernfs/ # Backing for sysfs, cgroupfs, tracefs
├── verity/ # fs-verity
├── crypto/ # fscrypt (filesystem-level encryption)
├── notify/ # core fsnotify infrastructure
├── nls/ # NLS character set tables
├── unicode/ # Unicode tables for case folding (ext4, f2fs)
├── pidfs.c, mount.h, internal.h, ... # Misc core
└── ...(Around 80 subdirectories total.)
Key abstractions
The VFS is built on four core objects:
| Object | File | Role |
|---|---|---|
struct super_block |
include/linux/fs.h, implementation in fs/super.c |
A mounted filesystem instance. |
struct inode |
include/linux/fs.h, fs/inode.c |
An on-disk object (file, directory, symlink, special). |
struct dentry |
fs/dcache.c |
A name-to-inode binding in the dcache (directory cache). |
struct file |
fs/file_table.c |
An open file descriptor's kernel-side state. |
Each is paired with an operation table:
struct super_operationsstruct inode_operationsstruct dentry_operationsstruct file_operationsstruct address_space_operations(page cache integration)
A filesystem implements these tables and registers a struct file_system_type.
How it works
graph LR
SC[Syscall: read/open/stat/...] --> VFS[VFS layer]
VFS -->|"path lookup<br/>fs/namei.c"| DCACHE[dcache]
DCACHE -->|"miss"| INODE_OPS["inode_operations<br/>per-FS"]
INODE_OPS --> FS[("Concrete FS<br/>(ext4, btrfs, xfs, ...)")]
VFS -->|"file ops"| FOP["file_operations<br/>per-FS"]
FOP --> PAGE_CACHE[mm/filemap.c]
PAGE_CACHE -->|"miss"| AOP["address_space_operations<br/>per-FS"]
AOP --> BIO[block/bio.c]
BIO --> BLK[Block layer]VFS path lookup
Path resolution happens in fs/namei.c. It walks each component, consulting the dcache for cached (parent, name) -> dentry bindings. On dcache misses it calls into the filesystem's inode_operations->lookup. Special features handled here: symlinks, mountpoints (a different superblock), bind mounts, RCU-walk for read-mostly fast paths, follow-link, mount namespaces.
File I/O
read(2), write(2), pread64, pwrite64, readv, writev go through vfs_read / vfs_write in fs/read_write.c. For regular files this typically dispatches to generic_file_read_iter / generic_file_write_iter which talk to the page cache, which talks to address_space_operations to populate or flush.
Mount and namespaces
fs/namespace.c implements the mount tree, mount namespaces, and bind/move/remount. The fsopen/fsconfig/fsmount/move_mount API is the modern mount syscall set; the older mount(2) is still supported.
Notifications
fsnotify is the core in fs/notify/ with three frontends: inotify (file-descriptor-based), dnotify (legacy directory-based), and fanotify (more powerful, can be used for AV scanning, with permission events).
binfmt loaders
fs/binfmt_*.c register handlers for executable formats:
binfmt_elf.c— ELF (the common case).binfmt_elf_fdpic.c— FDPIC ELF (no-MMU).binfmt_script.c—#!shebang.binfmt_misc.c— runtime-registered (qemu-user, wine).binfmt_flat.c— bFLT.
do_execveat_common() in fs/exec.c walks the registered formats.
Concrete filesystems
| FS | Page | Notes |
|---|---|---|
ext4 |
fs/ext4/ |
The traditional default for Linux distributions. Journaled. |
xfs |
fs/xfs/ |
Mature, scalable filesystem. Uses iomap and a delayed-allocation design. |
btrfs |
fs/btrfs/ |
Copy-on-write filesystem with snapshots, checksums, integrated RAID. ~40 source files. |
f2fs |
fs/f2fs/ |
Flash-friendly filesystem optimized for SSDs / eMMC. |
bcachefs |
fs/bcachefs/ |
COW filesystem with snapshots, replication, encryption, compression. Recently merged. |
ntfs3 |
fs/ntfs3/ |
Modern read-write NTFS. |
fuse |
fs/fuse/ |
Forwarding to a user-space daemon over /dev/fuse. |
nfs / nfsd |
fs/nfs/, fs/nfsd/ |
NFS client and server. |
smb (CIFS) / ksmbd |
fs/smb/ |
SMB client and in-kernel SMB server. |
ceph |
fs/ceph/ |
Ceph filesystem client. |
9p |
fs/9p/ |
Plan 9 protocol; common in QEMU/virtio. |
overlayfs |
fs/overlayfs/ |
Stackable union filesystem (used by container runtimes). |
tmpfs / shmem |
code in mm/shmem.c |
Backed by page cache; ABI surface in fs/. |
proc / sysfs / tracefs / debugfs / bpf |
various | Pseudo-filesystems exposing kernel state. |
fscrypt and fs-verity
- fscrypt (
fs/crypto/) — per-file/per-directory encryption, used by ext4, f2fs, ubifs. - fs-verity (
fs/verity/) — Merkle-tree authentication of file contents.
Network-FS cache
fs/netfs/ and fs/fscache/ provide a generic local-cache framework for network filesystems (NFS, AFS, Ceph, 9p).
Integration points
- mm/: page cache (
address_space), folios, writeback, readahead. - block/: filesystems submit bios; the block layer schedules them.
- net/: NFS, Ceph, SMB, 9p, sunrpc all use kernel sockets.
- security/: LSM hooks at
path_*,inode_*,file_*. - crypto/: fscrypt and fs-verity use the crypto API.
- kernel/: tracepoints, capability checks, signal delivery on file events.
Key source files
| File | Purpose |
|---|---|
fs/namei.c |
Path-name resolution. |
fs/dcache.c |
The dentry cache. |
fs/inode.c |
Inode lifecycle, struct inode_operations glue. |
fs/file.c, fs/file_table.c |
Per-process file descriptor table, struct file. |
fs/super.c |
Superblock lifecycle, mount. |
fs/namespace.c |
Mount tree and mount namespaces. |
fs/exec.c |
execve machinery. |
fs/binfmt_elf.c |
ELF binary loader. |
fs/read_write.c |
vfs_read, vfs_write, vfs_iter_read. |
fs/fs-writeback.c |
Per-bdi writeback threads. |
fs/buffer.c |
The buffer-head layer (legacy block I/O for some FSes). |
fs/iomap/ |
The iomap library used by xfs, gfs2, ext4 (DAX), bcachefs. |
Entry points for modification
- New filesystem: create
fs/myfs/, register afile_system_type, implement the four operation tables. ReadDocumentation/filesystems/vfs.rstandDocumentation/filesystems/porting.rst. - New VFS-level feature: modify
fs/namei.c,fs/file.c, etc., touch every consumer. Send to the FS list (linux-fsdevel@vger.kernel.org). - New filesystem syscall: rare; coordinate with
linux-api@. - New mount option: extend the new mount API in
fs/fs_context.candfs/fs_parser.c.
Related pages
- Block layer — where filesystem bios go.
- Memory management — page cache.
- Networking — kernel sockets used by network FSes.
- Security — LSM hooks on path/inode/file.
- Crypto — fscrypt, fs-verity.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.