Mount Table

Mount table 是 kernel 的 in-memory table,記錄目前哪些 file systems 被 mount 到哪些 mount points,以及 path traversal 要從哪個 root vnode / superblock 繼續。

Path traversal 中的角色

查找 /home/jane/a.txt 時,kernel 逐 component lookup。若 home 是 mount point,就查 mount table,切到 mounted file system 的 root,再找 jane/a.txt。因此它是多 file-system namespace 的切換表。

常見內容

  • mount point 的 vnode / inode reference;
  • mounted device / volume identifier;
  • file-system type(ufs、zfs、nfs、tmpfs 等);
  • mounted FS 的 superblock / root vnode;
  • mount options(read-only、noexec、permission policy);
  • reference counts,避免 busy file system 被 unmount。

Mount table 放在 memory 中是因為 path lookup 很頻繁;boot-time defaults 來自 configuration,手動 mount / unmount 則動態修改它。

UNIX vs Windows

UNIX 通常把 volumes mount 到 single directory tree。傳統 Windows 用 drive letters(C:D:),也可把 volume mount 到 directory;兩者都是 namespace entry 指向某個 mounted file system。