From owner-freebsd-standards@FreeBSD.ORG Tue Apr 23 11:10:02 2013 Return-Path: Delivered-To: freebsd-standards@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0FE5DBFF for ; Tue, 23 Apr 2013 11:10:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id DB7771773 for ; Tue, 23 Apr 2013 11:10:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r3NBA1uC085388 for ; Tue, 23 Apr 2013 11:10:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r3NBA11i085387; Tue, 23 Apr 2013 11:10:01 GMT (envelope-from gnats) Date: Tue, 23 Apr 2013 11:10:01 GMT Message-Id: <201304231110.r3NBA11i085387@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: Matthew Rezny Subject: Re: standards/177742: conflict of dd's bs= option with use of conv=sparse X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Matthew Rezny List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Apr 2013 11:10:02 -0000 The following reply was made to PR standards/177742; it has been noted by GNATS. From: Matthew Rezny To: Konstantin Belousov Cc: bug-followup@FreeBSD.org Subject: Re: standards/177742: conflict of dd's bs= option with use of conv=sparse Date: Tue, 23 Apr 2013 13:00:43 +0200 On Tue, 23 Apr 2013 09:21:23 +0300 Konstantin Belousov wrote: > On Thu, Apr 11, 2013 at 05:44:59AM +0200, Matthew Rezny wrote: > > Looking not just at my problem but the overall situation, it seems > > the logic in dd_in() does not hold up. The last line, (*cfunc)();, > > actually invokes the appropriate conversion(s) and then calls > > dd_out(0). With the simple test on line 361, we will never get down > > to that call if bs= option is used. Really, to make the code fit > > the comment, it should probably be something like > > if ((ddflags & ~(C_NOERROR | C_NOTRUNC | C_SYNC)) == C_BS) { > > out.dbcnt = in.dbcnt; > > dd_out(0); > > in.dbcnt = 0; > > continue; > > } > I do not see why did you changed dd_out(1) to dd_out(0). > > Anyway, I am going to commit the following patch, unless I get some > objection in two-three days: > > commit 37664b1393db30d97aa9eefa70360cd550bf9dd9 > Author: Konstantin Belousov > Date: Tue Apr 23 09:18:31 2013 +0300 > > Literally follow POSIX: > If the bs= expr operand is specified and no conversions other > than sync, noerror, or notrunc are requested, the data returned from > each input block shall be written as a separate output block. > > PR: standards/177742 > Submitted by: Matthew Rezny > > diff --git a/bin/dd/dd.c b/bin/dd/dd.c > index 01b66fc..9d0f9b1 100644 > --- a/bin/dd/dd.c > +++ b/bin/dd/dd.c > @@ -358,7 +358,7 @@ dd_in(void) > * than noerror, notrunc or sync are specified, the > block > * is output without buffering as it is read. > */ > - if (ddflags & C_BS) { > + if ((ddflags & ~(C_NOERROR | C_NOTRUNC | C_SYNC)) == > C_BS) { out.dbcnt = in.dbcnt; > dd_out(1); > in.dbcnt = 0; > On review, I think the dd_out(0) was an oversight. I put the more precise condition up top but then forgot to put it back to dd_out(1) as it had been. The one line patch you plan to commit should be effective. Thank you for taking the time to read my perhaps overly verbose report on the issue.