How to detect file system fault or unformatted partition in a user space program via a C api?

111 Views Asked by At

I have a SD card in /dev/mmcblk0, with one vfat partition at /dev/mmcblk0p1, mounted at /media/mmcblk0p1.

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.

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.

fsck.vfat'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.

0

There are 0 best solutions below