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