Coming soon to your mailbox (part 2)

Imre Leber <[email protected]> Thu, 31 Oct 2002 20:09:46 +0100
Newsgroups gmane.os.freedos.devel
Message-ID <[email protected]>
Please don't close this mail, i have realy something you might be interested
in.

In the last couple of weeks i have been busy writing my own version of
chkdsk, it is now completely written but i still have to give a much better
testing then what i have already done.

It works both on image files and on real disks.

The following test have been written and somewhat tested on image files and
floppy disks:

The first label of the FAT does not contain the media descriptor.  The first
label in the FAT is adjusted.
The string that gives an indication of the kind of file system is wrong, the
right string is put in the place.
FAT contains invalid cluster numbers. Cluster is changed to EOF.
Wrong valid in entries, the entries are filled with valid data.
Wrong LFN entries, the LFN entries are removed (only the SFN is kept).
File's cluster chain contains a loop. The loop is broken.
Files . and .. are non-directories. They are renamed.
Directories . and .. in root directory. They are dropped.
Duplicate directory entries. They are renamed.
Directories with non-zero size field. Size is set to zero.
Start cluster number of a file is invalid. The file is Deleted.
File contains bad or free clusters. The file is truncated.
File's cluster chain is longer than indicated by the size fields, or
File's cluster chain is shorter than indicated by the size fields.
The size field is adjusted. If the file in fact is empty then the file is
deleted.
Directory . does not point to parent directory. The start pointer is
adjusted.
Directory .. does not point to parent of parent directory. The start pointer
is adjusted.
Cross linked files, all the files get a copy of the cross linked clusters.
Lost clusters, they are converted to files.

I does some more checks on the boot of floppies, but doesn't correct them. A
more general check should be implemented for hard disks and other media (it
should work on anything that has a FAT12 or FAT16 file system, FAT32
checking will not directly be guaranteed to work because of lack of memory
(speed up data structures that take a few Kbytes on FAT16 take a few Mbytes
on FAT32, because a much higher cluster count).

Moreover it lets you show  files and the accompanying defragmentation factor
on the volume. As said it supports image files so my chkdsk is actualy the
only utility that i know of that actually lets you "dir" inside an image
file.

 The reason why i wrote it and why it was done so quickly is because it
contains for 90% the same code as defrag, which is to say it has been
written with the library i wrote for defrag (the FAT Transformation Engine).
So when testing the much easier algorithms in chkdsk (defrag has very
sophisticated algorithms) i am in fact also the testing the code for defrag.

The reason why i say this now is because according to Alain, Andreas has
already started on his version of chkdsk, while he said that he wasn't going
to work on it before at least 2003 (if nobody else, like me, had already
written it).

Imre