/** * @brief A simple command for displaying some info. * Displays some information about the currently mounted parttion. * * The accesing of the FF_PARTITION object is not recommended as this object * is subject to change in future versions. * **/ int info_cmd(int argc, char **argv, FF_ENVIRONMENT *pEv) { FF_IOMAN *pIoman = pEv->pIoman; FF_PARTITION *pPart = pEv->pIoman->pPartition; if(argc == 1) { switch(pPart->Type) { case FF_T_FAT32: cons_printf("FAT32 Formatted\n"); break; case FF_T_FAT16: cons_printf("FAT16 Formatted\n"); break; case FF_T_FAT12: cons_printf("FAT12 Formatted\n"); break; } cons_printf("FullFAT Driver Blocksize: \t%d\n", pIoman->BlkSize); cons_printf("Partition Blocksize: \t\t%d\n", pPart->BlkSize); cons_printf("Cluster Size: \t\t\t%dKb\n", (pPart->BlkSize * pPart->SectorsPerCluster) / 1024); #ifdef FF_64_NUM_SUPPORT cons_printf("Volume Size: \t\t\t%llu (%d MB)\n", FF_GetVolumeSize(pIoman), (unsigned int) (FF_GetVolumeSize(pIoman) / 1048576)); cons_printf("Volume Free: \t\t\t%llu (%d MB)\n", FF_GetFreeSize(pIoman), (unsigned int) (FF_GetFreeSize(pIoman) / 1048576)); #else cons_printf("Volume Size: \t\t\t%lu (%d MB)\n", FF_GetVolumeSize(pIoman), (unsigned int) (FF_GetVolumeSize(pIoman) / 1048576)); cons_printf("Volume Free: \t\t\t%lu (%d MB)\n", FF_GetFreeSize(pIoman), (unsigned int) (FF_GetFreeSize(pIoman) / 1048576)); #endif } else { cons_printf("Usage: %s\n", argv[0]); } return 0; }
int fsinfo_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) { FF_IOMAN *pIoman = pEnv->pIoman; FF_PARTITION *pPart = pIoman->pPartition; char *fatType; switch(pIoman->pPartition->Type) { case FF_T_FAT32:{ fatType = "FAT32"; break; } case FF_T_FAT16:{ fatType = "FAT16"; break; } case FF_T_FAT12: { fatType = "FAT12"; break; } } printf("Media Format : %s\n", fatType); printf("FullFAT Driver Blocksize: %d\n", pIoman->BlkSize); printf("Partition Blocksize : %d\n", pPart->BlkSize); printf("Total Clusters : %lu\n", pPart->NumClusters); printf("Cluster Size : %fKb\n", (float)(pPart->BlkSize * pPart->SectorsPerCluster) / 1024.0); #ifdef FF_64_NUM_SUPPORT printf("Volume Size : %llu (%d MB)\n", FF_GetVolumeSize(pIoman), (unsigned int) (FF_GetVolumeSize(pIoman) / 1048576)); printf("Volume Free : %llu (%d MB)\n", FF_GetFreeSize(pIoman, NULL), (unsigned int) (FF_GetFreeSize(pIoman, NULL) / 1048576)); #else printf("Volume Size : %lu (%d MB)\n", FF_GetVolumeSize(pIoman), (unsigned int) (FF_GetVolumeSize(pIoman) / 1048576)); printf("Volume Free : %lu (%d MB)\n", FF_GetFreeSize(pIoman, NULL), (unsigned int) (FF_GetFreeSize(pIoman, NULL) / 1048576)); #endif return 0; }
BaseType_t FF_RAMDiskShowPartition( FF_Disk_t *pxDisk ) { FF_Error_t xError; uint64_t ullFreeSectors; uint32_t ulTotalSizeMB, ulFreeSizeMB; int iPercentageFree; FF_IOManager_t *pxIOManager; const char *pcTypeName = "unknown type"; BaseType_t xReturn = pdPASS; if( pxDisk == NULL ) { xReturn = pdFAIL; } else { pxIOManager = pxDisk->pxIOManager; FF_PRINTF( "Reading FAT and calculating Free Space\n" ); switch( pxIOManager->xPartition.ucType ) { case FF_T_FAT12: pcTypeName = "FAT12"; break; case FF_T_FAT16: pcTypeName = "FAT16"; break; case FF_T_FAT32: pcTypeName = "FAT32"; break; default: pcTypeName = "UNKOWN"; break; } FF_GetFreeSize( pxIOManager, &xError ); ullFreeSectors = pxIOManager->xPartition.ulFreeClusterCount * pxIOManager->xPartition.ulSectorsPerCluster; iPercentageFree = ( int ) ( ( ramHUNDRED_64_BIT * ullFreeSectors + pxIOManager->xPartition.ulDataSectors / 2 ) / ( ( uint64_t )pxIOManager->xPartition.ulDataSectors ) ); ulTotalSizeMB = pxIOManager->xPartition.ulDataSectors / ramSECTORS_PER_MB; ulFreeSizeMB = ( uint32_t ) ( ullFreeSectors / ramSECTORS_PER_MB ); /* It is better not to use the 64-bit format such as %Lu because it might not be implemented. */ FF_PRINTF( "Partition Nr %8u\n", pxDisk->xStatus.bPartitionNumber ); FF_PRINTF( "Type %8u (%s)\n", pxIOManager->xPartition.ucType, pcTypeName ); FF_PRINTF( "VolLabel '%8s' \n", pxIOManager->xPartition.pcVolumeLabel ); FF_PRINTF( "TotalSectors %8lu\n", pxIOManager->xPartition.ulTotalSectors ); FF_PRINTF( "SecsPerCluster %8lu\n", pxIOManager->xPartition.ulSectorsPerCluster ); FF_PRINTF( "Size %8lu MB\n", ulTotalSizeMB ); FF_PRINTF( "FreeSize %8lu MB ( %d perc free )\n", ulFreeSizeMB, iPercentageFree ); } return xReturn; }