Brain Dump

Everything is a File

Tags
comp-arch

You may have encountered the old UNIX adage: Everything is a File. This describes the fact that in most UNIX systems file operations provide an interface to abstract many different operations. Network sockets, hardware devices, objects on the disk, etc. are all represented by file like objects.

The File API

A file like object must follow the following conventions:

  • It must present itself to the file system.
  • It must support common file-system operations such as open, read, write. At a minimum it must be opened and closed.

A file system is simply an implementation of this interface.

Table 1: List of file related functions a file-system should provide callbacks for (see more at fuse).
FunctionDescription
openOpens a file for IO
readRead contents of a file
writeWrite to a file
closeClose a file and free associated resources
chmodModify permissions of a file
ioctlInteract with device parameters of character devices (example: terminals)