Subject: dd seek speed on raw disk devices
To: None <tech-userlevel@netbsd.org>
From: Ignatios Souvatzis <is@jocelyn.rhein.de>
List: tech-userlevel
Date: 10/02/1998 23:15:37
Hi,

after Christoph comlained about the dd skip "speed" on raw disk devices, 
I looked at it and found that it never seeks on character devices which are
no tapes.

I changed it to try to seek unless on a tty, and skip over the data if a tty
or if the seek returns ESPIPE. The diff is appended below.

Is this the right thing to do?  (Well, to preserve dd programming style, 
I should do the isatty() in the getfdtype() function isntead, and set a bit
for later usage...)

	Ignatios

retrieving revision 1.6
diff -u -r1.6 position.c
--- position.c  1997/07/25 06:46:24     1.6
+++ position.c  1998/10/02 21:14:13
@@ -71,11 +71,12 @@
        int bcnt, cnt, nr, warned;
 
        /* If not a character, pipe or tape device, try to seek on it. */
-       if (!(in.flags & (ISCHR|ISPIPE|ISTAPE))) {
+       if (!isatty(in.fd)) {
                if (lseek(in.fd, (off_t)in.offset * (off_t)in.dbsz, SEEK_CUR)
-                   == -1)
+                   != (off_t)-1)
+                       return;
+               if (errno != ESPIPE)
                        err(1, "%s", in.name);
-               return;
        }
 
        /*