DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Directory and file management

Types of files

From the point of view of the user, there are three types of files:

  1. regular files

  2. directory files

  3. special files
The user and user application programs access all three types of files simply as a string of bytes, and must interpret the file appropriately. In SCO OpenServer, files normally reside on a disk.

Regular files

Regular files contain whatever information users write onto them (for example, character data, source programs or binary objects). Any file other than a special file or a directory file is a regular file. Every file is a (one-dimensional) array of bytes; SCO OpenServer imposes no further structure on the contents of files. A file of text consists simply of a string of characters, with the new-line character delimiting lines. Binary files are sequences of machine instructions as they appear in memory when the file executes. Some programs operate on files with more structure; for example, the assembler generates, and the loader expects, object files in a specific format. The programs that use files dictate their structure, not the system.

Directory files

Directory files (also called ``directories'') provide the mapping (paths) between the names of files and the files themselves. Directories induce a tree-like structure on the file system as a whole to create a hierarchical system of files with directories as the nodes in the hierarchy. A directory is a file that catalogs the files, including directories (sub-directories), directly beneath it in the hierarchy.

Each user owns a directory of files, and may also create sub-directories to contain groups of files conveniently treated together. A directory behaves exactly like a regular file except that only the operating system can write onto it. SCO OpenServer controls the contents of directories; however, users with permission may read a directory just like any other file.

The operating system maintains several directories for its own use. One of these is the root-directory. Each file in the file system can be found by tracing a path from the root-directory through a chain of directories until the desired file is reached. Other system directories contain any programs provided for general use; that is, all ``commands''; however, it is by no means necessary that a program reside in one of these directories for it to be executed.

Entries in a directory file are called links. A link associates a file-identifier with a filename. Each directory has at least two links, ``.'' (dot) and ``..'' (dot-dot). The link dot refers to the directory itself; while dot-dot refers to the parent of the directory in which dot-dot appears. Programs may read the current-directory using ``.'' without knowing its complete pathname.

The root-directory, which is the top-most node of the hierarchy, has itself as its parent-directory; thus, ``/'' is the pathname of both the root-directory and the parent-directory of the root-directory.

The directory structure is constrained to have the form of a rooted tree. Except for the special entries ``.'' and ``..'', each directory must appear as an entry in exactly one other directory, which is its parent. The reason for this is to simplify the writing of programs that visit sub-trees of the directory structure, and more important, to avoid the separation of portions of the hierarchy. If arbitrary links to directories were permitted, it would be quite difficult to detect when the last connection from the root-directory to a directory was severed.

Special files

Special files constitute the most unusual feature of the SCO OpenServer file system. Each supported I/O device is associated with at least one special file. Special files are read and written just like regular files, but requests to read or write result in activation of the associated device-handler (driver) rather than the normal file mechanism.

An entry for each special file resides under the directory ``/dev'', although a link may be made to one of these files just as it may to a regular file. For example, to write on magnetic tape one may write on the file ``/dev/rmt''. Special files exist for peripheral devices such as terminal ports, communication links, disk drives, tape drives and for physical main memory. Of course, the active disks and memory special files are protected from indiscriminate access by appropriate read and write permissions.

There are several advantages to treating I/O devices this way:


Next topic: Organization of files
Previous topic: Directory and file management

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005