Device file

From Wikipedia, the free encyclopedia

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. This allows software to interact with the device driver using standard input/output system calls, 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. 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.

[edit] Unix special files

Main article: Device node

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.

[edit] MS-DOS device files

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.

Some device files are listed below:

File name Purpose
CON Console device
PRN Printer
AUX Auxiliary device
COM0 COM1 COM2 COM3 COM4 COM5 COM6 COM7 COM8 COM9 Serial ports
LPT1 LPT2 PRN Parallel ports
NUL Bit bucket

Reserved words cannot even be used with extensions, so that file names like "nul.doc" and "con.htm" are invalid. This has been known to confuse some users.

In other languages