From a6b67ce6b5ba61efa34552bb3a852fdb4c36c8c1 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 7 Dec 2010 21:11:59 -0500 Subject: Fixed not writing the proper amount of data --- src/nukectl.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/nukectl.c b/src/nukectl.c index 2db3d06..2404a5b 100644 --- a/src/nukectl.c +++ b/src/nukectl.c @@ -59,7 +59,9 @@ void ignore_device(char** list, nndevice_t** d) void* wipe(void* device) { nndevice_t* d = (nndevice_t*)device; - unsigned long long bytes_written = 0; + unsigned long long times = 0; + unsigned long long block = 0; + unsigned long long bytes_out = 0; long double percent = 0.0L; if(d->path[0] == 0) @@ -80,20 +82,22 @@ void* wipe(void* device) COM(self, "%s, block size %d, blocks %llu, total bytes %llu\n", d->path, d->blksz, d->blks, d->sz); srand(nngetseed()); - while(bytes_written <= d->sz) + times = d->sz / d->blksz; + while(block <= times) { if(!writing) { if(verbose_flag) { - percent = (long double)((bytes_written / (long double)d->sz) * 100); - printf("%s: %llu of %llu (%0.2Lf%%)\n", d->path, bytes_written, d->sz, percent); + percent = (long double)((bytes_out / (long double)d->sz) * 100); + printf("%s: %llu of %llu (%0.2Lf%%)\n", d->path, bytes_out, d->sz, percent); } - bytes_written += nnwrite(fd, d->blksz); + bytes_out += nnwrite(fd, d->blksz); + block++; } } - - COM(self, "%s complete\n", d->path); + close(fd); + COM(self, "%s complete, wrote %llu bytes\n", d->path, bytes_out); pthread_exit(NULL); return NULL; -- cgit From 023bb328c7c0d9f1b95b2fd5f7207a61d0c69307 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 7 Dec 2010 21:12:48 -0500 Subject: Explicitly set block size, no matter what. --- src/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bus.c b/src/bus.c index e28bda1..7a15574 100644 --- a/src/bus.c +++ b/src/bus.c @@ -134,7 +134,7 @@ int scanbus_sysfs(nndevice_t** device) } device[i]->blksz = 512; - device[i]->sz = device[i]->blks * device[i]->blksz; + device[i]->sz = device[i]->blks * 512; COM(self, "%s %s %s %llu\n", device[i]->vendor, device[i]->path, device[i]->model, (device[i]->blks * device[i]->blksz)); ++i; -- cgit