Page MenuHomeFreeBSD

df: Fix the header when using the -P option
Needs ReviewPublic

Authored by jlduran on Dec 17 2025, 4:52 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jan 17, 11:04 AM
Unknown Object (File)
Fri, Jan 16, 9:20 AM
Unknown Object (File)
Thu, Jan 15, 9:21 PM
Unknown Object (File)
Mon, Jan 12, 12:38 PM
Unknown Object (File)
Mon, Jan 12, 10:34 AM
Unknown Object (File)
Mon, Jan 12, 6:16 AM
Unknown Object (File)
Sat, Jan 10, 3:37 PM
Unknown Object (File)
Fri, Jan 9, 7:41 PM
Subscribers

Details

Reviewers
des
emaste
imp
Summary

When both the -k and -P options are specified, the following header line
shall be written (in the POSIX locale):

"Filesystem 1024-blocks Used Available Capacity Mounted on\n"

When the -P option is specified without the -k option, the following
header line shall be written (in the POSIX locale):

"Filesystem 512-blocks Used Available Capacity Mounted on\n"

https://pubs.opengroup.org/onlinepubs/9799919799/utilities/df.html

Spell out "Available" in the header only when using the Portability
(POSIX) "-P" option.

Test Plan
$ kyua test
df_test:Pflag  ->  passed  [0.016s]
df_test:kPflags  ->  passed  [0.011s]
t_df:hflag  ->  passed  [0.009s]
t_df:normal  ->  passed  [0.008s]

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

des added inline comments.
bin/df/df.c
42
53
84–86

Initializing static variables to 0 is redundant.

You might also consider converting these from int to bool.

485

Since we already include <sys/param.h>, we may as well use the MAX macro it provides.

bin/df/df.c
84–86

Thank you for this and all the other suggestions, if you don't mind I'll address them separately. It was not in my plans to refactor df(1), but the changes are simple enough, so I might as well do it.
Originally I just wanted to make sure we had some basic testing before debating https://github.com/freebsd/freebsd-src/pull/1906, and at least pretend to have POSIX compliance.
df -P has been indirectly tested on macOS (chiefly because it is UNIX '03 certified), and the only issue I could find was df -c, but this is unrelated.

jlduran added inline comments.
bin/df/df.c
42

Implemented in D54457.

53

Implemented in D54457.

84–86

Implemented in D54457.

485

Implemented in D54457.

jlduran marked 3 inline comments as done.

Rebase.