FSformat Function

MDD File System Interface Library

MDDFS Interface Library Help
FSformat Function
C
int FSformat(
    char mode, 
    long int serialNumber, 
    char * volumeID
);
Description

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

Preconditions

The device must possess a valid master boot record.

Parameters
Parameters 
Description 
mode 
  • 0 - Just erase the FAT and root
  • 1 - Create a new boot sector
 
serialNumber 
Serial number to write to the card 
volumeID 
Name of the card 
Return Values
Return Values 
Description 
Format was successful 
EOF 
Format was unsuccessful 
Side Effects

The FSerrno variable will be changed.

Remarks

Only devices with a sector size of 512 bytes are supported by the format function

Microchip MDD File System Interface 1.4.2 - [Oct 15, 2012]
Copyright © 2012 Microchip Technology, Inc.  All rights reserved.