akaros/tests/sync.c
<<
>>
Prefs
   1#include <stdlib.h>
   2#include <stdio.h>
   3#include <sys/types.h>
   4#include <sys/stat.h>
   5#include <fcntl.h>
   6#include <unistd.h>
   7#include <errno.h>
   8
   9int main(int argc, char **argv)
  10{
  11        int fd, ret;
  12        char *path = ".";
  13
  14        if (argc > 2) {
  15                fprintf(stderr, "Usage: %s [PATH]\n", argv[0]);
  16                exit(-1);
  17        }
  18        if (argc == 2)
  19                path = argv[1];
  20        fd = open(path, O_READ);
  21        if (fd < 0) {
  22                perror("open");
  23                exit(-1);
  24        }
  25        ret = fsync(fd);
  26        if (ret)
  27                perror("fsync");
  28        close(fd);
  29        return ret;
  30}
  31