Everything is a file

from Wikipedia, the free encyclopedia

Everything is a file ( english for Everything is a file ) describes one of the defining features of UNIX and its derivatives , thus I / O resources such as files, directories, devices (such as hard drives, keyboards, printers.) And even interprocess - and network connections as simple byte streams via file system are available.

The advantage of this approach is that the same tools and programming interfaces can be used to access all of these resources. When a file is opened, the program receives a file descriptor from the kernel . This serves as an input / output interface for all subsequent operations. Since file descriptors are also created for anonymous pipes and network sockets , but these have no path, the principle is often also Everything is a file descriptor ('Everything is a file descriptor') or, according to Linus Torvalds , Everything is a stream of bytes ('Everything is a byte stream ').

In addition, there are a number of virtual file systems and pseudo file systems that make information about the system status and processes available in a hierarchically structured manner.

The term is consistently used as a catchphrase for the uniqueness of Unix systems in dealing with files. However, it is not sharply delineated and, as indicated above, aims at different aspects depending on its use. While the above-mentioned properties can only be found today in Unix-like operating systems and are widely associated with everything is a file , Unix also introduced innovations that are now ubiquitous. The following sections deal with the aspects in detail.

Directory structure as a namespace

The directory structure is a uniform, hierarchically structured namespace through which a file receives a path under whose name it is available. A directory is a special file that lists all directory entries it contains. This can include both files and directories. This resulting directory hierarchy can extend over different devices. The file system was already included in this form in Multics , a forerunner of Unix. Such directory structures are now widespread, albeit with certain deviations. For example, they are not uniform in MS-DOS and Windows : Paths also contain a device-specific drive letter .

The namespace is also used by named pipes and serves as the basis for the widespread System V - IPC interface, in which existing files act as a meeting point for two processes. The POSIX analog, POSIX-IPC names, are not based on files.

Secondary storage and files

Another reading of the principle, which is no longer widespread today, relates to the innovation that files under UNIX consist of a simple sequence of bytes and, moreover, are not subject to any restrictions in their format (in contrast to data record-oriented file systems that were widespread at the time ). The aim was to level device specifics, to abstract them from the memory organization and to leave as many decisions as possible to the user space :

“[…] The UNIX kernel does not support file access methods, file disposition, file formats, file maximum size, spooling, command language, logical records, physical records, assignment of logical file names, logical file names, more than one character set , an operator's console, an operator, log-in, or log-out. Many of these things are symptoms rather than features. Many of these things are implemented in user software using the kernel as a tool. "

This understanding of files is taken for granted today and can be found in most mainstream operating systems.

equipment

Dennis Ritchie claims that the idea of making devices available via files came from Dennis Ritchie .

See also

Individual evidence

  1. Machtelt Garrels: Introduction to Linux. A beginner's guide . 2nd Edition. Fultus, 2007, ISBN 1-59682-112-4 , section 3.1.1.1.
  2. Linus Torvalds: signalfd v2 - signalfd core . Retrieved January 17, 2013.
  3. ^ RC Daley, Peter G. Neumann: A General-Purpose File System For Secondary Storage. In: AFIPS '65 (case, part I). Las Vegas 1965, pp. 213-229 ( online ).
  4. See ftok () library function
  5. Marc J. Roch child: Advanced UNIX Programming. 2nd edition, Addison-Wesley, 2004, chapter 7.6.2.
  6. ^ A b Brian W. Kernighan , Rob Pike : The UNIX Programming Environment. Prentice Hall, 1984, chapter 2.
  7. Ken Thompson: UNIX Implementation. In: Bell System Technical. 1978, Issue 57, pp. 1931-1946.
  8. ^ Dennis Ritchie: The Evolution of the Unix Time-sharing System. In: Language Design and Programming Methodology. 25-35, Springer, Berlin / Heidelberg 1980, ( online ).