Skip to content

Instantly share code, notes, and snippets.

@kocolosk
Created April 23, 2010 01:16
Show Gist options
  • Save kocolosk/376047 to your computer and use it in GitHub Desktop.
Save kocolosk/376047 to your computer and use it in GitHub Desktop.
#define _XOPEN_SOURCE 600
#ifdef __APPLE__
#define _DARWIN_C_SOURCE
#endif
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char *argv[]) {
int fd;
fd = open(argv[1], O_RDONLY);
if(fd == -1) return 1;
#ifdef __linux__
fdatasync(fd);
posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
#endif
#ifdef __APPLE__
fcntl(fd, F_GLOBAL_NOCACHE, 1);
#endif
close(fd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment