Now clears the whole cluster when creating or extending a directory, bug found by Hermes

This commit is contained in:
Michael Chisholm 2006-09-30 16:00:01 +00:00
parent dbdb8900b5
commit 8956d40bc1
2 changed files with 8 additions and 3 deletions

View File

@ -34,6 +34,9 @@
2006-08-19 - Chishm 2006-08-19 - Chishm
* Fixed entryFromPath bug when looking for "." in root directory * Fixed entryFromPath bug when looking for "." in root directory
2006-10-01 - Chishm
* Now clears the whole new cluster when linking in more clusters for a directory
*/ */
#include <string.h> #include <string.h>
@ -201,7 +204,7 @@ static bool _FAT_directory_incrementDirEntryPosition (PARTITION* partition, DIR_
tempCluster = _FAT_fat_nextCluster(partition, position.cluster); tempCluster = _FAT_fat_nextCluster(partition, position.cluster);
if (tempCluster == CLUSTER_EOF) { if (tempCluster == CLUSTER_EOF) {
if (extendDirectory) { if (extendDirectory) {
tempCluster = _FAT_fat_linkFreeCluster (partition, position.cluster); tempCluster = _FAT_fat_linkFreeClusterCleared (partition, position.cluster);
if (tempCluster == CLUSTER_FREE) { if (tempCluster == CLUSTER_FREE) {
return false; // This will only happen if the disc is full return false; // This will only happen if the disc is full
} }

View File

@ -36,6 +36,9 @@
2006-08-19 - Chishm 2006-08-19 - Chishm
* Updated dirnext return values to return correctly * Updated dirnext return values to return correctly
2006-10-01 - Chishm
* Now clears the whole cluster when creating a new directory, bug found by Hermes
*/ */
#include <string.h> #include <string.h>
@ -382,7 +385,7 @@ int _FAT_mkdir_r (struct _reent *r, const char *path, int mode) {
dirEntry.entryData[DIR_ENTRY_attributes] = ATTRIB_DIR; dirEntry.entryData[DIR_ENTRY_attributes] = ATTRIB_DIR;
// Get a cluster for the new directory // Get a cluster for the new directory
dirCluster = _FAT_fat_linkFreeCluster (partition, CLUSTER_FREE); dirCluster = _FAT_fat_linkFreeClusterCleared (partition, CLUSTER_FREE);
if (dirCluster == CLUSTER_FREE) { if (dirCluster == CLUSTER_FREE) {
// No space left on disc for the cluster // No space left on disc for the cluster
r->_errno = ENOSPC; r->_errno = ENOSPC;
@ -419,7 +422,6 @@ int _FAT_mkdir_r (struct _reent *r, const char *path, int mode) {
_FAT_cache_writePartialSector ( partition->cache, newEntryData, _FAT_cache_writePartialSector ( partition->cache, newEntryData,
_FAT_fat_clusterToSector (partition, dirCluster), DIR_ENTRY_DATA_SIZE, DIR_ENTRY_DATA_SIZE); _FAT_fat_clusterToSector (partition, dirCluster), DIR_ENTRY_DATA_SIZE, DIR_ENTRY_DATA_SIZE);
// Flush any sectors in the disc cache // Flush any sectors in the disc cache
if (!_FAT_cache_flush(partition->cache)) { if (!_FAT_cache_flush(partition->cache)) {
r->_errno = EIO; r->_errno = EIO;