Feature #134

Make use of device/partition argument

Added by Robin Hahling over 6 years ago. Updated over 1 year ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


Original df command can take a device or partition in argument. In this case, it prints only information about this device.

[robin@thor ~] % df /dev/sda5
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda5       13173352 7048316   6125036  54% /var

Version 3.0.0 of dfc can do something similar. However, it requires usage of -p option like such:
[robin@thor ~] % dfc -p /dev/sda5
/dev/sda5   [===========---------]   54%      5.8G     12.6G /var

Behave like df would be nice.


#1 Updated by Robin Hahling over 6 years ago

  • Subject changed from Make use of file argument to Make use of device/partition argument

#2 Updated by George Angelopoulos over 1 year ago

I'm also interested in implementing this. I want to also note that "-p" has a bad quirk: It matches the truncated string of the filesystem name as it appears in the output. For example, if you have "/dev/mapper/vgroot-lvroot", it gets truncated to "+ev/mapper/vgroot-lvroot" in the output and this is what -p matches. This is definitely a bug. Maybe it deserves it's own issue. If I end up looking into the code, I'll be back with more details.

#3 Updated by Robin Hahling over 1 year ago

I'm also interested in implementing this.

Please, go ahead a submit a patch here or a pull request on the github mirror :)

The truncation thing is actually a "feature" (which I'm really considering for removal). Check -W option.

#4 Updated by George Angelopoulos over 1 year ago

Hi Robin, thanks for responding.

Just to clarify: truncation is of course a feature. The bug is that -p matches the given string against fsname after it has been truncated. If we disagree about this being a bug, just let me know and I'll elaborate.

However... I'm not sure what the best way would be to fix this considering how the truncation happens, considering that the original fsname value just gets overwritten. A very simple fix would be to just set Wflag when pflag is set, i.e. disable truncation when matching fsnames with -p.

Another solution would be to add another variable where we store the original value of fsname (maybe a new variable in struct fsmntinfo?) which is passed to fsfilter() for the pattern matching. The behavior would then be that the matches are done against the actual fsname as it is seen in the system, but the name that is output is still truncated.

If you go ahead and completely remove truncation then this whole problem goes away.

Finally, sorry for hijacking the original issue. I just think it's worth figuring out this truncation issue before implementing the arguments feature.

In conclusion, please let me know which approach you think is the best, and I'll try to implement it.

P.S. I'm a n00b when it comes to C. I'm using dfc somewhat as a learning project. Please bear with me if I'm making any obvious oversights. :)

Also available in: Atom PDF