int FSformat( char mode, long int serialNumber, char * volumeID );
The FSformat function can be used to create a new boot sector on a device, based on the information in the master boot record. This function will first initialize the I/O pins and the device, and then attempts to read the master boot record. If the MBR cannot be loaded successfully, the function will fail. Next, if the 'mode' argument is specified as '0' the existing boot sector information will be loaded. If the 'mode' argument is '1' an entirely new boot sector will be constructed using the disk values from the master boot record. Once the boot sector has been successfully loaded/created, the locations of the FAT and root will be loaded from it, and they will be completely erased. If the user has specified a volumeID parameter, a VOLUME attribute entry will be created in the root directory to name the device.
FAT12, FAT16 and FAT32 formatting are supported.
Based on the number of sectors, the format function automatically compute the smallest possible value for the cluster size in order to accommodate the physical size of the media. In this case, if a media with a big capacity is formatted, the format function may take a very long time to write all the FAT tables.
Therefore, the FORMAT_SECTORS_PER_CLUSTER macro may be used to specify the exact cluster size (in multiples of sector size). This macro can be defined in FSconfig.h
The device must possess a valid master boot record.
Parameters |
Description |
mode |
|
serialNumber |
Serial number to write to the card |
volumeID |
Name of the card |
Return Values |
Description |
0 |
Format was successful |
EOF |
Format was unsuccessful |
The FSerrno variable will be changed.
Only devices with a sector size of 512 bytes are supported by the format function