BeOS: Porting UNIX Applications

The strict definition of a device is any hardware component attached to the computer. Generally, devices are further subdivided into input devices (such as keyboards) and out-put devices (such as monitors). Some pieces of equipment, such as disk drives and terminals, can be classed as both input and output devices. We can also expand the definition of a device to include some special types of programs or servers that respond to requests in the same way as other devices but don't transfer the information to or from a specific piece of hardware.
Using and working with devices relies on a few core routines, many of which will be familiar to UNIX programmers. Under the BeOS, UNIX, and POSIX models, devices have the same basic interface as files, so using them at a basic level should not be too different from what we are already used to. In this chapter, we will take a general look at using I/O devices before moving on to take an in-depth look at the input/output device most people will encounter when porting software: the terminal. Finally, we will take a brief look at the issues involved in writing device drivers under the BeOS.
Although you may not appreciate it, you use I/O devices all the time. The keyboard is an input device; your monitor is an output device. For most people, using these and other devices requires a simple call to a function provided by the operating system.
For example,...