if (pattern)
printf("Writing 0x%X to the output\n", pattern);
+ if (lseek(fd, offset, SEEK_SET) != offset)
+ errp("lseek(%"PRIu64"u) failed", offset);
+
unsigned long long speed = 0;
struct timespec stime, etime, itime;
clock_gettime(CLOCK_MONOTONIC, &stime);
ret = write(fd, mem, sizeof(mem));
pos += ret;
if (ret != sizeof(mem)) {
- printf("\nread() returned %zi (wanted %zu)\n%'llu MB/s over entire run\n",
- ret, sizeof(mem), mbps(&itime, &etime, pos));
+ if (pos != max_size)
+ printf("\nread() returned %zi (wanted %zu)\n%'llu MB/s over entire run\n",
+ ret, sizeof(mem), mbps(&itime, &etime, pos));
return;
}
printf("%'llu bytes %u%% (%'llu MB/s)%20s\r", (unsigned long long)pos,
(unsigned)((pos * 100) / max_size), speed, "");
- if ((++fsync_pos % 16) == 0) {
+ if ((++fsync_pos % 32) == 0) {
speed = mbps(&stime, &etime, pos - last_pos);
last_pos = pos;
fflush(stdout);
status ? stderr : stdout,
"Usage: ddnuke [options] <dev>\n"
"\n"
- "Options:"
+ "Options:\n"
" -o <offset> Position to start writing\n"
- " -r Write random garbage to the device\n"
+ " -r Write three times: 0x00, then 0xaa, then 0x55\n"
);
exit(status);
}
off_t max_size = get_size(fd);
- if (lseek(fd, offset, SEEK_SET) != offset)
- errp("lseek(%"PRIu64"u) failed", offset);
-
nuke(fd, offset, max_size, 0x00);
if (random) {
nuke(fd, offset, max_size, 0xaa);