This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ﬁrst develop an understanding of Unix ﬁle I/O, which is the topic of the next section. 12.4 Unix ﬁle I/O
A Unix ﬁle is a sequence of Ò bytes
Ò ½ All I/O devices, such as networks, disks, and terminals, are modeled as ﬁles, and all input and output is performed by reading and writing the appropriate ﬁles. This elegant mapping of devices to ﬁles allows Unix to export a simple, low-level application interface, known as Unix I/O, that enables all input and output to be performed in a uniform and consistent way.
Aside: Standard I/O and Unix I/O. The familiar, higher-level I/O routines in the C standard library, such as printf and scanf, are all implemented using the lower-level Unix I/O functions. End Aside. An application announces its intention to access an I/O device by asking the kernel to open the corresponding ﬁle. The kernel returns a small non-negative integer, called a descriptor, that identiﬁes the ﬁle in all subsequent operations on the ﬁle. The kerne...
View Full Document
- Spring '10
- The American