From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbpoB-0006w3-Pv for qemu-devel@nongnu.org; Mon, 22 Aug 2016 10:02:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bbpo7-0006FC-Rl for qemu-devel@nongnu.org; Mon, 22 Aug 2016 10:02:35 -0400 Date: Mon, 22 Aug 2016 16:02:30 +0200 From: Reda Sallahi Message-ID: <20160822140229.GB21105@vps308710.ovh.net> References: <20160822075517.5859-1-fullmanet@gmail.com> <20160822075517.5859-4-fullmanet@gmail.com> <20160822133526.GE28679@stefanha-x1.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160822133526.GE28679@stefanha-x1.localdomain> Subject: Re: [Qemu-devel] [PATCH 3/7] qemu-img: add more conv= conversions to dd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi On Mon, Aug 22, 2016 at 09:35:26AM -0400, Stefan Hajnoczi wrote: > On Mon, Aug 22, 2016 at 09:55:13AM +0200, Reda Sallahi wrote: > > @@ -4325,20 +4388,43 @@ static int img_dd(int argc, char **argv) > > > > for (out_pos = out.offset * obsz; in_pos < size; block_count++) { > > int in_ret, out_ret; > > + bsz = in.bsz; > > > > if (in_pos + in.bsz > size) { > > - in_ret = blk_pread(blk1, in_pos, in.buf, size - in_pos); > > - } else { > > - in_ret = blk_pread(blk1, in_pos, in.buf, in.bsz); > > + bsz = size - in_pos; > > + } > > + > > + if (dd.conv & C_SYNC) { > > + memset(in.buf, 0, in.bsz); > > } > > Why is memset necessary? When we set conv=noerror,sync sync tells dd to pad each block with NULs so that if there is an error it preserves the size of the input read. -- Reda