Device file system

Device file system

In Unix-like operating systems, a device file system or special file system allows software to interact with a device driver using standard input/output system calls, which simplifies many tasks.

It includes "device files", "device nodes", or "device special files" which are interfaces for a device driver that appears in a file system as if it were an ordinary file. There are also special device files on Microsoft operating systems, such as MS-DOS and Windows.

Device files often provide simple interfaces to peripheral devices, such as printers. But they can also be used to access specific resources on those devices, such as disk partitions. Finally, device files are useful for accessing system resources that have no connection with any actual device such as data sinks and random number generators.

MS-DOS borrowed the concept of special files from Unix, but renamed them "device files". Because early versions of MS-DOS did not support a directory hierarchy, device files were distinguished from regular files by making their names reserved words. This means that certain file names are reserved for device files, and cannot be used to name new files or directories.The reserved names themselves are chosen to be compatible with "special files" handling of PIP command in CP/M.

There are two general kinds of device nodes in Unix-like operating systems, known as "character special files" and "block special files". The difference between them lies in how data written to them and read from them is processed by the operating system and hardware. These together can be called device special files in contrast to named pipes, which are not connected to a device but are not ordinary files either.

Implementation

By definition, device nodes correspond to resources that an operating-system kernel has already allocated. Unix identified those resources by a "major number" and a "minor number", both stored as part of the structure of a node. The assignment of these numbers occurs uniquely in different operating systems and on different computer platforms. Generally, the major number identifies the device driver and the minor number identifies a particular device (possibly out of many) that the driver controls: in this case the system may pass the minor number to a driver as an argument.

As with other special file types, the computer system accesses device nodes using standard system calls and treats them like regular computer files. Two standard types of device files exist, differentiated by the type of hardware with which they interface and the way the operating system processes input and output operations.

Devices

Character devices

"Character special files" or "character devices" relate to devices through which the system transmits data one character at a time. These device nodes often serve for stream communication with devices such as teletype machines, virtual terminals, and serial modems, and usually do not support random access to data.

In most implementations, character devices use unbuffered input and output routines. The system reads each character from the device immediately or writes each character to the device immediately.

Block devices

"Block special files" or "block devices" correspond to devices through which the system moves data in the form of blocks. These device nodes often represent addressable devices such as hard disks, CD-ROM drives, or memory-regions.

Block devices often support random access and seeking, and generally use buffered input and output routines. The operating system allocates a data buffer to hold a single block each for input and output. When a program sends a request to read data from or to write data to the device, the system stores each character of that data in the appropriate buffer. When the buffer fills up, the appropriate operation takes place (data transfer) and the system clears the buffer.

Pseudo-devices

Device nodes on Unix-like systems do not necessarily have to correspond to physical devices. Nodes that lack this correspondence form the group of "pseudo-devices". They provide various functions handled by the operating system. Some of the most commonly-used (character-based) pseudo-devices include:

;/dev/null:Accepts and discards all input; produces no output.;/dev/full:Always full device.;/dev/loop: loopback disk device;/dev/zero:Produces a continuous stream of NUL (zero value) characters.;/dev/random:Produces a variable-length stream of pseudo-random characters. (Blocking);/dev/urandom:Produces a variable-length stream of pseudo-random characters. (Non-Blocking)

Node creation

Nodes are created by the mknod system call. The command-line program for creating nodes has the same name. Nodes can be moved or deleted by the usual filesystem system calls (rename, unlink) and commands (mv, rm). When passed the option -R or -a while copying a device node, the cp command creates a new device node with the same attributes of the original.

Some Unix versions include a script named makedev to create all necessary devices in the directory /dev.

Naming conventions

