diff options
author | green <green@FreeBSD.org> | 1999-09-16 19:50:59 +0000 |
---|---|---|
committer | green <green@FreeBSD.org> | 1999-09-16 19:50:59 +0000 |
commit | a12ece1af8e8a375973b5cd4ea60516c4e61a819 (patch) | |
tree | cf94071b11c33e7d8ffb6c9317614d708c5d586f /bin/dd/dd.c | |
parent | f051cabc3624134f50f0a18014e1430c314c8bde (diff) | |
download | FreeBSD-src-a12ece1af8e8a375973b5cd4ea60516c4e61a819.zip FreeBSD-src-a12ece1af8e8a375973b5cd4ea60516c4e61a819.tar.gz |
Make count=0 set cpy_cnt to -1, which is slight overloading, but makes
what I was trying to do work much better (ie at all. I could have sworn
it was working...) Fix a SEEK_SET to be SEEK_CUR, and make Bruce's
lseek() test work correctly.
Diffstat (limited to 'bin/dd/dd.c')
-rw-r--r-- | bin/dd/dd.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/bin/dd/dd.c b/bin/dd/dd.c index da70ca7..49fd7be 100644 --- a/bin/dd/dd.c +++ b/bin/dd/dd.c @@ -225,10 +225,13 @@ getfdtype(io) if (S_ISCHR(sb.st_mode) && (type & D_TAPE) == 0) io->flags |= ISCHR; } - } else if (lseek(io->fd, (off_t)0, SEEK_CUR) == 0) - io->flags |= ISSEEK; - else if (errno == ESPIPE) + return; + } + errno = 0; + if (lseek(io->fd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE) io->flags |= ISPIPE; + else + io->flags |= ISSEEK; } static void @@ -237,8 +240,16 @@ dd_in() ssize_t n; for (;;) { - if (cpy_cnt && (st.in_full + st.in_part) >= cpy_cnt) + switch (cpy_cnt) { + case -1: /* count=0 was specified */ return; + case 0: + break; + default: + if (st.in_full + st.in_part >= cpy_cnt) + return; + break; + } /* * Zero the buffer first if sync; if doing block operations, |