Research V3 development
[unix-history] / man / man5 / fs.5
CommitLineData
c24b10df
KT
1.pa 1
2.he 'FILE SYSTEM (V)'3/15/72'FILE SYSTEM (V)'
3.ti 0
4NAME format of file system
5.sp
6.ti 0
7DESCRIPTION
8.br
9.in 8
10Every
11file system storage volume
12(e.g. RF disk, RK disk, DECtape reel)
13has a common format for certain vital information.
14
15Every such volume is divided into a certain number
16of 256 word (512 byte) blocks. Blocks 0 and 1 are
17collectively known as the super\b\b\b\b\b_____-block\b\b\b\b\b_____ for the device;
18they define its extent and contain an i-node map
19and a free-storage map.
20The first word
21contains the number of bytes in the free-storage
22map; it is always even.
23It is followed by the map.
24There is one bit for each block on the device; the bit is "1"
25if the block is free.
26Thus if the
27number of free-map bytes is n\b_, the blocks on the device
28are numbered 0 through 8n\b_-1.
29The free-map count is followed by the free map
30itself.
31The bit for block k\b_ of the device
32is in byte k\b_/8 of the map; it is offset k\b_(mod 8) bits from the right.
33Notice that bits exist for the superblock and the i-list,
34even though they are never allocated or freed.
35
36After the free map is a word containing the byte count
37for the i-node map. It too is always even.
38I-numbers below 41(10) are reserved
39for special files, and are
40never allocated; the first bit in the i-node
41free map refers to i-number 41.
42Therefore the byte number in the i-node map
43for i-node i\b_ is (i\b_-41)/8.
44It is offset (i\b_-41) (mod 8) bits from the right; unlike
45the free map, a "0" bit indicates an available i-node.
46
47I-numbers begin at 1, and the storage for i-nodes
48begins at block 2.
49Also, i-nodes are 32 bytes long, so 16 of them fit into a block.
50Therefore, i-node i\b_ is located in block (i\b_+31)/16 of
51the file system, and begins 32\u.\d((i\b_+31)(mod 16)) bytes
52from its start.
53
54There is always one file system which is always mounted;
55in standard UNIX it resides on the RF disk.
56This device is also used for swapping.
57On the primary file system device, there are
58several pieces of information following that previously
59discussed.
60There are two words with the calendar time
61(measured since 00:00 Jan 1, 1972);
62two words with the time spent executing in the system;
63two words with the time spent waiting for I/O on the RF and RK
64disks; two words with the time spent executing in a user's
65core; one byte with the count of errors on the RF
66disk; and one byte with the count of errors on the RK disk.
67All the times are measured in sixtieths of a second.
68
69I-node 41(10) is reserved for the root directory of the
70file system.
71No i-numbers other than this one and those from
721 to 40 (which represent special files) have a built-in
73meaning.
74Each i-node represents one file.
75The format of an i-node is as follows, where the
76left column represents the offset from the beginning
77of the i-node:
78.sp
79.nf
80.in +3
810-1 flags (see below)
822 number of links
833 user ID of owner
844-5 size in bytes
856-7 first indirect block or contents block
86.li
87...
8820-21 eighth indirect block or contents block
8922-25 creation time
9026-29 modification time
9130-31 unused
92.fi
93.sp
94.ti -3
95The flags are as follows:
96.sp
97.nf
98100000 i-node is allocated
99040000 directory
100020000 file has been modified (always on)
101010000 large file
102000040 set user ID on execution
103000020 executable
104000010 read, owner
105000004 write, owner
106000002 read, non-owner
107000001 write, non-owner
108.sp
109.in -3
110.fi
111The allocated bit (flag 100000) is believed even
112if the i-node map says the i-node is free;
113thus corruption of the map may cause i-nodes
114to become unallocatable, but will not cause active
115nodes to be reused.
116
117Byte number n\b_ of a file is accessed as follows:
118n\b_ is divided by 512 to find its logical block number (say b\b_)
119in the file.
120If the file is small (flag 010000 is 0),
121then b\b_ must be less than 8, and the physical block
122number corresponding to b\b_ is the b\b_th entry
123in the address portion of the i-node.
124
125Even if the file is large, b\b_ will be less than
126128 (128*512 = 2^16).
127The first number in the i-node address
128portion
129gives the physical block number of the indirect block.
130b\b_ is doubled
131to give a byte offset in the indirect block
132and the word there found is the physical address of
133the block corresponding to b\b_.
134
135For block b\b_ in a file to exist, it
136is not necessary that all blocks less than b\b_ exist.
137A zero block number either in the address words of
138the i-node or in an indirect block indicates that the
139corresponding block has never been allocated.
140Such a missing block reads as if it contained all zero words.
141
142.in 16
143.ti 0
144BUGS Two blocks are not enough to handle
145the i- and free-storage maps for an RP02
146disk pack, which contains around 10 million words.
147.sp