The hierarchical file system—a directed graph database that is not quite an adirected tree—in which every node is either a container of other nodes that has no content itself (a folder, or directory, or drawer for those lucky enough to work with Amiga Workbench) or a leaf node that has content but no other nodes (a file). To effectively use one of those, you need random-access storage; if you are using a tape you do not bother, you have a single table of contents at the front with offsets to the starts of the various files. If you use punchcards then your filing system is literally the cabinets full of drawers and folders you keep the cards in.
Early examples of such file systems have a single level of structure; you create directories at the top level, and files in those directories (this actually means that there are two levels of directory, because there must be a top-level index to find the directories you create). These have one of two purposes:
- Help a person organise their files in a way that makes it easier to find them.
- Keep multiple people who use a time-sharing system from getting in each others’ way, by giving them separate areas to store their files.
In 1965, someone on the Multics project notices that the laws of physics do not apply to computers, and you can fit a folder inside another folder. The arbitrarily-nested hierarchical file system is born. Now users on Multics and its progeny, Unix, can organise their files, and do so while keeping out of each others’ way! Access control stops any account reading, writing, or deleting another account’s files, unless someone who can change the rules gives that account explicit permission.
Unfortunately, as anybody who ever deleted /vmunix or C:\COMMAND.COM knows, saving user accounts from each other is not the whole story. We also need to save the operating system from the people using the computer. This means a new requirement:
- Keep multiple people who use a time-sharing system from interfering with the operating system, by making operating system files inaccessible from regular accounts.
But because we already shipped the multi-user filesystem and designed the file-access APIs around it, we cannot add this requirement to the model. So we invent a fiction: the operating system is another user account, or a collection of user accounts, that share the filesystem with the actual people who use the computer. So maybe the mail server has its own user account, and the print spool daemon, and so on.
Unfortunately, even this does not solve the problem, because the person who runs the computer needs to be able to configure, patch, and update the operating system. That person then gets access to an account that can work with all the files on the filesystem, starting at the root of the whole hierarchy: call it the root account.
They get that access, but they do not need that access, and indeed they should not have that access, because a person with the root account can violate requirements 2 and 3: they can get in another user’s way, and they can interfere with the operating system. Ideally the filesystem would help with requirement 1 and strictly enforce requirements 2-3, but the user-permissions model does not lend itself to that possibility. So add another layer to the cake: mandatory access controls stop people from fiddling with particular files, even if their user account has discretionary permission to operate on those files.
Unfortunately, computers no longer exist in isolation (nor did they at the time; but we assumed that someone who connected up a tape drive and spooled the contents of the tape into their local installation had a reason for doing so). People download files from the internet, and they download files from the internet that are programs, and they expect to run those programs, and they do not want for one bad (or well-intentioned but poorly coded) program to break the files they use in other programs, or even to read those files unless that is their explicit intent. Time to add a new requirement:
- Keep the documents that a person creates using a computer private and intact, even when that person runs arbitrary software.
Mandatory access control no longer cuts it; now the filesystem needs a dynamic level of protection, in which files created by different processes are maybe usable from other processes run by the same user account, but maybe not. It depends on what those processes are, and what the files are, too. And where the files came from, and whether the person using the computer intended to get the file, or whether the process they ran just sorta created it for them without telling them. And also, those processes want to keep their own files, to cache downloads, to store the working set from complex computations, to save configuration options, and for whatever purposes.
- Keep the files that arbitrary software creates private and intact, even when a person uses that or other arbitrary software.
Oh, and by the way, while all of that is going on, there are now so many files that even requirement 1 is long forgotten. People cannot remember whether that important report due tomorrow is in their Desktop folder, or in Desktop/Desktop.old, or in Desktop/Desktop.old/from_dell, or in their Documents folder, or in some unique folder that is managed by whichever app it is they use to edit the file.
- Help a person to find documents in a labyrinthine structure of folders that they do not understand.
…it is always possible that they accidentally deleted the file they need, or that they kept the file but deleted a critical section of the report that, on reflection, they realised the audience is actually going to care about.
- Help a person to browse and restore previous versions of a file, and deleted files.
…or maybe they were just saving the file as the battery on their laptop finally discharged?
- Provide resilience to common hardware failures that lead to incorrectly or partially committed filesystem changes.
…or, no, wait, I remember, the correct version of the report is on my desktop, I have been editing the version on my laptop, I will get that other version once it syncs via my cloud provider.
- (to a high number, probably around 94). Act as a cache to a remote file storage system; maintain most recently-used files locally while still evicting files as needed to make space for other files a person requests; resolve version conflicts when the remote version and the local version both have changes since the last sync point; resolve conflicts when one version has changes and the other version is deleted; retain confidentiality and integrity over the remote sync interface…
And we need to go back and redefine the idea of “users of a time-sharing system” that we mentioned in requirements 2-3, and invented in about 1965. You see, those time-sharing systems have changed somewhat. Some are little portable devices, so the person whose “account” is “logged in” gives them to a passing acquaintance to share a fun meme they saw. Some are big wall-mounted devices, so the person is using the system alongside six other people who can all see and interact with it.
But yeah, sure, I guess it is neat that the last time we improved the file system was ZFS circa 2005, and that the other file systems are still catching up.
Photo by Jack Krzysik on Unsplash.