summaryrefslogtreecommitdiffstats
path: root/toolbox
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2012-12-03 07:33:38 -0800
committerGerrit Code Review <noreply-gerritcodereview@google.com>2012-12-03 07:33:38 -0800
commit777991d9399f1268d27c72a03d56c1a36068a57f (patch)
tree42348cf71a6d8b6bfbc33c4b719b4d652cf7bba6 /toolbox
parent2a2f640886c9d356de1407b0888507823a7663b7 (diff)
parent1f90dcd0c022182220c37b300690cf73674d03b8 (diff)
downloadcore-777991d9399f1268d27c72a03d56c1a36068a57f.tar.gz
core-777991d9399f1268d27c72a03d56c1a36068a57f.tar.bz2
core-777991d9399f1268d27c72a03d56c1a36068a57f.zip
Merge "Fixed improper size displaying in 'df' utility"
Diffstat (limited to 'toolbox')
-rw-r--r--toolbox/df.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/toolbox/df.c b/toolbox/df.c
index 63940a153..9cd07431a 100644
--- a/toolbox/df.c
+++ b/toolbox/df.c
@@ -9,16 +9,22 @@ static int ok = EXIT_SUCCESS;
static void printsize(long long n)
{
char unit = 'K';
- n /= 1024;
- if (n > 1024) {
+ long long t;
+
+ n *= 10;
+
+ if (n > 1024*1024*10) {
n /= 1024;
unit = 'M';
}
- if (n > 1024) {
+
+ if (n > 1024*1024*10) {
n /= 1024;
unit = 'G';
}
- printf("%4lld%c", n, unit);
+
+ t = (n + 512) / 1024;
+ printf("%4lld.%1lld%c", t/10, t%10, unit);
}
static void df(char *s, int always) {
@@ -41,7 +47,7 @@ static void df(char *s, int always) {
}
int df_main(int argc, char *argv[]) {
- printf("Filesystem Size Used Free Blksize\n");
+ printf("Filesystem Size Used Free Blksize\n");
if (argc == 1) {
char s[2000];
FILE *f = fopen("/proc/mounts", "r");