4 The main file system algorithm is a set
10 Each file system process waits on
11 a message queue for an incoming request.
12 The request contains a 9P message and
13 the address of a reply queue.
16 process parses the message,
17 performs pseudo-disk I/O
18 to the corresponding file system block device,
19 formulates a response,
21 response back to the reply queue.
23 The unit of storage is a
25 (not physical sector) of data on a device:
27 .TA 0.5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i
44 BUFSIZE = RBUFSIZE - sizeof(Tag)
54 All devices are idealized as a perfect disk
55 of contiguously numbered blocks each of size
57 Each block has a tag that identifies what type
58 of block it is and a unique id of the file or directory
59 where this block resides.
60 The remaining data in the block depends on
61 what type of block it is.
65 process's main data structure is the directory entry.
66 This is the equivalent of a UNIX i-node and
67 defines the set of block addresses that comprise a file or directory.
69 the directory entry also has the name of the
70 file or directory in it:
96 Each directory entry holds the file or directory
97 name, protection mode, access times, user-id, group-id, and addressing
101 is the user-id of the last writer of the file
104 is the size of the file in bytes.
105 The addresses of the first 6
106 blocks of the file are held in the
109 If the file is larger than that,
110 an indirect block is allocated that holds
112 .CW BUFSIZE/sizeof(Off)
113 block addresses of the file.
114 The indirect block address is held in
116 If the file is larger yet,
117 then there is a double indirect block that points
119 The double indirect address is held in
121 and can point at another
122 .CW (BUFSIZE/sizeof(Off))\u\s-2\&2\s+2\d
124 This is extended through a quadruple indirect block at
126 but the code is now parameterised to permit easily changing the
127 number of direct blocks and the depth of indirect blocks,
128 and also the maximum size of a file name component.
129 The maximum addressable size of a file is
130 therefore 7.93 petabytes at a block size of 8k,
131 but 7.98 exabytes (just under $2 sup 63$ bytes) at a block size of 32k.
132 File size is restricted to $2 sup 63 - 1$ bytes in any case
133 because the length of a file is maintained in a
136 These numbers are based on
138 which has a block size of 8k and
142 The declarations of the indirect and double indirect blocks
147 INDPERBUF = BUFSIZE/sizeof(Off),
153 Off dblock[INDPERBUF];
160 Off iblock[INDPERBUF];
165 The root of a file system is a single directory entry
166 at a known block address.
167 A directory is a file that consists of a list of
169 To make access easier,
170 a directory entry cannot cross blocks.
173 there are 47 directory entries per block.
175 The device on which the blocks reside is implicit
176 and ultimately comes from the 9P
178 message that specifies the name of the
179 device containing the root.