Plan9: Everything is (Really) a File

Apr 10, 2022
Plan 9 from Bell Labs is like the Quakers: distinguished by its stress on the 'Inner Light,' noted for simplicity of life, in particular for plainness of speech. Like the Quakers, Plan 9 does not proselytize.

—Sape J. Mullender, Pierre G. Jansen
Real Time in a Real Operating System

One defining trait of Unix is that, in principle, everything is a file1. This simplicity in design means that the same tools and APIs can be used for all sorts of things – managing physical devices like keyboards and mice (devfs), accessing kernel and process information (procfs), and of course, your run-of-the-mill regular files. Yet, as the surface area grew, syscalls and other APIs grew into implementations.

Plan9 is one implementation that tried to generalize the Unix principle of "everything as a file" to everything, including things like computing and network resources. It was designed at Bell Labs by Ken Thompson (Unix, B, UTF-8, grep, and Go) and Rob Pike (Unix, UTF-8, Go), and others who worked on Unix. The OS has two design philosophies: (1) a simple messaging-oriented file system protocol (9P) and (2) a per-process name space.

Maybe most important, Plan9 aimed for simplicity. This simplicity meant that the implementation only needed to target the file system protocol (9P) to be compatible. You could implement a higher-level behavior like NAT overlays by simply overlaying the /net directory.

Simple protocols do not always have simple implementations but often do. For example, plan 9's 9P filesystem protocol could be implemented relatively easily relative to other filesystems. This simplicity made 9P find itself in many different use cases – mostly in embedded situations (KVM/QEMU, and one of the projects I worked on, minikube, uses it).

1Everything is technically a file descriptor

Subscribe for daily posts on startups & engineering.