Repository navigation
stat: print the -f block and free node counts signed, as GNU does - #15355
ozenyunus35 wants to merge 2 commits into
Conversation
GNU prints %a, %b, %d and %f of `stat -f` with out_int, so the `+` and ` ` flags add a sign: `stat -f -c %+b /` gives `+123`. We printed them unsigned and dropped the flags.
| format, | ||
| } => { | ||
| let output = match format { | ||
| // GNU prints the block and free node counts signed (`out_int`), so |
There was a problem hiding this comment.
please drop the out_int reference, we don't refer to GNU internals. "signed, so + and apply" is enough
There was a problem hiding this comment.
Done, it now just says the counts are signed so + and apply.
There was a problem hiding this comment.
I hope by "we don't refer to GNU internals", you mean you don't copy from GNU internals, not just that you keep it secret... It is frustrating to see this, yet again.
There was a problem hiding this comment.
You're right, and I'm sorry. This change came from reading GNU's stat.c, which uutils doesn't allow. I'm closing this PR, and I've also removed the part of #15352 that came from the same source.
| #[test] | ||
| #[cfg(any(target_os = "linux", target_os = "android", target_os = "macos"))] | ||
| fn test_fs_signed_counts_take_sign_flags() { | ||
| // GNU prints %a, %b, %d and %f signed, so `+` and ` ` add a sign there, |
There was a problem hiding this comment.
this comment repeats the one in stat.rs, could be removed?
GNU prints
%a,%b,%dand%fofstat -fwithout_int, which keeps the+andflags, sostat -f -c %+b /gives+120699413. We printed them unsigned and dropped the flags. The other counts (%c,%s,%S) go throughout_uintin GNU and stay unsigned here too.Added
test_fs_signed_counts_take_sign_flags(Linux, Android, macOS, wherestat -fis implemented), which fails without the change.This sits next to #15352, which makes
%s/%Sunsigned; the two touch neighbouring lines of the-fmatch, so whichever lands second may need a quick rebase, and I'll take care of it.I used an AI assistant to help draft parts of the code and tests; I reviewed the changes and ran the tests myself.