aboutsummaryrefslogtreecommitdiff
path: root/gnu/libexec/uucp/libunix/sync.c
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1995-08-19 21:30:30 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1995-08-19 21:30:30 +0000
commit6ec4b3339bbd81ee311eb50fe25a13676e2a02a7 (patch)
treee1ea6a3b65e0f2e9f5d6e0f0f3956a82ada4b85b /gnu/libexec/uucp/libunix/sync.c
parentea76f9453e3fc27708741a121e0757ba0c87bd05 (diff)
Notes
Diffstat (limited to 'gnu/libexec/uucp/libunix/sync.c')
-rw-r--r--gnu/libexec/uucp/libunix/sync.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/gnu/libexec/uucp/libunix/sync.c b/gnu/libexec/uucp/libunix/sync.c
new file mode 100644
index 000000000000..c346c58ccb7a
--- /dev/null
+++ b/gnu/libexec/uucp/libunix/sync.c
@@ -0,0 +1,42 @@
+/* sync.c
+ Sync a file to disk, if FSYNC_ON_CLOSE is set. */
+
+#include "uucp.h"
+
+#include "uudefs.h"
+#include "sysdep.h"
+#include "system.h"
+
+#include <errno.h>
+
+boolean
+fsysdep_sync (e, zmsg)
+ openfile_t e;
+ const char *zmsg;
+{
+ int o;
+
+#if USE_STDIO
+ if (fflush (e) == EOF)
+ {
+ ulog (LOG_ERROR, "%s: fflush: %s", zmsg, strerror (errno));
+ return FALSE;
+ }
+#endif
+
+#if USE_STDIO
+ o = fileno (e);
+#else
+ o = e;
+#endif
+
+#if FSYNC_ON_CLOSE
+ if (fsync (o) < 0)
+ {
+ ulog (LOG_ERROR, "%s: fsync: %s", zmsg, strerror (errno));
+ return FALSE;
+ }
+#endif
+
+ return TRUE;
+}