Skip to Content
UNIX Filesystems: Evolution, Design, and Implementation
book

UNIX Filesystems: Evolution, Design, and Implementation

by Steve D. Pate
January 2003
Intermediate to advanced content levelIntermediate to advanced
480 pages
13h 22m
English
Wiley
Content preview from UNIX Filesystems: Evolution, Design, and Implementation

Special Files

A special file is a file that has no associated storage but can be used to gain access to a device. The goal here is to be able to access a device using the same mechanisms by which regular files and directories can be accessed. Thus, callers are able to invoke open(), read(), and write() in the same way that these system calls can be used on regular files.

One noticeable difference between special files and other file types can be seen by issuing an ls command as follows:

$ ls -l /dev/vx/*dsk/homedg/h
brw------  1 root  root  142,4002 Jun 5  1999  /dev/vx/dsk/homedg/h
crw------  1 root  root  142,4002 Dec 5  21:48 /dev/vx/rdsk/homedg/h

In this example there are two device files denoted by the b and c as the first character displayed on each line. This letter indicates the type of device that this file represents. Block devices are represented by the letter b while character devices are represented by the letter c. For block devices, data is accessed in fixed-size blocks while for character devices data can be accessed in multiple different sized blocks ranging from a single character upwards.

Device special files are created with the mknod command as follows:

mknod name b major minor
mknod name c major minor

For example, to create the above two files, execute the following commands:

# mknod /dev/vx/dsk/homedg/h b 142 4002
# mknod /dev/vx/rdsk/homedg/h c 142 4002

The major number is used to point to the device driver that controls the device, while the minor number is ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Design and Implementation of the FreeBSD Operating System, 2nd Edition

Design and Implementation of the FreeBSD Operating System, 2nd Edition

Marshall Kirk McKusick, George V. Neville-Neil, Robert N.M. Watson

Publisher Resources

ISBN: 9780471456759Purchase book