Dave Murphy 2011-06-28 20:35:00 +00:00
parent a7307e0c0e
commit 1bb3bab6e4
4 changed files with 105 additions and 121 deletions

View File

@ -224,7 +224,7 @@ static bool _FAT_directory_entryGetAlias (const u8* entryData, char* destName) {
caseInfo = entryData[DIR_ENTRY_caseInfo] & CASE_LOWER_BASE; caseInfo = entryData[DIR_ENTRY_caseInfo] & CASE_LOWER_BASE;
for (i = 0; (i < 8) && (entryData[DIR_ENTRY_name + i] != ' '); i++) { for (i = 0; (i < 8) && (entryData[DIR_ENTRY_name + i] != ' '); i++) {
c = entryData[DIR_ENTRY_name + i]; c = entryData[DIR_ENTRY_name + i];
destName[i] = (caseInfo ? tolower(c) : c); destName[i] = (caseInfo ? tolower((unsigned char)c) : c);
} }
// Copy the extension from the dirEntry to the string // Copy the extension from the dirEntry to the string
if (entryData[DIR_ENTRY_extension] != ' ') { if (entryData[DIR_ENTRY_extension] != ' ') {
@ -232,7 +232,7 @@ static bool _FAT_directory_entryGetAlias (const u8* entryData, char* destName) {
caseInfo = entryData[DIR_ENTRY_caseInfo] & CASE_LOWER_EXT; caseInfo = entryData[DIR_ENTRY_caseInfo] & CASE_LOWER_EXT;
for ( j = 0; (j < 3) && (entryData[DIR_ENTRY_extension + j] != ' '); j++) { for ( j = 0; (j < 3) && (entryData[DIR_ENTRY_extension + j] != ' '); j++) {
c = entryData[DIR_ENTRY_extension + j]; c = entryData[DIR_ENTRY_extension + j];
destName[i++] = (caseInfo ? tolower(c) : c); destName[i++] = (caseInfo ? tolower((unsigned char)c) : c);
} }
} }
destName[i] = '\0'; destName[i] = '\0';

View File

@ -465,16 +465,16 @@ int _FAT_statvfs_r (struct _reent *r, const char *path, struct statvfs *buf)
_FAT_lock(&partition->lock); _FAT_lock(&partition->lock);
if(memcmp(&buf->f_flag, "SCAN", 4) == 0) if(memcmp(&buf->f_flag, "SCAN", 4) == 0)
{ {
//Special command was given to sync the numberFreeCluster //Special command was given to sync the numberFreeCluster
_FAT_partition_createFSinfo(partition); _FAT_partition_createFSinfo(partition);
} }
if(partition->filesysType == FS_FAT32) if(partition->filesysType == FS_FAT32)
freeClusterCount = partition->fat.numberFreeCluster; freeClusterCount = partition->fat.numberFreeCluster;
else else
freeClusterCount = _FAT_fat_freeClusterCount (partition); freeClusterCount = _FAT_fat_freeClusterCount (partition);
// FAT clusters = POSIX blocks // FAT clusters = POSIX blocks
buf->f_bsize = partition->bytesPerCluster; // File system block size. buf->f_bsize = partition->bytesPerCluster; // File system block size.

View File

@ -247,7 +247,7 @@ uint32_t _FAT_fat_linkFreeCluster(PARTITION* partition, uint32_t cluster) {
} }
partition->fat.firstFree = firstFree; partition->fat.firstFree = firstFree;
if(partition->fat.numberFreeCluster) if(partition->fat.numberFreeCluster)
partition->fat.numberFreeCluster--; partition->fat.numberFreeCluster--;
partition->fat.numberLastAllocCluster = firstFree; partition->fat.numberLastAllocCluster = firstFree;
if ((cluster >= CLUSTER_FIRST) && (cluster <= lastCluster)) if ((cluster >= CLUSTER_FIRST) && (cluster <= lastCluster))
@ -279,7 +279,7 @@ uint32_t _FAT_fat_linkFreeClusterCleared (PARTITION* partition, uint32_t cluster
return CLUSTER_ERROR; return CLUSTER_ERROR;
} }
emptySector = (uint8_t*) _FAT_mem_allocate(partition->bytesPerSector); emptySector = (uint8_t*) _FAT_mem_allocate(partition->bytesPerSector);
// Clear all the sectors within the cluster // Clear all the sectors within the cluster
memset (emptySector, 0, partition->bytesPerSector); memset (emptySector, 0, partition->bytesPerSector);
@ -317,8 +317,8 @@ bool _FAT_fat_clearLinks (PARTITION* partition, uint32_t cluster) {
// Erase the link // Erase the link
_FAT_fat_writeFatEntry (partition, cluster, CLUSTER_FREE); _FAT_fat_writeFatEntry (partition, cluster, CLUSTER_FREE);
if(partition->fat.numberFreeCluster < (partition->numberOfSectors/partition->sectorsPerCluster)) if(partition->fat.numberFreeCluster < (partition->numberOfSectors/partition->sectorsPerCluster))
partition->fat.numberFreeCluster++; partition->fat.numberFreeCluster++;
// Move onto next cluster // Move onto next cluster
cluster = nextCluster; cluster = nextCluster;
} }

