f_getfree

The f_getfree gets number of the free clusters.

FRESULT f_getfree (
  DWORD* Clusters     // Pointer to the variable to store number of free clusters.
);

Parameters

Clusters
Pointer to the DWORD variable to store number of free clusters.

Return Values

FR_OK (0)
The function succeeded. The *Clusters havs number of free clusters.
FR_NOT_READY
The disk drive cannot work due to no medium in the drive or any other reason.
FR_RW_ERROR
Any error occured in low level disk I/O.
FR_INCORRECT_DISK_CHANGE
Incorrect disk removal, such as a medium change during any file is opend, has been occured.
FR_NOT_ENABLED
FatFs module has not been enabled.
FR_NO_FILESYSTEM
There is no valid FAT partition on the disk.

Descriptions

The f_getfree gets number of free clusters on the drive. The FatFs.sects_clust is indicating number of sectors per cluster, so that the free space in unit of byte can be calcurated with this. This function is not supported in minimum configuration.

Samples Code

    DWORD clust;

    // Get free clusters
    res = f_getfree(&clust);
    if (res) die(res);

    // Get free bytes
    printf("%lu bytes available on the disk.\n", clust * FatFs->sects_clust * 512);

References

FATFS

Return