Compare commits
4 commits
ab43512e42
...
9d2645ad65
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d2645ad65 | ||
|
|
53239324ef | ||
|
|
a1556ca383 | ||
|
|
0a4626e7d1 |
2 changed files with 31 additions and 7 deletions
22
README.txt
22
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 <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
|
||||
|
||||
dd if=/dev/zero of=./disk.img bs=1M count=1024
|
||||
losetup -fP ./disk.img
|
||||
|
|
|
|||
16
writeimg.c
16
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -260,11 +261,17 @@ 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): ");
|
||||
printf("Is this okay? (y/N): ");
|
||||
fflush(stdout);
|
||||
if ('y' != getchar()) {
|
||||
printf("Aborting...\n");
|
||||
|
|
@ -280,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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue