summaryrefslogtreecommitdiff
path: root/dd.c
diff options
context:
space:
mode:
authorGlenn L McGrath2000-08-25 03:50:10 +0000
committerGlenn L McGrath2000-08-25 03:50:10 +0000
commit06aeb6c417dd9d113949714486a6e6337ef70b97 (patch)
tree0f002c36314483775fa2a248ae1c8b5346c70030 /dd.c
parent4d5ac2f346d01e51cde9c44431067138bd586f36 (diff)
downloadbusybox-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 'dd.c')
-rw-r--r--dd.c41
1 files changed, 6 insertions, 35 deletions
diff --git a/dd.c b/dd.c
index 6df2588..787e5da 100644
--- a/dd.c
+++ b/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