In Unix-like A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification operating systems An operating system is the software on a computer that manages the way different programs use its hardware, and regulates the ways that a user controls the computer. Operating systems are found on almost any device that contains a computer with multiple programs—from cellular phones and video game consoles to supercomputers and web servers. Some, a device file or special file is an interface An interface in computer science refers to a set of named operations that can be invoked by clients. Interface generally refers to an abstraction that an entity provides of itself to the outside. This separates the methods of external communication from internal operation , and allows it to be internally modified without affecting the way outside for a device driver In computing, a device driver or software driver is a computer program allowing higher-level computer programs to interact with a hardware device that appears in a file system A file system is a method of storing and organizing computer files and their data. Essentially, it organizes these files into a database for the storage, organization, manipulation, and retrieval by the computer's operating system as if it were an ordinary file A computer file is a block of arbitrary information, or resource for storing information, which is available to a computer program and is usually based on some kind of durable storage. A file is durable in the sense that it remains available for programs to use after the current program has finished. Computer files can be considered as the modern. There are also special device files in MS-DOS MS-DOS is an operating system for x86-based personal computers, which was purchased by Microsoft. It was the most commonly used member of the DOS family of operating systems, and was the main operating system for personal computers during the 1980s up to mid 1990s. It was preceded by M-DOS (also called MIDAS), designed and copyrighted by Microsoft and Microsoft Windows Microsoft Windows is a series of software operating systems and graphical user interfaces produced by Microsoft. Microsoft first introduced an operating environment named Windows in November 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal. They allow software to interact with a device driver using standard input/output In computing, input/output, or I/O, refers to the communication between an information processing system , and the outside world possibly a human, or another information processing system. Inputs are the signals or data received by the system, and outputs are the signals or data sent from it. The term can also be used as part of an action; to & system calls In computing, a system call is the mechanism used by an application program to request service from the operating system based on the monolithic kernel or to system servers on operating systems based on the microkernel-structure, which simplifies many tasks.

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 Disk partitioning is the act or practice of dividing the storage space of a hard disk drive into separate data areas known as partitions. A partition editor program can be used to create, delete or modify these partitions. Once a disk is divided into several partitions, directories and files of different categories may be stored in different. Finally, device files are useful for accessing system resources A resource, or system resource, is any physical or virtual component of limited availability within a computer system. Every device connected to a computer system is a resource. Every internal system component is a resource. Virtual system resources include files, network connections and memory areas that have no connection with any actual device such as data sinks and random number generators A random number generator is a computational or physical device designed to generate a sequence of numbers or symbols that lack any pattern, i.e. appear random. Hardware-based systems for random number generation are widely used, but often fall short of this goal, though they may meet some of the statistical tests for randomness intended to ensure.

MS-DOS MS-DOS is an operating system for x86-based personal computers, which was purchased by Microsoft. It was the most commonly used member of the DOS family of operating systems, and was the main operating system for personal computers during the 1980s up to mid 1990s. It was preceded by M-DOS (also called MIDAS), designed and copyrighted by Microsoft borrowed the concept of special files from Unix, but renamed them device files. Because early versions of MS-DOS did not support a directory Folder, directory, catalog, or drawer, in computing, is a virtual container within a digital file system, in which groups of computer files and other folders can be kept and organized 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 computing, a command is a directive to a computer program acting as an interpreter of some kind, in order to perform a specific task. Most commonly a command is a directive to some kind of command line interface, such as a shell in CP/M CP/M is an operating system originally created for Intel 8080/85 based microcomputers by Gary Kildall of Digital Research, Inc. Initially confined to single-tasking on 8-bit processors and no more than 64 kilobytes of memory, later versions of CP/M added multi-user variations, and were migrated to 16-bit processors.

There are two general kinds of device files 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 In computing, a named pipe is an extension to the traditional pipe concept on Unix and Unix-like systems, and is one of the methods of inter-process communication. Mac OS calls it a socket, which should not be confused with a TCP socket. The concept is also found in Microsoft Windows, although the semantics differ substantially. A traditional pipe, which are not connected to a device but are not ordinary files either.

Contents

Implementation

By definition, device nodes correspond to resources that an operating-system kernel In computing, the kernel is the central component of most computer operating systems; it is a bridge between applications and the actual data processing done at the hardware level. The kernel's responsibilities include managing the system's resources . Usually as a basic component of an operating system, a kernel can provide the lowest-level 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 A node is an abstract basic unit used to build linked data structures such as trees, linked lists, and computer-based representations of graphs. Each node contains some data and possibly links to other nodes. Links between nodes are often implemented by pointers or references. The assignment of these numbers occurs uniquely in different operating systems An operating system is the software on a computer that manages the way different programs use its hardware, and regulates the ways that a user controls the computer. Operating systems are found on almost any device that contains a computer with multiple programs—from cellular phones and video game consoles to supercomputers and web servers. Some and on different computer platforms In computing, a platform describes some sort of hardware architecture or software framework , that allows software to run. Typical platforms include a computer's architecture, operating system, programming languages and related runtime libraries or graphical user interface. 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. In presence of dynamic number allocation however, this may not be the case (e.g. on FreeBSD 5 and up).

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: character devices and block 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 In computer science, a byte stream is a bit stream, in which data bits are grouped into units, called bytes with devices such as mice, keyboards, virtual terminals, and serial modems A modem is a device that modulates an analog carrier signal to encode digital information, and also demodulates such a carrier signal to decode the transmitted information. The goal is to produce a signal that can be transmitted easily and decoded to reproduce the original digital data. Modems can be used over any means of transmitting analog, and usually do not support random access In computer science, random access is the ability to access an arbitrary element of a sequence in equal time. The opposite is sequential access, where a remote element takes longer time to access. A typical illustration of this distinction is to compare an ancient scroll (sequential; all material prior to the data needed must be unrolled) and the to data.

In most implementations, character devices use unbuffered In computing, a buffer is a region of memory used to temporarily hold data while it is being moved from one place to another. Typically, the data is stored in a buffer as it is retrieved from an input device or just before it is sent to an output device (such as a printer). However, a buffer may be used when moving data between processes within a 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 In computing , a block is a sequence of bytes or bits, having a nominal length (a block size). Data thus structured are said to be blocked. The process of putting data into blocks is called blocking. Blocking is used to facilitate the handling of the data-stream by the computer program receiving the data. Blocked data are normally read a whole. These device nodes often represent addressable devices such as hard disks Host adapter of system, in PCs typically integrated into motherboard. via one of:, CD-ROM CD-ROM is a pre-pressed compact disc that contains data accessible to, but not writable by, a computer for data storage and music playback, the 1985 “Yellow Book” standard developed by Sony and Philips adapted the format to hold any form of binary data drives, or memory-regions Computer data storage, often called storage or memory, refers to computer components, devices, and recording media that retain digital data used for computing for some interval of time. Computer data storage provides one of the core functions of the modern computer, that of information retention. It is one of the fundamental components of all.

Block devices often support random access and seeking Seek time is one of the three delays associated with reading or writing data on a computer's disk drive, and somewhat similar for CD or DVD drives. The others are rotational delay and transfer time. In order to read or write data in a particular place on the disk, the read/write head of the disk needs to be physically moved to the correct place, and generally use buffered In computing, a buffer is a region of memory used to temporarily hold data while it is being moved from one place to another. Typically, the data is stored in a buffer as it is retrieved from an input device or just before it is sent to an output device (such as a printer). However, a buffer may be used when moving data between processes within a input and output routines. The operating system allocates a data buffer In computing, a buffer is a region of memory used to temporarily hold data while it is being moved from one place to another. Typically, the data is stored in a buffer as it is retrieved from an input device or just before it is sent to an output device (such as a printer). However, a buffer may be used when moving data between processes within a 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/zero
Produces a continuous stream of NUL The null character is a character with the value zero, present in the ASCII and Unicode character sets, and available in nearly all mainstream programming languages (zero value) bytes.
/dev/random
Produces a variable-length stream of pseudo-random A pseudorandom process is a process that appears to be random but it is not. Pseudorandom sequences typically exhibit statistical randomness while being generated by an entirely deterministic causal process. Such a process is easier to produce than a genuine random one, and has the benefit that it can be used again and again to produce exactly the or truly random A random number generator is a computational or physical device designed to generate a sequence of numbers or symbols that lack any pattern, i.e. appear random. Hardware-based systems for random number generation are widely used, but often fall short of this goal, though they may meet some of the statistical tests for randomness intended to ensure numbers. (Blocking)
/dev/urandom
Produces a variable-length stream of pseudo-random A pseudorandom process is a process that appears to be random but it is not. Pseudorandom sequences typically exhibit statistical randomness while being generated by an entirely deterministic causal process. Such a process is easier to produce than a genuine random one, and has the benefit that it can be used again and again to produce exactly the numbers. (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 Rename is a word meaning change the name of something. Different areas, such as linguistics, relational algebra, and computer science incur renaming actions with different detailed activity, however the principles behind are all the same — change the name of something, unlink) and commands (mv mv is a Unix command that moves one or more files or directories from one place to another. The original filename or directory name is no longer accessible. The new filename may be same in another directory and/or a different filename. When the original and new files are on the same file system, mv will rename the file instead. Write permission is, rm rm is one of several basic Unix command lines that operates on files and directories. It is used to delete files and directories from a filesystem. The command does not actually destroy data. Rather, the file system is told to forget where the file is located, and the actual disk location may be overwritten by a new file. There are undelete). When passed the option -R or -a while copying a device node, the cp cp is a UNIX command used to copy a file from one directory to another, possibly on a different filesystem or disk. The original file remains unchanged, and the new file may have the same or a different name 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. It only makes sense on systems whose are statically assigned major numbers (e.g. by means of hardcoding it in their kernel module).

