fs: Correct human-readable output alignment
authorAndrew Deason <adeason@sinenomine.net>
Thu, 1 Jul 2010 16:22:13 +0000 (11:22 -0500)
committerDerrick Brashear <shadow@dementia.org>
Thu, 1 Jul 2010 17:03:46 +0000 (10:03 -0700)
'fs lq' output separates its space values by whitespace, but 'fs df'
does not, which was causing the human-readable output for 'fs' to not
be properly aligned with the output headers. Modify HumanPrintSpace to
take up exactly 10 characters (9 for the value, 1 for the exponent),
and have the callers print out an extra space if appropriate.

Change-Id: Ied81e73e1e84df34e63fdf0c80ad86341bea0cd4
Reviewed-on: http://gerrit.openafs.org/2311
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/venus/fs.c

index 4e726b0..519d035 100644 (file)
@@ -659,7 +659,7 @@ HumanPrintSpace(afs_int32 int_space)
        exponent++;
        space /= 1024;
     }
-    printf(" %8.1f%c", space, power_letter[exponent]);
+    printf("%9.1f%c", space, power_letter[exponent]);
 }
 
 static int
@@ -672,7 +672,9 @@ QuickPrintStatus(VolumeStatus * status, char *name, int human)
 
     if (status->MaxQuota != 0) {
        if (human) {
+           printf(" ");
            HumanPrintSpace(status->MaxQuota);
+           printf(" ");
            HumanPrintSpace(status->BlocksInUse);
        }
        else
@@ -680,11 +682,11 @@ QuickPrintStatus(VolumeStatus * status, char *name, int human)
        QuotaUsed =
            ((((double)status->BlocksInUse) / status->MaxQuota) * 100.0);
     } else {
-       printf("   no limit");
+       printf("   no limit ");
        if (human)
            HumanPrintSpace(status->BlocksInUse);
        else
-           printf(" %10d", status->BlocksInUse);
+           printf("%10d", status->BlocksInUse);
     }
     if (QuotaUsed > 90.0) {
        printf("%5.0f%%<<", QuotaUsed);