|

楼主 |
发表于 2025-9-17 10:44:25
|
显示全部楼层
/* Determine if a 32-bit FAT is present. If so, calculate the size of the root directory (since
it is variable in FAT32. */
if (media_ptr -> fx_media_32_bit_FAT == FX_TRUE)
{
/* Root First cluster starts from at least cluster 2, or higher. */
if (media_ptr -> fx_media_root_cluster_32 < FX_FAT_ENTRY_START)
{
return(FX_MEDIA_INVALID);
}
/* Calculate logical number of root dir sector. */
media_ptr -> fx_media_root_sector_start = media_ptr -> fx_media_data_sector_start +
(media_ptr -> fx_media_root_cluster_32 - FX_FAT_ENTRY_START) *
media_ptr -> fx_media_sectors_per_cluster;
/* Calculate maximum possible value for fx_media_root_directory_entries */
i = 0;
for (cluster_number = media_ptr -> fx_media_root_cluster_32;;)
{
status = _fx_utility_FAT_entry_read(media_ptr, cluster_number, &FAT_entry);
i++;
/* Determine if the read was successful. */
if (status != FX_SUCCESS)
{
/* Build the "uninitialize" I/O driver request. */
media_ptr -> fx_media_driver_request = FX_DRIVER_UNINIT;
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
/* If trace is enabled, insert this event into the trace buffer. */
FX_TRACE_IN_LINE_INSERT(FX_TRACE_INTERNAL_IO_DRIVER_UNINIT, media_ptr, 0, 0, 0, FX_TRACE_INTERNAL_EVENTS, 0, 0)
/* Call the specified I/O driver with the uninitialize request. */
(media_ptr -> fx_media_driver_entry) (media_ptr);
return(FX_FAT_READ_ERROR);
}
if ((cluster_number == FAT_entry) || (i > media_ptr -> fx_media_total_clusters))
{
/* Build the "uninitialize" I/O driver request. */
media_ptr -> fx_media_driver_request = FX_DRIVER_UNINIT;
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
/* If trace is enabled, insert this event into the trace buffer. */
FX_TRACE_IN_LINE_INSERT(FX_TRACE_INTERNAL_IO_DRIVER_UNINIT, media_ptr, 0, 0, 0, FX_TRACE_INTERNAL_EVENTS, 0, 0)
/* Call the specified I/O driver with the uninitialize request. */
(media_ptr -> fx_media_driver_entry) (media_ptr);
return(FX_FAT_READ_ERROR);
}
if (FAT_entry >= FX_RESERVED_1_32)
{
break;
}
cluster_number = FAT_entry;
}
/* Calculate the number of directory entries. */
media_ptr -> fx_media_root_directory_entries = (i * media_ptr -> fx_media_sectors_per_cluster *
media_ptr -> fx_media_bytes_per_sector) / FX_DIR_ENTRY_SIZE;
}
|
|