#define _GNU_SOURCE #include #include #include #include #include #include #include #define NUM_PAGES (256) int main(int argc, char **argv) { int ret, fd; long pagesize; struct iovec iov; if (argc < 2) { fprintf(stderr, "Usage: %s \n", argv[0]); return 1; } pagesize = sysconf(_SC_PAGESIZE); if (pagesize < 0) { perror("sysconf"); return 1; } fd = open(argv[1], O_CREAT|O_WRONLY|O_DIRECT, 0666); if (fd < 0) { perror("open"); return 1; } ret = posix_memalign(&iov.iov_base, pagesize, pagesize * NUM_PAGES); if (ret) { perror("posix_memalign"); return 1; } iov.iov_len = pagesize * NUM_PAGES; ret = writev(fd, &iov, 1); if (ret < 0) { perror("writev"); return 1; } return 0; }