]> mj.ucw.cz Git - libucw.git/blob - lib/sync.c
Added overflow-safe string functions allocating everything on the stack.
[libucw.git] / lib / sync.c
1 /*
2  *      UCW Library -- Syncing Directories
3  *
4  *      (c) 2004 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 | O_DIRECTORY);
16   if (fd < 0)
17     goto err;
18   int err = fsync(fd);
19   close(fd);
20   if (err >= 0)
21     return;
22  err:
23   log(L_ERROR, "Unable to sync directory %s: %m", name);
24 }