Microsoft KB Archive/60061

File Size Does Not Match Allocated Clusters in 4.01 PSS ID Number: Q60061 Article last modified on 07-14-1993 PSS database name: O_MSDOS

4.01

MS-DOS

Summary:

MS-DOS version 4.01 reports the wrong file size for the output of a C program run on a 600 MB Wren V hard drive with a 32K cluster size.

Microsoft has confirmed this to be a problem in MS-DOS version 4.01. We are researching this problem and will post new information here as it becomes available.

More Information:

After writing a file sequentially and closing the file using C’s level 2 I/O functions, the file size is too small. The recorded size seems to cluster around some multiple of 1 MB. CHKDSK detects that the number of clusters allocated to the file is larger than the recorded file size. After CHKDSK resets the file size, the data seems to be correct up to the expected end of file.

The following program was compiled with the Microsoft C Compiler version 5.10 and can be used to reproduce this problem:

/* ———- the source code for the C program —————— / / The program is executed with the following command line to create the problem:

 4000000 > outlis


 * 1) include  #include  #include 

main (argc, argv) int argc; char *argv []; { long doc = 0; long l; long total;

if (argc > 2 || argc < 1) {       printf (&quot;Usage: test [line_count]\n&quot;); exit (1); }

if (argc == 2) total = atol (argv [1]); else total = 2000000;

for (l = 0; l < total; l++) printf (&quot;< MEDLINE document %ld\n&quot;, doc++);

fclose (stdout); } This program was given 4000000 as the line count parameter, and the stdout was redirected to an output file. When the program finished, the output file size was 100,662,862 bytes. After running CHKDSK the file size was set to 110,919,680 bytes. The data seems to be correct up to the expected end of file.

Additional reference words: 4.01

Copyright Microsoft Corporation 1993.