From owner-svn-src-head@FreeBSD.ORG Wed Oct 29 16:55:30 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CEB56DF9; Wed, 29 Oct 2014 16:55:30 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 412F2686; Wed, 29 Oct 2014 16:55:30 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id s9TGtOIe006678 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 29 Oct 2014 18:55:24 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua s9TGtOIe006678 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id s9TGtOYD006676; Wed, 29 Oct 2014 18:55:24 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 29 Oct 2014 18:55:24 +0200 From: Konstantin Belousov To: Bruce Evans Subject: Re: svn commit: r273129 - head/sys/kern Message-ID: <20141029165523.GF53947@kib.kiev.ua> References: <201410151238.s9FCcRMe018200@svn.freebsd.org> <20141028040935.M3114@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141028040935.M3114@besplex.bde.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Oct 2014 16:55:30 -0000 On Tue, Oct 28, 2014 at 04:28:37AM +1100, Bruce Evans wrote: > @diff -u2 dd.c~ dd.c > @--- dd.c~ Wed Apr 7 20:20:48 2004 > @+++ dd.c Wed Apr 7 20:20:49 2004 > @@@ -247,21 +245,18 @@ > @ io->flags |= ISTRUNC; > @ if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) { > @- if (ioctl(io->fd, FIODTYPE, &type) == -1) { > @+ if (ioctl(io->fd, FIODTYPE, &type) == -1) > @ err(1, "%s", io->name); > @- } else { > @+ else { > @ if (type & D_TAPE) > @ io->flags |= ISTAPE; > @ else if (type & (D_DISK | D_MEM)) > @- io->flags |= ISSEEK; > @- if (S_ISCHR(sb.st_mode) && (type & D_TAPE) == 0) > @+ io->flags |= ISSEEKABLE; > @+ if (S_ISCHR(sb.st_mode)) > @ io->flags |= ISCHR; > @ } > @- return; > @- } > @- errno = 0; > @- if (lseek(io->fd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE) > @- io->flags |= ISPIPE; > @- else > @- io->flags |= ISSEEK; > @+ } else if (lseek(io->fd, (off_t)0, SEEK_CUR) == 0) > @+ io->flags |= ISSEEKABLE; > @+ else if (errno == ESPIPE) > @+ io->flags |= ISPIPE; /* XXX fixed in 4.4BSD */ > @ } > @ Ok, I tried to de-obfuscate and restore the patch above. diff --git a/bin/dd/dd.c b/bin/dd/dd.c index 8ae11a7..aadc7da 100644 --- a/bin/dd/dd.c +++ b/bin/dd/dd.c @@ -257,7 +257,7 @@ getfdtype(IO *io) err(1, "%s", io->name); if (S_ISREG(sb.st_mode)) io->flags |= ISTRUNC; - if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) { + if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) { if (ioctl(io->fd, FIODTYPE, &type) == -1) { err(1, "%s", io->name); } else { @@ -265,16 +265,14 @@ getfdtype(IO *io) io->flags |= ISTAPE; else if (type & (D_DISK | D_MEM)) io->flags |= ISSEEK; - if (S_ISCHR(sb.st_mode) && (type & D_TAPE) == 0) + if (S_ISCHR(sb.st_mode)) io->flags |= ISCHR; } - return; - } - errno = 0; - if (lseek(io->fd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE) - io->flags |= ISPIPE; - else + } else if (lseek(io->fd, (off_t)0, SEEK_CUR) == 0) { io->flags |= ISSEEK; + } else if (errno == ESPIPE) { + io->flags |= ISPIPE; + } } static void