am 777991d9: Merge "Fixed improper size displaying in \'df\' utility"

* commit '777991d9399f1268d27c72a03d56c1a36068a57f':
  Fixed improper size displaying in 'df' utility
This commit is contained in:
Elliott Hughes 2012-12-03 08:13:11 -08:00 committed by Android Git Automerger
commit b8db1e093d
1 changed files with 11 additions and 5 deletions

View File

@ -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");