diff options
Diffstat (limited to 'src/commands/dd.c')
-rw-r--r-- | src/commands/dd.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/commands/dd.c b/src/commands/dd.c index 78f6041..1387317 100644 --- a/src/commands/dd.c +++ b/src/commands/dd.c @@ -15,10 +15,13 @@ COMMAND(dd) { FILE* out_file = stdout; int bs = 1024; int count = -1; + int i; + char* buffer; + size_t read; parse_help(argc, argv, help); - for (int i = 0; i < argc; i++) { + for (i = 0; i < argc; i++) { if (prefix("if=", argv[i])) { char* path = argv[i] + 3; in_file = get_file(path, "rb"); @@ -42,8 +45,8 @@ COMMAND(dd) { } } - char* buffer = malloc(bs); - size_t read; + buffer = malloc(bs); + while ((read = fread(buffer, 1, bs, in_file)) != 0) { fwrite(buffer, 1, read, out_file); if (--count, count == 0) break; |