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
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to