Opened 13 months ago

Last modified 13 months ago

#18623 new enhancement

[/bin/df] df output on nightlies is kinda buggy

Reported by: bipolar Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: Applications/Command Line Tools Version: R1/beta4
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description (last modified by bipolar)

On beta4 df gives me:

> df
 Mount             Type      Total     Free      Flags   Device
----------------- --------- --------- --------- ------- ------------------------
/boot             bfs        20.0 GiB  10.1 GiB QAM-P-W /dev/disk/scsi/0/0/0/2_1
/boot/system      packagefs   4.0 KiB   4.0 KiB QAM-P-- 
/boot/home/config packagefs   4.0 KiB   4.0 KiB QAM-P-- 
/boot/system/var/shared_memory 
                  ramfs             0   2.4 GiB QAM-PRW 
/BeBackUp-01      bfs       700.0 MiB   4.7 MiB QAM-P-W /dev/disk/virtual/files/8/raw
/BackUp-02        bfs       700.0 MiB   5.5 MiB QAM-P-W /dev/disk/virtual/files/9/raw
/Data             ntfs       28.8 GiB 377.8 MiB ----P-- /dev/disk/usb/0/0/0

While after hrev57190 gives:

>> df
 Type      Total     Free      Flags   Device                   Mounted on
--------- --------- --------- ------- ------------------------ -----------------
bfs        20.0 GiB  10.1 GiB QAM-P-W /dev/disk/scsi/0/0/0/2_1 /boot             
packagefs   4.0 KiB   4.0 KiB QAM-P--                          /boot/system      
packagefs   4.0 KiB   4.0 KiB QAM-P--                          /boot/home/config 
ramfs             0   2.4 GiB QAM-PRW                          /boot/system/var/shared_memory 
                  
bfs       700.0 MiB   4.7 MiB QAM-P-W /dev/disk/virtual/files/8/raw /BeBackUp-01      
bfs       700.0 MiB   5.5 MiB QAM-P-W /dev/disk/virtual/files/9/raw /BackUp-02        
ntfs       28.8 GiB 377.8 MiB ----P--      /dev/disk/usb/0/0/0 /Data             

Notice the extra line in the middle containing extra spaces (" "), and the right-alignment of "Device" data, if they are short enough.

after applying this small patch:

diff --git a/src/bin/df.cpp b/src/bin/df.cpp
index c0fce748..9ae0ca4b 100644
--- a/src/bin/df.cpp
+++ b/src/bin/df.cpp
@@ -44,11 +44,8 @@ PrintMountPoint(dev_t device, bool verbose)
 
        if (verbose)
                printf("   Mounted at: %s\n", mount);
-       else {
-               printf("%-17s ", mount);
-               if (strlen(mount) > 17)
-                       printf("\n%17s ", "");
-       }
+       else
+               printf("%s ", mount);
 }
 
 
@@ -162,7 +159,7 @@ PrintCompact(dev_t device, bool showBlocks, bool all)
        PrintFlag(info.flags, B_FS_IS_REMOVABLE, 'R', '-');
        PrintFlag(info.flags, B_FS_IS_READONLY, '-', 'W');
 
-       printf(" %24s ", info.device_name);
+       printf(" %-24s ", info.device_name);
        PrintMountPoint(info.dev, false);
        printf("\n");
 }

I get:

> df
 Type      Total     Free      Flags   Device                   Mounted on
--------- --------- --------- ------- ------------------------ -----------------
bfs        20.0 GiB  10.1 GiB QAM-P-W /dev/disk/scsi/0/0/0/2_1 /boot             
packagefs   4.0 KiB   4.0 KiB QAM-P--                          /boot/system      
packagefs   4.0 KiB   4.0 KiB QAM-P--                          /boot/home/config 
ramfs             0   2.4 GiB QAM-PRW                          /boot/system/var/shared_memory 
bfs       700.0 MiB   4.7 MiB QAM-P-W /dev/disk/virtual/files/8/raw /BeBackUp-01      
bfs       700.0 MiB   5.5 MiB QAM-P-W /dev/disk/virtual/files/9/raw /BackUp-02        
ntfs       28.8 GiB 377.8 MiB ----P-- /dev/disk/usb/0/0/0      /Data             

Which looks a bit better, albeit it doesn't solves the issue when device names are longer than 24 chars.

If we don't care for the 80 columns limit on the "table headers", I guess we should find out the longest device name, and use that to calculate/adjust the columns widths.

But would take more effort than my simple patch :-P

(Edit: can someone edit my "niglies" typo in the title?)

Change History (4)

comment:1 by bipolar, 13 months ago

Description: modified (diff)

comment:2 by bipolar, 13 months ago

Description: modified (diff)

comment:3 by bipolar, 13 months ago

Description: modified (diff)

comment:4 by waddlesplash, 13 months ago

Component: - GeneralApplications/Command Line Tools
Summary: [/bin/df] df output on niglies is kinda buggy.[/bin/df] df output on nightlies is kinda buggy
Note: See TracTickets for help on using tickets.