When mounting my SD Card on my galaxy SIII files and folders in the card with characters that aren't in the ASCII range get corrupted. This happens by simply selecting 'Unmount card' in the Storage settings and mounting back. No need to physically remove the card and putting it back in. Turning the phone off and back on results in corruption as well.
Folders when viewed with a file manager on the phone show up as 0-size files with a date of Dec 31, 1969 (which is the linux epoch) and can't be navigated into to see their contents. They shw as empty folders. Files turn to size zero with that same date and can't be opened nor show in Gallery, music player etc. They open as an empty folder. (See image below)
I am using stock Android version 4.1.2.
The card is a SanDisk 64gb micro sdxc card (class 10). The issue ocurred when the card was factory-formated (with exFAT) and also after formating with the phone (settings > storage).
Examples of filenames that cause folder corruption are "Aṣa" or "דניאל". It makes no difference if the file was copied to the card using usb transfer or by taking the card out and using a reader on a Windows PC, or if the name was changed (using the phone) once the file was on the card.
Files with those same names don't get corrupted if they are in the internal phone memory and I can use them without problem.
When taking the card out and using it on a PC with Windows 7 files can be seen. But sometimes the affected folders appear duplicated. That is, twice with the same name both. Checking the disk with windows reports errors and attempts to fix them. But then when putting the card back in the phone the files are corrupted again.
How can I prevent this corruption from happening?
Update: with a 2GB card formated with FAT32 files didn't get corrupted. But after I formatted it to exFAT I could reproduce the file corruption. I think I can rule out a bad sd card.
More info, this is a report from Windows 7 after running checkdisk. Note that the 3 files existed in the TestFolder directory, which was corrupted:
[Window Title] Checking Disk Removable Disk (M:) [Main Instruction] Some problems were found and fixed [Content] Any files that were affected by these problems were moved to a folder named "Found" on the device or disk. Your device or disk is now ready to use. If you removed the device or disk before all files were fully written to it, parts of some files might still be missing. If so, go back to the source and recopy those files to your device or disk. [^] Hide details [Close] [Expanded Information] Volume Serial Number is 6518-E54A Windows is verifying files and folders... Corruption was found while examining files in directory \TestFolder\ (0). Corruption was found while examining files in directory \TestFolder\ (3). Corruption was found while examining files in directory \TestFolder\ (6). Corruption was found while examining files and directories. File and folder verification is complete. Windows has made corrections to the file system. 62363648 KB total disk space. 41656576 KB in 43 files. 768 KB in 6 indexes. 256 KB in use by the system. 20706048 KB available on disk. 131072 bytes in each allocation unit. 487216 total allocation units on disk. 161766 allocation units available on disk.
Folders don't get corrupted if they are created on the phone with hebrew names, then unmounted and checked on windows. Only after re-mounting on the phone.
MORE DATA: this is I think relevant info from
I//system/bin/fsck.exfat( 1897): fsck.exfat 1.1.0p2 I//system/bin/fsck.exfat( 1897): [fsck] Invalid dir entry: (92675,0) I//system/bin/fsck.exfat( 1897): [fsck] Wrong dir entry name hash I//system/bin/fsck.exfat( 1897): [fsck] Successfully recovered I//system/bin/fsck.exfat( 1897): Filesystem was modified. I/logwrapper( 1897): /system/bin/fsck.exfat terminated by exit(4) W/Vold ( 1897): exfat -> Filesystem modified - rechecking (pass 2) E/Vold ( 1897): MDM :: sdCardWriteAccessBlocked 0 D/Vold ( 1897): Detected exFAT file system.
And when booting without problematic filenames I instead get a cute little
I//system/bin/fsck.exfat( 1897): No errors I/Vold ( 1897): exfat -> Filesystem check completed OK
adb shell I can try and see the troublemakers (after remount, note 2 directories with apparently the same name, which in a windows console seems to be output as 2 characters per unicode character):
shell@android:/storage/extSdCard/Test $ ls * -l ls * -l drwxrwxr-x system media_rw 2013-02-18 18:39 ╫É╫æ╫Æ ╫É╫æ╫Æ: No such file or directory 1|shell@android:/storage/extSdCard/Test $
fsckin combination with [ex]FAT. Question is: Does it happen at mount time, or at unmount (i.e. after unmounting, taking the card out and use a card reader on your PC, are they already scrambled)?