aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2010-12-07 21:11:59 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2010-12-07 21:11:59 -0500
commita6b67ce6b5ba61efa34552bb3a852fdb4c36c8c1 (patch)
tree63146e1431d5f252b20a30cadc4baaae13ffa503
parent755866fee7ea4a6c2871a95fa9081656fb5bef23 (diff)
downloadNetNuke2-a6b67ce6b5ba61efa34552bb3a852fdb4c36c8c1.tar.gz
Fixed not writing the proper amount of data
-rw-r--r--src/nukectl.c18
1 files 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;