The following prefixes have come into common use in Linux-based systems, to identify device nodes generically in the /dev hierarchy: [Compare for example http://www.yiluda.net/manual/linux/rute/node21.html, retrieved 2007-09-04]
* fd: floppy disks
* hd: IDE hard disks
* lp: printers (compare lp)
* par: parallel ports
* pt: pseudo-terminals (virtual terminals)
* s: SCSI devices in general, notably hard disks (but also SATA and USB disks)
** scd: SCSI audio-oriented optical disc drives
** sd: SCSI hard disks (also SATA or USB disks)
** sg: SCSI generic devices
** sr: SCSI data-oriented optical disc drives
** st: SCSI magnetic tapes
* tty: (physical) terminals
** ttyS: serial ports

For most devices, this prefix is followed by a number uniquely identifying the particular device. For hard drives, a letter is used to identify devices and is followed by a number to identify partitions. Thus a file system may "know" an area on a disk as /dev/sda3, for example, or "see" a networked terminal session as associated with /dev/pts/14.

Some Linux distributions use the SCSI layer to access all fixed disks, so that they are made accessible via sd devices even if technically they are not SCSI. [ [http://ubuntuforums.org/archive/index.php/t-518221.html IDE hard disk seen as SCSI [Archive - Ubuntu Forums ] ]

devfs

"devfs" is a specific implementation of a device file system on Unix-like operating systems, used for presenting device files, an abstraction for accessing I/O and other peripherals. The underlying mechanism of implementation may vary, depending on the OS.

Maintaining these special files on a general-purpose file system is inconvenient, and as it needs kernel assistance anyway, the idea of a special-purpose file system that is not stored on disk arose.

Also defining when devices are ready to appear is not entirely trivial. The 'devfs' approach is for the device driver to request synchronously creation and deletion of 'devfs' entries related to the devices it enables and disables, and this makes it much simpler and with easier to understand semantics than systems like udev that have complicated asynchronous notifications.

Another advantage is that unlike udev it does not require any user-space daemon, thus making for a simpler and quicker boot, it does support one to allow user-space actions on device file creation and deletion.

Implementations

Device files

Some device files for DOS- and Windows-based operating systems are listed below:

Further reading

*
*
*
*
*
*
*
*
*
*
*

ee also

* Sysfs
* Block size
* Blocking
* Buffer
* File system
* Hardware abstraction
* User space
* Unix file types
* udev

References

External links

* http://www.atnf.csiro.au/people/rgooch/linux/docs/devfs.html - FAQ about Linux devfs


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • File system — For library and office filing systems, see Library classification. Further information: Filing cabinet A file system (or filesystem) is a means to organize data expected to be retained after a program terminates by providing procedures to store,… …   Wikipedia

  • Device file — In Unix like operating systems, a device file or special file is an interface for a device driver that appears in a file system as if it were an ordinary file. There are also special device files in MS DOS and Microsoft Windows. They allow… …   Wikipedia

  • File System — Système de fichiers Pour les articles homonymes, voir FS et SGF. Un système de fichiers (file system ou filesystem en anglais) ou système de gestion de fichiers (SGF) est une structure de données permettant de stocker les informations et de les… …   Wikipédia en Français

  • File system — Système de fichiers Pour les articles homonymes, voir FS et SGF. Un système de fichiers (file system ou filesystem en anglais) ou système de gestion de fichiers (SGF) est une structure de données permettant de stocker les informations et de les… …   Wikipédia en Français

  • Encrypting File System — The Encrypting File System (EFS) on Microsoft Windows is a feature introduced in version 3.0 of NTFS[1] that provides filesystem level encryption. The technology enables files to be transparently encrypted to protect confidential data from… …   Wikipedia

  • Journaling file system — For the IBM Journaled File System, see JFS (file system). A journaling file system is a file system that keeps track of the changes that will be made in a journal (usually a circular log in a dedicated area of the file system) before committing… …   Wikipedia

  • Professional File System — The Professional File System is a filesystem originally developed commercially for the Amiga. It tends to perform very well, due to the simplicity of design.The device is split into two main areas. At the beginning of the device is the metadata… …   Wikipedia

  • Veritas File System — For other uses, see Veritas (disambiguation). VERITAS File System Full name VERITAS File System Introduced 1991 Structures Directory contents extensible hash Limits Max file size 8 EB ( …   Wikipedia

  • MINIX file system — Developer Open Source Community Full name MINIX file system version 3 Introduced 1987 (MINIX 1.0) Partition identifier 0x81 (MBR) Features Dates recorded …   Wikipedia

  • Clustered file system — A clustered file system is a file system which is shared by being simultaneously mounted on multiple servers. There are several approaches to clustering, most of which do not employ a clustered file system. While many computer clusters don t use… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”