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


Reply via email to