View File

@ -91,10 +91,10 @@ enum BPB {
// File system information block offsets // File system information block offsets
enum FSIB enum FSIB
{ {
FSIB_SIG1 = 0x00, FSIB_SIG1 = 0x00,
FSIB_SIG2 = 0x1e4, FSIB_SIG2 = 0x1e4,
FSIB_numberOfFreeCluster = 0x1e8, FSIB_numberOfFreeCluster = 0x1e8,
FSIB_numberLastAllocCluster = 0x1ec, FSIB_numberLastAllocCluster = 0x1ec,
FSIB_bootSig_55 = 0x1FE, FSIB_bootSig_55 = 0x1FE,
FSIB_bootSig_AA = 0x1FF FSIB_bootSig_AA = 0x1FF
}; };
@ -103,20 +103,14 @@ static const char FAT_SIG[3] = {'F', 'A', 'T'};
static const char FS_INFO_SIG1[4] = {'R', 'R', 'a', 'A'}; static const char FS_INFO_SIG1[4] = {'R', 'R', 'a', 'A'};
static const char FS_INFO_SIG2[4] = {'r', 'r', 'A', 'a'}; static const char FS_INFO_SIG2[4] = {'r', 'r', 'A', 'a'};
sec_t FindFirstValidPartition(const DISC_INTERFACE* disc) sec_t FindFirstValidPartition_buf(const DISC_INTERFACE* disc, uint8_t *sectorBuffer)
{ {
uint8_t part_table[16*4]; uint8_t part_table[16*4];
uint8_t *ptr; uint8_t *ptr;
int i; int i;
uint8_t *sectorBuffer = (uint8_t*) _FAT_mem_allocate(MAX_SECTOR_SIZE);
if(!sectorBuffer) {
return 0;
}
// Read first sector of disc // Read first sector of disc
if (!_FAT_disc_readSectors (disc, 0, 1, sectorBuffer)) { if (!_FAT_disc_readSectors (disc, 0, 1, sectorBuffer)) {
_FAT_mem_free(sectorBuffer);
return 0; return 0;
} }
@ -128,7 +122,6 @@ sec_t FindFirstValidPartition(const DISC_INTERFACE* disc)
if (!memcmp(sectorBuffer + BPB_FAT16_fileSysType, FAT_SIG, sizeof(FAT_SIG)) || if (!memcmp(sectorBuffer + BPB_FAT16_fileSysType, FAT_SIG, sizeof(FAT_SIG)) ||
!memcmp(sectorBuffer + BPB_FAT32_fileSysType, FAT_SIG, sizeof(FAT_SIG))) { !memcmp(sectorBuffer + BPB_FAT32_fileSysType, FAT_SIG, sizeof(FAT_SIG))) {
_FAT_mem_free(sectorBuffer);
return part_lba; return part_lba;
} }
@ -141,61 +134,53 @@ sec_t FindFirstValidPartition(const DISC_INTERFACE* disc)
for(n=0;n<8;n++) // max 8 logic partitions for(n=0;n<8;n++) // max 8 logic partitions
{ {
if(!_FAT_disc_readSectors (disc, part_lba+next_lba2, 1, sectorBuffer)) { if(!_FAT_disc_readSectors (disc, part_lba+next_lba2, 1, sectorBuffer)) return 0;
_FAT_mem_free(sectorBuffer);
return 0;
}
part_lba2 = part_lba + next_lba2 + u8array_to_u32(sectorBuffer, 0x1C6) ; part_lba2 = part_lba + next_lba2 + u8array_to_u32(sectorBuffer, 0x1C6) ;
next_lba2 = u8array_to_u32(sectorBuffer, 0x1D6); next_lba2 = u8array_to_u32(sectorBuffer, 0x1D6);
if(!_FAT_disc_readSectors (disc, part_lba2, 1, sectorBuffer)) { if(!_FAT_disc_readSectors (disc, part_lba2, 1, sectorBuffer)) return 0;
_FAT_mem_free(sectorBuffer);
return 0;
}
if (!memcmp(sectorBuffer + BPB_FAT16_fileSysType, FAT_SIG, sizeof(FAT_SIG)) || if (!memcmp(sectorBuffer + BPB_FAT16_fileSysType, FAT_SIG, sizeof(FAT_SIG)) ||
!memcmp(sectorBuffer + BPB_FAT32_fileSysType, FAT_SIG, sizeof(FAT_SIG))) { !memcmp(sectorBuffer + BPB_FAT32_fileSysType, FAT_SIG, sizeof(FAT_SIG)))
_FAT_mem_free(sectorBuffer); {
return part_lba2; return part_lba2;
} }
if(next_lba2==0) break; if(next_lba2==0) break;
} }
} else { } else {
if(!_FAT_disc_readSectors (disc, part_lba, 1, sectorBuffer)) { if(!_FAT_disc_readSectors (disc, part_lba, 1, sectorBuffer)) return 0;
_FAT_mem_free(sectorBuffer);
return 0;
}
if (!memcmp(sectorBuffer + BPB_FAT16_fileSysType, FAT_SIG, sizeof(FAT_SIG)) || if (!memcmp(sectorBuffer + BPB_FAT16_fileSysType, FAT_SIG, sizeof(FAT_SIG)) ||
!memcmp(sectorBuffer + BPB_FAT32_fileSysType, FAT_SIG, sizeof(FAT_SIG))) { !memcmp(sectorBuffer + BPB_FAT32_fileSysType, FAT_SIG, sizeof(FAT_SIG))) {
_FAT_mem_free(sectorBuffer);
return part_lba; return part_lba;
} }
} }
} }
_FAT_mem_free(sectorBuffer);
return 0; return 0;
} }
sec_t FindFirstValidPartition(const DISC_INTERFACE* disc)
{
uint8_t *sectorBuffer = (uint8_t*) _FAT_mem_align(MAX_SECTOR_SIZE);
if (!sectorBuffer) return 0;
sec_t ret = FindFirstValidPartition_buf(disc, sectorBuffer);
_FAT_mem_free(sectorBuffer);
return ret;
}
PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cacheSize, uint32_t sectorsPerPage, sec_t startSector) {
PARTITION* _FAT_partition_constructor_buf (const DISC_INTERFACE* disc, uint32_t cacheSize, uint32_t sectorsPerPage, sec_t startSector, uint8_t *sectorBuffer)
{
PARTITION* partition; PARTITION* partition;
uint8_t *sectorBuffer = (uint8_t*) _FAT_mem_allocate(MAX_SECTOR_SIZE);
if(!sectorBuffer) {
return NULL;
}
// Read first sector of disc // Read first sector of disc
if (!_FAT_disc_readSectors (disc, startSector, 1, sectorBuffer)) { if (!_FAT_disc_readSectors (disc, startSector, 1, sectorBuffer)) {
_FAT_mem_free(sectorBuffer);
return NULL; return NULL;
} }
// Make sure it is a valid MBR or boot sector // Make sure it is a valid MBR or boot sector
if ( (sectorBuffer[BPB_bootSig_55] != 0x55) || (sectorBuffer[BPB_bootSig_AA] != 0xAA)) { if ( (sectorBuffer[BPB_bootSig_55] != 0x55) || (sectorBuffer[BPB_bootSig_AA] != 0xAA)) {
_FAT_mem_free(sectorBuffer);
return NULL; return NULL;
} }
@ -208,23 +193,21 @@ PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cach
// Check for FAT32 // Check for FAT32
startSector = 0; startSector = 0;
} else { } else {
startSector = FindFirstValidPartition(disc); startSector = FindFirstValidPartition_buf(disc, sectorBuffer);
if (!_FAT_disc_readSectors (disc, startSector, 1, sectorBuffer)) { if (!_FAT_disc_readSectors (disc, startSector, 1, sectorBuffer)) {
_FAT_mem_free(sectorBuffer);
return NULL; return NULL;
} }
} }
// Now verify that this is indeed a FAT partition // Now verify that this is indeed a FAT partition
if (memcmp(sectorBuffer + BPB_FAT16_fileSysType, FAT_SIG, sizeof(FAT_SIG)) && if (memcmp(sectorBuffer + BPB_FAT16_fileSysType, FAT_SIG, sizeof(FAT_SIG)) &&
memcmp(sectorBuffer + BPB_FAT32_fileSysType, FAT_SIG, sizeof(FAT_SIG))) { memcmp(sectorBuffer + BPB_FAT32_fileSysType, FAT_SIG, sizeof(FAT_SIG)))
_FAT_mem_free(sectorBuffer); {
return NULL; return NULL;
} }
partition = (PARTITION*) _FAT_mem_allocate (sizeof(PARTITION)); partition = (PARTITION*) _FAT_mem_allocate (sizeof(PARTITION));
if (partition == NULL) { if (partition == NULL) {
_FAT_mem_free(sectorBuffer);
return NULL; return NULL;
} }
@ -253,11 +236,10 @@ PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cach
partition->bytesPerSector = u8array_to_u16(sectorBuffer, BPB_bytesPerSector); partition->bytesPerSector = u8array_to_u16(sectorBuffer, BPB_bytesPerSector);
if(partition->bytesPerSector < MIN_SECTOR_SIZE || partition->bytesPerSector > MAX_SECTOR_SIZE) { if(partition->bytesPerSector < MIN_SECTOR_SIZE || partition->bytesPerSector > MAX_SECTOR_SIZE) {
// Unsupported sector size // Unsupported sector size
_FAT_mem_free(sectorBuffer); _FAT_mem_free(partition);
_FAT_mem_free(partition); return NULL;
return NULL; }
}
partition->sectorsPerCluster = sectorBuffer[BPB_sectorsPerCluster]; partition->sectorsPerCluster = sectorBuffer[BPB_sectorsPerCluster];
partition->bytesPerCluster = partition->bytesPerSector * partition->sectorsPerCluster; partition->bytesPerCluster = partition->bytesPerSector * partition->sectorsPerCluster;
@ -269,14 +251,14 @@ PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cach
partition->totalSize = ((uint64_t)partition->numberOfSectors - (partition->dataStart - startSector)) * (uint64_t)partition->bytesPerSector; partition->totalSize = ((uint64_t)partition->numberOfSectors - (partition->dataStart - startSector)) * (uint64_t)partition->bytesPerSector;
//FS info sector //FS info sector
partition->fsInfoSector = startSector + (u8array_to_u16(sectorBuffer, BPB_FAT32_fsInfo) ? u8array_to_u16(sectorBuffer, BPB_FAT32_fsInfo) : 1); partition->fsInfoSector = startSector + (u8array_to_u16(sectorBuffer, BPB_FAT32_fsInfo) ? u8array_to_u16(sectorBuffer, BPB_FAT32_fsInfo) : 1);
// Store info about FAT // Store info about FAT
uint32_t clusterCount = (partition->numberOfSectors - (uint32_t)(partition->dataStart - startSector)) / partition->sectorsPerCluster; uint32_t clusterCount = (partition->numberOfSectors - (uint32_t)(partition->dataStart - startSector)) / partition->sectorsPerCluster;
partition->fat.lastCluster = clusterCount + CLUSTER_FIRST - 1; partition->fat.lastCluster = clusterCount + CLUSTER_FIRST - 1;
partition->fat.firstFree = CLUSTER_FIRST; partition->fat.firstFree = CLUSTER_FIRST;
partition->fat.numberFreeCluster = 0; partition->fat.numberFreeCluster = 0;
partition->fat.numberLastAllocCluster = 0; partition->fat.numberLastAllocCluster = 0;
if (clusterCount < CLUSTERS_PER_FAT12) { if (clusterCount < CLUSTERS_PER_FAT12) {
@ -314,11 +296,20 @@ PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cach
_FAT_partition_readFSinfo(partition); _FAT_partition_readFSinfo(partition);
_FAT_mem_free(sectorBuffer);
return partition; return partition;
} }
PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cacheSize, uint32_t sectorsPerPage, sec_t startSector)
{
uint8_t *sectorBuffer = (uint8_t*) _FAT_mem_align(MAX_SECTOR_SIZE);
if (!sectorBuffer) return NULL;
PARTITION *ret = _FAT_partition_constructor_buf(disc, cacheSize,
sectorsPerPage, startSector, sectorBuffer);
_FAT_mem_free(sectorBuffer);
return ret;
}
void _FAT_partition_destructor (PARTITION* partition) { void _FAT_partition_destructor (PARTITION* partition) {
FILE_STRUCT* nextFile; FILE_STRUCT* nextFile;
@ -331,8 +322,8 @@ void _FAT_partition_destructor (PARTITION* partition) {
nextFile = nextFile->nextOpenFile; nextFile = nextFile->nextOpenFile;
} }
// Write out the fs info sector // Write out the fs info sector
_FAT_partition_writeFSinfo(partition); _FAT_partition_writeFSinfo(partition);
// Free memory used by the cache, writing it to disc at the same time // Free memory used by the cache, writing it to disc at the same time
_FAT_cache_destructor (partition->cache); _FAT_cache_destructor (partition->cache);
@ -359,89 +350,82 @@ PARTITION* _FAT_partition_getPartitionFromPath (const char* path) {
void _FAT_partition_createFSinfo(PARTITION * partition) void _FAT_partition_createFSinfo(PARTITION * partition)
{ {
if(partition->readOnly || partition->filesysType != FS_FAT32) if(partition->readOnly || partition->filesysType != FS_FAT32)
return; return;
uint8_t *sectorBuffer = (uint8_t*) _FAT_mem_allocate(partition->bytesPerSector); uint8_t *sectorBuffer = (uint8_t*) _FAT_mem_align(partition->bytesPerSector);
if(!sectorBuffer) { if (!sectorBuffer) return;
return; memset(sectorBuffer, 0, partition->bytesPerSector);
int i;
for(i = 0; i < 4; ++i)
{
sectorBuffer[FSIB_SIG1+i] = FS_INFO_SIG1[i];
sectorBuffer[FSIB_SIG2+i] = FS_INFO_SIG2[i];
} }
memset(sectorBuffer, 0, partition->bytesPerSector);
int i; partition->fat.numberFreeCluster = _FAT_fat_freeClusterCount(partition);
for(i = 0; i < 4; ++i) u32_to_u8array(sectorBuffer, FSIB_numberOfFreeCluster, partition->fat.numberFreeCluster);
{ u32_to_u8array(sectorBuffer, FSIB_numberLastAllocCluster, partition->fat.numberLastAllocCluster);
sectorBuffer[FSIB_SIG1+i] = FS_INFO_SIG1[i];
sectorBuffer[FSIB_SIG2+i] = FS_INFO_SIG2[i];
}
partition->fat.numberFreeCluster = _FAT_fat_freeClusterCount(partition); sectorBuffer[FSIB_bootSig_55] = 0x55;
u32_to_u8array(sectorBuffer, FSIB_numberOfFreeCluster, partition->fat.numberFreeCluster); sectorBuffer[FSIB_bootSig_AA] = 0xAA;
u32_to_u8array(sectorBuffer, FSIB_numberLastAllocCluster, partition->fat.numberLastAllocCluster);
sectorBuffer[FSIB_bootSig_55] = 0x55; _FAT_disc_writeSectors (partition->disc, partition->fsInfoSector, 1, sectorBuffer);
sectorBuffer[FSIB_bootSig_AA] = 0xAA;
_FAT_disc_writeSectors (partition->disc, partition->fsInfoSector, 1, sectorBuffer); _FAT_mem_free(sectorBuffer);
_FAT_mem_free(sectorBuffer);
} }
void _FAT_partition_readFSinfo(PARTITION * partition) void _FAT_partition_readFSinfo(PARTITION * partition)
{ {
if(partition->filesysType != FS_FAT32) if(partition->filesysType != FS_FAT32)
return; return;
uint8_t *sectorBuffer = (uint8_t*) _FAT_mem_allocate(partition->bytesPerSector); uint8_t *sectorBuffer = (uint8_t*) _FAT_mem_align(partition->bytesPerSector);
if(!sectorBuffer) { if (!sectorBuffer) return;
return; memset(sectorBuffer, 0, partition->bytesPerSector);
}
memset(sectorBuffer, 0, partition->bytesPerSector);
// Read first sector of disc // Read first sector of disc
if (!_FAT_disc_readSectors (partition->disc, partition->fsInfoSector, 1, sectorBuffer)) { if (!_FAT_disc_readSectors (partition->disc, partition->fsInfoSector, 1, sectorBuffer)) {
_FAT_mem_free(sectorBuffer); _FAT_mem_free(sectorBuffer);
return; return;
} }
if(memcmp(sectorBuffer+FSIB_SIG1, FS_INFO_SIG1, 4) != 0 || if(memcmp(sectorBuffer+FSIB_SIG1, FS_INFO_SIG1, 4) != 0 ||
memcmp(sectorBuffer+FSIB_SIG2, FS_INFO_SIG2, 4) != 0 || memcmp(sectorBuffer+FSIB_SIG2, FS_INFO_SIG2, 4) != 0 ||
u8array_to_u32(sectorBuffer, FSIB_numberOfFreeCluster) == 0) { u8array_to_u32(sectorBuffer, FSIB_numberOfFreeCluster) == 0)
//sector does not yet exist, create one! {
_FAT_partition_createFSinfo(partition); //sector does not yet exist, create one!
_FAT_mem_free(sectorBuffer); _FAT_partition_createFSinfo(partition);
return; } else {
} partition->fat.numberFreeCluster = u8array_to_u32(sectorBuffer, FSIB_numberOfFreeCluster);
partition->fat.numberLastAllocCluster = u8array_to_u32(sectorBuffer, FSIB_numberLastAllocCluster);
partition->fat.numberFreeCluster = u8array_to_u32(sectorBuffer, FSIB_numberOfFreeCluster); }
partition->fat.numberLastAllocCluster = u8array_to_u32(sectorBuffer, FSIB_numberLastAllocCluster); _FAT_mem_free(sectorBuffer);
_FAT_mem_free(sectorBuffer);
} }
void _FAT_partition_writeFSinfo(PARTITION * partition) void _FAT_partition_writeFSinfo(PARTITION * partition)
{ {
if(partition->filesysType != FS_FAT32) if(partition->filesysType != FS_FAT32)
return; return;
uint8_t *sectorBuffer = (uint8_t*) _FAT_mem_allocate(partition->bytesPerSector); uint8_t *sectorBuffer = (uint8_t*) _FAT_mem_align(partition->bytesPerSector);
if(!sectorBuffer) { if (!sectorBuffer) return;
return; memset(sectorBuffer, 0, partition->bytesPerSector);
}
memset(sectorBuffer, 0, partition->bytesPerSector);
// Read first sector of disc // Read first sector of disc
if (!_FAT_disc_readSectors (partition->disc, partition->fsInfoSector, 1, sectorBuffer)) { if (!_FAT_disc_readSectors (partition->disc, partition->fsInfoSector, 1, sectorBuffer)) {
_FAT_mem_free(sectorBuffer); _FAT_mem_free(sectorBuffer);
return; return;
} }
if(memcmp(sectorBuffer+FSIB_SIG1, FS_INFO_SIG1, 4) || memcmp(sectorBuffer+FSIB_SIG2, FS_INFO_SIG2, 4)) { if(memcmp(sectorBuffer+FSIB_SIG1, FS_INFO_SIG1, 4) || memcmp(sectorBuffer+FSIB_SIG2, FS_INFO_SIG2, 4)) {
_FAT_mem_free(sectorBuffer); _FAT_mem_free(sectorBuffer);
return; return;
} }
u32_to_u8array(sectorBuffer, FSIB_numberOfFreeCluster, partition->fat.numberFreeCluster); u32_to_u8array(sectorBuffer, FSIB_numberOfFreeCluster, partition->fat.numberFreeCluster);
u32_to_u8array(sectorBuffer, FSIB_numberLastAllocCluster, partition->fat.numberLastAllocCluster); u32_to_u8array(sectorBuffer, FSIB_numberLastAllocCluster, partition->fat.numberLastAllocCluster);
// Read first sector of disc // Write first sector of disc
_FAT_disc_writeSectors (partition->disc, partition->fsInfoSector, 1, sectorBuffer); _FAT_disc_writeSectors (partition->disc, partition->fsInfoSector, 1, sectorBuffer);
_FAT_mem_free(sectorBuffer); _FAT_mem_free(sectorBuffer);
} }