1/* sync.c
2   Sync a file to disk, if FSYNC_ON_CLOSE is set.  */
3
4#include "uucp.h"
5
6#include "uudefs.h"
7#include "sysdep.h"
8#include "system.h"
9
10#include <errno.h>
11
12boolean
13fsysdep_sync (e, zmsg)
14     openfile_t e;
15     const char *zmsg;
16{
17  int o;
18
19#if USE_STDIO
20  if (fflush (e) == EOF)
21    {
22      ulog (LOG_ERROR, "%s: fflush: %s", zmsg, strerror (errno));
23      return FALSE;
24    }
25#endif
26
27#if USE_STDIO
28  o = fileno (e);
29#else
30  o = e;
31#endif
32
33#if FSYNC_ON_CLOSE
34  if (fsync (o) < 0)
35    {
36      ulog (LOG_ERROR, "%s: fsync: %s", zmsg, strerror (errno));
37      return FALSE;
38    }
39#endif
40
41  return TRUE;
42}
43