diff -ur bonnie++-1.03a/bonnie++.cpp bonnie++-1.03a-urand/bonnie++.cpp --- bonnie++-1.03a/bonnie++.cpp 2002-12-04 00:40:35.000000000 +1100 +++ bonnie++-1.03a-urand/bonnie++.cpp 2007-01-01 13:03:41.644378000 +1100 @@ -41,6 +41,9 @@ #include #include #include +#include +#include +#include #ifdef AIX_MEM_SIZE #include @@ -148,6 +151,28 @@ } } +void load_random_data(char *temp_buffer,int length) +{ + int filedes, numbytes; + + filedes=open("/dev/urandom",O_RDONLY); + if(filedes<0) + { + perror("Open of /dev/urandom failed, falling back to 0's"); + memset(temp_buffer, 0, length); + } + else + { + numbytes=read(filedes,temp_buffer,length); + if(numbytes!=length) + { + perror("Read from /dev/urandom failed, falling back to 0's"); + memset(temp_buffer, 0, length); + } + close(filedes); + } +} + int main(int argc, char *argv[]) { int file_size = DefaultFileSize; @@ -477,7 +502,8 @@ return 1; globals.decrement_and_wait(FastWrite); if(!globals.quiet) fprintf(stderr, "Writing intelligently..."); - memset(buf, 0, globals.chunk_size()); + // memset(buf, 0, globals.chunk_size()); + load_random_data(buf, globals.chunk_size()); globals.timer.timestamp(); bufindex = 0; // for the number of chunks of file data