diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2017-07-09 04:21:29 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2017-07-09 04:21:29 +0300 |
commit | 5fcc5068d7b62d109d902e41cfa9759e71baf2c3 (patch) | |
tree | 68613fd37efdabd88fc2bf11e746cce95ad43ceb | |
parent | 3ab3d03b8b603f210d878d352b56442eec14f6af (diff) |
small utility to sync one filesystem instead of all (for linux)
-rw-r--r-- | syncfs.c | 28 |
1 files changed, 28 insertions, 0 deletions
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 <unistd.h> +#include <stdio.h> +#include <errno.h> +#include <string.h> + +int main(int argc, char** argv) +{ + if(argc != 2) + { + printf("usage:\n\t%s <some valid path insied filesystem>\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; +} |