heinbali01 wrote on Tuesday, June 06, 2017:
Hi Vladimir,
You are right, +FAT only recognises the 11-byte Volume label as stored in the partition table, found at these offsets:
#define FF_FAT_16_VOL_LABEL 0x02B
#define FF_FAT_32_VOL_LABEL 0x047
The root directory indeed may contain a Volume label, if it has this file-entry attribute:
#define FF_FAT_ATTR_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 & FF_FAT_ATTR_VOLID ) != FF_FAT_ATTR_VOLID )
+ else if( ( pxDirEntry->ucAttrib & FF_FAT_ATTR_VOLID ) == FF_FAT_ATTR_VOLID )
+ {
+ #if( ffconfigDIRECTORY_VOLID_SUPPORT != 0 )
+ {
+ const size_t uxLength = sizeof( pxIOManager->pcDirectoryVolID ) - ( size_t )1u;
+
+ memcpy( pxIOManager->pcDirectoryVolID, pucEntryBuffer, uxLength );
+ pxIOManager->pcDirectoryVolID[ uxLength ] = '\0';
+ }
+ #endif /* ffconfigDIRECTORY_VOLID_SUPPORT */
+ }
+ else
And add a new member in include\ff_ioman.h
, around line 291:
uint8_t ucPreventFlush; /* Flushing to disk only allowed when 0. */
uint8_t ucFlags; /* Bit-Mask: identifying allocated pointers and other flags */
#if( ffconfigHASH_CACHE != 0 )
FF_HashTable_t xHashCache[ ffconfigHASH_CACHE_DEPTH ];
#endif
+#if( ffconfigDIRECTORY_VOLID_SUPPORT != 0 )
+ char pcDirectoryVolID[ 12 ]; /* Volume Label of the partition as recorded in the root directory. */
+#endif
void *pvFATLockHandle;
} FF_IOManager_t;
Any access to the root directory of the volume will include fetching the new volume ID,