Skip to content

Instantly share code, notes, and snippets.

@mmgaggle
Created March 31, 2016 16:41
Show Gist options
  • Save mmgaggle/2c8c78da4545bf8fe3f519aedbe09fe4 to your computer and use it in GitHub Desktop.
Save mmgaggle/2c8c78da4545bf8fe3f519aedbe09fe4 to your computer and use it in GitHub Desktop.
#define _GNU_SOURCE
#define O_DIRECT 00040000ULL
#define O_ATOMIC 040000000ULL
#include<stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main ()
{
FILE *fp;
int fd;
char *str;
str = (char *) malloc(16384);
memset(str,0,16384);
fd = open( "./append16kb.txt" , O_DIRECT | O_WRONLY | O_TRUNC | O_ATOMIC);
while (1) {
write(fd, str, 16384);
fdatasync(fd);
}
close(fd);
return(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment