FreeRTOS+FAT: disk name? disk available space?

dnadler wrote on Wednesday, October 05, 2016:

I had a quick look at FreeRTOS+FAT and didn’t see a couple things we always need:

How much space is available on disk?
To avoid nasty accidents our applications must check for adequate disk space prior trying to create files.

What is the disk name?
We usually show the disk name (for inserted USB memory sticks and uSD cards especially).

Sorry if I missed the APIs for these functions?
Thanks,
Best Regards, Dave

heinbali01 wrote on Wednesday, October 05, 2016:

Hi Dave,

Both the free diskspace and the volume label are available, although there is not an API for this.
I don’t think that stdio has standard functions for this?

Here is how you can retrieve all information:

    pxSDDisk = FF_SDDiskInit( mainSD_CARD_DISK_NAME );
    if( pxSDDisk != NULL )
    {
        FF_IOManager_t *pxIOManager = sddisk_ioman( pxSDDisk );
        uint64_t ullFreeBytes =
            ( uint64_t ) pxIOManager->xPartition.ulFreeClusterCount *
                pxIOManager->xPartition.ulSectorsPerCluster * 512ull;
        FreeRTOS_printf( ( "Volume %-12.12s: Free clusters %lu total clusters %lu Free space %lu KB\n",
            pxIOManager->xPartition.pcVolumeLabel,
            pxIOManager->xPartition.ulFreeClusterCount,
            pxIOManager->xPartition.ulNumClusters,
            ( uint32_t ) ( ullFreeBytes / 1024ull ) ) );
    }

Is that enough?

Regards.

dnadler wrote on Thursday, October 06, 2016:

Thanks Hein - That’s adequate, glad its accessible.
IMOH, Nice APIs would be better for such common requirements…
Thanks again,
Best Regards, Dave

heinbali01 wrote on Thursday, October 06, 2016:

Nice APIs would be better for such common requirements…

I Agree. Will you write a proposal?

When using ff_stdio.h, it should also be possible to retrieve information for a virtual drive, such as “/ram”, a RAM-disk.