void _FAT_partition_createFSinfo(PARTITION * partition) { if(partition->readOnly || partition->filesysType != FS_FAT32) return; uint8_t *sectorBuffer = (uint8_t*) _FAT_mem_align(partition->bytesPerSector); if (!sectorBuffer) 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]; } partition->fat.numberFreeCluster = _FAT_fat_freeClusterCount(partition); u32_to_u8array(sectorBuffer, FSIB_numberOfFreeCluster, partition->fat.numberFreeCluster); u32_to_u8array(sectorBuffer, FSIB_numberLastAllocCluster, partition->fat.numberLastAllocCluster); sectorBuffer[FSIB_bootSig_55] = 0x55; sectorBuffer[FSIB_bootSig_AA] = 0xAA; _FAT_disc_writeSectors (partition->disc, partition->fsInfoSector, 1, sectorBuffer); _FAT_mem_free(sectorBuffer); }
static void _FAT_updateFS_INFO(PARTITION * partition, uint8_t *sectorBuffer) { partition->fat.numberFreeCluster = _FAT_fat_freeClusterCount(partition); u32_to_u8array(sectorBuffer, FSIB_numberOfFreeCluster, partition->fat.numberFreeCluster); u32_to_u8array(sectorBuffer, FSIB_numberLastAllocCluster, partition->fat.numberLastAllocCluster); _FAT_disc_writeSectors (partition->disc, partition->fsInfoSector, 1, sectorBuffer); }