From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcIzx-0005AY-Eq for qemu-devel@nongnu.org; Tue, 23 Aug 2016 17:12:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bcIzu-0007E0-70 for qemu-devel@nongnu.org; Tue, 23 Aug 2016 17:12:41 -0400 Date: Tue, 23 Aug 2016 12:03:21 -0400 From: Stefan Hajnoczi Message-ID: <20160823160321.GD3948@stefanha-x1.localdomain> References: <20160822075517.5859-1-fullmanet@gmail.com> <20160822075517.5859-4-fullmanet@gmail.com> <20160822133526.GE28679@stefanha-x1.localdomain> <20160822140229.GB21105@vps308710.ovh.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="SFyWQ0h3ruR435lw" Content-Disposition: inline In-Reply-To: <20160822140229.GB21105@vps308710.ovh.net> 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: Reda Sallahi Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz --SFyWQ0h3ruR435lw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Aug 22, 2016 at 04:02:30PM +0200, Reda Sallahi wrote: > 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) > > > =20 > > > for (out_pos =3D out.offset * obsz; in_pos < size; block_count++= ) { > > > int in_ret, out_ret; > > > + bsz =3D in.bsz; > > > =20 > > > if (in_pos + in.bsz > size) { > > > - in_ret =3D blk_pread(blk1, in_pos, in.buf, size - in_pos= ); > > > - } else { > > > - in_ret =3D blk_pread(blk1, in_pos, in.buf, in.bsz); > > > + bsz =3D size - in_pos; > > > + } > > > + > > > + if (dd.conv & C_SYNC) { > > > + memset(in.buf, 0, in.bsz); > > > } > >=20 > > Why is memset necessary? >=20 > When we set conv=3Dnoerror,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. Ah, I see. Stefan --SFyWQ0h3ruR435lw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJXvHPJAAoJEJykq7OBq3PIMMUH/1GNSNWGx0HnA2dauwtc/jK/ nVL0eRqE6z0aNkiuX+wN/nABVpzW2WfaUkpkUDXMgHH4o0SgwrTp1E6Jnb1AKAJ4 ap2CygNcciwXsDnKA8iRclOm6+wn36/dp/q0o2VPPwZ9YGq2dlegET9FgXMrmiNs 2JGDJ5t9FYV+rkju3h4X17RAsVkkYMSXF/rHVWsBNvZcNe+QtVY4VQoaliWpSzV0 nFMtUL+H9QITnGBaE5V1sSToGEmzgAxBZtVYAw6RGX7sMSmYNXEVvYow6aHehXTp PwWcPnuNdyjNfS6s0sD7YZclfpT5HTg+y7ijDV4iXAFURHKfPbvi9AxHKXLa/m4= =hPBJ -----END PGP SIGNATURE----- --SFyWQ0h3ruR435lw--