The index nodes contain meta data and points to where the actual data is. But how does the system know where in the directory tree the file or folder is, and how does it translate the filename into an i-node?

An explanation from the file systems point-of-view of the process that happens when I request the file /folder/directory/filename would be much appreciated.


A directory is technically just a file containing file names, their inode numbers, and attributes. In BSD and Plan9, you can even read it like a file. (Although on modern filesystems the on-disk format is some kind of a binary tree, not a sequential list.)

The basic process (for Unix-like paths) is:

  1. Split the given path into components separated by /
  2. The location of / is already known by the kernel.
  3. Scan the directory / looking for an item named "folder". Get the associated inode number.
    • If /folder is not a directory (or a symlink pointing to a directory), return ENOTDIR.
  4. Scan the directory /folder looking for an item named "directory". Get inode number, read inode, find data.
  5. Scan the directory /folder/directory looking for an item named "filename" and get the associated inode number.
  6. Read the inode and get the file's metadata, permission bits, data location, etc.

Note: /, /folder, and /folder/directory can be mount-points for completely separate filesystems. A common configuration is to have one partition for / and another for /home. (This also applies to non-Unix systems, such as Windows NT.) The process above should list lookups in the kernel's mount table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.