|
@@ -540,9 +540,13 @@ FINSH_FUNCTION_EXPORT(mkfs, make a file system);
|
|
|
int df(const char *path)
|
|
|
{
|
|
|
int result;
|
|
|
+ int minor = 0;
|
|
|
long long cap;
|
|
|
struct statfs buffer;
|
|
|
|
|
|
+ int unit_index = 0;
|
|
|
+ char *unit_str[] = {"KB", "MB", "GB"};
|
|
|
+
|
|
|
result = dfs_statfs(path ? path : NULL, &buffer);
|
|
|
if (result != 0)
|
|
|
{
|
|
@@ -551,8 +555,16 @@ int df(const char *path)
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
+ for (unit_index = 0; unit_index < 3; unit_index ++)
|
|
|
+ {
|
|
|
+ if (cap < 1024) break;
|
|
|
+
|
|
|
+ minor = (cap % 1024) * 10 / 1024; /* only one decimal point */
|
|
|
+ cap = cap / 1024;
|
|
|
+ }
|
|
|
+
|
|
|
+ rt_kprintf("disk free: %d.%d %s [ %d block, %d bytes per block ]\n",
|
|
|
+ (unsigned long)cap, minor, unit_str[unit_index], buffer.f_bfree, buffer.f_bsize);
|
|
|
return 0;
|
|
|
}
|
|
|
FINSH_FUNCTION_EXPORT(df, get disk free);
|