File Systems: The Interface

directory structure

How you organise a thousand files matters as much as how you organise a thousand papers on a desk. Dump them all in one pile and you will never find anything; sort them into labelled drawers and sub-folders and the same thousand papers become manageable. Directory structure is the overall scheme by which a file system arranges its directories and the files inside them, and it has a real history of getting better.

The simplest scheme is the single-level directory: one directory for the entire system, every file in the same place. It is easy to build but hopeless once there are many files or many users, because every name must be unique across everyone, two people cannot both have a file called report. The two-level directory fixes the worst of this by giving each user their own private directory, so names only need to be unique per user; but it still cannot group a single user's many files. The breakthrough is the tree-structured directory: directories can contain other directories without limit, forming the branching tree we all use, with one root at the top. A further refinement, the acyclic-graph directory, relaxes the strict tree so that a single file or directory can be reached by more than one path (genuine sharing), as long as no cycles are created.

Why it matters: directory structure is one of those quiet design choices that shapes daily life on a computer profoundly. The tree is the standard because it scales, supports per-user privacy, and lets related files be grouped naturally. The honest tension in the acyclic-graph design is sharing versus simplicity: allowing multiple paths to one file (via links) is powerful, but it complicates deletion (when is the file really gone?) and risks dangling references, problems a pure tree never has.

An old shared mainframe with a single-level directory forced everyone to invent unique names like alice_report and bob_report. A modern system instead gives /home/alice and /home/bob, and inside each a free tree of folders, so both can simply have report.txt without clashing.

From one flat pile, to per-user drawers, to the nested tree we use today.

The acyclic-graph directory enables true sharing but complicates deletion and risks dangling links, costs a strict tree avoids. This is the interface-level view; how directories are stored on disk is a separate topic.

Also called
directory organization目錄組織