RE: [PATCH] fs: fat: add check for dir size in fat_calc_dir_size

From: Anupam Aggarwal
Date: Mon Jul 06 2020 - 07:53:27 EST


Hi Ogawa,

>Anyway, fsck would be main way. And on other hand, if we want to add
>mitigation for corruption, we would have to see much more details of
>this corruption. Can you put somewhere to access the corrupted image
>(need the only metadata) to reproduce?

Sorry, uploading of any file not allowed from within.
So, metadata image is not possible to be shared via. upload.
Can try to arrange few more logs via. fsck.

>What happens if you recursively traversed directories on Windows? This
>issue happens on Windows too?

After connecting USB to windows 10, when corrupted dir(\CorruptedDIR) is browsed,
it shows 2623 number of files and directories, without delay.
Name and timestamps of those file/directories are garbage values.

Further if we browse these sub-directories and open files of corrupted dir(\CorruptedDIR)
following popups are coming on Windows 10:
1. The filename, directory name, or volume label syntax is incorrect
2. Specified path does not exist. Check the path and try again

So issue of un-ending browsing(ls -lR) of corrupted USB is not coming on windows 10,
it lists limited number of files/directories, of corrupted dir(\CorruptedDIR) without delay.

>BTW, if you run fsck, the corrupted directories and issue are gone at
>least?

Yes, issues are gone, after running "chkdsk /f" on USB, on Windows 10 PC,
corrupted directory(\CorruptedDIR) is converted to file of 1.06 GB,
so issues are not coming further.
Following is the output of chkdsk write only mode.

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

chkdsk /f e:
The type of the file system is FAT32.
Volume AAA created 12/28/2018 3:15 PM
Volume Serial Number is 1606-72DC
Windows is verifying files and folders...
The \$TXRAJNL.DAT entry contains a nonvalid link.
The size of the \$TXRAJNL.DAT entry is not valid.
Unrecoverable error in folder \CorruptedDIR.
Convert folder to file (Y/N)? Y
\DDD\file.txt is cross-linked on allocation unit 736512.
Cross link resolved by copying.
\BBB\file1.txt is cross-linked on allocation unit 433153.
Cross link resolved by copying.
\System Volume Information\LightningSand.CFD is cross-linked on allocation unit 1114114.
Cross link resolved by copying.
\CCC\file1.txt is cross-linked on allocation unit 179989.
Cross link resolved by copying.
File and folder verification is complete.
Convert lost chains to files (Y/N)? Y
3531520 KB in 31 recovered files.

Windows has made corrections to the file system.
No further action is required.
30,015,472 KB total disk space.
400 KB in 2 hidden files.
2,816 KB in 49 folders.
23,470,800 KB in 7,616 files.
6,539,408 KB are available.

16,384 bytes in each allocation unit.
1,875,967 total allocation units on disk.
408,713 allocation units available on disk.

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

Thanks,
Anupam