-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix dynamic FAT variant detection #55 #56
Conversation
Only the first two bytes were considered when reading the end-of-chain value from the FAT table. Extend to 4 bytes and relax requirement for first 3 bits. Make requirement for FAT12 more strict because all valid, non-reserved cluster bits must be set.
https://github.com/FreeRTOS/Lab-Project-FreeRTOS-FAT/blob/main/ff_fat.c#L737-L770 |
Hello @cookpate, thank you for this PR, but please mention something like this in "Description": "This PR solves a problem that was reported in issue #55. Thank you Carl J Kugler for doing so. Actually I was on my way to produce this PR my self, but you were quicker. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cookpate, have you tested these changes?
I did and now I see errors with a FAT16 volume that previously worked well:
Partition at 9 has strange FAT data FFFFFFF8
FF_RAMDiskInit: FF_Mount: IOMAN_INVALID_FORMAT
I think that replacing FF_getShort()
with FF_getLong()
is enough, beside removing the earlier _HT_
comment.
Hi Patrick, I have checked the function I would like to keep the name A shortcoming in your code was that you compared a 32-bit value with a 12- or 16-bit pattern ( Thanks |
All I know about this I learned from Design of the FAT file system; Special entries.
So, I don't think the checks are quite right. For example,
because allowed values are Maybe
should be
|
Hello @cookpate, would you be so kind to copy the function contained in this ZIP file: into the your copy of @carlk3 and I went through my earlier solution prvDetermineFatType_v2.zip and agreed on the above prvDetermineFatType_v4.zip. Thanks |
on-behalf-of: Hein Tibosch hein_tibosch@yahoo.es
Happy Thanksgiving! I applied v4 to |
I'll look into formatting this later. Need to docker into a Ubuntu 20 instance in order to get the correct version of Uncrustify... |
/bot run formatting |
Unfortunately, Clang-format is not used in the majority of FreeRTOS repos. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ffconfigFAT_CHECK
is a helpful option that helps determine/verify the FAT type, FAT12, FAT16, or FAT32.
It reads the first cluster address of the FAT table, which is supposed to have the value of end-of-chain.
I retested the latest version on a Xilinx Zynq, and it still works as expected.
Thanks for this PR
Fix dynamic FAT variant detection
Description
Only the first two bytes were considered when reading the end-of-chain value from the FAT table. This resulted in FAT32 not being fully detected.
This commit extends the check to the first 4 bytes in the table and makes FAT12 checks more strict while relaxing FAT16 and FAT32 checks since the first 3 bits are ignored but all other valid bits are checked.
Test Steps
Format a valid FAT32 partition (e.g. onto an SD card).
Observe debug output indicating bad partition magic when mounting the partition.
prvDetermineFatType: firstWord 0x0000FFF8
Checklist:
Related Issue
#55
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.