In this project, you will be developing a program to check the file system consistency.
The program, called as fcheck, reads a file system image and checks its consistency.
When the image is not consistent, fcheck should output appropriate error message.
You can do this project individually or with a partner. You cannot share your work with
anyone other than your project partner.
This project should be developed in any of the cs* machines, but executed only in net*
A Basic Checker
For this project, you will use an xv6 file system image as the basic image that you will be
reading and checking. The file include/fs.h includes the basic structures you need to
understand, including the superblock, on disk inode format (struct dinode), and
directory entry format (struct dirent). The file ‘tools/mkfs.c’ will also be useful to look at,
in order to see how an empty file-system image is created.
Much of this project will be puzzling out the exact on-disk format xv6 uses for its simple
file system, and then writing checks to see if various parts of that structure are
consistent. Thus, reading through mkfs.c and the file system code itself will help you
understand how xv6 uses the bits in the image to record persistent information.
Your program should read through the file system image and determine the consistency
of a number of things, including the following. When a problem is detected, print the
error message, exactly as shown below in bold, to standard error and exit immediately
with exit code 1 (i.e., call exit(1)).
1. Each inode is either unallocated or one of the valid types (T_FILE, T_DIR, T_DEV).
If not, print ERROR: bad inode.
2. For in-use inodes, each address that is used by the inode is valid (points to a valid
datablock address within the image). If the direct block is used and is invalid,
print ERROR: bad direct address in inode.; if the indirect block is in use
and is invalid, print ERROR: bad indirect address in inode.
3. Root directory exists, its inode number is 1, and the parent of the root directory is
itself. If not, print ERROR: root directory does not exist.
4. Each directory contains . and .. entries, and the . entry points to the directory
itself. If not, print ERROR: directory not properly formatted.
5. For in-use inodes, each address in use is also marked in use in the bitmap. If not,
print ERROR: address used by inode but marked free in bitmap.
6. For blocks marked in-use in bitmap, the block should actually be in-use in an
inode or indirect block somewhere. If not, print ERROR: bitmap marks block
in use but it is not in use.
7. For in-use inodes, each direct address in use is only used once. If not,
print ERROR: direct address used more than once.
8. For in-use inodes, each indirect address in use is only used once. If not,
print ERROR: indirect address used more than once.
9. For all inodes marked in use, each must be referred to in at least one directory. If
not, print ERROR: inode marked use but not found in a directory.
10. For each inode number that is referred to in a valid directory, it is actually marked
in use. If not, print ERROR: inode referred to in directory but marked
11. Reference counts (number of links) for regular files match the number of times
file is referred to in directories (i.e., hard links work correctly). If not, print ERROR:
bad reference count for file.
12. No extra links allowed for directories (each directory only appears in one other
directory). If not, print ERROR: directory appears more than once in file
Ensure your output the error message exactly as specified (including the ‘.’ at the end.)
We will use automated script to grade your program. If the output does not match the
expected output for a test case, it will show that your program failed the test case.
Get Free Quote!
273 Experts Online