Include the file size in the write job struct for future reference in data rate and progress bar

This commit is contained in:
Imbus 2026-02-07 13:52:13 +01:00
parent c11bdd7f47
commit 804a6b1485

View file

@ -27,6 +27,8 @@
#define BLOCKSIZE (4 * 1024 * 1024) #define BLOCKSIZE (4 * 1024 * 1024)
#endif #endif
#define BYTES_TO_MIB(bts) ((double)bts / (1024 * 1024))
// clang-format off // clang-format off
const char help[] = const char help[] =
"Usage:\n" "Usage:\n"
@ -50,6 +52,7 @@ struct write_job {
char *buffer2; /* For memcmp integrity checks */ char *buffer2; /* For memcmp integrity checks */
size_t bufsize; size_t bufsize;
size_t block_size; size_t block_size;
size_t total_bytes;
char verify_only; char verify_only;
} wjob = {0}; } wjob = {0};
@ -207,6 +210,7 @@ int main(int argc, char *argv[]) {
wjob.bufsize = BLOCKSIZE; wjob.bufsize = BLOCKSIZE;
wjob.block_size = BLOCKSIZE; wjob.block_size = BLOCKSIZE;
wjob.total_bytes = file_stat.st_size;
assert(file_stat.st_size >= 0); assert(file_stat.st_size >= 0);
perform_write(&wjob); perform_write(&wjob);
@ -216,7 +220,7 @@ int main(int argc, char *argv[]) {
if (wjob.buffer2) if (wjob.buffer2)
free(wjob.buffer2); free(wjob.buffer2);
printf("\nOkay!\n"); printf("\n%.1f MiB's written and verified.\nAll good!\n", BYTES_TO_MIB(wjob.total_bytes));
exit(0); exit(0);
return 0; return 0;
} }