inode = 1 pointer to a data block + 1 pointer to indirect blockThe value "99" signifies a null pointer when referring to a disk block address or directory name. An empty directory has one disk block with the contents "99 99". The inumber for root directory is "/" is 0.indirect block = 2 pointers to data blocks
directory = a regular file containing zero or more pairs of integers; the first integer of each pair is a file name and the second is the file's inumber
The following data are stored on disk:
inode array:
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
10 6 |
7 99 |
8 99 |
3 99 |
disk blocks:
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
32 3 |
96 1 |
1 99 |
99 99 |
99 99 |
57 6 |
directory path name | inumber | indirect blocks | data blocks | contents (subdirectories) | / |
0 |
directory path name | inumber | indirect blocks | data blocks | contents (subdirectories) | /87 |
fd = open(foo, O_CREAT|O_WRONLY);Assume that creating a file is synchronous -- all writes to disk complete before the call returns. Assume that write() calls are asynchronous (they write data and metadata to memory, but don't force the writes to disk), but that close() does not return until all writes to the file and metadata are safely on disk. Assume that all of the data structures that must be read to perform this action are already in the cache.
p = &editBuffer;
numBlocks = editBufferSize / 1024;
for (i = 0; i < numBlocks; i++) {
write(fd, p, 1024);
p += 1024;
}
lengthOfLastPartialBlock = editBufferSize % 1024;
write(fd, p, lengthOfLastPartialBlock);
close(fd);
In use | 0 | 1 | 0 | 1 |
Free | 0 | 0 | 1 | 1 |