#include #include #include #define BLOCK_SIZE (4096) #warning ARCH DEPENDENT fixup for your arch #define O_DIRECT 040000 // ARCH DEPENDENT fixup for your arch */ static char buf[128 * BLOCK_SIZE]; int main(int argc, char** argv) { int fd; char* aligned_buf = (char*)(( (uintptr_t)&buf + (BLOCK_SIZE-1)) & ~(BLOCK_SIZE-1)); int aligned_size = sizeof(buf) - BLOCK_SIZE; if (-1 == ( fd = open (argv[1], O_RDWR | O_CREAT | O_DIRECT))) { perror("open: "); return 1; } while (1) { if( aligned_size!=write(fd, aligned_buf, aligned_size)) { perror("write: "); return 1; } } }