Whamcloud - gitweb
LU-17452 tests: fix interop sanityn tests with b2_15
[fs/lustre-release.git] / lustre / tests / fadvise_dontneed_helper.c
1 #include <errno.h>
2 #include <fcntl.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include <unistd.h>
6
7 int main(int argc, char *argv[])
8 {
9         int fd;
10         int rc;
11
12         if (argc != 2) {
13                 fprintf(stderr, "usage: %s file\n", argv[0]);
14                 return 1;
15         }
16
17         fd = open(argv[1], O_RDWR, 0);
18         if (fd <= 0) {
19                 fprintf(stderr,
20                         "open failed on %s, error: %s\n",
21                         argv[1], strerror(errno));
22                 return errno;
23         }
24
25         rc = posix_fadvise(fd, 0, 1024 * 1024, POSIX_FADV_DONTNEED);
26         if (rc) {
27                 fprintf(stderr,
28                         "fadvise FADV_DONTNEED failed on %s, error: %s\n",
29                         argv[1], strerror(errno));
30                 return errno;
31         }
32         return 0;
33 }