3.2   Files, Devices, and Drivers

In VxWorks, applications access I/O devices by opening named files. A file can refer to one of two things:

Consider the following named files:

/usr/myfile

/pipe/mypipe

/tyCo/0

The first refers to a file called myfile, on a disk device called /usr. The second is a named pipe (by convention, pipe names begin with /pipe). The third refers to a physical serial channel. However, I/O can be done to or from any of these in the same way. Within VxWorks, they are all called files, even though they refer to very different physical objects.

Devices are handled by program modules called drivers. In general, using the I/O system does not require any further understanding of the implementation of devices and drivers. Note, however, that the VxWorks I/O system gives drivers considerable flexibility in the way they handle each specific device. Drivers strive to follow the conventional user view presented here, but can differ in the specifics. See 3.7 Devices in VxWorks.

Although all I/O is directed at named files, it can be done at two different levels: basic and buffered. The two differ in the way data is buffered and in the types of calls that can be made. These two levels are discussed in later sections.

3.2.1   File Names and the Default Device

A file name is specified as a character string. An unstructured device is specified with the device name. In the case of file system devices, the device name is followed by a file name. Thus the name /tyCo/0 might name a particular serial I/O channel, and the name DEV1:/file1 probably indicates the file file1 on the DEV1: device.

When a file name is specified in an I/O call, the I/O system searches for a device with a name that matches at least an initial substring of the file name. The I/O function is then directed at this device.

If a matching device name cannot be found, then the I/O function is directed at a default device. You can set this default device to be any device in the system, including no device at all, in which case failure to match a device name returns an error.

Non-block devices are named when they are added to the I/O system, usually at system initialization time. Block devices are named when they are initialized for use with a specific file system. The VxWorks I/O system imposes no restrictions on the names given to devices. The I/O system does not interpret device or file names in any way, other than during the search for matching device and file names.

It is useful to adopt some naming conventions for device and file names: most device names begin with a slash (/), except non-NFS network devices and VxWorks DOS devices (dosFs).

By convention, NFS-based network devices are mounted with names that begin with a slash. For example:

/usr

Non-NFS network devices are named with the remote machine name followed by a colon. For example:

host:

The remainder of the name is the file name in the remote directory on the remote system.

File system devices using dosFs are often named with uppercase letters and/or digits followed by a colon. For example:

DEV1:


*

NOTE: File names and directory names on dosFs devices are often separated by backslashes (\). These can be used interchangeably with forward slashes (/).


*

CAUTION: Because device names are recognized by the I/O system using simple substring matching, a slash (/) should not be used alone as a device name.