Virtual File System

Virtual File System(VFS)是 generic file system syscalls 與 specific file-system implementations 之間的 abstraction layer。Application 仍用 open() / read() / write() / close();VFS 決定底層是 ext4、ZFS、tmpfs、procfs、NFS 等,再 dispatch。

Layering

  1. System-call interface:path、file descriptor、open/read/write/close。
  2. VFS layer:用 common objects / operations 表示 file-system-generic 行為。
  3. Implementation / protocol layer:local disk FS、remote protocol、pseudo FS 的實作。

VFS 避免每個 syscall 內到處寫「若是 UFS 做 A、NFS 做 B」。它用 operation table / function pointer 讓每種 file system 填入自己的 methods。

Local / remote transparency

Client process 對 NFS file 呼叫 read() 時,VFS 看到 vnode 是 remote object,就呼叫 NFS client operation;NFS client 再用 RPC 問 server。對 application 來說仍是普通 file read。

Key objects