Microsoft KB Archive/69572

CHKDSK /F Can Destroy Subdirectories Without Warning PSS ID Number: Q69572 Article last modified on 07-14-1993 PSS database name: O_MSDOS

3.x 4.00 4.01 4.01a

MS-DOS

Summary:

If CHKDSK finds a subdirectory with a damaged structure, you are prompted multiple times to convert the directory to a file. Each time CHKDSK prompts you, it moves one level toward the root directory. If you respond Yes to all the consecutive prompts, and if you specified /F on the command line, CHKDSK destroys the entire directory tree that contained the one bad subdirectory.

Actual changes to the disk occur only if you specify the /F option when invoking CHKDSK. If CHKDSK /F is run, but lost chains are not converted to files, all data from files in the converted subdirectories is lost.

If CHKDSK encounters a bad subdirectory, answer only the first prompt with Yes, and answer No to the remaining prompts.

Microsoft has confirmed this to be a problem in MS-DOS versions 3.2, 3.21, 3.3, 3.3a, 4.0, and 4.01. This problem does not occur in later versions of MS-DOS.

A damaged subdirectory is a rare occurrence, so this problem is not often encountered.

More Information:

Note: Actual changes to the disk occur only if you specify the /F option when invoking CHKDSK.

When CHKDSK finds an invalid subdirectory, it displays the message:

Invalid subdirectory entry Convert directory to file (Y/N)?

Answering Yes to this question causes CHKDSK to alter the file attribute bit of the invalid directory. Because subdirectories under MS-DOS are very similar to data files, the directory becomes a normal file with the same structure as a directory.

If the invalid directory is a subdirectory of the root directory, CHKDSK will continue normally. However, if the invalid subdirectory is a child of another subdirectory, the following prompt is repeated:

Convert directory to file (Y/N)?

No explanation is given to indicate why the prompt is redisplayed. This is very misleading because no error message is displayed. You may think that the CHKDSK command did not accept your input from the first prompt. This prompt is really asking you if the PARENT of the invalid subdirectory should be converted to a file. Usually, the parent directory is not invalid, and answering Yes to the second prompt can cause data loss. The process is repeated until all subdirectories down to the root have caused a prompt to be displayed.

If CHKDSK encounters a bad subdirectory, answer only the first prompt with Yes, and answer No to the remaining prompts.

If more than the first prompt is given a Yes response, try the following recovery methods:


 * A subdirectory is only a special form of a file; therefore, recovery of the contents can be done with a disk utility program that can change the DIRECTORY attribute of a file entry. Doing this re-creates the directories that CHKDSK destroyed. If this process is repeated down the subdirectory tree, the entire damaged directory structure can be repaired (with the exception of the original damaged directory).
 * Even if a utility to change the attribute bit is not available, complete data loss does NOT take place if you use CHKDSK /F to convert the resulting lost chains to files. When lost chains are converted to files, the root directory contains all of the files that were orphaned when the subdirectory they were in was converted to files. Although these files have numeric names, they contain the data from the original files. By copying the contents of the root directory to a floppy disk and repeating the CHKDSK /F command, all lost files can be recovered. The previous method is the preferred solution because it maintains the exact file size of the original, where this method creates files that contain extra data at the end (caused by rounding the size up to the next cluster boundary).

WARNING: If CHKDSK /F is run, but lost chains are not converted to files, all data from files in the converted subdirectories is lost.

Example
In the following subdirectory tree, the HELLO subdirectory is invalid:

C:

When CHKDSK is executed with the /F parameter, it reports:

C: Invalid subdirectory entry Convert directory to file (Y/N)?

Pressing Y, ENTER changes the subdirectory entry for HELLO to a file, thus truncating the tree to C:. However, CHKDSK then displays the following prompt again:

C: Invalid subdirectory entry Convert directory to file (Y/N)? Y Convert directory to file (Y/N)?

Answering Yes here causes the directory entry for DIR2 to be changed to a file. Now, only the DIR1 directory remains as a directory; its children have been truncated to a file.

CHKDSK repeats this for DIR1:

C: Invalid subdirectory entry Convert directory to file (Y/N)? Y Convert directory to file (Y/N)? Y Convert directory to file (Y/N)?

It is important to note that only when the /F parameter is specified do changes actually get written to disk. Running CHKDSK without the /F parameter generates a simulated run, giving error messages as if CHKDSK were altering the disk contents.

Additional reference words: 3.20 3.30 3.30a 4.00 4.01 noupd

Copyright Microsoft Corporation 1993.