Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Oct 2014 18:55:24 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r273129 - head/sys/kern
Message-ID:  <20141029165523.GF53947@kib.kiev.ua>
In-Reply-To: <20141028040935.M3114@besplex.bde.org>
References:  <201410151238.s9FCcRMe018200@svn.freebsd.org> <20141028040935.M3114@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20141029165523.GF53947>