Everything Is a File: Corporate Personhood and Shipping Containers

One of the foundational tenets of UNIX is: "Everything is a file."

Whether you are communicating over a serial port, reading entropy from /dev/urandom, inspecting hardware sensors via /sys, or reading an invoice from an ext4 disk, the operating system forces you through the exact same set of verbs: open(), read(), write(), and close().

To junior engineers, this often looks like an arbitrary quirk of C programming. But it is actually an instance of one of humanity's most powerful scaling patterns: Universal Flattening.

The Problem: The M * N Interface Explosion

Imagine you have M programs (grep, cat, sort, compression tools, text editors) and N hardware or software data sources (magnetic tapes, hard disks, terminals, network pipes, printer ports).

If each data source had its own specialized access protocol:

  • You would need a custom version of grep for tape drives (tape_grep), another for memory buffers (mem_grep), and another for serial ports (serial_grep).
  • The complexity of the ecosystem scales at O(M * N). Every new device requires rewriting every existing tool.

To avoid this combinatorial collapse, systems use interface flattening: inventing an artificial, uniform entity that forces both sides of the market to meet at a single shared boundary O(M + N).

Traditional Bespoke Interfaces (M x N):
Programs ──── (custom protocols) ──── Devices

Universal Flattened Interface (M + N):
Programs ──── [ Standard Stream / File ] ──── Devices

Analogy 1: Corporate Personhood (The Universal Legal Agent)

The Anglo-American legal system faced this exact scaling crisis centuries ago.

The Real-World Dilemma

How can thousands of dispersed shareholders collectively own property, erect factories, hire labor, sign commercial contracts, borrow capital, and pay taxes without the court system tracking the identity and signature of every individual owner? If five thousand people co-own a trading venture, must a counterparty sue all five thousand partners when a shipment goes missing?

The Legal Fiction

The law invented a concept called Corporate Personhood. By legal decree, an abstract nexus of physical factories, contracts, employees, and shareholders is flattened into a single fictitious "Person."

The Structural Parallel

Because a corporation is legally treated as an individual "Person," courts and counterparties do not need bespoke legal rulebooks for every corporate structure:

Real-World Complexity The Flattened Interface Standard Operational Verbs
Multinational conglomerate (factories, supply chains, investors) Legal "Person" Sue(), Contract(), Own(), Fine()
Flesh-and-blood human Legal "Person" Sue(), Contract(), Own(), Fine()

The law deliberately discards internal anatomy in exchange for universal composability.

Analogy 2: Intermodal Shipping Containers (The Universal Cargo)

Before 1956, global freight was handled as break-bulk cargo.

Dockworkers loaded wooden crates of oranges, cloth sacks of grain, metal barrels of rum, and loose timber onto ships one item at a time. Every dock needed specialized cranes, slings, cargo nets, and stevedore crews. Trains could not unload directly onto ships, and trucks could not carry train-sized loads.

In 1956, Malcolm McLean championed the standardized intermodal shipping container (the 20-foot and 40-foot ISO box).

[ Cargo: Bananas / Cars / Microchips ]
               │
      (Encapsulated into)
               ▼
   [ Standard 40ft Steel Box ]  ◄── Twistlocks & Standard Corner Castings
               │
    ┌──────────┼──────────┐
    ▼          ▼          ▼
[ Gantry Crane ] [ Flatbed Truck ] [ Container Ship ]

The cranes, flatbed railcars, trucks, and container ships have zero awareness of what is inside the box. They only interact with eight standard twistlocks at the corners. By flattening all cargo into a uniform dimensional interface, global freight costs plummeted by over 90%, igniting the modern global economy.

The Kernel Reality: The UNIX Virtual File System (VFS)

In Linux, the Virtual File System (VFS) is the shipping container and the legal person of the computing universe.

// The Universal Interface Table: struct file_operations (include/linux/fs.h)
struct file_operations {
    ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
    ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
    int (*open) (struct inode *, struct file *);
    int (*release) (struct inode *, struct file *);
    long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
    // ...
};

Whether you open:

  1. A regular file on a NVMe drive (/home/user/doc.txt)
  2. A pipe connecting two processes (pipe())
  3. A pseudo-file exposing kernel state (/proc/sys/net/ipv4/ip_forward)
  4. A physical character device (/dev/ttyS0 or /dev/urandom)
  5. A GPU acceleration node (/dev/dri/card0)

The operating system hands your process an integer File Descriptor (fd) backed by a struct file. The caller simply invokes:

ssize_t bytes = read(fd, buffer, sizeof(buffer));

The consumer code does not contain a single if (is_disk) ... else if (is_network_socket) ... branch. The dispatch occurs transparently through function pointers in the kernel's file_operations table.

The Leaky Abstraction: Where Flattening Breaks

Every universal abstraction comes with a cost: loss of dimensionality. When an interface is flattened to the lowest common denominator, specialized capabilities have nowhere to go.

  1. The ioctl() Garbage Can: When a device has operations that don't fit into pure read or write (e.g., ejecting a CD-ROM tray, setting a terminal baud rate, or allocating GPU command buffers), UNIX was forced to invent ioctl (I/O Control). It became an untyped, chaotic backdoor where any driver can define arbitrary custom opcodes.
  2. Network Sockets: While BSD sockets give you a file descriptor you can read() and write(), you cannot create or connect one using standard open(). Setting up addresses and network state required separate system calls: socket(), bind(), listen(), connect(), and accept().
  3. The Legal Distortion: Just as ioctl creates strange loopholes in UNIX, corporate personhood creates bizarre legal side effects in human society—such as corporations claiming constitutional protections intended for living humans.

Takeaway

When you see "Everything is a file", do not think of physical documents on a desktop.

Think of an intermodal shipping container: an agreed-upon box with standardized corner latches that allows heterogeneous producers and consumers to build a planetary-scale pipeline without ever speaking to one another.

Loading...