mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2026-11-13 10:27:37 +00:00
* fatfs: clear n_frag when opening an existing file on exFAT This is ChaN's FatFs R0.12c patch 1 (2017-03-11). f_open() did not reset fp->obj.n_frag when it opened an existing file on an exFAT volume, so a FIL taken from uninitialized memory could carry a stale fragment count into f_write()/f_lseek() and break the FAT chain. * fatfs: set NoFatChain again when f_truncate makes a chain contiguous This is ChaN's FatFs R0.12c patch 2 (2017-03-18). On exFAT, a file that was already fragmented when it was opened kept a FAT chain after f_truncate() made it contiguous again, so later reads and writes kept walking the FAT for no reason. * fatfs: fix exFAT directory growth and f_sync in a stretched directory This is ChaN's FatFs R0.12c patch 3 (2017-04-22): "On the exFAT volume, new cluster allocation for directory fails with FR_INT_ERR." load_obj_dir() left dp->obj.n_frag uninitialized. f_sync() calls it with a DIR on the stack, so when the file's entry sits past the first cluster of a FAT-chained directory, get_fat() can see a non-zero n_frag, return EOC, and the directory entry is never updated: the data is written but the file stays 0 bytes and its clusters leak. dir_register() also needed the rest of the patch: clear the 'stretched' flag after handling it, fill the FAT fragments for the root directory too, and grow objsize only after the containing entry block is loaded. With only the n_frag line, creating the next file in the same directory fails with FR_INT_ERR. Fixes #4464