]> mj.ucw.cz Git - libucw.git/blob - ucw/io-sync.c
Build: Just removed redundant parentheses.
[libucw.git] / ucw / io-sync.c
1 /*
2  *      UCW Library -- Syncing Directories
3  *
4  *      (c) 2004--2012 Martin Mares <mj@ucw.cz>
5  */
6
7 #include <ucw/lib.h>
8 #include <ucw/io.h>
9
10 #include <fcntl.h>
11 #include <unistd.h>
12
13 void
14 sync_dir(const char *name)
15 {
16   int fd = open(name, O_RDONLY
17 #ifdef CONFIG_LINUX
18                 | O_DIRECTORY
19 #endif
20 );
21   if (fd < 0)
22     goto err;
23   int err = fsync(fd);
24   close(fd);
25   if (err >= 0)
26     return;
27  err:
28   msg(L_ERROR, "Unable to sync directory %s: %m", name);
29 }