Gregwar/fatcat

Only finds 1 FAT table... how to fix?

kmpm opened this issue · 5 comments

kmpm commented

When using fatcat on a image I have that is dumped from a micro sd card I get a warning about missing fat table, WARNING: Fats number different of 2 (1). How this happened I don't know but there have been issues with that specific card.

The card is mountable in both Windows and Linux. I've tried to dump with dd and ddrescue but same issue occurs. The card is partitioned starting at sector 63 so I need an offset of 32256.

When commenting out strange++ in FatSystem.cpp for the fats check I can backup both tables and do other stuff.
When using -t 1 I get a file that is essentially empty but -t 2 looks like a valid one.
As a test I patched the first table with data from the second but it still complains about missing fat table.

Info shows (after commenting out the check)

WARNING: Fats number different of 2 (1)
FAT Filesystem information

Filesystem type: FAT
OEM name:
Total sectors: 3868609
Total data clusters: 106496
Data size: 3489660928 (3.25G)
Disk size: 1980727808 (1.8447G)
Bytes per sector: 512
Sectors per cluster: 64
Bytes per cluster: 32768
Reserved sectors: 1
Root entries: 512
Root clusters: 1
Sectors per FAT: 416
Fat size: 212992 (208K)
FAT1 start address: 0000000000000200
FAT2 start address: 0000000000034200
Data start address: 0000000000034200
Root directory cluster: 0
Disk label: NO NAME

Free clusters: 36219/106496 (34.0097%)
Free space: 1186824192 (1.10532G)
Used space: 2302836736 (2.14468G)

Is it fixable?
How to fix it?
How dangerous is it to do stuff without fixing it?

zub2 commented

I ran into the same (or similar?) issue with a disk from an LG TV recorder. The filesystem is clearly strange but I wish fatcat gave me more info rather than giving up outright.

The exact error message I get is:

WARNING: Fats number different of 2 (1)
! Failed to init the FAT filesystem

Hello,
It is actually possible to have more or less than 2 FATs:

$ dd if=/dev/zero of=test.bin bs=1M count=128
128+0 enregistrements lus
128+0 enregistrements écrits
134217728 bytes (134 MB, 128 MiB) copied, 0,0671249 s, 2,0 GB/s
$ mkfs.fat -f 1 test.bin 
mkfs.fat 4.1 (2017-01-24)
$ fatcat test.bin -l /
WARNING: Fats number different of 2 (1)
! Failed to init the FAT filesystem
$ mkfs.fat -f 3 test.bin 
mkfs.fat 4.1 (2017-01-24)
$ fatcat test.bin -l /
WARNING: Fats number different of 2 (3)
! Failed to init the FAT filesystem
$ 

So I guess fatcat is currently not supporting this.

Actually, this warning should maybe be removed. However, note that the compare option should not be used in that case since there is actually only one fat entry on the disk.

So I removed this warning, and added a die if you try to call compare or merge operation with a number of FAT different from 2.

With master version fatcat is not isuing this warning and is also able to list a file on a FAT filesystem with only one FAT table:

root@hyperion:/tmp# dd if=/dev/zero of=test.bin bs=1M count=128
128+0 enregistrements lus
128+0 enregistrements écrits
134217728 bytes (134 MB, 128 MiB) copied, 0,101574 s, 1,3 GB/s
root@hyperion:/tmp# mkfs.fat -f 1 -F 32 test.bin 
mkfs.fat 4.1 (2017-01-24)
root@hyperion:/tmp# mount test.bin x/
root@hyperion:/tmp# touch x/test.txt
root@hyperion:/tmp# umount x
root@hyperion:/tmp# fatcat test.bin -l /
Listing path /
Directory cluster: 2
f 8/10/2019 11:36:04  test.txt                       c=0 s=0 (0B)
zub2 commented

Thank you for the quick fix! Now -i displays some useful info. -l / displays nothing, but I suspect the FS is just weird and I need to do some reading up on FAT now.

OK, keep me in touch if you find something that can be improved in fatcat, I will close this issue in the meantime
Thanks for reporting