X-Git-Url: http://git.efficios.com/?p=test-ssd.git;a=blobdiff_plain;f=test-ssd-write.c;h=ea852481e6b94f776cf8df1b983fac7293249311;hp=5b7c8c4df06f218338d2cd7f96272fbd565fbd09;hb=6ab408bac4a2188efe2ad033e3e08ee3d4223d9e;hpb=0c8d2e51959ce92a89cd156fbfde882f041c2e1e diff --git a/test-ssd-write.c b/test-ssd-write.c index 5b7c8c4..ea85248 100644 --- a/test-ssd-write.c +++ b/test-ssd-write.c @@ -146,13 +146,18 @@ static int rand_write(int fd, size_t len) uint64_t valcount; int ret; + if (len < BUFLEN) { + fprintf(stderr, "Error: File size needs to be at least %u\n", BUFLEN); + exit(EXIT_FAILURE); + } + memset(buf, 0, BUFLEN); for (;;) { if (len > UINT32_MAX) { - offset = (((size_t) rand() << 32) + (size_t) rand()) % len; + offset = (((size_t) rand() << 32) + (size_t) rand()) % (len - BUFLEN); } else { - offset = rand() % len; + offset = rand() % (len - BUFLEN); } if ((offset >= validate_offset &&