FSCK FAQ

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Question: Can the partition table in the MBR or EBRs point to more than one extended partition? Am I always guaranteed that the extended partition will be the last valid partition in a given table?

Answer: You are guaranteed that each MBR or EBR can point to only one extended partition. Only the last valid entry in a partition table can point to an extended partition. There are disk utilities that break the above conventions, but you don't have to worry about complex partition structures for this lab.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Question: I get seven partitions, not six, as stated in the lab handout. What's wrong?is the partition table I see for the disk image different from that stated in the handout?

Answer: Extended partitions contained within the extended boot records should not count as a partition.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Question: Why is there a not a valid superblock in every block group?

Answer: The ext2 partitions in the disk image use sparse superblocks. Valid superblocks only exist at block group 0, 1, and groups corresponding to powers of 3, 5, and 7.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Question: Is it okay for a phase of FSCK to break some filesystem consistency requirement as long as a latter phase of FSCK re-establishes the requirement?

Answer: Yes. Keep this option in mind, as it will make implementing certain phases of FSCK much easier. You might also end up in situations where it is easier to implement some later phase of FSCK in a manner that breaks the consistency established by some previous phase. In such scenarios, feel free to run FSCK phases out of order, or to re-run FSCK phases as necessary.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Question: For FSCK Pass 1, if I find a directory entry that does not contain a "." or ".." entry, do I have to shift all the existing entries down to insert the missing entry?

No, if necessary, you are free to overwrite the first or second directory entries with "." or ".." The disk is configured so that the record length of any overwritable entry is greater than that necessary to fit the "." and ".." filenames. Unreferenced inodes that result due to overwritten entries will be found and inserted into lost+found in pass 2.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Question: For pass 2 of FSCK, should I make sure that only the minimal set of items are inserted into lost+found? For example, if I find an unreferenced directory inode, should I make sure that only the directory inode is inserted into lost+found, or is it okay to insert the directory inode *and* all of its subdirectories and files seperately?

Inserting the minimal set is necessary, else you can violate fsck consistency requirements.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Question: Some inodes seem to have an i_blocks value that is greater than the number of data blocks actually allocated to them. This discrepency is keeping my pass4 implementation from working. Am I doing something wrong?

Answer: Ext2 allows "block reservations." Files are allowed to tell the filesystem the extent to which they will grow by setting their i_blocks field appropriately. The filesystem will use this hint for placement and for an idea of how much free space is actually left on disk. However, actual data blocks will be allocated to files only as they actually need them. So, a file with block reservations will have an i_blocks field that contains a value greater than the actual number of blocks allocated to it.

You cannot base your pass4 implementation on the i_blocks field because of block reservations. I suggest checking every block pointer in the inode for a valid block reference in pass4. This is not completely necessary, but it makes your code robust against odd filesysem inconsistencies.