📄 diskinfo.c
字号:
/*
**********************************************************************
* Micrium, Inc.
* 949 Crestview Circle
* Weston, FL 33327-1848
*
* uC/FS
*
* (c) Copyright 2001 - 2003, Micrium, Inc.
* All rights reserved.
*
***********************************************************************
----------------------------------------------------------------------
File : Diskinfo.c
Purpose : Sample program demonstrating how to retrieve disk info
---------------------------END-OF-HEADER------------------------------
*/
#include "fs_api.h"
#include <string.h>
#include <stdio.h>
/*********************************************************************
*
* MainTask
*/
void MainTask(void);
void MainTask(void) {
FS_DISKFREE_T disk_data;
FS_U32 free;
FS_U32 space;
char ac[500];
int x;
FS_X_Log("Test FS_IoCtl command FS_CMD_GET_DISKFREE :\n");
x = FS_IoCtl("",FS_CMD_GET_DISKFREE,0,(void*) &disk_data);
if (x==0) {
space = disk_data.total_clusters * disk_data.sectors_per_cluster * disk_data.bytes_per_sector;
free = disk_data.avail_clusters * disk_data.sectors_per_cluster * disk_data.bytes_per_sector;
sprintf(ac,"Total clusters : %lu\n"
"Available clusters : %lu\n"
"Sectors/cluster : %u\n"
"Bytes per sector : %u\n"
"Total space : %lu\n"
"Free space : %lu\n",
disk_data.total_clusters, disk_data.avail_clusters, disk_data.sectors_per_cluster, disk_data.bytes_per_sector, space, free);
FS_X_Log(ac);
FS_X_Log("OK\n");
#if FS_FAT_DISKINFO
space = FS_GetTotalSpace("", 0);
free = FS_GetFreeSpace("", 0);
sprintf(ac, "Total space : %lu\nFree space : %lu\n", space, free);
FS_X_Log(ac);
FS_X_Log("OK\n");
#endif
} else {
FS_X_ErrorOut("Test failed\n");
}
FS_X_Log("\n");
}
/*************************** End of file ****************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -