aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bus.c2
-rw-r--r--src/nukectl.c18
2 files changed, 12 insertions, 8 deletions
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;
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;