/* $Cambridge: hermes/doc/benchmarks/SR2300-vs-EonStor/readv.c,v 1.1 2003/10/19 19:43:05 dpc22 Exp $ */

#define _GNU_SOURCE   /* For LARGEFILE support */

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/uio.h>

int main()
{
    static char buf[1024*1024];  /* BSS */
    int i, fd;

    if ((fd=open("testfile", 0644, O_RDONLY|O_LARGEFILE)) < 0) {
        fprintf(stderr, "Failed to open testfile: %s", strerror(errno));
        exit(1);
    }

    for (i=0 ; i < 20480 ; i++) {
        if (read(fd, buf, 1024*1024) < 0) {
            fprintf(stderr, "writev() failed: %s\n", strerror(errno));
            exit(1);
        }
    }
    fsync(fd);
    close(fd);
}
