mirror of
https://github.com/wiiu-env/wiiu-nanddumper-payload.git
synced 2024-11-22 03:19:17 +01:00
fat writing optimization
This commit is contained in:
parent
1258dbb2fe
commit
7396fe9009
@ -131,6 +131,7 @@ int fatfs_init(struct fatfs *fs)
|
|||||||
|
|
||||||
// For FAT32 (which this may be)
|
// For FAT32 (which this may be)
|
||||||
fs->rootdir_first_cluster = GET_32BIT_WORD(fs->currentsector.sector, BPB_FAT32_ROOTCLUS);
|
fs->rootdir_first_cluster = GET_32BIT_WORD(fs->currentsector.sector, BPB_FAT32_ROOTCLUS);
|
||||||
|
fs->last_free_cluster = fs->rootdir_first_cluster + 1;
|
||||||
fs->fs_info_sector = GET_16BIT_WORD(fs->currentsector.sector, BPB_FAT32_FSINFO);
|
fs->fs_info_sector = GET_16BIT_WORD(fs->currentsector.sector, BPB_FAT32_FSINFO);
|
||||||
|
|
||||||
// For FAT16 (which this may be), rootdir_first_cluster is actuall rootdir_first_sector
|
// For FAT16 (which this may be), rootdir_first_cluster is actuall rootdir_first_sector
|
||||||
|
@ -60,6 +60,7 @@ struct fatfs
|
|||||||
uint8 sectors_per_cluster;
|
uint8 sectors_per_cluster;
|
||||||
uint32 cluster_begin_lba;
|
uint32 cluster_begin_lba;
|
||||||
uint32 rootdir_first_cluster;
|
uint32 rootdir_first_cluster;
|
||||||
|
uint32 last_free_cluster;
|
||||||
uint32 rootdir_first_sector;
|
uint32 rootdir_first_sector;
|
||||||
uint32 rootdir_sectors;
|
uint32 rootdir_sectors;
|
||||||
uint32 fat_begin_lba;
|
uint32 fat_begin_lba;
|
||||||
|
@ -337,6 +337,7 @@ int fatfs_find_blank_cluster(struct fatfs *fs, uint32 start_cluster, uint32 *fre
|
|||||||
while (nextcluster != 0x0);
|
while (nextcluster != 0x0);
|
||||||
|
|
||||||
// Found blank entry
|
// Found blank entry
|
||||||
|
fs->last_free_cluster = current_cluster + 1;
|
||||||
*free_cluster = current_cluster;
|
*free_cluster = current_cluster;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ int fatfs_add_free_space(struct fatfs *fs, uint32 *startCluster, uint32 clusters
|
|||||||
for (i=0;i<clusters;i++)
|
for (i=0;i<clusters;i++)
|
||||||
{
|
{
|
||||||
// Start looking for free clusters from the beginning
|
// Start looking for free clusters from the beginning
|
||||||
if (fatfs_find_blank_cluster(fs, fs->rootdir_first_cluster, &nextcluster))
|
if (fatfs_find_blank_cluster(fs, fs->last_free_cluster, &nextcluster))
|
||||||
{
|
{
|
||||||
// Point last to this
|
// Point last to this
|
||||||
fatfs_fat_set_cluster(fs, start, nextcluster);
|
fatfs_fat_set_cluster(fs, start, nextcluster);
|
||||||
@ -103,7 +103,7 @@ int fatfs_allocate_free_space(struct fatfs *fs, int newFile, uint32 *startCluste
|
|||||||
// Allocated first link in the chain if a new file
|
// Allocated first link in the chain if a new file
|
||||||
if (newFile)
|
if (newFile)
|
||||||
{
|
{
|
||||||
if (!fatfs_find_blank_cluster(fs, fs->rootdir_first_cluster, &nextcluster))
|
if (!fatfs_find_blank_cluster(fs, fs->last_free_cluster, &nextcluster))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// If this is all that is needed then all done
|
// If this is all that is needed then all done
|
||||||
@ -230,7 +230,7 @@ static int fatfs_find_free_dir_offset(struct fatfs *fs, uint32 dirCluster, int e
|
|||||||
uint32 newCluster;
|
uint32 newCluster;
|
||||||
|
|
||||||
// Get a new cluster for directory
|
// Get a new cluster for directory
|
||||||
if (!fatfs_find_blank_cluster(fs, fs->rootdir_first_cluster, &newCluster))
|
if (!fatfs_find_blank_cluster(fs, fs->last_free_cluster, &newCluster))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Add cluster to end of directory tree
|
// Add cluster to end of directory tree
|
||||||
|
Loading…
Reference in New Issue
Block a user