Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 2 | /* |
Eric Andersen | c499601 | 1999-10-20 22:08:37 +0000 | [diff] [blame] | 3 | * Mini dd implementation for busybox |
| 4 | * |
Eric Andersen | c499601 | 1999-10-20 22:08:37 +0000 | [diff] [blame] | 5 | * |
Matt Kraai | 3eeab3b | 2001-12-07 16:27:37 +0000 | [diff] [blame] | 6 | * Copyright (C) 2000,2001 Matt Kraai |
Eric Andersen | c499601 | 1999-10-20 22:08:37 +0000 | [diff] [blame] | 7 | * |
Bernhard Reutner-Fischer | c2cb0f3 | 2006-04-13 12:45:04 +0000 | [diff] [blame] | 8 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
Eric Andersen | cbe31da | 2001-02-20 06:14:08 +0000 | [diff] [blame] | 11 | #include "busybox.h" |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 12 | #include <signal.h> /* For FEATURE_DD_SIGNAL_HANDLING */ |
Eric Andersen | cbe31da | 2001-02-20 06:14:08 +0000 | [diff] [blame] | 13 | |
Matt Kraai | a164c64 | 2001-02-05 17:50:03 +0000 | [diff] [blame] | 14 | static const struct suffix_mult dd_suffixes[] = { |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 15 | { "c", 1 }, |
| 16 | { "w", 2 }, |
| 17 | { "b", 512 }, |
| 18 | { "kD", 1000 }, |
| 19 | { "k", 1024 }, |
Denis Vlasenko | 5625415 | 2006-10-07 16:24:46 +0000 | [diff] [blame] | 20 | { "K", 1024 }, // compat with coreutils dd |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 21 | { "MD", 1000000 }, |
| 22 | { "M", 1048576 }, |
| 23 | { "GD", 1000000000 }, |
| 24 | { "G", 1073741824 }, |
| 25 | { NULL, 0 } |
| 26 | }; |
| 27 | |
Denis Vlasenko | 7039a66 | 2006-10-08 17:54:47 +0000 | [diff] [blame^] | 28 | static off_t out_full, out_part, in_full, in_part; |
Rob Landley | c559817 | 2006-05-02 22:44:04 +0000 | [diff] [blame] | 29 | |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 30 | static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal) |
Rob Landley | c559817 | 2006-05-02 22:44:04 +0000 | [diff] [blame] | 31 | { |
Denis Vlasenko | 7039a66 | 2006-10-08 17:54:47 +0000 | [diff] [blame^] | 32 | bb_fprintf(stderr, OFF_FMT"+"OFF_FMT" records in\n" |
| 33 | OFF_FMT"+"OFF_FMT" records out\n", |
Denis Vlasenko | 5625415 | 2006-10-07 16:24:46 +0000 | [diff] [blame] | 34 | in_full, in_part, |
| 35 | out_full, out_part); |
Rob Landley | c559817 | 2006-05-02 22:44:04 +0000 | [diff] [blame] | 36 | } |
| 37 | |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 38 | int dd_main(int argc, char **argv) |
Eric Andersen | 3cf52d1 | 1999-10-12 22:26:06 +0000 | [diff] [blame] | 39 | { |
Denis Vlasenko | 5625415 | 2006-10-07 16:24:46 +0000 | [diff] [blame] | 40 | #define sync_flag (1<<0) |
| 41 | #define noerror (1<<1) |
| 42 | #define trunc_flag (1<<2) |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 43 | #define twobufs_flag (1<<3) |
| 44 | int flags = trunc_flag; |
Denis Vlasenko | 5625415 | 2006-10-07 16:24:46 +0000 | [diff] [blame] | 45 | size_t oc = 0, ibs = 512, obs = 512; |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 46 | ssize_t n; |
Denis Vlasenko | 7039a66 | 2006-10-08 17:54:47 +0000 | [diff] [blame^] | 47 | off_t seek = 0, skip = 0, count = OFF_T_MAX; |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 48 | int oflag, ifd, ofd; |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 49 | const char *infile = NULL, *outfile = NULL; |
| 50 | char *ibuf, *obuf; |
Eric Andersen | ddea368 | 2000-11-29 22:33:02 +0000 | [diff] [blame] | 51 | |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 52 | if (ENABLE_FEATURE_DD_SIGNAL_HANDLING) { |
Rob Landley | c559817 | 2006-05-02 22:44:04 +0000 | [diff] [blame] | 53 | struct sigaction sa; |
| 54 | |
| 55 | memset(&sa, 0, sizeof(sa)); |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 56 | sa.sa_handler = dd_output_status; |
Rob Landley | c559817 | 2006-05-02 22:44:04 +0000 | [diff] [blame] | 57 | sa.sa_flags = SA_RESTART; |
| 58 | sigemptyset(&sa.sa_mask); |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 59 | sigaction(SIGUSR1, &sa, 0); |
Rob Landley | c559817 | 2006-05-02 22:44:04 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 62 | for (n = 1; n < argc; n++) { |
Denis Vlasenko | 5625415 | 2006-10-07 16:24:46 +0000 | [diff] [blame] | 63 | // FIXME: make them capable of eating LARGE numbers |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 64 | if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("ibs=", argv[n], 4)) { |
Denis Vlasenko | 1385899 | 2006-10-08 12:49:22 +0000 | [diff] [blame] | 65 | ibs = xatoul_sfx(argv[n]+4, dd_suffixes); |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 66 | flags |= twobufs_flag; |
| 67 | } else if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("obs=", argv[n], 4)) { |
Denis Vlasenko | 1385899 | 2006-10-08 12:49:22 +0000 | [diff] [blame] | 68 | obs = xatoul_sfx(argv[n]+4, dd_suffixes); |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 69 | flags |= twobufs_flag; |
| 70 | } else if (!strncmp("bs=", argv[n], 3)) |
Denis Vlasenko | 1385899 | 2006-10-08 12:49:22 +0000 | [diff] [blame] | 71 | ibs = obs = xatoul_sfx(argv[n]+3, dd_suffixes); |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 72 | else if (!strncmp("count=", argv[n], 6)) |
Denis Vlasenko | 1385899 | 2006-10-08 12:49:22 +0000 | [diff] [blame] | 73 | count = xatoul_sfx(argv[n]+6, dd_suffixes); |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 74 | else if (!strncmp("seek=", argv[n], 5)) |
Denis Vlasenko | 1385899 | 2006-10-08 12:49:22 +0000 | [diff] [blame] | 75 | seek = xatoul_sfx(argv[n]+5, dd_suffixes); |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 76 | else if (!strncmp("skip=", argv[n], 5)) |
Denis Vlasenko | 1385899 | 2006-10-08 12:49:22 +0000 | [diff] [blame] | 77 | skip = xatoul_sfx(argv[n]+5, dd_suffixes); |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 78 | else if (!strncmp("if=", argv[n], 3)) |
| 79 | infile = argv[n]+3; |
| 80 | else if (!strncmp("of=", argv[n], 3)) |
| 81 | outfile = argv[n]+3; |
| 82 | else if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("conv=", argv[n], 5)) { |
| 83 | ibuf = argv[n]+5; |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 84 | while (1) { |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 85 | if (!strncmp("notrunc", ibuf, 7)) { |
Denis Vlasenko | 5625415 | 2006-10-07 16:24:46 +0000 | [diff] [blame] | 86 | flags &= ~trunc_flag; |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 87 | ibuf += 7; |
| 88 | } else if (!strncmp("sync", ibuf, 4)) { |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 89 | flags |= sync_flag; |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 90 | ibuf += 4; |
| 91 | } else if (!strncmp("noerror", ibuf, 7)) { |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 92 | flags |= noerror; |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 93 | ibuf += 7; |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 94 | } else { |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 95 | bb_error_msg_and_die(bb_msg_invalid_arg, argv[n]+5, "conv"); |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 96 | } |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 97 | if (ibuf[0] == '\0') break; |
| 98 | if (ibuf[0] == ',') ibuf++; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 99 | } |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 100 | } else |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 101 | bb_show_usage(); |
Eric Andersen | 3cf52d1 | 1999-10-12 22:26:06 +0000 | [diff] [blame] | 102 | } |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 103 | ibuf = xmalloc(ibs); |
Eric Andersen | 3cf52d1 | 1999-10-12 22:26:06 +0000 | [diff] [blame] | 104 | |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 105 | if (flags & twobufs_flag) |
| 106 | obuf = xmalloc(obs); |
| 107 | else |
| 108 | obuf = ibuf; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 109 | |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 110 | if (infile != NULL) |
Denis Vlasenko | 7039a66 | 2006-10-08 17:54:47 +0000 | [diff] [blame^] | 111 | ifd = xopen(infile, O_RDONLY); |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 112 | else { |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 113 | ifd = STDIN_FILENO; |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 114 | infile = bb_msg_standard_input; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 115 | } |
| 116 | |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 117 | if (outfile != NULL) { |
Denis Vlasenko | 7039a66 | 2006-10-08 17:54:47 +0000 | [diff] [blame^] | 118 | oflag = O_WRONLY | O_CREAT; |
Matt Kraai | c9acf8c | 2001-01-17 00:21:05 +0000 | [diff] [blame] | 119 | |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 120 | if (!seek && (flags & trunc_flag)) |
Matt Kraai | c9acf8c | 2001-01-17 00:21:05 +0000 | [diff] [blame] | 121 | oflag |= O_TRUNC; |
| 122 | |
Rob Landley | d921b2e | 2006-08-03 15:41:12 +0000 | [diff] [blame] | 123 | ofd = xopen3(outfile, oflag, 0666); |
Matt Kraai | c9acf8c | 2001-01-17 00:21:05 +0000 | [diff] [blame] | 124 | |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 125 | if (seek && (flags & trunc_flag)) { |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 126 | if (ftruncate(ofd, seek * obs) < 0) { |
Matt Kraai | eb83478 | 2002-02-05 15:28:54 +0000 | [diff] [blame] | 127 | struct stat st; |
| 128 | |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 129 | if (fstat(ofd, &st) < 0 || S_ISREG(st.st_mode) || |
| 130 | S_ISDIR(st.st_mode)) |
| 131 | goto die_outfile; |
Matt Kraai | eb83478 | 2002-02-05 15:28:54 +0000 | [diff] [blame] | 132 | } |
Matt Kraai | c9acf8c | 2001-01-17 00:21:05 +0000 | [diff] [blame] | 133 | } |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 134 | } else { |
| 135 | ofd = STDOUT_FILENO; |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 136 | outfile = bb_msg_standard_output; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 137 | } |
| 138 | |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 139 | if (skip) { |
Denis Vlasenko | 7039a66 | 2006-10-08 17:54:47 +0000 | [diff] [blame^] | 140 | if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) { |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 141 | while (skip-- > 0) { |
| 142 | n = safe_read(ifd, ibuf, ibs); |
| 143 | if (n < 0) |
| 144 | bb_perror_msg_and_die("%s", infile); |
| 145 | if (n == 0) |
| 146 | break; |
| 147 | } |
Glenn L McGrath | eaed78a | 2002-11-28 11:05:28 +0000 | [diff] [blame] | 148 | } |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 149 | } |
Eric Andersen | ddea368 | 2000-11-29 22:33:02 +0000 | [diff] [blame] | 150 | |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 151 | if (seek) { |
Denis Vlasenko | 7039a66 | 2006-10-08 17:54:47 +0000 | [diff] [blame^] | 152 | if (lseek(ofd, seek * obs, SEEK_CUR) < 0) |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 153 | goto die_outfile; |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 154 | } |
Eric Andersen | ddea368 | 2000-11-29 22:33:02 +0000 | [diff] [blame] | 155 | |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 156 | while (in_full + in_part != count) { |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 157 | if (flags & noerror) { |
Eric Andersen | ef38b39 | 2002-04-27 01:31:43 +0000 | [diff] [blame] | 158 | /* Pre-zero the buffer when doing the noerror thing */ |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 159 | memset(ibuf, '\0', ibs); |
Eric Andersen | ef38b39 | 2002-04-27 01:31:43 +0000 | [diff] [blame] | 160 | } |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 161 | |
| 162 | n = safe_read(ifd, ibuf, ibs); |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 163 | if (n == 0) |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 164 | break; |
Eric Andersen | ef38b39 | 2002-04-27 01:31:43 +0000 | [diff] [blame] | 165 | if (n < 0) { |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 166 | if (flags & noerror) { |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 167 | n = ibs; |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 168 | bb_perror_msg("%s", infile); |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 169 | } else |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 170 | bb_perror_msg_and_die("%s", infile); |
Eric Andersen | ef38b39 | 2002-04-27 01:31:43 +0000 | [diff] [blame] | 171 | } |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 172 | if ((size_t)n == ibs) |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 173 | in_full++; |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 174 | else { |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 175 | in_part++; |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 176 | if (sync_flag) { |
| 177 | memset(ibuf + n, '\0', ibs - n); |
| 178 | n = ibs; |
| 179 | } |
Glenn L McGrath | eaed78a | 2002-11-28 11:05:28 +0000 | [diff] [blame] | 180 | } |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 181 | if (flags & twobufs_flag) { |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 182 | char *tmp = ibuf; |
| 183 | while (n) { |
| 184 | size_t d = obs - oc; |
| 185 | |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 186 | if (d > n) |
| 187 | d = n; |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 188 | memcpy(obuf + oc, tmp, d); |
| 189 | n -= d; |
| 190 | tmp += d; |
| 191 | oc += d; |
| 192 | if (oc == obs) { |
Rob Landley | 5343747 | 2006-07-16 08:14:35 +0000 | [diff] [blame] | 193 | xwrite(ofd, obuf, obs); |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 194 | out_full++; |
| 195 | oc = 0; |
| 196 | } |
| 197 | } |
Glenn L McGrath | eaed78a | 2002-11-28 11:05:28 +0000 | [diff] [blame] | 198 | } else { |
Rob Landley | 5343747 | 2006-07-16 08:14:35 +0000 | [diff] [blame] | 199 | xwrite(ofd, ibuf, n); |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 200 | if (n == ibs) |
| 201 | out_full++; |
| 202 | else |
| 203 | out_part++; |
Glenn L McGrath | eaed78a | 2002-11-28 11:05:28 +0000 | [diff] [blame] | 204 | } |
Glenn L McGrath | f0b073f | 2000-09-11 00:32:13 +0000 | [diff] [blame] | 205 | } |
Denis Vlasenko | 9213a9e | 2006-09-17 16:28:10 +0000 | [diff] [blame] | 206 | |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 207 | if (ENABLE_FEATURE_DD_IBS_OBS && oc) { |
Rob Landley | 5343747 | 2006-07-16 08:14:35 +0000 | [diff] [blame] | 208 | xwrite(ofd, obuf, oc); |
Rob Landley | 2686d3b | 2006-05-16 16:52:12 +0000 | [diff] [blame] | 209 | out_part++; |
| 210 | } |
Glenn L McGrath | eaed78a | 2002-11-28 11:05:28 +0000 | [diff] [blame] | 211 | if (close (ifd) < 0) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 212 | bb_perror_msg_and_die("%s", infile); |
Glenn L McGrath | eaed78a | 2002-11-28 11:05:28 +0000 | [diff] [blame] | 213 | } |
Matt Kraai | 3eeab3b | 2001-12-07 16:27:37 +0000 | [diff] [blame] | 214 | |
Glenn L McGrath | eaed78a | 2002-11-28 11:05:28 +0000 | [diff] [blame] | 215 | if (close (ofd) < 0) { |
Bernhard Reutner-Fischer | 73561cc | 2006-08-28 23:31:54 +0000 | [diff] [blame] | 216 | die_outfile: |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 217 | bb_perror_msg_and_die("%s", outfile); |
Glenn L McGrath | eaed78a | 2002-11-28 11:05:28 +0000 | [diff] [blame] | 218 | } |
Matt Kraai | 3eeab3b | 2001-12-07 16:27:37 +0000 | [diff] [blame] | 219 | |
Rob Landley | c559817 | 2006-05-02 22:44:04 +0000 | [diff] [blame] | 220 | dd_output_status(0); |
Matt Kraai | 24ac017 | 2000-12-18 21:38:57 +0000 | [diff] [blame] | 221 | |
Matt Kraai | 3e856ce | 2000-12-01 02:55:13 +0000 | [diff] [blame] | 222 | return EXIT_SUCCESS; |
Eric Andersen | 3cf52d1 | 1999-10-12 22:26:06 +0000 | [diff] [blame] | 223 | } |