From 5fcc5068d7b62d109d902e41cfa9759e71baf2c3 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Sun, 9 Jul 2017 04:21:29 +0300 Subject: small utility to sync one filesystem instead of all (for linux) --- syncfs.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 syncfs.c (limited to 'syncfs.c') diff --git a/syncfs.c b/syncfs.c new file mode 100644 index 0000000..e45e875 --- /dev/null +++ b/syncfs.c @@ -0,0 +1,28 @@ +#define _GNU_SOURCE + +#include +#include +#include +#include + +int main(int argc, char** argv) +{ + if(argc != 2) + { + printf("usage:\n\t%s \n", argv[0]); + return -1; + } + FILE *f = fopen(argv[1], "r"); + if(!f) + { + printf("fopen failed %s\n", strerror(errno)); + return -1; + } + int fd = fileno(f); + int err = syncfs(fd); + if(err < 0) + { + printf("syncfs failed %s\n", strerror(errno)); + } + return 0; +} -- cgit v1.2.3