OFS(4S) — File Formats
NAME
ofs − optical virtual file system
SYNOPSIS
#include <sys/mount.h>
#include <ofs/omount.h>
mount ("ofs", dir, flags, args);
DESCRIPTION
The Optical File System (OFS) allows optical archive volumes to serve as data storage and retrieval media in a fully file-structured manner, supporting all the standard features and functions of the native UNIX File System (UFS) maintained on conventional magnetic storage devices.
dir is the mount point for the optical file system. args is the address of a mount structure defined in <ofs/omount.h>. flags is a union of control flags defined in <sys/mount.h>.
Due to the write-once nature of the medium, the allocation schemes for inodes and data employed in the UNIX file system are not suitable for use on optical disks. Since file index information is continually updated, it cannot be kept in a contiguous array indexed by position, as it is on a magnetic disk. The indirect pointer mechanism used to locate data blocks in UNIX files would entail excessive overhead to implement update operations, and the threaded free-space management technique that stores pointers in free blocks is totally unusable in the write-once optical environment.
Each file on an optical file system is described by an index block (iblock) analogous to the index node (inode) structure employed in the UNIX file system. An index block contains all the same file attributes (file type, permission mask, link count, owner and group identifiers, access, update and change times) just as they appear in an inode, using the same type and value for each item. However, the data block pointers in the inode structure are replaced by an entirely different data location scheme, and several other items are added to compensate for the write-once nature of the medium. For more information, see the include file <ofs/iblock.h>.
Index blocks are allocated on the optical volume beginning in the last addressable block and proceeding backward through successive preceeding blocks. The first item in each index block identifies the file it describes. Whenever an index block is altered, it is simply written to the next available block. When a demounted volume is remounted, the array of index blocks is scanned from back to front, and a list is compiled showing the location of the index block for each file. Successive index blocks describing the same file supercede their precursors in this list, so that only the most recent version of the index for each file is retained.
On a rewritable volume, the index blocks form a positional table in which the index for a file is located by subtracting the file index number from the total number of blocks on the volume, so that index 1 is in the very last block, index 2 is in the preceeding block, and so on. Index 1 on a rewritable volume describes a special pseudo-file used to manage space recovered as other true files and directories are deleted or truncated. Index 2 always identifies the root directory on every volume.
Data space is allocated starting with the first block on the volume and continuing forward. The last item in a file index block is an array of data descriptors, each of which defines the origin and extent of a contiguous group of data blocks. The number of such descriptors in a single index block depends upon the file system logical block length, which is normally the same as the physical block size of the optical medium. If a file ever needs more than this number of descriptors, index blocks may be chained together. Each index block in the chain has its own identifier, but only the first block in the chain contains the file attributes. The identifier of this block identifies the file as a whole.
Directory files, symbolic links and other files whose total data length is smaller than the descriptor space in an index block may actually record data in this space instead of descriptors, thus halving the space needed to hold the file and the time required to access it. This is especially important for directory files, since the optical disk need not perform a seek to access the directory contents, thereby expediting the traversal of directory trees.
Since the index blocks do not occupy a fixed, reserved area on the volume, and since superceded index blocks cannot be re-used on write-once optical media, the significance of the index usage statistics for optical volumes are substantially different from those for magnetic volumes. In particular, the figures presented by df(1) and statfs(2) for free file nodes reflect the number of superceded or recovered index blocks, not the number of blocks available for index expansion, which is always the same as the number of free blocks on the volume.
SEE ALSO
df(1), statfs(2), ofsd(8), omount(8)
— 30 September 1990