Dave Murphy 2009-05-01 07:37:36 +00:00
parent 116092466a
commit 52def810fc
2 changed files with 6 additions and 5 deletions

View File

@ -463,12 +463,12 @@ int _FAT_statvfs_r (struct _reent *r, const char *path, struct statvfs *buf)
buf->f_bsize = partition->bytesPerCluster; // File system block size. buf->f_bsize = partition->bytesPerCluster; // File system block size.
buf->f_frsize = partition->bytesPerCluster; // Fundamental file system block size. buf->f_frsize = partition->bytesPerCluster; // Fundamental file system block size.
buf->f_blocks = partition->fat.lastCluster - CLUSTER_FIRST; // Total number of blocks on file system in units of f_frsize. buf->f_blocks = partition->fat.lastCluster - CLUSTER_FIRST + 1; // Total number of blocks on file system in units of f_frsize.
buf->f_bfree = freeClusterCount; // Total number of free blocks. buf->f_bfree = freeClusterCount; // Total number of free blocks.
buf->f_bavail = freeClusterCount; // Number of free blocks available to non-privileged process. buf->f_bavail = freeClusterCount; // Number of free blocks available to non-privileged process.
// Treat requests for info on inodes as clusters // Treat requests for info on inodes as clusters
buf->f_files = partition->fat.lastCluster - CLUSTER_FIRST; // Total number of file serial numbers. buf->f_files = partition->fat.lastCluster - CLUSTER_FIRST + 1; // Total number of file serial numbers.
buf->f_ffree = freeClusterCount; // Total number of free file serial numbers. buf->f_ffree = freeClusterCount; // Total number of free file serial numbers.
buf->f_favail = freeClusterCount; // Number of file serial numbers available to non-privileged process. buf->f_favail = freeClusterCount; // Number of file serial numbers available to non-privileged process.

View File

@ -195,12 +195,13 @@ 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;
// Store info about FAT // Store info about FAT
partition->fat.lastCluster = (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.firstFree = CLUSTER_FIRST; partition->fat.firstFree = CLUSTER_FIRST;
if (partition->fat.lastCluster < CLUSTERS_PER_FAT12) { if (clusterCount < CLUSTERS_PER_FAT12) {
partition->filesysType = FS_FAT12; // FAT12 volume partition->filesysType = FS_FAT12; // FAT12 volume
} else if (partition->fat.lastCluster < CLUSTERS_PER_FAT16) { } else if (clusterCount < CLUSTERS_PER_FAT16) {
partition->filesysType = FS_FAT16; // FAT16 volume partition->filesysType = FS_FAT16; // FAT16 volume
} else { } else {
partition->filesysType = FS_FAT32; // FAT32 volume partition->filesysType = FS_FAT32; // FAT32 volume