I was able to reduce this to: When a file is in use, and it is renamed and the attributes are changed, it becomes it's original filename again. In case of a long filename, it will be renamed to it's short filename. See RenFileBug.c for a testcase.
It is caused by the cached entry of the fcb table not having updated the 8.3 filename on a rename. But when the attributes are changed, the unmodified 8.3 filename is written back to disk.
The attached patch fixes this issue for me. Two remarks though:
- It introduces duplicate code, I have copied the main part shamelessly from the vfatUpdateFCB function.
- The if is not required, I'm not sure it is better to leave it out.