Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Jun 2017 17:15:15 +0800
From:      Christopher Hall <christopherhall.hsw@gmail.com>
To:        Dewayne Geraghty <dewaynegeraghty@gmail.com>
Cc:        freebsd-stable stable <freebsd-stable@freebsd.org>
Subject:   Re: dd is returning different content using same inputs
Message-ID:  <20170608171515.72fa7844@arria.bitmark.lan>
In-Reply-To: <CAGnMC6ryoG7tDLthS8=6AC3vtXifaocnrBDxOO1kFjyToVPqgA@mail.gmail.com>
References:  <CAGnMC6ryoG7tDLthS8=6AC3vtXifaocnrBDxOO1kFjyToVPqgA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hello Dewayne,

On Thu, 8 Jun 2017 18:10:11 +1000, Dewayne Geraghty
<dewaynegeraghty@gmail.com> wrote:

> I'm attempting to skip the first three bytes of a file and then pull
> the header out of message. Please note the file size varies between
> 105 and 54 bytes, even though the input file and everything else
> remains constant, on
> 
> FreeBSD hathor 11.1-PRERELEASE FreeBSD 11.1-PRERELEASE #0 r319562M:
> Mon Jun  5 03:13:08 AEST 2017
> root@hathor:/110007/D/K8/hqdev-amd64-smp-vga amd64 1100514 1100514
> 
> # rm encheader;dd if=/tmp/tLbdoJ/encmessage bs=1 skip=3 | dd bs=384
> count=1 of=encheader ; ls -lrth  encheader
> 0+1 records in
> 0+1 records out
> 105 bytes transferred in 0.000026 secs (4071661 bytes/sec)
> -rw-r--r--  1 root  wheel   105B Jun  8 16:35 encheader
> # rm encheader;dd if=/tmp/tLbdoJ/encmessage bs=1 skip=3 | dd bs=384
> count=1 of=encheader ; ls -lrth  encheader
> 0+1 records in
> 0+1 records out
> 67 bytes transferred in 0.000026 secs (2554912 bytes/sec)
> -rw-r--r--  1 root  wheel    67B Jun  8 16:35 encheader
> # rm encheader;dd if=/tmp/tLbdoJ/encmessage bs=1 skip=3 | dd bs=384
> count=1 of=encheader ; ls -lrth  encheader
> 0+1 records in
> 0+1 records out
> 68 bytes transferred in 0.000024 secs (2867263 bytes/sec)
> -rw-r--r--  1 root  wheel    68B Jun  8 16:35 encheader
> # rm encheader;dd if=/tmp/tLbdoJ/encmessage bs=1 skip=3 | dd bs=384
> count=1 of=encheader ; ls -lrth  encheader
> 0+1 records in
> 0+1 records out
> 54 bytes transferred in 0.000025 secs (2167717 bytes/sec)
> -rw-r--r--  1 root  wheel    54B Jun  8 16:35 encheader
> # rm encheader;dd if=/tmp/tLbdoJ/encmessage bs=1 skip=3 | dd bs=384
> count=1 of=encheader ; ls -lrth  encheader
> 0+1 records in
> 0+1 records out
> 91 bytes transferred in 0.000024 secs (3751494 bytes/sec)
> -rw-r--r--  1 root  wheel    91B Jun  8 16:35 encheader
> 
> I used this around May 8th (from a OS and ports rebuild on 4th May)
> and was performing some final testing on an 11.1 Prerelease built on
> Jun 5.
> 
It works similarly on TrueOS (FreeBSD 12) I suspect it is because you
block sizes are different on the input and output dd commands.
I would think that the output block size (obs) on 1st dd needs to be
specified the same input block size on receiving dd to make it work
correctly.

> This works correctly so perhaps I'm not using dd correctly?
> dd if=/tmp/tLbdoJ/encmessage skip=1 bs=3  | dd bs=1 count=384
> of=encheader ; hd encheader|head -n1; ls -l encheader
> _______________________________________________
> freebsd-stable@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-stable
> To unsubscribe, send any mail to
> "freebsd-stable-unsubscribe@freebsd.org"


-- 
Best Regards.
Christopher Hall.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170608171515.72fa7844>