[Midnightbsd-cvs] src [11343] trunk/bin/dd/tests: sync with freebsd
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Thu Jul 5 15:06:56 EDT 2018
Revision: 11343
http://svnweb.midnightbsd.org/src/?rev=11343
Author: laffer1
Date: 2018-07-05 15:06:56 -0400 (Thu, 05 Jul 2018)
Log Message:
-----------
sync with freebsd
Modified Paths:
--------------
trunk/bin/dd/Makefile
trunk/bin/dd/args.c
trunk/bin/dd/conv.c
trunk/bin/dd/conv_tab.c
trunk/bin/dd/dd.1
trunk/bin/dd/dd.c
trunk/bin/dd/dd.h
trunk/bin/dd/extern.h
trunk/bin/dd/gen.c
trunk/bin/dd/misc.c
trunk/bin/dd/position.c
trunk/bin/dd/ref.ascii
trunk/bin/dd/ref.ebcdic
trunk/bin/dd/ref.ibm
trunk/bin/dd/ref.lcase
trunk/bin/dd/ref.oldascii
trunk/bin/dd/ref.oldebcdic
trunk/bin/dd/ref.oldibm
trunk/bin/dd/ref.pareven
trunk/bin/dd/ref.parnone
trunk/bin/dd/ref.parodd
trunk/bin/dd/ref.parset
trunk/bin/dd/ref.swab
trunk/bin/dd/ref.ucase
Added Paths:
-----------
trunk/bin/dd/ref.obs_zeroes
trunk/bin/dd/tests/
trunk/bin/dd/tests/Makefile
trunk/bin/dd/tests/dd2_test.sh
Property Changed:
----------------
trunk/bin/dd/dd.1
trunk/bin/dd/ref.ascii
trunk/bin/dd/ref.ebcdic
trunk/bin/dd/ref.ibm
trunk/bin/dd/ref.lcase
trunk/bin/dd/ref.oldascii
trunk/bin/dd/ref.oldebcdic
trunk/bin/dd/ref.oldibm
trunk/bin/dd/ref.pareven
trunk/bin/dd/ref.parnone
trunk/bin/dd/ref.parodd
trunk/bin/dd/ref.parset
trunk/bin/dd/ref.swab
trunk/bin/dd/ref.ucase
Modified: trunk/bin/dd/Makefile
===================================================================
--- trunk/bin/dd/Makefile 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/Makefile 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,7 +1,9 @@
+# $MidnightBSD$
# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD: src/bin/dd/Makefile,v 1.18 2004/04/09 07:13:27 njl Exp $
-# $MidnightBSD: src/bin/dd/Makefile,v 1.2 2006/07/07 15:47:03 laffer1 Exp $
+# $FreeBSD: stable/10/bin/dd/Makefile 298258 2016-04-19 07:34:31Z thomas $
+.include <bsd.own.mk>
+
PROG= dd
SRCS= args.c conv.c conv_tab.c dd.c misc.c position.c
@@ -23,6 +25,21 @@
LC_ALL=en_US.US-ASCII hexdump -C | \
diff -I FreeBSD - ${.CURDIR}/ref.${conv}
.endfor
- @rm -f gen
+ @${ECHO} "testing sparse file (obs zeroes)"
+ @./gen 189284 | ./dd ibs=16 obs=8 conv=sparse of=obs_zeroes 2> /dev/null
+ @hexdump -C obs_zeroes | diff -I FreeBSD - ${.CURDIR}/ref.obs_zeroes
+ @${ECHO} "testing spase file (all zeroes)"
+ @./dd if=/dev/zero of=1M_zeroes bs=1048576 count=1 2> /dev/null
+ @./dd if=1M_zeroes of=1M_zeroes.1 bs=1048576 conv=sparse 2> /dev/null
+ @./dd if=1M_zeroes of=1M_zeroes.2 bs=1048576 2> /dev/null
+ @diff 1M_zeroes 1M_zeroes.1
+ @diff 1M_zeroes 1M_zeroes.2
+
+ @rm -f gen 1M_zeroes* obs_zeroes
+
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
.include <bsd.prog.mk>
Modified: trunk/bin/dd/args.c
===================================================================
--- trunk/bin/dd/args.c 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/args.c 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -30,9 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $FreeBSD: src/bin/dd/args.c,v 1.40 2004/08/15 19:10:05 rwatson Exp $ */
-
#ifndef lint
#if 0
static char sccsid[] = "@(#)args.c 8.3 (Berkeley) 4/2/94";
@@ -39,7 +38,7 @@
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/bin/dd/args.c 321140 2017-07-18 17:36:25Z ngie $");
#include <sys/types.h>
@@ -47,6 +46,7 @@
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
+#include <signal.h>
#include <stdlib.h>
#include <string.h>
@@ -67,6 +67,7 @@
static void f_of(char *);
static void f_seek(char *);
static void f_skip(char *);
+static void f_status(char *);
static uintmax_t get_num(const char *);
static off_t get_off_t(const char *);
@@ -89,6 +90,7 @@
{ "oseek", f_seek, C_SEEK, C_SEEK },
{ "seek", f_seek, C_SEEK, C_SEEK },
{ "skip", f_skip, C_SKIP, C_SKIP },
+ { "status", f_status, C_STATUS,C_STATUS },
};
static char *oper;
@@ -164,14 +166,6 @@
errx(1, "cbs meaningless if not doing record operations");
} else
cfunc = def;
-
- /*
- * Bail out if the calculation of a file offset would overflow.
- */
- if (in.offset > OFF_MAX / (ssize_t)in.dbsz ||
- out.offset > OFF_MAX / (ssize_t)out.dbsz)
- errx(1, "seek offsets cannot be larger than %jd",
- (intmax_t)OFF_MAX);
}
static int
@@ -293,6 +287,18 @@
in.offset = get_off_t(arg);
}
+static void
+f_status(char *arg)
+{
+
+ if (strcmp(arg, "none") == 0)
+ ddflags |= C_NOINFO;
+ else if (strcmp(arg, "noxfer") == 0)
+ ddflags |= C_NOXFER;
+ else
+ errx(1, "unknown status %s", arg);
+}
+
static const struct conv {
const char *name;
u_int set, noset;
Modified: trunk/bin/dd/conv.c
===================================================================
--- trunk/bin/dd/conv.c 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/conv.c 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -30,9 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $FreeBSD: src/bin/dd/conv.c,v 1.19 2004/04/06 20:06:45 markm Exp $ */
-
#ifndef lint
#if 0
static char sccsid[] = "@(#)conv.c 8.3 (Berkeley) 4/2/94";
@@ -39,7 +38,7 @@
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/bin/dd/conv.c 127958 2004-04-06 20:06:54Z markm $");
#include <sys/param.h>
Modified: trunk/bin/dd/conv_tab.c
===================================================================
--- trunk/bin/dd/conv_tab.c 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/conv_tab.c 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -30,7 +31,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $FreeBSD: src/bin/dd/conv_tab.c,v 1.12 2004/04/06 20:06:45 markm Exp $ */
#ifndef lint
#if 0
@@ -38,10 +38,16 @@
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/bin/dd/conv_tab.c 250469 2013-05-10 18:43:36Z eadler $");
#include <sys/types.h>
+#include <signal.h>
+#include <stdint.h>
+
+#include "dd.h"
+#include "extern.h"
+
/*
* There are currently six tables:
*
Modified: trunk/bin/dd/dd.1
===================================================================
--- trunk/bin/dd/dd.1 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/dd.1 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"-
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -30,10 +31,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)dd.1 8.2 (Berkeley) 1/13/94
-.\" $FreeBSD: src/bin/dd/dd.1,v 1.30.2.1 2005/09/24 01:59:35 keramida Exp $
-.\" $MidnightBSD: src/bin/dd/dd.1,v 1.2 2006/07/07 15:47:03 laffer1 Exp $
+.\" $FreeBSD: stable/10/bin/dd/dd.1 316203 2017-03-30 02:23:02Z sevan $
.\"
-.Dd January 23, 2009
+.Dd October 5, 2016
.Dt DD 1
.Os
.Sh NAME
@@ -157,6 +157,17 @@
For pipes, the correct number of bytes is read.
For all other devices, the correct number of blocks is read without
distinguishing between a partial or complete block being read.
+.It Cm status Ns = Ns Ar value
+Where
+.Cm value
+is one of the symbols from the following list.
+.Bl -tag -width ".Cm noxfer"
+.It Cm noxfer
+Do not print the transfer statistics as the last line of status output.
+.It Cm none
+Do not print the status output.
+Error messages are shown; informational messages are not.
+.El
.It Cm conv Ns = Ns Ar value Ns Op , Ns Ar value ...
Where
.Cm value
@@ -379,12 +390,12 @@
.Sh EXAMPLES
Check that a disk drive contains no bad blocks:
.Pp
-.Dl "dd if=/dev/ad0 of=/dev/null bs=1m"
+.Dl "dd if=/dev/ada0 of=/dev/null bs=1m"
.Pp
Do a refresh of a disk drive, in order to prevent presently
recoverable read errors from progressing into unrecoverable read errors:
.Pp
-.Dl "dd if=/dev/ad0 of=/dev/ad0 bs=1m"
+.Dl "dd if=/dev/ada0 of=/dev/ada0 bs=1m"
.Pp
Remove parity bit from a file:
.Pp
@@ -398,9 +409,15 @@
for data CD-ROM disks, use a block size of 2048 bytes:
.Pp
.Dl "dd if=/dev/acd0 of=filename.iso bs=2048"
+.Pp
+Write a filesystem image to a memory stick, padding the end with zeros,
+if necessary, to a 1MiB boundary:
+.Pp
+.Dl "dd if=memstick.img of=/dev/da0 bs=1m conv=noerror,sync"
.Sh SEE ALSO
.Xr cp 1 ,
.Xr mt 1 ,
+.Xr recoverdisk 1 ,
.Xr tr 1 ,
.Xr geom 4
.Sh STANDARDS
@@ -411,7 +428,9 @@
standard.
The
.Cm files
-operand and the
+and
+.Cm status
+operands and the
.Cm ascii ,
.Cm ebcdic ,
.Cm ibm ,
@@ -422,6 +441,11 @@
values are extensions to the
.Tn POSIX
standard.
+.Sh HISTORY
+A
+.Nm
+command appeared in
+.At v5 .
.Sh BUGS
Protection mechanisms in the
.Xr geom 4
Property changes on: trunk/bin/dd/dd.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/dd/dd.c
===================================================================
--- trunk/bin/dd/dd.c 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/dd.c 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -30,7 +31,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $FreeBSD: src/bin/dd/dd.c,v 1.43 2004/08/15 19:10:05 rwatson Exp $ */
#if 0
#ifndef lint
@@ -44,7 +44,7 @@
#endif /* not lint */
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/bin/dd/dd.c 298258 2016-04-19 07:34:31Z thomas $");
#include <sys/param.h>
#include <sys/stat.h>
@@ -53,6 +53,7 @@
#include <sys/filio.h>
#include <sys/time.h>
+#include <assert.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
@@ -82,6 +83,7 @@
uintmax_t files_cnt = 1; /* # of files to copy */
const u_char *ctab; /* conversion table */
char fill_char; /* Character to fill with if defined */
+volatile sig_atomic_t need_summary;
int
main(int argc __unused, char *argv[])
@@ -90,7 +92,7 @@
jcl(argv);
setup();
- (void)signal(SIGINFO, summaryx);
+ (void)signal(SIGINFO, siginfo_handler);
(void)signal(SIGINT, terminate);
atexit(summary);
@@ -99,6 +101,13 @@
dd_in();
dd_close();
+ /*
+ * Some devices such as cfi(4) may perform significant amounts
+ * of work when a write descriptor is closed. Close the out
+ * descriptor explicitly so that the summary handler (called
+ * from an atexit() hook) includes this work.
+ */
+ close(out.fd);
exit(0);
}
@@ -166,6 +175,8 @@
} else if ((in.db = malloc(MAX(in.dbsz, cbsz) + cbsz)) == NULL ||
(out.db = malloc(out.dbsz + cbsz)) == NULL)
err(1, "output buffer");
+
+ /* dbp is the first free position in each buffer. */
in.dbp = in.db;
out.dbp = out.db;
@@ -233,8 +244,8 @@
ctab = casetab;
}
- (void)gettimeofday(&tv, (struct timezone *)NULL);
- st.start = tv.tv_sec + tv.tv_usec * 1e-6;
+ (void)gettimeofday(&tv, NULL);
+ st.start = tv.tv_sec + tv.tv_usec * 1e-6;
}
static void
@@ -369,6 +380,9 @@
in.dbp += in.dbrcnt;
(*cfunc)();
+ if (need_summary) {
+ summary();
+ }
}
}
@@ -396,6 +410,15 @@
}
if (out.dbcnt || pending)
dd_out(1);
+
+ /*
+ * If the file ends with a hole, ftruncate it to extend its size
+ * up to the end of the hole (without having to write any data).
+ */
+ if (out.seek_offset > 0 && (out.flags & ISTRUNC)) {
+ if (ftruncate(out.fd, out.seek_offset) == -1)
+ err(1, "truncating %s", out.name);
+ }
}
void
@@ -424,8 +447,15 @@
* we play games with the buffer size, and it's usually a partial write.
*/
outp = out.db;
+
+ /*
+ * If force, first try to write all pending data, else try to write
+ * just one block. Subsequently always write data one full block at
+ * a time at most.
+ */
for (n = force ? out.dbcnt : out.dbsz;; n = out.dbsz) {
- for (cnt = n;; cnt -= nw) {
+ cnt = n;
+ do {
sparse = 0;
if (ddflags & C_SPARSE) {
sparse = 1; /* Is buffer sparse? */
@@ -440,20 +470,24 @@
nw = cnt;
} else {
if (pending != 0) {
- if (force)
- pending--;
- if (lseek(out.fd, pending, SEEK_CUR) ==
- -1)
+ /*
+ * Seek past hole. Note that we need to record the
+ * reached offset, because we might have no more data
+ * to write, in which case we'll need to call
+ * ftruncate to extend the file size.
+ */
+ out.seek_offset = lseek(out.fd, pending, SEEK_CUR);
+ if (out.seek_offset == -1)
err(2, "%s: seek error creating sparse file",
out.name);
- if (force)
- write(out.fd, outp, 1);
pending = 0;
}
- if (cnt)
+ if (cnt) {
nw = write(out.fd, outp, cnt);
- else
+ out.seek_offset = 0;
+ } else {
return;
+ }
}
if (nw <= 0) {
@@ -463,27 +497,29 @@
err(1, "%s", out.name);
nw = 0;
}
+
outp += nw;
st.bytes += nw;
- if ((size_t)nw == n) {
- if (n != out.dbsz)
- ++st.out_part;
- else
- ++st.out_full;
- break;
+
+ if ((size_t)nw == n && n == out.dbsz)
+ ++st.out_full;
+ else
+ ++st.out_part;
+
+ if ((size_t) nw != cnt) {
+ if (out.flags & ISTAPE)
+ errx(1, "%s: short write on tape device",
+ out.name);
+ if (out.flags & ISCHR && !warned) {
+ warned = 1;
+ warnx("%s: short write on character device",
+ out.name);
+ }
}
- ++st.out_part;
- if ((size_t)nw == cnt)
- break;
- if (out.flags & ISTAPE)
- errx(1, "%s: short write on tape device",
- out.name);
- if (out.flags & ISCHR && !warned) {
- warned = 1;
- warnx("%s: short write on character device",
- out.name);
- }
- }
+
+ cnt -= nw;
+ } while (cnt != 0);
+
if ((out.dbcnt -= n) < out.dbsz)
break;
}
Modified: trunk/bin/dd/dd.h
===================================================================
--- trunk/bin/dd/dd.h 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/dd.h 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -31,8 +32,7 @@
* SUCH DAMAGE.
*
* @(#)dd.h 8.3 (Berkeley) 4/2/94
- * $FreeBSD: src/bin/dd/dd.h,v 1.22 2004/08/15 19:10:05 rwatson Exp $
- * $MidnightBSD$
+ * $FreeBSD: stable/10/bin/dd/dd.h 298258 2016-04-19 07:34:31Z thomas $
*/
/* Input/output stream state. */
@@ -55,6 +55,7 @@
const char *name; /* name */
int fd; /* file descriptor */
off_t offset; /* # of blocks to skip */
+ off_t seek_offset; /* offset of last seek past output hole */
} IO;
typedef struct {
@@ -69,32 +70,35 @@
} STAT;
/* Flags (in ddflags). */
-#define C_ASCII 0x00001
-#define C_BLOCK 0x00002
-#define C_BS 0x00004
-#define C_CBS 0x00008
-#define C_COUNT 0x00010
-#define C_EBCDIC 0x00020
-#define C_FILES 0x00040
-#define C_IBS 0x00080
-#define C_IF 0x00100
-#define C_LCASE 0x00200
-#define C_NOERROR 0x00400
-#define C_NOTRUNC 0x00800
-#define C_OBS 0x01000
-#define C_OF 0x02000
-#define C_OSYNC 0x04000
-#define C_PAREVEN 0x08000
-#define C_PARNONE 0x100000
-#define C_PARODD 0x200000
-#define C_PARSET 0x400000
-#define C_SEEK 0x800000
-#define C_SKIP 0x1000000
-#define C_SPARSE 0x2000000
-#define C_SWAB 0x4000000
-#define C_SYNC 0x8000000
-#define C_UCASE 0x10000000
-#define C_UNBLOCK 0x20000000
-#define C_FILL 0x40000000
+#define C_ASCII 0x00000001
+#define C_BLOCK 0x00000002
+#define C_BS 0x00000004
+#define C_CBS 0x00000008
+#define C_COUNT 0x00000010
+#define C_EBCDIC 0x00000020
+#define C_FILES 0x00000040
+#define C_IBS 0x00000080
+#define C_IF 0x00000100
+#define C_LCASE 0x00000200
+#define C_NOERROR 0x00000400
+#define C_NOTRUNC 0x00000800
+#define C_OBS 0x00001000
+#define C_OF 0x00002000
+#define C_OSYNC 0x00004000
+#define C_PAREVEN 0x00008000
+#define C_PARNONE 0x00010000
+#define C_PARODD 0x00020000
+#define C_PARSET 0x00040000
+#define C_SEEK 0x00080000
+#define C_SKIP 0x00100000
+#define C_SPARSE 0x00200000
+#define C_SWAB 0x00400000
+#define C_SYNC 0x00800000
+#define C_UCASE 0x01000000
+#define C_UNBLOCK 0x02000000
+#define C_FILL 0x04000000
+#define C_STATUS 0x08000000
+#define C_NOXFER 0x10000000
+#define C_NOINFO 0x20000000
#define C_PARITY (C_PAREVEN | C_PARODD | C_PARNONE | C_PARSET)
Modified: trunk/bin/dd/extern.h
===================================================================
--- trunk/bin/dd/extern.h 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/extern.h 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -31,8 +32,7 @@
* SUCH DAMAGE.
*
* @(#)extern.h 8.3 (Berkeley) 4/2/94
- * $FreeBSD: src/bin/dd/extern.h,v 1.15 2004/08/15 19:10:05 rwatson Exp $
- * $MidnightBSD$
+ * $FreeBSD: stable/10/bin/dd/extern.h 250469 2013-05-10 18:43:36Z eadler $
*/
void block(void);
@@ -44,7 +44,7 @@
void pos_in(void);
void pos_out(void);
void summary(void);
-void summaryx(int);
+void siginfo_handler(int);
void terminate(int);
void unblock(void);
void unblock_close(void);
@@ -62,3 +62,4 @@
extern const u_char a2ibm_32V[], a2ibm_POSIX[];
extern u_char casetab[];
extern char fill_char;
+extern volatile sig_atomic_t need_summary;
Modified: trunk/bin/dd/gen.c
===================================================================
--- trunk/bin/dd/gen.c 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/gen.c 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,18 +1,25 @@
+/* $MidnightBSD$ */
/*-
* This program is in the public domain
*
- * $FreeBSD: src/bin/dd/gen.c,v 1.2 2005/01/10 08:39:21 imp Exp $
- * $MidnightBSD$
+ * $FreeBSD: stable/10/bin/dd/gen.c 298258 2016-04-19 07:34:31Z thomas $
*/
#include <stdio.h>
+#include <string.h>
int
-main(int argc __unused, char **argv __unused)
+main(int argc, char **argv)
{
int i;
- for (i = 0; i < 256; i++)
- putchar(i);
+ if (argc > 1 && !strcmp(argv[1], "189284")) {
+ fputs("ABCDEFGH", stdout);
+ for (i = 0; i < 8; i++)
+ putchar(0);
+ } else {
+ for (i = 0; i < 256; i++)
+ putchar(i);
+ }
return (0);
}
Modified: trunk/bin/dd/misc.c
===================================================================
--- trunk/bin/dd/misc.c 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/misc.c 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -30,7 +31,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $FreeBSD: src/bin/dd/misc.c,v 1.27 2004/04/06 20:06:46 markm Exp $ */
#ifndef lint
#if 0
@@ -38,7 +38,7 @@
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/bin/dd/misc.c 264577 2014-04-17 00:31:20Z delphij $");
#include <sys/types.h>
#include <sys/time.h>
@@ -45,6 +45,7 @@
#include <errno.h>
#include <inttypes.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -58,41 +59,37 @@
{
struct timeval tv;
double secs;
- char buf[100];
- (void)gettimeofday(&tv, (struct timezone *)NULL);
+ if (ddflags & C_NOINFO)
+ return;
+
+ (void)gettimeofday(&tv, NULL);
secs = tv.tv_sec + tv.tv_usec * 1e-6 - st.start;
if (secs < 1e-6)
secs = 1e-6;
- /* Use snprintf(3) so that we don't reenter stdio(3). */
- (void)snprintf(buf, sizeof(buf),
+ (void)fprintf(stderr,
"%ju+%ju records in\n%ju+%ju records out\n",
st.in_full, st.in_part, st.out_full, st.out_part);
- (void)write(STDERR_FILENO, buf, strlen(buf));
- if (st.swab) {
- (void)snprintf(buf, sizeof(buf), "%ju odd length swab %s\n",
+ if (st.swab)
+ (void)fprintf(stderr, "%ju odd length swab %s\n",
st.swab, (st.swab == 1) ? "block" : "blocks");
- (void)write(STDERR_FILENO, buf, strlen(buf));
- }
- if (st.trunc) {
- (void)snprintf(buf, sizeof(buf), "%ju truncated %s\n",
+ if (st.trunc)
+ (void)fprintf(stderr, "%ju truncated %s\n",
st.trunc, (st.trunc == 1) ? "block" : "blocks");
- (void)write(STDERR_FILENO, buf, strlen(buf));
+ if (!(ddflags & C_NOXFER)) {
+ (void)fprintf(stderr,
+ "%ju bytes transferred in %.6f secs (%.0f bytes/sec)\n",
+ st.bytes, secs, st.bytes / secs);
}
- (void)snprintf(buf, sizeof(buf),
- "%ju bytes transferred in %.6f secs (%.0f bytes/sec)\n",
- st.bytes, secs, st.bytes / secs);
- (void)write(STDERR_FILENO, buf, strlen(buf));
+ need_summary = 0;
}
/* ARGSUSED */
void
-summaryx(int notused __unused)
+siginfo_handler(int signo __unused)
{
- int save_errno = errno;
- summary();
- errno = save_errno;
+ need_summary = 1;
}
/* ARGSUSED */
Modified: trunk/bin/dd/position.c
===================================================================
--- trunk/bin/dd/position.c 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/position.c 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -30,7 +31,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $FreeBSD: src/bin/dd/position.c,v 1.23 2004/04/06 20:06:46 markm Exp $ */
#ifndef lint
#if 0
@@ -38,7 +38,7 @@
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/bin/dd/position.c 321140 2017-07-18 17:36:25Z ngie $");
#include <sys/types.h>
#include <sys/mtio.h>
@@ -46,11 +46,41 @@
#include <err.h>
#include <errno.h>
#include <inttypes.h>
+#include <limits.h>
+#include <signal.h>
#include <unistd.h>
#include "dd.h"
#include "extern.h"
+static off_t
+seek_offset(IO *io)
+{
+ off_t n;
+ size_t sz;
+
+ n = io->offset;
+ sz = io->dbsz;
+
+ _Static_assert(sizeof(io->offset) == sizeof(int64_t), "64-bit off_t");
+
+ /*
+ * If the lseek offset will be negative, verify that this is a special
+ * device file. Some such files (e.g. /dev/kmem) permit "negative"
+ * offsets.
+ *
+ * Bail out if the calculation of a file offset would overflow.
+ */
+ if ((io->flags & ISCHR) == 0 && (n < 0 || n > OFF_MAX / (ssize_t)sz))
+ errx(1, "seek offsets cannot be larger than %jd",
+ (intmax_t)OFF_MAX);
+ else if ((io->flags & ISCHR) != 0 && (uint64_t)n > UINT64_MAX / sz)
+ errx(1, "seek offsets cannot be larger than %ju",
+ (uintmax_t)UINT64_MAX);
+
+ return ((off_t)( (uint64_t)n * sz ));
+}
+
/*
* Position input/output data streams before starting the copy. Device type
* dependent. Seekable devices use lseek, and the rest position by reading.
@@ -68,7 +98,7 @@
/* 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 &&
+ if (lseek(in.fd, seek_offset(&in), SEEK_CUR) == -1 &&
errno != 0)
err(1, "%s", in.name);
return;
@@ -92,6 +122,8 @@
}
} else
--cnt;
+ if (need_summary)
+ summary();
continue;
}
@@ -134,7 +166,7 @@
*/
if (out.flags & (ISSEEK | ISPIPE)) {
errno = 0;
- if (lseek(out.fd, out.offset * out.dbsz, SEEK_CUR) == -1 &&
+ if (lseek(out.fd, seek_offset(&out), SEEK_CUR) == -1 &&
errno != 0)
err(1, "%s", out.name);
return;
Modified: trunk/bin/dd/ref.ascii
===================================================================
--- trunk/bin/dd/ref.ascii 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/ref.ascii 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,4 +1,4 @@
-$FreeBSD: src/bin/dd/ref.ascii,v 1.1 2004/03/05 19:30:13 phk Exp $
+$FreeBSD: stable/10/bin/dd/ref.ascii 126666 2004-03-05 19:30:13Z phk $
00000000 00 01 02 03 9c 09 86 7f 97 8d 8e 0b 0c 0d 0e 0f |................|
00000010 10 11 12 13 9d 85 08 87 18 19 92 8f 1c 1d 1e 1f |................|
00000020 80 81 82 83 84 0a 17 1b 88 89 8a 8b 8c 05 06 07 |................|
Property changes on: trunk/bin/dd/ref.ascii
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/dd/ref.ebcdic
===================================================================
--- trunk/bin/dd/ref.ebcdic 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/ref.ebcdic 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,4 +1,4 @@
-$FreeBSD: src/bin/dd/ref.ebcdic,v 1.1 2004/03/05 19:30:13 phk Exp $
+$FreeBSD: stable/10/bin/dd/ref.ebcdic 126666 2004-03-05 19:30:13Z phk $
00000000 00 01 02 03 37 2d 2e 2f 16 05 25 0b 0c 0d 0e 0f |....7-./..%.....|
00000010 10 11 12 13 3c 3d 32 26 18 19 3f 27 1c 1d 1e 1f |....<=2&..?'....|
00000020 40 5a 7f 7b 5b 6c 50 7d 4d 5d 5c 4e 6b 60 4b 61 |@Z.{[lP}M]\Nk`Ka|
Property changes on: trunk/bin/dd/ref.ebcdic
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/dd/ref.ibm
===================================================================
--- trunk/bin/dd/ref.ibm 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/ref.ibm 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,4 +1,4 @@
-$FreeBSD: src/bin/dd/ref.ibm,v 1.1 2004/03/05 19:30:13 phk Exp $
+$FreeBSD: stable/10/bin/dd/ref.ibm 126666 2004-03-05 19:30:13Z phk $
00000000 00 01 02 03 37 2d 2e 2f 16 05 25 0b 0c 0d 0e 0f |....7-./..%.....|
00000010 10 11 12 13 3c 3d 32 26 18 19 3f 27 1c 1d 1e 1f |....<=2&..?'....|
00000020 40 5a 7f 7b 5b 6c 50 7d 4d 5d 5c 4e 6b 60 4b 61 |@Z.{[lP}M]\Nk`Ka|
Property changes on: trunk/bin/dd/ref.ibm
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/dd/ref.lcase
===================================================================
--- trunk/bin/dd/ref.lcase 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/ref.lcase 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,4 +1,4 @@
-$FreeBSD: src/bin/dd/ref.lcase,v 1.1 2004/03/05 19:30:13 phk Exp $
+$FreeBSD: stable/10/bin/dd/ref.lcase 126666 2004-03-05 19:30:13Z phk $
00000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |................|
00000010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |................|
00000020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./|
Property changes on: trunk/bin/dd/ref.lcase
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/bin/dd/ref.obs_zeroes
===================================================================
--- trunk/bin/dd/ref.obs_zeroes (rev 0)
+++ trunk/bin/dd/ref.obs_zeroes 2018-07-05 19:06:56 UTC (rev 11343)
@@ -0,0 +1,3 @@
+$FreeBSD: stable/10/bin/dd/ref.obs_zeroes 298258 2016-04-19 07:34:31Z thomas $
+00000000 41 42 43 44 45 46 47 48 00 00 00 00 00 00 00 00 |ABCDEFGH........|
+00000010
Property changes on: trunk/bin/dd/ref.obs_zeroes
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/dd/ref.oldascii
===================================================================
--- trunk/bin/dd/ref.oldascii 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/ref.oldascii 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,4 +1,4 @@
-$FreeBSD: src/bin/dd/ref.oldascii,v 1.1 2004/03/05 19:30:13 phk Exp $
+$FreeBSD: stable/10/bin/dd/ref.oldascii 126666 2004-03-05 19:30:13Z phk $
00000000 00 01 02 03 9c 09 86 7f 97 8d 8e 0b 0c 0d 0e 0f |................|
00000010 10 11 12 13 9d 85 08 87 18 19 92 8f 1c 1d 1e 1f |................|
00000020 80 81 82 83 84 0a 17 1b 88 89 8a 8b 8c 05 06 07 |................|
Property changes on: trunk/bin/dd/ref.oldascii
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/dd/ref.oldebcdic
===================================================================
--- trunk/bin/dd/ref.oldebcdic 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/ref.oldebcdic 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,4 +1,4 @@
-$FreeBSD: src/bin/dd/ref.oldebcdic,v 1.1 2004/03/05 19:30:13 phk Exp $
+$FreeBSD: stable/10/bin/dd/ref.oldebcdic 126666 2004-03-05 19:30:13Z phk $
00000000 00 01 02 03 37 2d 2e 2f 16 05 25 0b 0c 0d 0e 0f |....7-./..%.....|
00000010 10 11 12 13 3c 3d 32 26 18 19 3f 27 1c 1d 1e 1f |....<=2&..?'....|
00000020 40 4f 7f 7b 5b 6c 50 7d 4d 5d 5c 4e 6b 60 4b 61 |@O.{[lP}M]\Nk`Ka|
Property changes on: trunk/bin/dd/ref.oldebcdic
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/dd/ref.oldibm
===================================================================
--- trunk/bin/dd/ref.oldibm 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/ref.oldibm 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,4 +1,4 @@
-$FreeBSD: src/bin/dd/ref.oldibm,v 1.1 2004/03/05 19:30:13 phk Exp $
+$FreeBSD: stable/10/bin/dd/ref.oldibm 126666 2004-03-05 19:30:13Z phk $
00000000 00 01 02 03 37 2d 2e 2f 16 05 25 0b 0c 0d 0e 0f |....7-./..%.....|
00000010 10 11 12 13 3c 3d 32 26 18 19 3f 27 1c 1d 1e 1f |....<=2&..?'....|
00000020 40 5a 7f 7b 5b 6c 50 7d 4d 5d 5c 4e 6b 60 4b 61 |@Z.{[lP}M]\Nk`Ka|
Property changes on: trunk/bin/dd/ref.oldibm
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/dd/ref.pareven
===================================================================
--- trunk/bin/dd/ref.pareven 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/ref.pareven 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,4 +1,4 @@
-$FreeBSD: src/bin/dd/ref.pareven,v 1.1 2004/03/05 19:35:51 phk Exp $
+$FreeBSD: stable/10/bin/dd/ref.pareven 126667 2004-03-05 19:35:51Z phk $
00000000 00 81 82 03 84 05 06 87 88 09 0a 8b 0c 8d 8e 0f |................|
00000010 90 11 12 93 14 95 96 17 18 99 9a 1b 9c 1d 1e 9f |................|
00000020 a0 21 22 a3 24 a5 a6 27 28 a9 aa 2b ac 2d 2e af |.!".$..'(..+.-..|
Property changes on: trunk/bin/dd/ref.pareven
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/dd/ref.parnone
===================================================================
--- trunk/bin/dd/ref.parnone 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/ref.parnone 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,4 +1,4 @@
-$FreeBSD: src/bin/dd/ref.parnone,v 1.1 2004/03/05 19:35:51 phk Exp $
+$FreeBSD: stable/10/bin/dd/ref.parnone 126667 2004-03-05 19:35:51Z phk $
00000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |................|
00000010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |................|
00000020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./|
Property changes on: trunk/bin/dd/ref.parnone
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/dd/ref.parodd
===================================================================
--- trunk/bin/dd/ref.parodd 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/ref.parodd 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,4 +1,4 @@
-$FreeBSD: src/bin/dd/ref.parodd,v 1.1 2004/03/05 19:35:51 phk Exp $
+$FreeBSD: stable/10/bin/dd/ref.parodd 126667 2004-03-05 19:35:51Z phk $
00000000 80 01 02 83 04 85 86 07 08 89 8a 0b 8c 0d 0e 8f |................|
00000010 10 91 92 13 94 15 16 97 98 19 1a 9b 1c 9d 9e 1f |................|
00000020 20 a1 a2 23 a4 25 26 a7 a8 29 2a ab 2c ad ae 2f | ..#.%&..)*.,../|
Property changes on: trunk/bin/dd/ref.parodd
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/dd/ref.parset
===================================================================
--- trunk/bin/dd/ref.parset 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/ref.parset 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,4 +1,4 @@
-$FreeBSD: src/bin/dd/ref.parset,v 1.1 2004/03/05 19:35:51 phk Exp $
+$FreeBSD: stable/10/bin/dd/ref.parset 126667 2004-03-05 19:35:51Z phk $
00000000 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f |................|
00000010 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f |................|
00000020 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af |................|
Property changes on: trunk/bin/dd/ref.parset
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/dd/ref.swab
===================================================================
--- trunk/bin/dd/ref.swab 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/ref.swab 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,4 +1,4 @@
-$FreeBSD: src/bin/dd/ref.swab,v 1.1 2004/03/05 19:30:13 phk Exp $
+$FreeBSD: stable/10/bin/dd/ref.swab 126666 2004-03-05 19:30:13Z phk $
00000000 01 00 03 02 05 04 07 06 09 08 0b 0a 0d 0c 0f 0e |................|
00000010 11 10 13 12 15 14 17 16 19 18 1b 1a 1d 1c 1f 1e |................|
00000020 21 20 23 22 25 24 27 26 29 28 2b 2a 2d 2c 2f 2e |! #"%$'&)(+*-,/.|
Property changes on: trunk/bin/dd/ref.swab
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/dd/ref.ucase
===================================================================
--- trunk/bin/dd/ref.ucase 2018-07-05 19:05:29 UTC (rev 11342)
+++ trunk/bin/dd/ref.ucase 2018-07-05 19:06:56 UTC (rev 11343)
@@ -1,4 +1,4 @@
-$FreeBSD: src/bin/dd/ref.ucase,v 1.1 2004/03/05 19:30:13 phk Exp $
+$FreeBSD: stable/10/bin/dd/ref.ucase 126666 2004-03-05 19:30:13Z phk $
00000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |................|
00000010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |................|
00000020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./|
Property changes on: trunk/bin/dd/ref.ucase
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/bin/dd/tests/Makefile
===================================================================
--- trunk/bin/dd/tests/Makefile (rev 0)
+++ trunk/bin/dd/tests/Makefile 2018-07-05 19:06:56 UTC (rev 11343)
@@ -0,0 +1,9 @@
+# $MidnightBSD$
+# $FreeBSD: stable/10/bin/dd/tests/Makefile 321140 2017-07-18 17:36:25Z ngie $
+
+ATF_TESTS_SH= dd2_test
+NETBSD_ATF_TESTS_SH= dd_test
+
+.include <netbsd-tests.test.mk>
+
+.include <bsd.test.mk>
Property changes on: trunk/bin/dd/tests/Makefile
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/bin/dd/tests/dd2_test.sh
===================================================================
--- trunk/bin/dd/tests/dd2_test.sh (rev 0)
+++ trunk/bin/dd/tests/dd2_test.sh 2018-07-05 19:06:56 UTC (rev 11343)
@@ -0,0 +1,70 @@
+#
+# Copyright (c) 2017 Spectra Logic Corporation
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD: stable/10/bin/dd/tests/dd2_test.sh 321140 2017-07-18 17:36:25Z ngie $
+# $MidnightBSD$
+
+
+atf_test_case max_seek
+max_seek_head()
+{
+ atf_set "descr" "dd(1) can seek by the maximum amount"
+}
+max_seek_body()
+{
+ case `df -T . | tail -n 1 | cut -wf 2` in
+ "ufs")
+ atf_skip "UFS's maximum file size is too small";;
+ "zfs") ;; # ZFS is fine
+ "tmpfs")
+ atf_skip "tmpfs can't create arbitrarily large spare files";;
+ *) atf_skip "Unknown file system";;
+ esac
+
+ touch f.in
+ seek=`echo "2^63 / 4096 - 1" | bc`
+ atf_check -s exit:0 -e ignore dd if=f.in of=f.out bs=4096 seek=$seek
+}
+
+atf_test_case seek_overflow
+seek_overflow_head()
+{
+ atf_set "descr" "dd(1) should reject too-large seek values"
+}
+seek_overflow_body()
+{
+ touch f.in
+ seek=`echo "2^63 / 4096" | bc`
+ atf_check -s not-exit:0 -e match:"seek offsets cannot be larger than" \
+ dd if=f.in of=f.out bs=4096 seek=$seek
+ atf_check -s not-exit:0 -e match:"seek offsets cannot be larger than" \
+ dd if=f.in of=f.out bs=4096 seek=-1
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case max_seek
+ atf_add_test_case seek_overflow
+}
Property changes on: trunk/bin/dd/tests/dd2_test.sh
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
More information about the Midnightbsd-cvs
mailing list