NEP 4.3.0
NetCDF Expansion Pack
Loading...
Searching...
No Matches
perf_disk.h
Go to the documentation of this file.
1
14
15#ifndef NEP_PERF_DISK_H
16#define NEP_PERF_DISK_H
17
18#include <errno.h>
19#include <fcntl.h>
20#include <unistd.h>
21
30static inline int
31nep_perf_sync_file(const char *path)
32{
33 int fd, ret;
34
35 if ((fd = open(path, O_RDONLY)) < 0)
36 return -1;
37 ret = fsync(fd);
38 close(fd);
39 return ret;
40}
41
53static inline int
54nep_perf_drop_cache(const char *path)
55{
56 int fd, ret;
57
58 if ((fd = open(path, O_RDONLY)) < 0)
59 return -1;
60 if (fsync(fd) < 0)
61 {
62 close(fd);
63 return -1;
64 }
65 ret = posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
66 close(fd);
67 if (ret)
68 {
69 errno = ret;
70 return -1;
71 }
72 return 0;
73}
74
75#endif /* NEP_PERF_DISK_H */
static int nep_perf_drop_cache(const char *path)
Drop a file's pages from the page cache.
Definition perf_disk.h:54
static int nep_perf_sync_file(const char *path)
Flush a closed file's data to the storage device.
Definition perf_disk.h:31