I. Refreshing files 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_fadvise (fd,0,st.st_size,posix_fadv_dontneed)!= 0) {
printf ("Cache Fadv_dontneed failed,%s\n", Strerror (errno));
}
else {
printf ("Cache fadv_dontneed done\n");
}
return 0;
}
int main (int argc, char *argv[])
{
if (ARGC < 2)
{
printf ("Please input filename\n");
return-1;
}
Clear_file_cache (argv[1]);
return 0;
}
Generate Fadvise after cross compilation, execute./fadvise file name
Two. See if the file is refreshed using Fincore
https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/
Cross-compile util-linux-2.32.tar.gz
1. Set up cross environment variables
2. Because using the libtinfo.so library, and my cross compilation chain is not, but now all with libncurses.so.5.9, so need to do a soft connection
Ln-s libncurses.so.5.9 libtinfo.so
3. Vim sys-utils/fallocate.c +354 Add semicolon
4. CC=ARM-OPENWRT-LINUX-GCC ld=arm-openwrt-linux-ld./configure--host=arm-linux--prefix=//home/happy/2disk/dirty_ Cow/util-linux-2.32/install
Make
Make install
Fincore files will be generated in the Install/bin directory
Download to the Board
Execute./fincore/lib//lib/libcurl.so.4.5.0
RES PAGES SIZE FILE
32K 8 351k/lib/libcurl.so.4.5.0
You can use one of the code to refresh the file, and then to view, but some cache is not out of the refresh.