Deleted Added
sdiff udiff text old ( 256281 ) new ( 321140 )
full compact
1/*-
2 * Copyright (c) 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Keith Muller of the University of California, San Diego and Lance
7 * Visser of Convex Computer Corporation.
8 *

--- 23 unchanged lines hidden (view full) ---

32 */
33
34#ifndef lint
35#if 0
36static char sccsid[] = "@(#)position.c 8.3 (Berkeley) 4/2/94";
37#endif
38#endif /* not lint */
39#include <sys/cdefs.h>
40__FBSDID("$FreeBSD: stable/10/bin/dd/position.c 250469 2013-05-10 18:43:36Z eadler $");
41
42#include <sys/types.h>
43#include <sys/mtio.h>
44
45#include <err.h>
46#include <errno.h>
47#include <inttypes.h>
48#include <signal.h>
49#include <unistd.h>
50
51#include "dd.h"
52#include "extern.h"
53
54/*
55 * Position input/output data streams before starting the copy. Device type
56 * dependent. Seekable devices use lseek, and the rest position by reading.
57 * Seeking past the end of file can cause null blocks to be written to the
58 * output.
59 */
60void
61pos_in(void)
62{
63 off_t cnt;
64 int warned;
65 ssize_t nr;
66 size_t bcnt;
67
68 /* If known to be seekable, try to seek on it. */
69 if (in.flags & ISSEEK) {
70 errno = 0;
71 if (lseek(in.fd, in.offset * in.dbsz, SEEK_CUR) == -1 &&
72 errno != 0)
73 err(1, "%s", in.name);
74 return;
75 }
76
77 /* Don't try to read a really weird amount (like negative). */
78 if (in.offset < 0)
79 errx(1, "%s: illegal offset", "iseek/skip");

--- 51 unchanged lines hidden (view full) ---

131
132 /*
133 * If not a tape, try seeking on the file. Seeking on a pipe is
134 * going to fail, but don't protect the user -- they shouldn't
135 * have specified the seek operand.
136 */
137 if (out.flags & (ISSEEK | ISPIPE)) {
138 errno = 0;
139 if (lseek(out.fd, out.offset * out.dbsz, SEEK_CUR) == -1 &&
140 errno != 0)
141 err(1, "%s", out.name);
142 return;
143 }
144
145 /* Don't try to read a really weird amount (like negative). */
146 if (out.offset < 0)
147 errx(1, "%s: illegal offset", "oseek/seek");

--- 39 unchanged lines hidden ---