File systems

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the unix category.

Last Updated: 2024-11-23

What does a file system (or "fs") do?

It controls how data is stored and retrieved. Without a file system, data placed in a storage medium would be one large body of data with no way to tell where one piece of data stops and the next one begins. By separating the data into pieces and giving each piece a name, the data is easily isolated and identified. Each of these groups of of data is called a "file".

3-Layer Architecture

  1. The logical file system is responsible for interaction with the user application. It provides the API for file operations — OPEN, CLOSE, READ, etc., and passes the requested operation to the layer below it for processing.

  2. The second (optional) layer is the virtual file system (VFS). "This interface allows support for multiple concurrent instances of physical file systems, each of which is called a file system implementation." The purpose of a VFS is to allow client applications to access different types of concrete file systems in a uniform way. A VFS can, for example, be used to access local and network storage devices transparently without the client application noticing the difference.

  3. The third layer is the physical file system. This layer is concerned with the physical operation of the storage device (e.g. disk). It processes physical blocks being read or written. It handles buffering and memory management and is responsible for the physical placement of blocks in specific locations on the storage medium. The physical file system interacts with the device drivers or with the channel to drive the storage device.

File system types on macos

When I ran mount, I saw (amongst other things) the following:

/dev/disk1s5 on / (apfs, local, read-only, journaled)
devfs on /dev (devfs, local, nobrowse)
map auto_home on /System/Volumes/Data/home (autofs, automounted, nobrowse)

What are the differences between these file systems? (apfs, devfs autofs)?

apfs - Apple File System

devfs

In Unix-like operating systems, a device file or special file is an interface to a device driver that appears in a file system as if it were an ordinary file.

These special files allow an application program to interact with a device by using its device driver via standard input/output system calls. Using standard system calls simplifies many programming tasks, and leads to consistent user-space I/O mechanisms regardless of device features and functions

In some Unix-like systems, most device files are managed as part of a virtual file system traditionally mounted at /dev, possibly associated with a controlling daemon, which monitors hardware addition and removal at run time, making corresponding changes to the device file system if that's not automatically done by the kernel, and possibly invoking scripts in system or user space to handle special device needs.

So where does the devfs come in on my mac? Maintaining these special files on a physically implemented file system (i.e. on a hard-drive) is inconvenient, and as it needs kernel assistance anyway, the idea arose for a special-purpose logical file system that is not physically stored.

Resources