#include #include /* Normal doesn't include O_DIRECT on the host used */ #include #include #include /* This is a test snippet that fails on Linux kernel 2.4. The source is a slightly modified version of https://mail.clusterfs.com/pipermail/lustre-discuss/2006-March/001344.html You need to create the file before running this program, % touch testfile.dat If you replace 512 below with 'block_size', write works. */ int main(int argc, char **argv) { int i, err, fd, block_size; mode_t io_mode; char *buf, *filename; long long offset = 0; struct stat statBuf; filename = "testfile.dat"; /* get system block size */ stat(filename, &statBuf); block_size = statBuf.st_blksize; printf("Writing to file: %s block_size=%d\n",filename,block_size); buf = (char*) malloc(block_size * 2); buf += block_size - ((long)buf % 512); printf("Pointer is : 0x%x, block_size=0x%x\n",buf, block_size); for (i=0; i