diff options
author | Alan Brault <alan.brault@incruentatus.net> | 2010-12-07 21:54:42 -0500 |
---|---|---|
committer | Alan Brault <alan.brault@incruentatus.net> | 2010-12-07 21:54:42 -0500 |
commit | c267a95ca3ddfbd78f28b6ac69214e84ed431b07 (patch) | |
tree | 1cfd381ceb0f55ecc5200434d86afd9fa528a1fb /src | |
parent | 9605c32456e53caf9d724f8e074300bf087b6b96 (diff) | |
parent | b17aea7621494724fc06e6a4dee35c8bf5dffc07 (diff) | |
download | NetNuke2-c267a95ca3ddfbd78f28b6ac69214e84ed431b07.tar.gz |
Merge branch 'master' of git://github.com/jhunkeler/NetNuke
Diffstat (limited to 'src')
-rw-r--r-- | src/bus.c | 2 | ||||
-rw-r--r-- | src/nukectl.c | 18 |
2 files changed, 12 insertions, 8 deletions
@@ -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; 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; |