+FAT – Incorrect Volume Label
Hello!
I`am started to using FreeRTOS with +FAT file system and want to thank its authors for their hard work!
And here is an issue I have encountered.
The Volume Label acquired by FF_Mount function in pxIOManager->xPartition.pcVolumeLabel structure member is invalid/outdated.
This label is copied directly from partition sector, but there is another place for it – root directory entry with the attribute ATTRVOLUMEID, which holds an actual volume label.
So, in my case (Windows 10), SD card with the label “SD CARD”, has the wrong (outdated) “NO NAME” label reported by +FAT 🙁
Regards
Vladimir
+FAT – Incorrect Volume Label
Hi Vladimir,
You are right, +FAT only recognises the 11-byte Volume label as stored in the partition table, found at these offsets:
~~~
#define FFFAT16VOLLABEL 0x02B
#define FFFAT32VOLLABEL 0x047
~~~
The root directory indeed may contain a Volume label, if it has this file-entry attribute:
~~~
#define FFFATATTR_VOLID 0x08
~~~
The FreeRTOS+FAT library is developed for embedded applications, and the choice was made to ignore these Volume ID entries in the root directory.
But, well, here is a read-only version, that needs a minimum of changes to the source code:
Replace on line in
ff_dir.c
around line 1799 :
~~~
– else if( ( pxDirEntry->ucAttrib & FFFATATTRVOLID ) != FFFATATTRVOLID )
+ else if( ( pxDirEntry->ucAttrib & FFFATATTRVOLID ) == FFFATATTRVOLID )
+ {
+ #if( ffconfigDIRECTORYVOLIDSUPPORT != 0 )
+ {
+ const sizet uxLength = sizeof( pxIOManager->pcDirectoryVolID ) – ( sizet )1u;
+
+ memcpy( pxIOManager->pcDirectoryVolID, pucEntryBuffer, uxLength );
+ pxIOManager->pcDirectoryVolID[ uxLength ] = ‘