The f_getfree function gets number of the free clusters.
FRESULT f_getfree ( const char* Path, /* Root directory of the drive */ DWORD* Clusters, /* Pointer to the variable to store number of free clusters */ FATFS** FileSystemObject /* Pointer to pointer to file system object */ );
The f_getfree function gets number of free clusters on the drive. The sects_clust member in the file system object refreting number of sectors per cluster, so that the free space in unit of sector can be calcurated with this. When _USE_FSINFO option is enabled, this function can return inaccurate free cluster count on FAT32 volume. When _USE_FSINFO option is disabled, this function will take a time on FAT32 volume.
This function is not supported in read-only configuration and minimization level of >= 1.
FATFS *fs; DWORD clust; // Get free clusters res = f_getfree("", &clust, &fs); if (res) die(res); // Get free space printf("%lu KB total disk space.\n" "%lu KB available on the disk.\n", (DWORD)(fs->max_clust - 2) * fs->sects_clust / 2, clust * fs->sects_clust / 2);