summaryrefslogtreecommitdiff
path: root/nacl/curvecp/savesync.c
diff options
context:
space:
mode:
Diffstat (limited to 'nacl/curvecp/savesync.c')
-rw-r--r--nacl/curvecp/savesync.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/nacl/curvecp/savesync.c b/nacl/curvecp/savesync.c
new file mode 100644
index 00000000..73074a4b
--- /dev/null
+++ b/nacl/curvecp/savesync.c
@@ -0,0 +1,24 @@
1#include <sys/types.h>
2#include <sys/stat.h>
3#include <fcntl.h>
4#include <unistd.h>
5#include "open.h"
6#include "savesync.h"
7#include "writeall.h"
8
9static int writesync(int fd,const void *x,long long xlen)
10{
11 if (writeall(fd,x,xlen) == -1) return -1;
12 return fsync(fd);
13}
14
15int savesync(const char *fn,const void *x,long long xlen)
16{
17 int fd;
18 int r;
19 fd = open_write(fn);
20 if (fd == -1) return -1;
21 r = writesync(fd,x,xlen);
22 close(fd);
23 return r;
24}