aboutsummaryrefslogtreecommitdiff
path: root/dd.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>1999-11-19 02:38:58 +0000
committerEric Andersen <andersen@codepoet.org>1999-11-19 02:38:58 +0000
commit08b1034f4f0b910660a8b1a537f86462fa41ebad (patch)
tree4a39b721f4654120bff47fcd7cd95906172ec16f /dd.c
parentab746abfc05c28824b25e12b86a538b09fb9275d (diff)
downloadbusybox-08b1034f4f0b910660a8b1a537f86462fa41ebad.tar.gz
Stuf
Diffstat (limited to 'dd.c')
-rw-r--r--dd.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/dd.c b/dd.c
index 9468cddfc..39c6a6263 100644
--- a/dd.c
+++ b/dd.c
@@ -162,8 +162,13 @@ extern int dd_main (int argc, char **argv)
intotal = 0;
outTotal = 0;
- if (inFile == NULL)
- inFd = STDIN;
+ if (inFile == NULL) {
+ struct stat statBuf;
+ inFd = fileno(stdin);
+ if (fstat(inFd, &statBuf) < 0)
+ exit( FALSE);
+ count = statBuf.st_size;
+ }
else
inFd = open (inFile, 0);
@@ -174,7 +179,7 @@ extern int dd_main (int argc, char **argv)
}
if (outFile == NULL)
- outFd = STDOUT;
+ outFd = fileno(stdout);
else
outFd = creat (outFile, 0666);
@@ -191,6 +196,8 @@ extern int dd_main (int argc, char **argv)
if (inCc < 0) {
perror (inFile);
goto cleanup;
+ } else if (inCc == 0) {
+ goto cleanup;
}
intotal += inCc;
cp = buf;
@@ -202,6 +209,8 @@ extern int dd_main (int argc, char **argv)
if (outCc < 0) {
perror (outFile);
goto cleanup;
+ } else if (outCc == 0) {
+ goto cleanup;
}
inCc -= outCc;