man(1) Manual page archive

file(5) - Unix First Edition Manual Page
11/3/71FILE SYSTEM

(V)
NAME format of file system
SYNOPSIS
DESCRIPTION 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 256word (512 byte) blocks. Blocks 0 and 1 are collectively known as the super--block for the device; they define itsextent 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 1if 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; itis offset k(mod 8) bits from the right. Notice that bits exist for the superblock and the i--list, even though theyare never allocated or freed.


After the free map is a word containing the byte count forthe i--node map. It too is always even. I--numbers below 41(10) are reserved for special files , and are neverallocated; the first bit in the i--node free map refers to i--number 41. Therefore the byte number in the i--node mapfor 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 anavailable i--node.


I--numbers begin at 1, and the storage for i--nodes begins atblock 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*(i+31)(mod 16)) bytes from its start. There is always one file system which is always mounted; instandard UNIX it resides on the RF disk. This device is also used for swapping. The swap areas are at the highaddresses on the device. It would be convenient if these addresses did not appear in the free list, but in fact thisis not so. Therefore a certain number of blocks at the top of the device appear in the free map, are not marked free,yet do not appear within any file. These are the blocks that show up missing in a check of the RE' disk. Again on the primary file system device, there


11/3/71FILE SYSTEM

(V)


are several pieces of information following that previouslydiscussed. They contain basically the information typed by the tm command; namely, the times spent since a cold bootin various categories, and a count of I/O errors. In particular, there are two words with the calendar time(measured since 00:00 Jan 1, 1971); two words with the time spent executing in the system; two words with the timespent waiting for I/O on the RF and RK disks; two words with the time spent executing in a user's core; one bytewith the count of errors on the RF disk; and one byte with the count of errors on the RK disk. All the times aremeasured in sixtieths of a second.


I--node 41(10) is reserved for the root directory of thefile system. No i--numbers other than this one and those from I 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 representsthe offset from the beginning of the i--node:


0--1 flags (see below)2 number of links 3 user ID of owner4--5 size in bytes 6--7 first indirect block or contents block... 20--21 eighth indirect block or contents block22--25 creation time


26--29 modification time30--31 unused


The flags are as follows:


100000 i--node is allocated040000 directory


020000 file has been modified (always on)010000 large file 000040 set user ID on execution000020 executable 000010 read, owner000004 write, owner 000002 read, non--owner000001 write, non--owner


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 notcause active nodes to be reused.


Byte number n of a file is accessed as follows: n isdivided by 512 to find its logical block number (say b) in the file. If the file is small


11/3/71FILE SYSTEM

(V)


(flag 010000 is 0), then b must be less than 8, and thephysical block number corresponding to b is the bth entry in the address portion of the i--node.


If the file is large, b is divided by 256 to yield a numberwhich must be less than 8 (or the file is too large for UNIX to handle). The corresponding slot in the i--nodeaddress portion gives the physical block number of an indirect block. The residue mod 256 of b is multiplied bytwo (to give a byte offset in the indirect block) and the word found there is the physical address of the blockcorresponding to b.


If block b in a file exists, it is not necessary that allblocks less than b exist. A zero block number either in the address words of the i--node or in an indirect blockindicates that the corresponding block has never been allocated. Such a missing block reads as if it containedall zero words.


FILES
SEE_ALSO format of directories
DIAGNOSTICS
BUGS Two blocks are not enough to handle the i-- and free--storagemaps for an RP02 disk pack, which contains around 10


million words.

OWNER