+FAT FF_Format feature request: Specify volume label

The FF_Format() function in FreeRTOS +FAT has no provision for specifying the volume label. Instead, it is hardcoded to “MY_DISK ” in ff_format.c. My system has three removeable SD cards, and it would be nice to be able to specify a label to help keep track of them when they are loose. Two of the cards have the same content (for redundancy), which makes them even harder to tell apart.

This looks like it should be quite a simple change, just an extra parameter to FF_Format(). However FF_Format() is called from multiple drivers, so they would need to be updated too. Is it feasible to leave FF_Format() as is and provide a separate function to set the label? Would you be willing to create a pull request with this change?

What about the following change:

/* Earlier version of FF_Format(), kept for compatibility. */
FF_Error_t FF_Format( FF_Disk_t *pxDisk, BaseType_t xPartitionNumber, BaseType_t xPreferFAT16, BaseType_t xSmallClusters )
{
	FF_FormatDisk( pxDisk, xPartitionNumber, xPreferFAT16, xSmallClusters, "MY_DISK    " );
}

/* Please provide 11 characters in the parameter 'pcVolumeName '. */
FF_Error_t FF_FormatDisk( FF_Disk_t *pxDisk, BaseType_t xPartitionNumber, BaseType_t xPreferFAT16, BaseType_t xSmallClusters, const char *pcVolumeName )
{

and:

-    memcpy( pucSectorBuffer, "MY_DISK    ", 11 );
-    strncpy( pucSectorBuffer, pcVolumeName, 11 );

Note that the label name is filled out with spaces, and it doesn’t have a terminating null character.

Hi Hein,

Looks good.

Does FreeRTOS do C99? If so, I’d suggest one small change:

FF_Error_t FF_FormatDisk( FF_Disk_t *pxDisk, BaseType_t xPartitionNumber, BaseType_t xPreferFAT16, BaseType_t xSmallClusters, const char pcVolumeName[const static 11])

-Carl