diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-11-19 02:38:58 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-11-19 02:38:58 +0000 |
commit | 08b1034f4f0b910660a8b1a537f86462fa41ebad (patch) | |
tree | 4a39b721f4654120bff47fcd7cd95906172ec16f /dd.c | |
parent | ab746abfc05c28824b25e12b86a538b09fb9275d (diff) | |
download | busybox-w32-08b1034f4f0b910660a8b1a537f86462fa41ebad.tar.gz busybox-w32-08b1034f4f0b910660a8b1a537f86462fa41ebad.tar.bz2 busybox-w32-08b1034f4f0b910660a8b1a537f86462fa41ebad.zip |
Stuf
Diffstat (limited to 'dd.c')
-rw-r--r-- | dd.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -162,8 +162,13 @@ extern int dd_main (int argc, char **argv) | |||
162 | intotal = 0; | 162 | intotal = 0; |
163 | outTotal = 0; | 163 | outTotal = 0; |
164 | 164 | ||
165 | if (inFile == NULL) | 165 | if (inFile == NULL) { |
166 | inFd = STDIN; | 166 | struct stat statBuf; |
167 | inFd = fileno(stdin); | ||
168 | if (fstat(inFd, &statBuf) < 0) | ||
169 | exit( FALSE); | ||
170 | count = statBuf.st_size; | ||
171 | } | ||
167 | else | 172 | else |
168 | inFd = open (inFile, 0); | 173 | inFd = open (inFile, 0); |
169 | 174 | ||
@@ -174,7 +179,7 @@ extern int dd_main (int argc, char **argv) | |||
174 | } | 179 | } |
175 | 180 | ||
176 | if (outFile == NULL) | 181 | if (outFile == NULL) |
177 | outFd = STDOUT; | 182 | outFd = fileno(stdout); |
178 | else | 183 | else |
179 | outFd = creat (outFile, 0666); | 184 | outFd = creat (outFile, 0666); |
180 | 185 | ||
@@ -191,6 +196,8 @@ extern int dd_main (int argc, char **argv) | |||
191 | if (inCc < 0) { | 196 | if (inCc < 0) { |
192 | perror (inFile); | 197 | perror (inFile); |
193 | goto cleanup; | 198 | goto cleanup; |
199 | } else if (inCc == 0) { | ||
200 | goto cleanup; | ||
194 | } | 201 | } |
195 | intotal += inCc; | 202 | intotal += inCc; |
196 | cp = buf; | 203 | cp = buf; |
@@ -202,6 +209,8 @@ extern int dd_main (int argc, char **argv) | |||
202 | if (outCc < 0) { | 209 | if (outCc < 0) { |
203 | perror (outFile); | 210 | perror (outFile); |
204 | goto cleanup; | 211 | goto cleanup; |
212 | } else if (outCc == 0) { | ||
213 | goto cleanup; | ||
205 | } | 214 | } |
206 | 215 | ||
207 | inCc -= outCc; | 216 | inCc -= outCc; |