Saturday, March 23, 2013

Linux Filesystem

Inode (Information Node) is a physical object on disk as well as a conceptual object in kernel.  Directory acts as a mapping of user-friendly name to inode.  A name and an inode pair is called a link.

Kernel resolve a directory path by walking each directory entry (dentry) in the pathname.  Each dentry will map to a inode allowing the kernel to get to the next level.  A cache called dentry cache is used to speed up resolution.

Hard link map multiple filenames to a same inode.  Hard link cannot cross filesystem as there will be a collision of inode.  Symbolic link (symlink) allows this.  Symbolic link is like a regular file that comprises its own inode and data chunk.  Symlink can point to either directory or link.  It can even points to something nonexisting (called broken link). 

Using hard link is entire transparent.  Manipulating symlink requires special system calls.  Symlink is more like a shortcut than a fulesystem internal links.

No comments: