一. 刷新文件pagecache
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/stat.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
int clear_file_cache(const char *filename)
{
struct stat st;
if(stat(filename , &st) < 0) {
fprintf(stderr , "stat localfile failed, path:%s\n",filename);
return -1;
}
int fd = open(filename, O_RDONLY);
if( fd < 0 ) {
fprintf(stderr , "open localfile failed, path:%s\n",filename);
return -1;
}
//clear cache by posix_fadvise
if( posix