Compare commits

..

No commits in common. "9d2645ad65688140c645c489b8c4855217906825" and "ab43512e425ba3789253c2b7d077ba7c2ac5b178" have entirely different histories.

2 changed files with 7 additions and 31 deletions

View file

@ -1,24 +1,4 @@
# 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 <device> <file.img>
Args:
<file.img> 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
Simple dd-like image writer with additional security checks.
dd if=/dev/zero of=./disk.img bs=1M count=1024
losetup -fP ./disk.img

View file

@ -175,8 +175,7 @@ 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) {
fflush(stdout);
fprintf(stderr, "\nWARNING: File did not verify correctly!\n");
fprintf(stderr, "WARNING: File did not verify correctly!\n");
exit(EXIT_FAILURE);
}
}
@ -261,17 +260,11 @@ 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\" (%.1f MiB) to \"%s\"\n",
basename(wjob.filename),
BYTES_TO_MIB(wjob.total_bytes),
wjob.dev_name);
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");
@ -287,6 +280,9 @@ 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)