Page MenuHomeFreeBSD

dd: Correct padding in status=progress
ClosedPublic

Authored by tom_hur.st on Aug 30 2018, 9:45 PM.
Tags
None
Referenced Files
F105910043: D16960.diff
Sun, Dec 22, 12:10 PM
Unknown Object (File)
Thu, Dec 12, 7:01 AM
Unknown Object (File)
Nov 6 2024, 2:32 AM
Unknown Object (File)
Oct 25 2024, 5:55 PM
Unknown Object (File)
Oct 2 2024, 8:19 PM
Unknown Object (File)
Sep 30 2024, 1:34 AM
Unknown Object (File)
Sep 28 2024, 9:08 AM
Unknown Object (File)
Sep 28 2024, 12:32 AM
Subscribers
None

Details

Summary

Output padding is specified via outlen, which is set using the return value of fprintf. Because it's printing that padding plus a trailing byte, it grows by one each iteration.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Hi @imp - I've also received some other questions about status=progress:

1.) What's the rationale for a mix of SI/IEC here? You deal professionally with larger storage and personally with smaller storage, so I assume there's a good reason for it. =)

2.) Any objection to making the final line of SIGINFO consistent with this?

Not just mixing SI/IEC, but they have different effective widths, so they scale differently - one will be counting up thousands of MBs while the other's totting up GiBs, (9294 MB, 8.7 GiB):

char si[4 + 1 + 2 + 1];         /* 123 <space> <suffix> NUL */
char iec[4 + 1 + 2 + 1];        /* 123 <space> <suffix> NUL */

If that's intended, shouldn't this be iec[3 + 1 + 3 + 1]? If it's not intended, char iec[4 + 1 + 3 + 1] is the obvious tweak for a more consistent (8407 MB, 8018 MiB), except then I also get (25 GB, ) if I dd with a larger block size(?!).

Oh, this is why:

humanize_number(persec, sizeof(iec), (int64_t)(st.bytes / secs), "B",

Formatting into persec but using the size of iec. I guess at high speeds it's filling the buffer and the trailing NULL is overflowing into iec.

I listed both because different applications require different numbers.
Sometimes you need SI stuff since you are more familiar with that stuff due to there aspects of your pipeline (eg disks or networks)
Other times you want the IEC ones because you (eg memory images)
It's also not burdensome to do both, just tricky to get the code right...

looks good, as does the good humanize_number catch.

This revision is now accepted and ready to land.Aug 31 2018, 3:39 PM

Fix persec humanize_number call. Size IEC buffer to make room for the longer suffix.

This revision now requires review to proceed.Aug 31 2018, 3:49 PM
This revision is now accepted and ready to land.Aug 31 2018, 3:57 PM
In D16960#362030, @imp wrote:

looks good, as does the good humanize_number catch.

Do you want to take this through re@, or shall I?

This revision was automatically updated to reflect the committed changes.