diff options
author | Glenn L McGrath | 2000-08-25 03:50:10 +0000 |
---|---|---|
committer | Glenn L McGrath | 2000-08-25 03:50:10 +0000 |
commit | 06aeb6c417dd9d113949714486a6e6337ef70b97 (patch) | |
tree | 0f002c36314483775fa2a248ae1c8b5346c70030 /coreutils/dd.c | |
parent | 4d5ac2f346d01e51cde9c44431067138bd586f36 (diff) | |
download | busybox-06aeb6c417dd9d113949714486a6e6337ef70b97.zip busybox-06aeb6c417dd9d113949714486a6e6337ef70b97.tar.gz |
ar.c now uses a linked list to process headers, uses getopt, new internal function extractAr(srcFD, dstFd, filename) to make it easily accessable to other busybox functions.
moved copySubFile from ar.c to utilities.c
modified dd.c to use fullWrite
modified copyFile in utilities.c to use copySubFile
Diffstat (limited to 'coreutils/dd.c')
-rw-r--r-- | coreutils/dd.c | 41 |
1 files changed, 6 insertions, 35 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c index 6df2588..787e5da 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c @@ -44,7 +44,6 @@ extern int dd_main(int argc, char **argv) { char *inFile = NULL; char *outFile = NULL; - char *cp; int inFd; int outFd; int inCc = 0; @@ -135,42 +134,14 @@ extern int dd_main(int argc, char **argv) lseek(inFd, skipBlocks * blockSize, SEEK_SET); lseek(outFd, seekBlocks * blockSize, SEEK_SET); - // - //TODO: Convert to using fullRead & fullWrite - // from utility.c - // -Erik - while (outTotal < count * blockSize) { - inCc = read(inFd, buf, blockSize); - if (inCc < 0) { - perror(inFile); - goto cleanup; - } else if (inCc == 0) { - goto cleanup; - } - intotal += inCc; - cp = buf; - - while (intotal > outTotal) { - if (outTotal + inCc > count * blockSize) - inCc = count * blockSize - outTotal; - outCc = write(outFd, cp, inCc); - if (outCc < 0) { - perror(outFile); - goto cleanup; - } else if (outCc == 0) { - goto cleanup; - } - - inCc -= outCc; - cp += outCc; - outTotal += outCc; - } - } - if (inCc < 0) - perror(inFile); + while ((inCc = read(inFd, buf, sizeof(buf))) > 0) { + intotal +=inCc; + if ((outCc = fullWrite(outFd, buf, inCc)) < 0) + break; + outTotal += outCc; + } - cleanup: /* Note that we are not freeing memory or closing * files here, to save a few bytes. */ #ifdef BB_FEATURE_CLEAN_UP |