| 1 |
/* COVERAGE: sync_file_range sync_file_range2 sync syncfs */ |
| 2 |
|
| 3 |
#define _GNU_SOURCE |
| 4 |
#include <unistd.h> |
| 5 |
#include <sys/types.h> |
| 6 |
#include <sys/stat.h> |
| 7 |
#include <fcntl.h> |
| 8 |
#include <sys/syscall.h> |
| 9 |
#include <sys/mman.h> |
| 10 |
|
| 11 |
int main() |
| 12 |
{ |
| 13 |
int fd; |
| 14 |
char *string1 = "Hello world"; |
| 15 |
|
| 16 |
mlockall(MCL_CURRENT); |
| 17 |
|
| 18 |
sync(); |
| 19 |
//staptest// sync () = 0 |
| 20 |
|
| 21 |
// Create a test file. |
| 22 |
fd = creat("foobar", S_IREAD|S_IWRITE); |
| 23 |
write(fd, string1, sizeof(string1) - 1); |
| 24 |
|
| 25 |
// We use syscall() to avoid link time problems |
| 26 |
#ifdef __NR_syncfs |
| 27 |
syscall(__NR_syncfs, fd); |
| 28 |
//staptest// syncfs (NNNN) = 0 |
| 29 |
|
| 30 |
syscall(__NR_syncfs, (int)-1); |
| 31 |
//staptest// syncfs (-1) = -NNNN |
| 32 |
#endif |
| 33 |
|
| 34 |
close(fd); |
| 35 |
return 0; |
| 36 |
} |