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.
Function | Description |
---|---|
open | Opens a file for IO |
read | Read contents of a file |
write | Write to a file |
close | Close a file and free associated resources |
chmod | Modify permissions of a file |
ioctl | Interact with device parameters of character devices (example: terminals) |