Files and I/O Interfaces

Files that are organized as a sequence of data are called regular files. Regular files can contain ASCII text, text in some
other binary data encoding, executable code, or any combination of text, data,
and code.

A regular file is made up of the following components:

Control data, which is called the inode.
This data includes the file type, the access permissions, the owner, the file
size, and the location of the data blocks.

File contents: a nonterminated sequence of bytes.

The Solaris operating environment provides the following basic forms
of file input/output interfaces:

The traditional, raw style of file I/O is described in Basic File I/O.

The standard I/O buffering provides an easier interface and
improved efficiency to an application run on a system without virtual memory.
In an application running in a virtual memory environment, such as on the
SunOS™ operating system, standard file I/O is outdated.

The memory mapping interface is described in Memory Management Interfaces.
Mapping files is the most efficient form of file I/O for most applications
run under the SunOS™ platform.

Basic File I/O

The following interfaces perform basic operations on files and on character
I/O devices.

The following code sample demonstrates the use of the basic file I/O
interface. read(2)
and write(2)
both transfer no more than the specified number of bytes, starting at the
current offset into the file. The number of bytes actually transferred is
returned. The end of a file is indicated on a read(2) by a return value of zero.