title: How to detect file system fault or unformatted partition in a user space program via a C api?
body: <p>I have a SD card in <code>/dev/mmcblk0</code>, with one <code>vfat</code> partition at <code>/dev/mmcblk0p1</code>, mounted at <code>/media/mmcblk0p1</code>.</p>
  
  <p>When my application starts up, I want it to check the file system in that partition, try to repair it, and notify user if there are non-repairable errors, and possibly recommend a re-format.</p>
  
  <p>This SD card is installed internally, not removable, and is shipped with the product. I want to keep it as healthy as possible to avoid a customer service nightmare. </p>
  
  <p><a href="http://linux.die.net/man/8/fsck.vfat" rel="nofollow">fsck.vfat</a>'s exit status doesn't distinguish between "No recoverable errors have been detected." and "Non-recoverable errors have been detected.", so it doesn't exactly meet the need here.</p>