Naming conventions

The following prefixes have come into common use in GNU systems based on Linux kernel, to identify device drivers in the /dev hierarchy:

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.

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. There are pros and cons for a kernel-managed devfs vs. a userspace-managed /dev directory (e.g. via udev).

Pros:

Cons[1]:

Implementations

Operating System Filesystem or managing software Standard mount point Author Notes
Linux 2.3.46pre5–2.6.17 devfs /dev Richard Gooch Implemented fully in the kernel. DEPRECATED: Users are encouraged to migrate to udev.
Linux 2.6.15– udev on any fs, but usually tmpfs /dev Greg Kroah-Hartman, Kay Sievers and Dan Stekloff Implemented largely in user space, device information is gathered from sysfs. Device files can be stored on a conventional general-purpose file system, or in a memory file system (tmpfs).
Linux 2.6.32– devtmpfs with or without udev /dev Kay Sievers, Jan Blunck, Greg Kroah-Hartman A hybrid kernel/userspace approach of a device filesystem to provide nodes before udev runs for the first time[2]
Solaris /dev Sun Microsystems
FreeBSD 2.0– devfs /dev Poul-Henning Kamp Implemented fully in the kernel.
DragonFly BSD 2.3.2- devfs /dev Alex Hornung Implemented fully in the kernel.
Mac OS X devfs /dev ? Implemented fully in the kernel.
HP-UX B.11.31 devfs /dev/deviceFileSystem HP Implemented fully in the kernel.
Plan 9 # Bell Labs Implemented in kernel. Cannot be mounted elsewhere or unmounted.
Windows 9x \\devices\ Microsoft

Device files

A device file is a reserved keyword used in MS-DOS and MS-DOS–based systems to allow access to certain ports and devices.

MS-DOS uses device files for access to printers and ports. Most versions of windows also contain this support, which can cause confusion when trying to make files and folders of certain names, as they cannot have these names.[3] A common misconception is that these are bugs which Microsoft has failed to fix.

Device keyword[3] Use as input Use as output
CON Receives typed data until ^Z (Ctrl-Z) is pressed. Prints data to the console.
PRN N/A Prints text to the printer.
AUX Reads data from an auxiliary device, usually a serial port. Sends data to an auxiliary device, usually a serial port.
NUL Returns null or no data. Discards received data.
CLOCK$ Returns system real-time clock. N/A
LPT1 (also 2–9) Reads data from the selected parallel port Sends data to the selected parallel port
COM1 (also 2–9) Reads data from the selected serial port Sends data to the selected serial port

Using pipes, data can be sent to or received from a device. For example, typing 'type c:\data.txt > PRN' will send the file c:\data.txt to the printer, although this may not work on all systems or printers.

Further reading

See also

References

  1. ^ http://www.kroah.com/linux/talks/ols_2003_udev_paper/Reprint-Kroah-Hartman-OLS2003.pdf
  2. ^ http://lwn.net/Articles/345480/ , retrieved August 10, 2009
  3. ^ a b "MS-DOS Device Driver Names Cannot be Used as File Names". Microsoft. 2003-05-12. http://support.microsoft.com/kb/74496. Retrieved 2008-05-01.

External links

Categories: Special purpose file systems | Device file

 

The above information uses material from Wikipedia and is licensed under the GNU Free Documentation License.
Some facts may not have been fully verified for accuracy. [Disclaimers]
This page was last archived by our server on Sun Aug 1 05:32:34 2010. [ refresh local cache ]
Displaying this page or its contents does not use any Wikimedia Foundation's resources.
The owners of this site proudly support the Wikimedia Foundation.