show volume size in KBytes in df

This commit is contained in:
prife 2013-01-25 12:15:34 +08:00
parent 72bd8b9978
commit 4be62911f9
1 changed files with 10 additions and 4 deletions

View File

@ -492,9 +492,10 @@ void mkfs(const char *fs_name, const char *device_name)
} }
FINSH_FUNCTION_EXPORT(mkfs, make a file system); FINSH_FUNCTION_EXPORT(mkfs, make a file system);
void df(const char *path) int df(const char *path)
{ {
int result; int result;
long long cap;
struct statfs buffer; struct statfs buffer;
if (path == RT_NULL) if (path == RT_NULL)
@ -502,11 +503,16 @@ void df(const char *path)
else else
result = dfs_statfs(path, &buffer); result = dfs_statfs(path, &buffer);
if (result == 0) if (result != 0)
{ {
rt_kprintf("disk free: %d block[%d bytes per block]\n", rt_kprintf("dfs_statfs failed.\n");
buffer.f_bfree, buffer.f_bsize); return -1;
} }
cap = buffer.f_bsize * buffer.f_bfree / 1024;
rt_kprintf("disk free: %d KB [ %d block, %d bytes per block ]\n",
(unsigned long)cap, buffer.f_bfree, buffer.f_bsize);
return 0;
} }
FINSH_FUNCTION_EXPORT(df, get disk free); FINSH_FUNCTION_EXPORT(df, get disk free);
#endif #endif