Bug 472376

Summary: dd tool, human readable fix
Product: [Fedora] Fedora Reporter: Andrey Arapov <andrey.arapov>
Component: coreutilsAssignee: Ondrej Vasik <ovasik>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: medium    
Version: rawhideCC: anton, kdudka, ovasik, twaugh
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 6.12 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-11-20 15:51:21 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
proposed patch
none
proposed patch
none
reworked patch none

Description Andrey Arapov 2008-11-20 15:35:10 UTC
Created attachment 324184 [details]
proposed patch

dd tool is showing wrong information about the size of the copied data

Example:
fedora ~ # dd if=/dev/zero of=/tmp/tmpdata bs=1M count=6
6+0 records in
6+0 records out
6291456 bytes (6.3 MB) copied, 0.0142112 s, 443 MB/s
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-!!!
It must be 6.0 MB copied
fedora ~ # echo "6291456/1024/1024"|bc -l
6.00000000000000000000

Comment 1 Andrey Arapov 2008-11-20 15:39:03 UTC
Created attachment 324185 [details]
proposed patch

Comment 2 Ondrej Vasik 2008-11-20 15:51:21 UTC
Thanks for report and patch, however that's NOTABUG ... 

Please read again what's written in dd --help:
"BLOCKS and BYTES may be followed by the following multiplicative suffixes:
xM M, c 1, w 2, b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,
GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y."

So generally - you have specified blocksize 1024*1024 - and output is shown in MB (1000*1000) form (and obviously rounded).

Comment 3 Ondrej Vasik 2008-11-20 16:32:36 UTC
Additionally there is no  "| human_base_1024" in dd.c 's human_opts, so I wonder what was the original version of sources you have.

Comment 4 Andrey Arapov 2008-11-20 16:52:05 UTC
Created attachment 324202 [details]
reworked patch

Comment 5 Ondrej Vasik 2008-11-20 21:39:25 UTC
Please, read again comment #2 before making another patch... that behaviour is expected, correct and there is nothing to be patched... MB is 1000*1000 , M is 1024*1024 ... you requested size 1024*1024*6 , which is obviously displayed as 6.3*1000*1000 ... 
If you want your 6.0MB copied, try to use 6 * 1MB block and not 6* 1M block...
fedora ~ # dd if=/dev/zero of=/tmp/tmpdata bs=1MB count=6

Note: 1MB = 1 Megabyte = 10^6 bytes
      1MiB = 1 Mebibyte = 2^20 bytes

Official reference: http://physics.nist.gov/cuu/Units/binary.html