.TH file "" "" "Definition"
.PC "The way to access bits"
.PP
The term
.B file
is used throughout the world of computing.
Because there are several distinct types of \*(CO ``files,''
understanding what \*(CO means by a ``file''
can help you grasp how \*(CO works.
.PP
.\"Under a traditional operating system, such as \*(MD, a
A file is a mass of bits that is given a name and
is stored on some physical medium
(e.g., floppy disk, hard disk, RAM disk, or CD-ROM).
These bits may represent data (e.g., ASCII or EBCDIC characters)
or machine-executable instructions.
.\".PP
.\"However, the \*(UN operating system (and operating systems derived from
.\"it, including \*(CO) defines ``file'' as being a bit of data that is named,
.\"that is stored on disk, and that points to a device.
.\"By using the system call \fBopen()\fR to ``open'' the file,
.\"you gain access to the
.\"device to which the file points, and can read data from that device.
.\"Thus, a \*(UN/\*(CO file can point to a chunk of memory,
.\"to an external device (e.g., tape drive,
.\"serial port,
.\"parallel port,
.\"audio I/O,
.\"mouse,
.\"or battery-backed clock chip),
.\"or to a location on a disk.
.\".PP
\*(CO defines a number of different types of files.
A file's type defines its behavior.
Some common file types include the following:
.IP \fBregular\fR
.\"This is the traditional notion of a file.
This file points to a location on a disk, which can be read or written.
The location pointed to can contain data (e.g., text) or executable instructions
in the form of shell commands or binary instructions.
Regular files are sometimes called
.I ordinary
files.
.IP \fBdirectory\fR
A directory holds
the names and addresses of other files, including other directories.
.IP \fBspecial\fR
Special files designate \*(CO devices.
A device can represent a physical
device, such as a floppy disk drive, a printer port, or a serial port.
It can also represent a part of a physical device,
such as a RAM disk (representing part of memory) or
one partition of a hard disk.
It can also represent a logical device
that has no physical counterpart, like the bit bucket
.BR /dev/null .
.sp \n(pDu
Special files come in two flavors:
\fIcharacter special\fR and \fIblock special\fR.
The former access data in streams (that is, one character at a time), and
so access devices like tape drives and serial ports.
The latter access one block at a time, and so access disk drives and other
devices that return their data in block-sized chunks.
(\*(CO defines a block as being 512 characters.)
.IP \fBFIFO\fR
This is a variety of regular file that
contains semantics to hook together two processes, just like a pipe `|' in
the \*(CO shell.
See the Lexicon article \fBnamed pipe\fR for details on this variety of file.
.IP \fBprocess\fR
This kind of file corresponds one-to-one with the existence of a process on a
system.
It tends to be short-lived.
.PP
Files live with a \fIfile system\fR, which organizes the files hierarchically
within directories.
The Lexicon entry for the command \fBmkfs\fR gives some technical information
on how a file system is constructed.
The Lexicon entry for the command \fBmount\fR gives some information on
how a file system relates to device on which it lives,
and how different file systems from different partitions are hooked together
to form one large file system for the entire computer.
.PP
The same file can have (and be accessed by) more than one name.
The Lexicon entry for the command \fBln\fR shows how you can link additional
names to a file.
The entry for the system call \fBunlink()\fR gives some details on the
relationship between a file and its names.
.PP
Finally, a file has \fIpermissions\fR associated with it.
Every file is owned by someone; and the owner can restrict access to the file
if she wishes.
The Lexicon entry for the command \fBls\fR describes what permissions are
available for a file.
The entry for the command \fBchmod\fR shows how you can change permissions
on a file.
The entry for the command \fBumask\fR shows how you can change
the permissions that \*(CO gives by default to any files that you create.
.SH "See Also"
.Xr "chgrp," chgrp
.Xr "chmod," chmod
.Xr "chown," chown
.Xr "directory," directory
.Xr "FILE," file
.Xr "device drivers," device_dr
.Xr "ls," ls
.Xr "mkfs," mkfs
.Xr "named pipe," named_pip
.Xr "open()," open
.Xr "Programming COHERENT," programmi
.Xr "stream," stream
.Xr "umask," umask
.Xr "Using COHERENT" using_coh
.br
\*(AS \(sc\fR4.9.3
