I am using Android NDK version: r9c
I need posix_fadvise()to report that the OS does not cache the file that I opened, to bypass the cache and force I / O to access the storage device when I need to read / write it.
The reason why I did not open the file with the flag O_DIRECThas O_DIRECThas a compatible problem on different devices.
I tried calling __NR_arm_fadvise64_64directly, but not using, and __NR_fadvisenot defined in NDK r9c.
Below is an example code, a system call readwill not result in I / O access, which means that the page cache still has a record for this file.
ret= fdatasync(fd);
ret = syscall(__NR_arm_fadvise64_64, fd, 0, 0, POSIX_FADV_DONTNEED);
if(ret !=0){
LOGE("syscall __NR_arm_fadvise64_64 errno: %s\n", strerror(errno));
}
ret = read(fd, buff, page_size);
if(ret<0){
LOGE("read errno: %s\n", strerror(errno));
return -1;
}
Is there any other way to bypass the cache or how to enable a function call posix_fadvisein the Android system?