summaryrefslogtreecommitdiffstats
path: root/bin/dd/position.c
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>1999-07-13 18:44:56 +0000
committergreen <green@FreeBSD.org>1999-07-13 18:44:56 +0000
commitac63841b827307ed6eac081c9536253d8c1fb21b (patch)
treea8f689318a437158780b279a77fc4790cfa02e2b /bin/dd/position.c
parentf091c51c34a496d3062026be39d6948fa02b6c6e (diff)
downloadFreeBSD-src-ac63841b827307ed6eac081c9536253d8c1fb21b.zip
FreeBSD-src-ac63841b827307ed6eac081c9536253d8c1fb21b.tar.gz
Implement seekability for disk devices (not just regular files).
Also, fix pos_out() to do the same checks pos_in() did. Done for: jdp, luigi, the good of the world
Diffstat (limited to 'bin/dd/position.c')
-rw-r--r--bin/dd/position.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/bin/dd/position.c b/bin/dd/position.c
index 7bab913..ae5191f 100644
--- a/bin/dd/position.c
+++ b/bin/dd/position.c
@@ -40,7 +40,7 @@
static char sccsid[] = "@(#)position.c 8.3 (Berkeley) 4/2/94";
#endif
static const char rcsid[] =
- "$Id: position.c,v 1.8 1998/05/13 07:33:54 charnier Exp $";
+ "$Id: position.c,v 1.10 1999/06/20 14:58:55 green Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -66,7 +66,7 @@ pos_in()
off_t cnt;
/* If not a character, pipe or tape device, try to seek on it. */
- if (!(in.flags & (ISCHR|ISPIPE|ISTAPE))) {
+ if (!(in.flags & (ISCHR|ISPIPE|ISTAPE)) || in.flags & ISDISK) {
if (lseek(in.fd, in.offset * in.dbsz, SEEK_CUR) == -1)
err(1, "%s", in.name);
return;
@@ -121,12 +121,8 @@ pos_out()
off_t cnt;
ssize_t n;
- /*
- * 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)) {
+ /* If not a character, pipe or tape device, try to seek on it. */
+ if (!(out.flags & (ISCHR|ISPIPE|ISTAPE)) || out.flags & ISDISK) {
if (lseek(out.fd, out.offset * out.dbsz, SEEK_SET) == -1)
err(1, "%s", out.name);
return;
OpenPOWER on IntegriCloud