From 0a4626e7d133ecc87c1af004a450267a3c9790ff Mon Sep 17 00:00:00 2001 From: Imbus Date: Sat, 7 Feb 2026 18:23:33 +0100 Subject: [PATCH 1/4] Fix formatting when error occurs --- writeimg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/writeimg.c b/writeimg.c index 3d6c04b..90c7323 100644 --- a/writeimg.c +++ b/writeimg.c @@ -175,7 +175,8 @@ int perform_write(write_job_t *job) { int cmp = memcmp((const void *)job->buffer2, (const void *)job->buffer, (size_t)read_file); if (0 != cmp) { - fprintf(stderr, "WARNING: File did not verify correctly!\n"); + fflush(stdout); + fprintf(stderr, "\nWARNING: File did not verify correctly!\n"); exit(EXIT_FAILURE); } } From a1556ca383b5dedf802e0dcb3f4d524a83bb6e50 Mon Sep 17 00:00:00 2001 From: Imbus Date: Sat, 7 Feb 2026 18:23:59 +0100 Subject: [PATCH 2/4] Set (y/n) prompt to (y/N) to better reflect behaviour --- writeimg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/writeimg.c b/writeimg.c index 90c7323..a369075 100644 --- a/writeimg.c +++ b/writeimg.c @@ -265,7 +265,7 @@ int main(int argc, char *argv[]) { printf("Writing %s to %s\n", wjob.filename, wjob.dev_name); if (ask_permission && !wjob.verify_only) { - printf("Is this okay? (y/n): "); + printf("Is this okay? (y/N): "); fflush(stdout); if ('y' != getchar()) { printf("Aborting...\n"); From 53239324ef9b1ec738372e0994eb9e05db29715b Mon Sep 17 00:00:00 2001 From: Imbus Date: Sat, 7 Feb 2026 18:24:32 +0100 Subject: [PATCH 3/4] Tell the user how much data will be written beforehand --- writeimg.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/writeimg.c b/writeimg.c index a369075..7bcd467 100644 --- a/writeimg.c +++ b/writeimg.c @@ -261,8 +261,14 @@ int main(int argc, char *argv[]) { } close(fd); + wjob.total_bytes = file_stat.st_size; + assert(file_stat.st_size >= 0); + if (!wjob.verify_only) - printf("Writing %s to %s\n", wjob.filename, wjob.dev_name); + printf("Writing \"%s\" (%.1f MiB) to \"%s\"\n", + basename(wjob.filename), + BYTES_TO_MIB(wjob.total_bytes), + wjob.dev_name); if (ask_permission && !wjob.verify_only) { printf("Is this okay? (y/N): "); @@ -281,9 +287,6 @@ int main(int argc, char *argv[]) { wjob.bufsize = BLOCKSIZE; wjob.block_size = BLOCKSIZE; - wjob.total_bytes = file_stat.st_size; - assert(file_stat.st_size >= 0); - perform_write(&wjob); if (wjob.buffer) From 9d2645ad65688140c645c489b8c4855217906825 Mon Sep 17 00:00:00 2001 From: Imbus Date: Sat, 7 Feb 2026 18:38:48 +0100 Subject: [PATCH 4/4] Readme --- README.txt | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/README.txt b/README.txt index da4be03..2af80c3 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,24 @@ -Simple dd-like image writer with additional security checks. +# Simple dd-like image writer with additional security checks. + +``` +writeimg v0.2.0, Rev. 5323932-dirty +In honor of SwePwnage - the OG disk destroyer +Copyright (C) 2026 Imbus, BSD-2-Clause +Build date: 2026-02-07 + +Usage: + writeimg [-v] -d + +Args: + Binary image file + -v Verify only + -d device Target block device + -h, --help Print this help message + -n, --noconfirm Do not ask for premission + -V, --version Print version +``` + +## Testing dd if=/dev/zero of=./disk.img bs=1M count=1024 losetup -fP ./disk.img