Hardware Reference
In-Depth Information
the system searches the working directory for the file name, ''foo.c'', in order to
locate its i-node number. Having found the i-node number, it can then read in the
i-node, which tells it all about the file.
When a longer path name is specified, the basic steps outlined above are re-
peated several times until the full path has been parsed. For example, to locate the
i-node number for /usr/ast/data , the system first searches the root directory for an
entry usr . Having found the i-node for usr , it can read that file (a directory is a file
in UNIX ). In this file it looks for an entry ast , thus locating the i-node number for
the file /usr/ast . By reading /usr/ast , the system can then find the entry for data ,
and thus the i-node number for /usr/ast/data . Given the i-node number for the file,
it can then find out everything about the file from the i-node.
The format, contents, and layout of an i-node vary somewhat from system to
system (especially when networking is in use), but the following items are typi-
cally found in each i-node.
1. The file type, the 9 RWX protection bits, and a few other bits.
2. The number of links to the file (number of directory entries for it).
3. The owner's identity.
4. The owner's group.
5. The file length in bytes.
6. Thirteen disk addresses.
7. The time the file was last read.
8. The time the file was last written.
9. The time the i-node was last changed.
The file type distinguishes ordinary files, directories, and two kinds of special files,
for block-structured and unstructured I/O devices, respectively. The number of
links and the owner identification have already been discussed. The file length is
an integer giving the highest byte that has a value. It is perfectly legal to create a
file, do an lseek to position 1,000,000, and write 1 byte, which yields a file of
length 1,000,001. The file would not , however, require storage for all the ''miss-
ing'' bytes.
The first 10 disk addresses point to data blocks. With a block size of 1024
bytes, files up to 10,240 bytes can be handled this way. Address 11 points to a disk
block, called an indirect block , which contains more disk addresses. With a
1024-byte block and 32-bit disk addresses, the indirect block would contain 256
disk addresses. Files up to 10,240 + 256
1024 = 272,384 bytes are handled this
way. For still larger files, address 12 points to a block containing the addresses of
256 indirect blocks, which takes care of files up to 272,384 + 256
×
1024 =
67,381,248 bytes. If this double indirect block scheme is still too small, disk ad-
×
256
×
 
Search WWH ::




Custom Search