Microsoft included five undocumented and unsupported
functions in Windows NT 4.0 for doing disk
defragmentation. The functions were added as a result
of bad experiences with third party defragmenters
written for Windows NT 3.5 and 3.51 (explained in
section 5.4.2 on page
). [Rus97]
These functions are:
Mapping a drive requires three steps: [Rus97]
In order to catch changes, defragmenters must repeat all three steps for each file it processes. Clusters are moved with MoveFile. [Rus97]
If there are any clusters in use but not allocated to a file, these clusters are system metadata, directories, or files opened exclusively by a process other than the defragmenter. There's also the MFT. Clusters of these types can not be moved. [Rus97]
The above is fine for FAT partitions. However, extra complications exist for NTFS partitions. The first problem is that NTFS performs compression on 16 cluster segments. As a result, MoveFile can not move individual clusters. Clusters must be moved in blocks of 16. The other problem is that deallocated clusters can't be used again until NTFS has checkpointed the drive, which occurs once every few seconds. [Rus97]