summaryrefslogtreecommitdiff
path: root/src/commands/dd.c
diff options
context:
space:
mode:
authorTyler Murphy <tylerm@tylerm.dev>2023-05-04 16:10:37 -0400
committerTyler Murphy <tylerm@tylerm.dev>2023-05-04 16:10:37 -0400
commitb1364be7e271c5a080e29efcda209a190a82d6d9 (patch)
treefc64d1546e59b5ed1c2c204612b6181bc401c27f /src/commands/dd.c
parentgrep (diff)
downloadlazysphere-b1364be7e271c5a080e29efcda209a190a82d6d9.tar.gz
lazysphere-b1364be7e271c5a080e29efcda209a190a82d6d9.tar.bz2
lazysphere-b1364be7e271c5a080e29efcda209a190a82d6d9.zip
ansii c
Diffstat (limited to '')
-rw-r--r--src/commands/dd.c9
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;