Special file is used in two ways. The looser way refers to anything that is not a plain file, and includes directories, sockets, named pipes and symbolic links, as well as the deviecs described by the more exacting definition.

A special file informs the operating system about the location of the device it's associated with and the means by which it can communicate with the device.

Special files are created with the mknod command and are stored in /dev (also /devices for SunOS 5.X).

Once a special file exists I/O is performed with the device simply by reading or writing to the associated file.

All I/O devices are classified as either block or character (raw) devices. The block special device causes the I/O to be buffered in large pieces. The character (raw) device causes I/O to occur one character (byte) at a time. Some devices, such as disks and tapes, can be both block and character devices, and must have entries for each mode. Terminals operate in character mode. The first entry in the permission field indicates either b-->block, or c-->character.

In Perl there are various file test operators to see if a file is special. Under the more exacting definition, the are -b and -c which return true if a file is a blocm special file or character special file, respectively.

For the looser definition, there is -f which tells you when a file is in no way special. Use -d to look for a directory, -S for a socket, -p for a named pipe and -l for a symbolic link.

Log in or register to write something here or to contact authors.