What are possible reasons for binary files corruption on android devices What are possible reasons for binary files corruption on android devices linux linux

What are possible reasons for binary files corruption on android devices


I have some simmilar experience in some embedded applications that corrupt binaries.First of all, double check your file handling (specially in multithreading environments), I can imagine you have done it thoroughly. Then, try to sync all the writings. The linux kernel doesn't write as you command your app to write, but buffers data before flushing to disk.

http://linux.die.net/man/2/sync

Hope this helps.


check your file handling thats usually the problem in my experience


Broken files, or even broken file system are strangely caused by the '4096 bytes files'.

This corruption is due to cluster size for ext4 file system that is equal to page size.

At the moment, the default size of a block is 4KiB, which is a commonly supported page size on most MMU-capable hardware. This is fortunate, as ext4 code is not prepared to handle the case where the block size exceeds the page size.

PS

I am taking ext4 as it is the default file system for Linux based OSs (including but not limited to Android)

Now off to the reasons why could the 4KiB file be dangerous, reasons are simple to be understood:

  • Improper file handling: Wrong procedure in creating, reading, editing or deleting the files could damage the files and break them maybe alongside the full file system. These 'improper procedures' include non-human behavior and accidents. (PS: this is not limited to 4KiB files)
  • Improper Low Level data treatment: not a common case, still, it's possible. That happens when the Kernel or user is trying to edit the file system at low level. (You will need to investigate further this case as it should be written in a too long article!)
  • There are still many strange ways to get data broken, i am trying to keep brief. The other reasons are dependent of many factors, so i mentioned the most common causes for that issue on an Android device.

You can keep reading more here:

  • Ext4 Disk Layout : All what a researcher needs to know about Ext4
  • Exfat file system : Exfat insight! Another commonly used file system (even with Android) that is know to be too vulnerable!
  • ...