summaryrefslogtreecommitdiff
path: root/coreutils/dd.c
diff options
context:
space:
mode:
authorEric Andersen1999-11-19 05:31:45 +0000
committerEric Andersen1999-11-19 05:31:45 +0000
commit6a76e652aab7d614c2b47b50318e0690c06779c4 (patch)
treeeb5564c774b9ef03dc095e7c06e8adb2a8ede1c8 /coreutils/dd.c
parent08b1034f4f0b910660a8b1a537f86462fa41ebad (diff)
downloadbusybox-6a76e652aab7d614c2b47b50318e0690c06779c4.zip
busybox-6a76e652aab7d614c2b47b50318e0690c06779c4.tar.gz
Stuf
Diffstat (limited to 'coreutils/dd.c')
-rw-r--r--coreutils/dd.c37
1 files changed, 13 insertions, 24 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 39c6a62..6494857 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -32,6 +32,7 @@
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
+#include <inttypes.h>
static const char dd_usage[] =
"dd [if=name] [of=name] [bs=n] [count=n]\n\n"
@@ -92,27 +93,20 @@ static long getNum (const char *cp)
extern int dd_main (int argc, char **argv)
{
- const char *inFile;
- const char *outFile;
+ const char *inFile = NULL;
+ const char *outFile = NULL;
char *cp;
int inFd;
int outFd;
int inCc = 0;
int outCc;
- int skipBlocks;
- int blockSize;
- long count;
- long intotal;
- long outTotal;
+ size_t blockSize = 512;
+ //uintmax_t skipBlocks = 0;
+ uintmax_t count = (uintmax_t)-1;
+ uintmax_t intotal;
+ uintmax_t outTotal;
unsigned char *buf;
- inFile = NULL;
- outFile = NULL;
- blockSize = 512;
- skipBlocks = 0;
- count = 1;
-
-
argc--;
argv++;
@@ -125,14 +119,14 @@ extern int dd_main (int argc, char **argv)
else if (strncmp("count", *argv, 5) == 0) {
count = getNum ((strchr(*argv, '='))+1);
if (count <= 0) {
- fprintf (stderr, "Bad count value %ld\n", count);
+ fprintf (stderr, "Bad count value %s\n", *argv);
goto usage;
}
}
else if (strncmp(*argv, "bs", 2) == 0) {
blockSize = getNum ((strchr(*argv, '='))+1);
if (blockSize <= 0) {
- fprintf (stderr, "Bad block size value %d\n", blockSize);
+ fprintf (stderr, "Bad block size value %s\n", *argv);
goto usage;
}
}
@@ -162,13 +156,8 @@ extern int dd_main (int argc, char **argv)
intotal = 0;
outTotal = 0;
- if (inFile == NULL) {
- struct stat statBuf;
+ if (inFile == NULL)
inFd = fileno(stdin);
- if (fstat(inFd, &statBuf) < 0)
- exit( FALSE);
- count = statBuf.st_size;
- }
else
inFd = open (inFile, 0);
@@ -227,9 +216,9 @@ extern int dd_main (int argc, char **argv)
close (outFd);
free (buf);
- printf ("%ld+%d records in\n", intotal / blockSize,
+ printf ("%ld+%d records in\n", (long)(intotal / blockSize),
(intotal % blockSize) != 0);
- printf ("%ld+%d records out\n", outTotal / blockSize,
+ printf ("%ld+%d records out\n", (long)(outTotal / blockSize),
(outTotal % blockSize) != 0);
exit( TRUE);
usage: