rolinh / dfc

Report file system space usage information with style
BSD 3-Clause "New" or "Revised" License
106 stars 10 forks source link

filter against full names/types, not truncated #20

Closed gangelop closed 7 years ago

gangelop commented 7 years ago

This patch makes dfc store the original fsname, fstype, and mntdir in seperate variables before truncating them so that we can use either.

Also, name and type filtering now filters against these newly added "og" variables.

This is essentially one proposed fix for the issue I point out in https://projects.gw-computing.net/issues/134.

If you would like to get rid of the truncation altogether, thus rendering this patch obsolete, that's also cool with me. 👍

ONLY TESTED ON LINUX I did not compile and test on bsd or solaris.

gangelop commented 7 years ago

Just for clarity, this is the change in behavior introduced by this patch:

# grep long /etc/mtab
/dev/mapper/testvg-very--long--lv--name /tmp/verylongmountdir ext4 rw,relatime,data=ordered 0 0

### BEFORE ###
# dfc -p /dev
FILESYSTEM               (=) USED      FREE (-)  %USED AVAILABLE  TOTAL MOUNTED ON               
/dev/mapper/luks-root    [===================-]  94.7%     12.4G 232.7G /                        
/dev/sda1                [====----------------]  15.7%    815.9M 968.3M /boot                    

### AFTER ###
# bin/dfc -p /dev
FILESYSTEM               (=) USED      FREE (-)  %USED AVAILABLE  TOTAL MOUNTED ON               
/dev/mapper/luks-root    [===================-]  94.7%     12.4G 232.7G /                        
/dev/sda1                [====----------------]  15.7%    815.9M 968.3M /boot                    
+vg-very--long--lv--name [==------------------]   6.3%      1.8G   1.9G /tmp/verylongmountdir 
rolinh commented 7 years ago

Nice catch! I did not test your patch on BSD or Solaris yet but I see no reason why it would not work since the changes are essentially the same for all platforms and they modify the non-platform specific part of the fsmntinfo structure. I am indeed planning on removing the truncation feature altogether since it seems that it usually confuses users but I'm unsure yet if I should simply completely get rid of it or make truncation an option switch rather than the default. Any opinion? I think that in the meantime, I shall go ahead, merge your PR and release 3.1.1. Oh, you may want to add your name to the list of contributors before I merge :wink:

gangelop commented 7 years ago

I'm unsure yet if I should simply completely get rid of it or make truncation an option switch rather than the default. Any opinion?

I think it's simple enough that it would be acceptable to keep it as an option even if there is one guy who would want it, instead of completely removing it.

Oh, you may want to add your name to the list of contributors before I merge

done!

rolinh commented 7 years ago

Thanks!