summaryrefslogtreecommitdiff
path: root/components/dfs/src/dfs_fs.c
diff options
context:
space:
mode:
authorprife <[email protected]>2013-01-25 12:15:34 +0800
committerprife <[email protected]>2013-01-25 12:17:47 +0800
commit4be62911f997bebbf9bb3ab6525c62a2a9dd813d (patch)
tree3c3fe356a8d4478ee0f98f670c9977fb848cc9cb /components/dfs/src/dfs_fs.c
parent72bd8b9978b7bc5210c185d7bcc2ec9074fb3d5c (diff)
show volume size in KBytes in df
Diffstat (limited to 'components/dfs/src/dfs_fs.c')
-rw-r--r--components/dfs/src/dfs_fs.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c
index 20f987a9a7..cb57df2513 100644
--- a/components/dfs/src/dfs_fs.c
+++ b/components/dfs/src/dfs_fs.c
@@ -492,9 +492,10 @@ void mkfs(const char *fs_name, const char *device_name)
}
FINSH_FUNCTION_EXPORT(mkfs, make a file system);
-void df(const char *path)
+int df(const char *path)
{
int result;
+ long long cap;
struct statfs buffer;
if (path == RT_NULL)
@@ -502,11 +503,16 @@ void df(const char *path)
else
result = dfs_statfs(path, &buffer);
- if (result == 0)
+ if (result != 0)
{
- rt_kprintf("disk free: %d block[%d bytes per block]\n",
- buffer.f_bfree, buffer.f_bsize);
+ rt_kprintf("dfs_statfs failed.\n");
+ 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);
#endif