df: adjusted width of columns and unit names

- Larger columns to fit new name of file system and new default mount points.
- Correct unit names based on norm IEC 60027-2.

Signed-off-by: Adrien Destugues <[email protected]>

Fixes #13312.
This commit is contained in:
Dariusz Knociński
2017-03-12 10:47:52 +01:00
committed by Adrien Destugues
parent 4d8811742f
commit b03efd582a
+8 -7
View File
@@ -45,9 +45,9 @@ PrintMountPoint(dev_t device, bool verbose)
if (verbose) if (verbose)
printf(" Mounted at: %s\n", mount); printf(" Mounted at: %s\n", mount);
else { else {
printf("%-15s ", mount); printf("%-17s ", mount);
if (strlen(mount) > 15) if (strlen(mount) > 17)
printf("\n%15s ", ""); printf("\n%17s ", "");
} }
} }
@@ -55,10 +55,10 @@ PrintMountPoint(dev_t device, bool verbose)
void void
PrintType(const char *fileSystem) PrintType(const char *fileSystem)
{ {
char type[10]; char type[16];
strlcpy(type, fileSystem, sizeof(type)); strlcpy(type, fileSystem, sizeof(type));
printf("%-8s", type); printf("%-9s", type);
} }
@@ -71,7 +71,8 @@ ByteString(int64 numBlocks, int64 blockSize)
if (blocks < 1024) if (blocks < 1024)
sprintf(string, "%" B_PRId64, numBlocks * blockSize); sprintf(string, "%" B_PRId64, numBlocks * blockSize);
else { else {
const char *units[] = {"K", "M", "G", NULL}; const char *units[] = {"KiB", "MiB", "GiB", "TiB", "PiB", "EiB",
"ZiB", "YiB", NULL};
int32 i = -1; int32 i = -1;
do { do {
@@ -237,7 +238,7 @@ main(int argc, char **argv)
// If not, then just iterate over all devices and give a compact summary // If not, then just iterate over all devices and give a compact summary
printf(" Mount Type Total Free Flags Device\n" printf(" Mount Type Total Free Flags Device\n"
"--------------- -------- --------- --------- ------- --------------------------\n"); "----------------- --------- --------- --------- ------- ------------------------\n");
int32 cookie = 0; int32 cookie = 0;
while ((device = next_dev(&cookie)) >= B_OK) { while ((device = next_dev(&cookie)) >= B_OK) {