unformat()
PROTOTYPE
#include <posix.h>
int unformat(const char *name);
DESCRIPTION
unformat() removes the volume specified by name from its file system and erases file system metadata from the volume. After the unformat() call, the volume is unmountable until it is re-added and formatted.
For eMMC volumes whose version is greater than MMC 4.3, every volume sector is marked unused and the Sanitize command is given. For TargetFTL-NOR volumes, every assigned flash block is erased. For TargetFTL-NDM volumes, every assigned good block is erased. Bad blocks are untouched, as it is not allowed to erase bad blocks.
For volumes hosted on a hard drive, SD Card, or an eMMC device that doesn’t support Sanitize, the TargetFAT unformat clears the volume boot sector and the TargetXFS unformat clears the super pages.
If successful, unformat() returns 0. Otherwise, it sets errno and returns -1.
ERROR CODES
| EFAULT | name equals NULL. |
| EINVAL | The specified volume is currently mounted. |
| ENOENT | No attached volume matches name. |
| EROFS | The volume is read-only. |
EXAMPLE
/*-----------------------------------------------------------------*/
/* Unformat the "flash" volume and check for success. */
/*-----------------------------------------------------------------*/
if (unformat("flash"))
puts("unformat(\"flash\") failed");