Act I - The Linux Kernel's VFS - exposition

Act II - Relations Of The VFS With The Rest Of The System - the plot thickens...

VFS And The System - Static Relations

The following figure shows the static relations of the VFS with the rest of the system:

VFS And The System - Dynamic Relations

The following figure shows the dynamic relations of the VFS objects with the rest of the system:

Act III - Internal Components Of The VFS - the naked souls...

The following components comprise the VFS:

About Caches

The Dcache

The Inode Cache

The File Object

Act IV - The VFS Sources - there's a birdhouse in your code...

Lets review the more-interesting source files of the VFS, all found under directory "fs":

Act V - Example VFS Operations - three paths to your soul...

VFS Operations - Path To Inode Translation

Given a (full or relative) path to a file, find its inode:

Entry function: user_path_walk, in include/linux/fs.h.
Actual lookup function: link_path_walk, in fs/namei.c.

  1. First, get the dentry to "/" (if it's a full path) or to "." (if it's a relative path).
  2. Start scanning the path, and follow via the dcache.
    1. Handle "." by skipping.
    2. Handle ".." using dentry->d_parent.
    3. Handle others via a cache lookup.
    4. If not found in the cache - ask the underlying filesystem to perform a real lookup.

VFS Operations - File Open

Given a file path, an open mode and a file permissions mask:

Entry function: sys_open, in fs/open.c.
Underlying open function: filp_open, in fs/open.c.

Actually Opening The File

Entry function: open_namei, in fs/namei.c.

VFS Create

Entry function: vfs_create, in fs/namei.c.

VFS Operations - File Read

Entry function: sys_read, in fs/read_write.c:

Reading Via The Page Cache

Entry function: do_generic_file_read, in mm/filemap.c:


  1. Linux Kernel 2.4 Internals - Virtual Filesystem (VFS)
  2. The Linux Virtual File-System Layer
  3. Linux Virtual File System (lecture slides from 1998).
  4. A Small Trail Through The Linux Kernel (code walk-through for open and read system calls).
Originally written by Valid HTML 4.01!guy keren