diff options
author | green <green@FreeBSD.org> | 1999-09-13 21:47:10 +0000 |
---|---|---|
committer | green <green@FreeBSD.org> | 1999-09-13 21:47:10 +0000 |
commit | 996b2b913e8dd8f5ecb4b791313fc73854fe47f9 (patch) | |
tree | 5a6e0a8cdbccc055d27764c695287ded89d56c6a /bin/dd/position.c | |
parent | 167f52768b0c86277d20f1b46457a6859e342221 (diff) | |
download | FreeBSD-src-996b2b913e8dd8f5ecb4b791313fc73854fe47f9.zip FreeBSD-src-996b2b913e8dd8f5ecb4b791313fc73854fe47f9.tar.gz |
Even more dd(1) cleanups! Thanks to Bruce for staying on my case until
we're done (not yet!) :)
Diffstat (limited to 'bin/dd/position.c')
-rw-r--r-- | bin/dd/position.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/bin/dd/position.c b/bin/dd/position.c index 09b69a8..e6774a5 100644 --- a/bin/dd/position.c +++ b/bin/dd/position.c @@ -67,8 +67,8 @@ pos_in() ssize_t nr; size_t bcnt; - /* If not a character, pipe or tape device, try to seek on it. */ - if (!(in.flags & (ISCHR|ISPIPE|ISTAPE)) || in.flags & ISSEEK) { + /* If known to be seekable, try to seek on it. */ + if (in.flags & ISSEEK) { errno = 0; if (lseek(in.fd, in.offset * in.dbsz, SEEK_CUR) == -1 && errno != 0) @@ -125,8 +125,12 @@ pos_out() off_t cnt; ssize_t n; - /* If not a character, pipe or tape device, try to seek on it. */ - if (!(out.flags & (ISCHR|ISPIPE|ISTAPE)) || out.flags & ISSEEK) { + /* + * If not a tape, try seeking on the file. Seeking on a pipe is + * going to fail, but don't protect the user -- they shouldn't + * have specified the seek operand. + */ + if (!(out.flags & ISTAPE)) { errno = 0; if (lseek(out.fd, out.offset * out.dbsz, SEEK_SET) == -1 && errno != 0) |