Filesystems
A file name is not the file bytes. Directories resolve names to inode metadata, allocation maps logical offsets to blocks, and caches delay storage work. We will follow descriptors, links, allocation, page cache and journaling before returning to the server trace.
#Section 36Filesystems and path lookup
A path lookup starts with a directory entry that maps a name to an inode number. The lookup reaches filesystem metadata that identifies the object and its data blocks. Directories associate names with object identities, so the same object can have several names.
The distinction lets unlink remove a name while open descriptors still refer to the underlying object. The data and inode can be reclaimed only when no directory link and no open reference remains. File types include regular files, directories, sockets, pipes and symbolic links, each with different operations.
Directory traversal checks each component under the filesystem’s lookup and permission rules. The final inode describes a regular file, directory or another supported object; its block references identify the stored data for that object. Renaming changes a directory relationship rather than copying every data byte to a new inode. Keeping names separate from identity is what makes open references meaningful across a rename.
Descriptors provide a common handle interface, not common persistence semantics. A log involves filesystem storage; a socket involves transport queues; a pipe has a kernel buffer.
#Section 37File descriptors
open returns a small integer index in the process’s descriptor table. Descriptor 0 is standard input, 1 standard output and 2 standard error by convention. A new file or socket can occupy descriptor 3. The descriptor refers to kernel open-file state, which includes access mode and current offset where relevant.
Sockets, pipes, terminals and regular files therefore share a handle shape even though their readiness and storage behavior differ. A forked child inherits descriptor references, and a shell uses that fact to connect pipeline endpoints. A close-on-exec flag prevents accidental inheritance into a replaced program.
The integer is local to a process, so descriptor 3 in another process can name a different resource. Duplicating a descriptor can create another reference to the same open-file description, and inherited references after fork can share its current offset. Closing one reference does not automatically close the object while other references remain. This distinction matters for shell pipes and concurrent file access.
Listeners, logs, and event handles consume the descriptor budget too. A recycled integer can name a different object, so delayed callbacks must preserve connection identity.
#Section 38Inodes, hard links and symbolic links
Inodes
An inode stores file type, permissions, owner, size, timestamps, link count and references to data blocks. It usually does not store the filename. The directory owns the name-to-inode mapping, which is why one inode can have several names.
Hard links and symbolic links
A hard link is another directory entry for the same inode. Removing the original name does not remove the data while another hard link or open reference remains. A symbolic link is a separate file containing a path, so it can become dangling if the target name disappears or moves.
Hard links normally cannot cross filesystem boundaries because the inode belongs to one filesystem. Symbolic links can point across such boundaries because they store a path. Relative symbolic links resolve relative to the link’s directory, which makes moving the containing tree part of the correctness analysis.
A hard link names the same object. A symbolic link resolves another path, which can later refer to a replacement. Identical initial reads do not imply identical rename or deletion behavior.
Unlinking the last name does not reclaim bytes while an open reference remains. Deleted logs can therefore occupy storage until closure. Diagnose path identity and open lifetime separately.
#Section 39Allocation, cache and journaling
Filesystems allocate blocks with contiguous, linked or indexed strategies. Inode-based allocation uses metadata references to locate file ranges, while free-space structures track available blocks. Contiguous extents help sequential access but can fragment as files grow.
The page cache keeps file data in RAM and marks changed pages dirty. A write returning to an application does not automatically mean the storage device has durable bytes. A filesystem journal records metadata intent and ordering so crash recovery can restore a consistent filesystem state. Database WAL solves a related durability problem at another layer.
Allocation and page cache
Linked allocation follows each block to the next and makes random lookup expensive. Indexed allocation uses a lookup structure so an offset can identify its block more directly. Contiguous allocation and extents improve sequential placement but need a policy for growth and free-space fragmentation. The physical layout is independent of whether application bytes currently reside in the page cache.
Journaling and persistence
Buffered writes may only dirty cache. Persistence needs the promised synchronization boundary; journaling preserves its declared scope, not every application byte or the database’s transaction invariant.