28 static uint32_t
ran(
void)
35 offset = fseek(stream, offset, whence);
37 fprintf(stderr,
"seek failed\n");
42 int main(
int argc,
char **argv)
48 printf(
"USAGE: trasher <filename> <count> <maxburst> <seed>\n");
52 f = fopen(argv[1],
"rb+");
57 count = atoi(argv[2]);
58 maxburst = atoi(argv[3]);
59 state = atoi(argv[4]);
66 int burst = 1 +
ran() * (uint64_t) (abs(maxburst) - 1) / UINT32_MAX;
67 int pos =
ran() * (uint64_t) length / UINT32_MAX;
73 if (pos + burst > length)
77 int val =
ran() * 256ULL / UINT32_MAX;
82 fwrite(&val, 1, 1, f);