These services and capabilities both define and limit how to write programs
that run on a Linux system.
Consider files and the file system. Linux, like the UNIX systems on which it is modeled, is built on
the key idiom that ???everything is a file.??? This is a powerful metaphor and model that dramatically
simplifies writing application programs to communicate with all sorts of devices. How? You can
use the same function, the write() system call, to write data to a text file; to send data to a
printer; to send keystrokes to an application; and, if you had one, to tell your network-connected
coffee pot to brew another pot of coffee.
The file metaphor works this way because Linux treats all devices, such as modems, monitors,
CD-ROM drives, disc drives, keyboards, mice, and printers, as if they were files. Device drivers,
which are part of the kernel, sit between a device and the user and application trying to access it.
A device driver translates an application??™s write() call into a form that the device can understand.
So, if an application uses the write() system call to write data to a text file on an ext3 file system,
the ext3 driver writes the necessary bytes to a file on the disk, but if the application later uses the
write() system call to write that same data to a printer, the printer driver transmits that data out
the parallel port (or across the network) to the printer in a manner that the printer can understand
and interpret.
Pages:
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367