V3/usr/man/man5/fs.5

Find at most related files.
including files from this version of Unix.

.pa 1
.he 'FILE SYSTEM (V)'3/15/72'FILE SYSTEM (V)'
.ti 0
NAME		format of file system
.sp
.ti 0
DESCRIPTION
.br
.in 8
Every
file system storage volume
(e.g. RF disk, RK disk, DECtape reel)
has a common format for certain vital information.

Every such volume is divided into a certain number
of 256 word (512 byte) blocks.  Blocks 0 and 1 are
collectively known as the super_____-block_____ for the device;
they define its extent and contain an i-node map
and a free-storage map.
The first word
contains the number of bytes in the free-storage
map; it is always even.
It is followed by the map.
There is one bit for each block on the device; the bit is "1"
if the block is free.
Thus if the
number of free-map bytes is n_, the blocks on the device
are numbered 0 through 8n_-1.
The free-map count is followed by the free map
itself.
The bit for block k_ of the device
is in byte k_/8 of the map; it is offset k_(mod 8) bits from the right.
Notice that bits exist for the superblock and the i-list,
even though they are never allocated or freed.

After the free map is a word containing the byte count
for the i-node map.  It too is always even.
I-numbers below 41(10) are reserved
for special files, and are
never allocated; the first bit in the i-node
free map refers to i-number 41.
Therefore the byte number in the i-node map
for i-node i_ is (i_-41)/8.
It is offset (i_-41) (mod 8) bits from the right; unlike
the free map, a "0" bit indicates an available i-node.

I-numbers begin at 1, and the storage for i-nodes
begins at block 2.
Also, i-nodes are 32 bytes long, so 16 of them fit into a block.
Therefore, i-node i_ is located in block (i_+31)/16 of
the file system, and begins 32\u.\d((i_+31)(mod 16)) bytes
from its start.

There is always one file system which is always mounted;
in standard UNIX it resides on the RF disk.
This device is also used for swapping.
On the primary file system device, there are
several pieces of information following that previously
discussed.
There are two words with the calendar time
(measured since 00:00 Jan 1, 1972);
two words with the time spent executing in the system;
two words with the time spent waiting for I/O on the RF and RK
disks; two words with the time spent executing in a user's
core; one byte with the count of errors on the RF
disk; and one byte with the count of errors on the RK disk.
All the times are measured in sixtieths of a second.

I-node 41(10) is reserved for the root directory of the
file system.
No i-numbers other than this one and those from
1 to 40 (which represent special files) have a built-in
meaning.
Each i-node represents one file.
The format of an i-node is as follows, where the
left column represents the offset from the beginning
of the i-node:
.sp
.nf
.in +3
0-1	flags (see below)
2	number of links
3	user ID of owner
4-5	size in bytes
6-7	first indirect block or contents block
.li
...
20-21	eighth indirect block or contents block
22-25	creation time
26-29	modification time
30-31		unused
.fi
.sp
.ti -3
The flags are as follows:
.sp
.nf
100000	i-node is allocated
040000	directory
020000	file has been modified (always on)
010000	large file
000040	set user ID on execution
000020	executable
000010	read, owner
000004	write, owner
000002	read, non-owner
000001	write, non-owner
.sp
.in -3
.fi
The allocated bit (flag 100000) is believed even
if the i-node map says the i-node is free;
thus corruption of the map may cause i-nodes
to become unallocatable, but will not cause active
nodes to be reused.

Byte number n_ of a file is accessed as follows:
n_ is divided by 512 to find its logical block number (say b_)
in the file.
If the file is small (flag 010000 is 0),
then b_ must be less than 8, and the physical block
number corresponding to b_ is the b_th entry
in the address portion of the i-node.

Even if the file is large, b_ will be less than
128 (128*512 = 2^16).
The first number in the i-node address
portion
gives the physical block number of the indirect block.
b_ is doubled
to give a byte offset in the indirect block
and the word there found is the physical address of
the block corresponding to b_.

For block b_ in a file to exist, it
is not necessary that all blocks less than b_ exist.
A zero block number either in the address words of
the i-node or in an indirect block indicates that the
corresponding block has never been allocated.
Such a missing block reads as if it contained all zero words.

.in 16
.ti 0
BUGS		Two blocks are not enough to handle
the i- and free-storage maps for an RP02
disk pack, which contains around 10 million words.
.sp