diff options
Diffstat (limited to 'bin/dd')
-rw-r--r-- | bin/dd/Makefile | 3 | ||||
-rw-r--r-- | bin/dd/Makefile.depend | 4 | ||||
-rw-r--r-- | bin/dd/args.c | 8 | ||||
-rw-r--r-- | bin/dd/conv.c | 8 | ||||
-rw-r--r-- | bin/dd/conv_tab.c | 8 | ||||
-rw-r--r-- | bin/dd/dd.1 | 3 | ||||
-rw-r--r-- | bin/dd/dd.c | 29 | ||||
-rw-r--r-- | bin/dd/dd.h | 3 | ||||
-rw-r--r-- | bin/dd/extern.h | 8 | ||||
-rw-r--r-- | bin/dd/gen.c | 2 | ||||
-rw-r--r-- | bin/dd/misc.c | 64 | ||||
-rw-r--r-- | bin/dd/position.c | 16 | ||||
-rw-r--r-- | bin/dd/ref.ascii | 1 | ||||
-rw-r--r-- | bin/dd/ref.ebcdic | 1 | ||||
-rw-r--r-- | bin/dd/ref.ibm | 1 | ||||
-rw-r--r-- | bin/dd/ref.lcase | 1 | ||||
-rw-r--r-- | bin/dd/ref.obs_zeroes | 1 | ||||
-rw-r--r-- | bin/dd/ref.oldascii | 1 | ||||
-rw-r--r-- | bin/dd/ref.oldebcdic | 1 | ||||
-rw-r--r-- | bin/dd/ref.oldibm | 1 | ||||
-rw-r--r-- | bin/dd/ref.pareven | 1 | ||||
-rw-r--r-- | bin/dd/ref.parnone | 1 | ||||
-rw-r--r-- | bin/dd/ref.parodd | 1 | ||||
-rw-r--r-- | bin/dd/ref.parset | 1 | ||||
-rw-r--r-- | bin/dd/ref.swab | 1 | ||||
-rw-r--r-- | bin/dd/ref.ucase | 1 | ||||
-rw-r--r-- | bin/dd/tests/Makefile | 2 | ||||
-rw-r--r-- | bin/dd/tests/Makefile.depend | 1 | ||||
-rwxr-xr-x | bin/dd/tests/dd2_test.sh | 92 |
29 files changed, 138 insertions, 127 deletions
diff --git a/bin/dd/Makefile b/bin/dd/Makefile index 9088112536dd..1f8462aef5fa 100644 --- a/bin/dd/Makefile +++ b/bin/dd/Makefile @@ -1,6 +1,3 @@ -# @(#)Makefile 8.1 (Berkeley) 5/31/93 -# $FreeBSD$ - .include <src.opts.mk> PACKAGE=runtime diff --git a/bin/dd/Makefile.depend b/bin/dd/Makefile.depend index 1adfc08a54d6..ad56045f44d3 100644 --- a/bin/dd/Makefile.depend +++ b/bin/dd/Makefile.depend @@ -1,14 +1,14 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcapsicum \ + lib/libcasper/libcasper \ lib/libcompiler_rt \ + lib/libutil \ .include <dirdeps.mk> diff --git a/bin/dd/args.c b/bin/dd/args.c index 35a076175a93..10bb89e632b0 100644 --- a/bin/dd/args.c +++ b/bin/dd/args.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)args.c 8.3 (Berkeley) 4/2/94"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <ctype.h> diff --git a/bin/dd/conv.c b/bin/dd/conv.c index ef5194ee1e08..d64d57040fca 100644 --- a/bin/dd/conv.c +++ b/bin/dd/conv.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)conv.c 8.3 (Berkeley) 4/2/94"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <err.h> diff --git a/bin/dd/conv_tab.c b/bin/dd/conv_tab.c index 36e23531bbbb..feba45826e03 100644 --- a/bin/dd/conv_tab.c +++ b/bin/dd/conv_tab.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)conv_tab.c 8.1 (Berkeley) 5/31/93"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <signal.h> diff --git a/bin/dd/dd.1 b/bin/dd/dd.1 index 8bd5fa662ac6..fa04b3673d39 100644 --- a/bin/dd/dd.1 +++ b/bin/dd/dd.1 @@ -29,9 +29,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)dd.1 8.2 (Berkeley) 1/13/94 -.\" $FreeBSD$ -.\" .Dd June 4, 2020 .Dt DD 1 .Os diff --git a/bin/dd/dd.c b/bin/dd/dd.c index c43645fa0073..ca79b684bf1e 100644 --- a/bin/dd/dd.c +++ b/bin/dd/dd.c @@ -33,20 +33,6 @@ * SUCH DAMAGE. */ -#if 0 -#ifndef lint -static char const copyright[] = -"@(#) Copyright (c) 1991, 1993, 1994\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94"; -#endif /* not lint */ -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/stat.h> #include <sys/capsicum.h> @@ -64,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include <fcntl.h> #include <inttypes.h> #include <locale.h> +#include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -91,12 +78,15 @@ char fill_char; /* Character to fill with if defined */ size_t speed = 0; /* maximum speed, in bytes per second */ volatile sig_atomic_t need_summary; volatile sig_atomic_t need_progress; +volatile sig_atomic_t kill_signal; int main(int argc __unused, char *argv[]) { struct itimerval itv = { { 1, 0 }, { 1, 0 } }; /* SIGALARM every second, if needed */ + prepare_io(); + (void)setlocale(LC_CTYPE, ""); jcl(argv); setup(); @@ -110,7 +100,6 @@ main(int argc __unused, char *argv[]) (void)signal(SIGALRM, sigalarm_handler); setitimer(ITIMER_REAL, &itv, NULL); } - (void)signal(SIGINT, terminate); atexit(summary); @@ -154,7 +143,9 @@ setup(void) iflags = 0; if (ddflags & C_IDIRECT) iflags |= O_DIRECT; + before_io(); in.fd = open(in.name, O_RDONLY | iflags, 0); + after_io(); if (in.fd == -1) err(1, "%s", in.name); } @@ -191,14 +182,18 @@ setup(void) oflags |= O_FSYNC; if (ddflags & C_ODIRECT) oflags |= O_DIRECT; + before_io(); out.fd = open(out.name, O_RDWR | oflags, DEFFILEMODE); + after_io(); /* * May not have read access, so try again with write only. * Without read we may have a problem if output also does * not support seeks. */ if (out.fd == -1) { + before_io(); out.fd = open(out.name, O_WRONLY | oflags, DEFFILEMODE); + after_io(); out.flags |= NOREAD; cap_rights_clear(&rights, CAP_READ); } @@ -415,7 +410,9 @@ dd_in(void) in.dbrcnt = 0; fill: + before_io(); n = read(in.fd, in.dbp + in.dbrcnt, in.dbsz - in.dbrcnt); + after_io(); /* EOF */ if (n == 0 && in.dbrcnt == 0) @@ -596,7 +593,9 @@ dd_out(int force) pending = 0; } if (cnt) { + before_io(); nw = write(out.fd, outp, cnt); + after_io(); out.seek_offset = 0; } else { return; diff --git a/bin/dd/dd.h b/bin/dd/dd.h index ea606f288f3f..d2d564494a54 100644 --- a/bin/dd/dd.h +++ b/bin/dd/dd.h @@ -31,9 +31,6 @@ * 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. - * - * @(#)dd.h 8.3 (Berkeley) 4/2/94 - * $FreeBSD$ */ /* Input/output stream state. */ diff --git a/bin/dd/extern.h b/bin/dd/extern.h index 07c08e2ef8f2..505f107221c4 100644 --- a/bin/dd/extern.h +++ b/bin/dd/extern.h @@ -31,9 +31,6 @@ * 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. - * - * @(#)extern.h 8.3 (Berkeley) 4/2/94 - * $FreeBSD$ */ void block(void); @@ -49,7 +46,9 @@ void progress(void); void summary(void); void sigalarm_handler(int); void siginfo_handler(int); -void terminate(int); +void prepare_io(void); +void before_io(void); +void after_io(void); void unblock(void); void unblock_close(void); @@ -69,3 +68,4 @@ extern u_char casetab[]; extern char fill_char; extern volatile sig_atomic_t need_summary; extern volatile sig_atomic_t need_progress; +extern volatile sig_atomic_t kill_signal; diff --git a/bin/dd/gen.c b/bin/dd/gen.c index d53d8fb2b5ac..01e0f61b27b1 100644 --- a/bin/dd/gen.c +++ b/bin/dd/gen.c @@ -1,7 +1,5 @@ /*- * This program is in the public domain - * - * $FreeBSD$ */ #include <stdio.h> diff --git a/bin/dd/misc.c b/bin/dd/misc.c index 405448eb1cb0..05c19b5b2073 100644 --- a/bin/dd/misc.c +++ b/bin/dd/misc.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <err.h> @@ -48,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include <inttypes.h> #include <libutil.h> #include <signal.h> +#include <stdatomic.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -147,11 +140,58 @@ sigalarm_handler(int signo __unused) need_progress = 1; } -/* ARGSUSED */ +static void terminate(int signo) __dead2; +static void +terminate(int signo) +{ + kill_signal = signo; + summary(); + (void)fflush(stderr); + raise(kill_signal); + /* NOT REACHED */ + _exit(1); +} + +static sig_atomic_t in_io = 0; +static sig_atomic_t sigint_seen = 0; + +static void +sigint_handler(int signo __unused) +{ + atomic_signal_fence(memory_order_acquire); + if (in_io) + terminate(SIGINT); + sigint_seen = 1; +} + void -terminate(int sig) +prepare_io(void) { + struct sigaction sa; + int error; + + memset(&sa, 0, sizeof(sa)); + sa.sa_flags = SA_NODEFER | SA_RESETHAND; + sa.sa_handler = sigint_handler; + error = sigaction(SIGINT, &sa, 0); + if (error != 0) + err(1, "sigaction"); +} - summary(); - _exit(sig == 0 ? 0 : 1); +void +before_io(void) +{ + in_io = 1; + atomic_signal_fence(memory_order_seq_cst); + if (sigint_seen) + terminate(SIGINT); +} + +void +after_io(void) +{ + in_io = 0; + atomic_signal_fence(memory_order_seq_cst); + if (sigint_seen) + terminate(SIGINT); } diff --git a/bin/dd/position.c b/bin/dd/position.c index 21a100cd3b24..c092b5c5f8db 100644 --- a/bin/dd/position.c +++ b/bin/dd/position.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)position.c 8.3 (Berkeley) 4/2/94"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/mtio.h> @@ -191,9 +183,11 @@ pos_out(void) /* Read it. */ for (cnt = 0; cnt < out.offset; ++cnt) { - if ((n = read(out.fd, out.db, out.dbsz)) > 0) + before_io(); + n = read(out.fd, out.db, out.dbsz); + after_io(); + if (n > 0) continue; - if (n == -1) err(1, "%s", out.name); @@ -208,7 +202,9 @@ pos_out(void) err(1, "%s", out.name); while (cnt++ < out.offset) { + before_io(); n = write(out.fd, out.db, out.dbsz); + after_io(); if (n == -1) err(1, "%s", out.name); if (n != out.dbsz) diff --git a/bin/dd/ref.ascii b/bin/dd/ref.ascii index 7ff13e5a80ed..a8299b6cb056 100644 --- a/bin/dd/ref.ascii +++ b/bin/dd/ref.ascii @@ -1,4 +1,3 @@ -$FreeBSD$ 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 |................| diff --git a/bin/dd/ref.ebcdic b/bin/dd/ref.ebcdic index 605716552cab..b2428c8517ce 100644 --- a/bin/dd/ref.ebcdic +++ b/bin/dd/ref.ebcdic @@ -1,4 +1,3 @@ -$FreeBSD$ 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| diff --git a/bin/dd/ref.ibm b/bin/dd/ref.ibm index 4836baf221aa..3d05cf9a9ef0 100644 --- a/bin/dd/ref.ibm +++ b/bin/dd/ref.ibm @@ -1,4 +1,3 @@ -$FreeBSD$ 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| diff --git a/bin/dd/ref.lcase b/bin/dd/ref.lcase index 9f9567296468..a653527f8c63 100644 --- a/bin/dd/ref.lcase +++ b/bin/dd/ref.lcase @@ -1,4 +1,3 @@ -$FreeBSD$ 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 | !"#$%&'()*+,-./| diff --git a/bin/dd/ref.obs_zeroes b/bin/dd/ref.obs_zeroes index 473ff7cc4108..e26380a1e7d3 100644 --- a/bin/dd/ref.obs_zeroes +++ b/bin/dd/ref.obs_zeroes @@ -1,3 +1,2 @@ -$FreeBSD$ 00000000 41 42 43 44 45 46 47 48 00 00 00 00 00 00 00 00 |ABCDEFGH........| 00000010 diff --git a/bin/dd/ref.oldascii b/bin/dd/ref.oldascii index bb1ad0a7242b..a748a9d6361f 100644 --- a/bin/dd/ref.oldascii +++ b/bin/dd/ref.oldascii @@ -1,4 +1,3 @@ -$FreeBSD$ 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 |................| diff --git a/bin/dd/ref.oldebcdic b/bin/dd/ref.oldebcdic index 4a7fde7e65b6..122f463b5cf4 100644 --- a/bin/dd/ref.oldebcdic +++ b/bin/dd/ref.oldebcdic @@ -1,4 +1,3 @@ -$FreeBSD$ 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| diff --git a/bin/dd/ref.oldibm b/bin/dd/ref.oldibm index 4836baf221aa..3d05cf9a9ef0 100644 --- a/bin/dd/ref.oldibm +++ b/bin/dd/ref.oldibm @@ -1,4 +1,3 @@ -$FreeBSD$ 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| diff --git a/bin/dd/ref.pareven b/bin/dd/ref.pareven index c64e63e30660..3c7c240d6f2f 100644 --- a/bin/dd/ref.pareven +++ b/bin/dd/ref.pareven @@ -1,4 +1,3 @@ -$FreeBSD$ 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 |.!".$..'(..+.-..| diff --git a/bin/dd/ref.parnone b/bin/dd/ref.parnone index fba31c142448..c6e394f59d8c 100644 --- a/bin/dd/ref.parnone +++ b/bin/dd/ref.parnone @@ -1,4 +1,3 @@ -$FreeBSD$ 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 | !"#$%&'()*+,-./| diff --git a/bin/dd/ref.parodd b/bin/dd/ref.parodd index f0bc449e3648..ada582f87265 100644 --- a/bin/dd/ref.parodd +++ b/bin/dd/ref.parodd @@ -1,4 +1,3 @@ -$FreeBSD$ 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 | ..#.%&..)*.,../| diff --git a/bin/dd/ref.parset b/bin/dd/ref.parset index baa1c57163a2..742ed22642d8 100644 --- a/bin/dd/ref.parset +++ b/bin/dd/ref.parset @@ -1,4 +1,3 @@ -$FreeBSD$ 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 |................| diff --git a/bin/dd/ref.swab b/bin/dd/ref.swab index 79e57b79b738..07cf9ffafa8f 100644 --- a/bin/dd/ref.swab +++ b/bin/dd/ref.swab @@ -1,4 +1,3 @@ -$FreeBSD$ 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 |! #"%$'&)(+*-,/.| diff --git a/bin/dd/ref.ucase b/bin/dd/ref.ucase index 70d8a903c354..a761c99431f5 100644 --- a/bin/dd/ref.ucase +++ b/bin/dd/ref.ucase @@ -1,4 +1,3 @@ -$FreeBSD$ 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 | !"#$%&'()*+,-./| diff --git a/bin/dd/tests/Makefile b/bin/dd/tests/Makefile index 029808e6eb28..70ce32336f91 100644 --- a/bin/dd/tests/Makefile +++ b/bin/dd/tests/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - ATF_TESTS_SH= dd2_test NETBSD_ATF_TESTS_SH= dd_test diff --git a/bin/dd/tests/Makefile.depend b/bin/dd/tests/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/bin/dd/tests/Makefile.depend +++ b/bin/dd/tests/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/bin/dd/tests/dd2_test.sh b/bin/dd/tests/dd2_test.sh index c0b33fc17226..c4a3065763cd 100755 --- a/bin/dd/tests/dd2_test.sh +++ b/bin/dd/tests/dd2_test.sh @@ -1,30 +1,9 @@ # # Copyright (c) 2017 Spectra Logic Corporation -# All rights reserved. +# Copyright (c) 2023 Klara, Inc. # -# 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. +# SPDX-License-Identifier: BSD-2-Clause # -# 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$ - atf_test_case max_seek max_seek_head() @@ -33,17 +12,23 @@ max_seek_head() } 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";; + 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 sparse files" + ;; + *) + atf_skip "Unknown file system" + ;; esac touch f.in - seek=`echo "2^63 / 4096 - 1" | bc` + seek=$(bc -e "2^63 / 4096 - 1") atf_check -s exit:0 -e ignore dd if=f.in of=f.out bs=4096 seek=$seek } @@ -55,15 +40,58 @@ seek_overflow_head() seek_overflow_body() { touch f.in - seek=`echo "2^63 / 4096" | bc` + seek=$(bc -e "2^63 / 4096") 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_test_case sigint +sigint_open_head() +{ + atf_set "descr" "SIGINT while opening destination" +} +sigint_open_body() +{ + atf_check mkfifo fifo + set -m + dd if=fifo of=/dev/null 2>stderr & + pid=$! + sleep 3 + kill -INT $pid + wait $pid + rv=$? + atf_check test "$rv" -gt 128 + atf_check -o inline:"INT\n" kill -l $((rv-128)) + atf_check test -s stderr +} + +atf_test_case sigint +sigint_read_head() +{ + atf_set "descr" "SIGINT while reading source" +} +sigint_read_body() +{ + atf_check mkfifo fifo + (sleep 30 >fifo &) # ensures that dd does not block on open + set -m + dd if=fifo of=/dev/null 2>stderr & + pid=$! + sleep 3 + kill -INT $pid + wait $pid + rv=$? + atf_check test "$rv" -gt 128 + atf_check -o inline:"INT\n" kill -l $((rv-128)) + atf_check test -s stderr +} + atf_init_test_cases() { atf_add_test_case max_seek atf_add_test_case seek_overflow + atf_add_test_case sigint_open + atf_add_test_case sigint_read } |