163 lines
5.2 KiB
HTML
163 lines
5.2 KiB
HTML
<html>
|
|
<head><title>The BFS filesystem structure</title></head>
|
|
<body>
|
|
|
|
<center><h1>The BFS filesystem structure</h1></center>
|
|
The UnixWare Boot FileSystem (BFS) is a filesystem used in SCO UnixWare.
|
|
It contains all files necessary for UnixWare boot procedures (such as
|
|
<tt>unix</tt>).
|
|
Because the object of the bfs filesystem type is to allow quick and
|
|
simple booting, BFS was designed as a contiguous flat filesystem. It
|
|
is not intended to support general users. The only directory bfs
|
|
supports is the root directory. Users can create only regular files;
|
|
no directories or special files can be created in the bfs filesystem.<p>
|
|
|
|
A BFS filesystem consists of three parts:
|
|
<ul>
|
|
<li> Superblock
|
|
<li> Inodes
|
|
<li> Data area
|
|
</ul>
|
|
Each block on disk is 512 bytes long, blocks are numbered from zero. Most
|
|
data structures use "offset from begining of disk". Divide this number to
|
|
get block number.<p>
|
|
|
|
<b>NOTE:</b> Operations on a BFS filesystem in SCO UnixWare severely limited.
|
|
For example, it is not possible to have two files open for writing
|
|
simultaneously. These restrictions do not
|
|
apply to operations involving only the reading of files.<p>
|
|
|
|
You can read a BFS filesystem from your Linux box. See
|
|
<A href="http://www.penguin.cz/~mhi/fs/bfs/">BFS Linux module home page</a>.
|
|
<p>
|
|
|
|
<h2>The BFS superblock</h2>
|
|
|
|
The superblock is at the begining of disk, block 0.
|
|
|
|
<table border=1>
|
|
<tr><th>Type
|
|
<th>Name
|
|
<th>Description
|
|
<tr><td>32bit int
|
|
<td>magic
|
|
<td>Magic number (0x1BADFACE)
|
|
<tr><td>32bit int
|
|
<td>start
|
|
<td>Start of data blocks (in bytes)
|
|
<tr><td>32bit int
|
|
<td>size
|
|
<td>Size of filesystem (in bytes)
|
|
<tr><td>4x 32bit int
|
|
<td>sanity words
|
|
<td>Sanity words are used to recover filesystem after interrupted
|
|
<A href="#compaction">compaction</a>. They are usually 0xFFFFFFFF.
|
|
</table>
|
|
|
|
|
|
<h2>BFS inodes</h2>
|
|
The inode contains all the information about a file except its name.
|
|
Filenames are kept in the root directory, the only directory in the
|
|
BFS filesystem. An inode is 64 bytes long. Inode table starts at
|
|
block number 1 and fills the space between superblock and first data
|
|
block (usually root directory). First inode has number 2.
|
|
|
|
<table border=1>
|
|
<tr><th>Type
|
|
<th>Name
|
|
<th>Description
|
|
<tr><td>32bit int
|
|
<td>inode number
|
|
<td>Inode number, often contains "garbage" in high 16 bits.
|
|
<tr><td>32bit int
|
|
<td>first block
|
|
<td>First block of file. Next block is n+1, n+2, ... n+x.
|
|
<tr><td>32bit int
|
|
<td>Last block
|
|
<td>Last block of file
|
|
<tr><td>32bit int
|
|
<td>offset to eof
|
|
<td>Disk offset to end of file (in bytes)
|
|
<tr><td>32bit int
|
|
<td>Attributes
|
|
<td>File attributes (1 = regular file, 2 = directory)
|
|
<tr><td>32bit int
|
|
<td>mode
|
|
<td>File mode, rwxrwxrwx (only low 9 bits used)
|
|
<tr><td>32bit int
|
|
<td>uid
|
|
<td>File owner - user id
|
|
<tr><td>32bit int
|
|
<td>gid
|
|
<td>File owner - group id
|
|
<tr><td>32bit int
|
|
<td>nlinks
|
|
<td>Hard link count
|
|
<tr><td>32bit int
|
|
<td>atime
|
|
<td>Access time
|
|
<tr><td>32bit int
|
|
<td>mtime
|
|
<td>Modify time
|
|
<tr><td>32bit int
|
|
<td>ctime
|
|
<td>Create time
|
|
<tr><td>4x 32bit int
|
|
<td>spare
|
|
<td>Unused, should be zero
|
|
</table>
|
|
The number of inodes is defined when mkfs is used to create the filesystem.
|
|
<p>
|
|
|
|
<h2>BFS storage blocks</h2>
|
|
The remainder of the space allocated to the filesystem is taken up by
|
|
data blocks. The storage blocks store the root directory and
|
|
the regular files. For a regular file, the storage blocks contain the
|
|
contents of the file. For the root directory, the storage blocks
|
|
contain 16-byte entries.
|
|
<table border=1>
|
|
<tr><th>Type
|
|
<th>Name
|
|
<th>Description
|
|
<tr><td>16bit int
|
|
<td>inode
|
|
<td>File inode number
|
|
<tr><td>14 8bit characters
|
|
<td>name
|
|
<td>File name
|
|
</table>
|
|
The root directory *MUST* begin with two entries "." and "..", both with
|
|
inode number 2 (root directory).
|
|
<p>
|
|
|
|
<h2>Managing BFS data blocks</h2>
|
|
The data or storage blocks for a file are allocated contiguously. The
|
|
data block after the last data block used in the filesystem is
|
|
considered the next data block available to store a file. When a file
|
|
is deleted, its data blocks are released.<p>
|
|
|
|
<A name="compaction"><h2>Compaction</h2></a>
|
|
Compaction is a way of recovering data blocks by shifting files until
|
|
the gaps left behind by deleted files are eliminated. This operation
|
|
can be expensive, but it is necessary because of the method used by
|
|
BFS to store and delete files.
|
|
You need to perform compaction when either of the following situations occurs:
|
|
<ul>
|
|
<li> The system has reached the end of the filesystem, and there are
|
|
still free blocks available.
|
|
<li> The system deletes a large file and the file after it on disk is
|
|
small and is the last file in the filesystem. (Small files are
|
|
files of no more than ten blocks; large files are files of 500 or
|
|
more blocks.)
|
|
</ul>
|
|
|
|
<h2>Related links</h2>
|
|
<A href="http://www.penguin.cz/~mhi/fs/bfs/">BFS Linux module</a><br>
|
|
<A href="http://www.sco.com/">SCO homepage</a><br>
|
|
<A href="http://www.penguin.cz/~mhi/fs/">Filesystems HOWTO</a><br>
|
|
|
|
<hr>
|
|
<center><i>Copyright (c) 1999 Martin Hinner,
|
|
<A href="mailto:mhi@penguin.cz">mhi@penguin.cz</a></i></center>
|
|
</body>
|