aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/drivers
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2013-11-29 10:46:36 +0100
committerLukas Larsson <[email protected]>2013-11-29 10:46:36 +0100
commit670150ff9bfdce856c327fb76c30e58039df2cba (patch)
tree575e29d27c2dca7039f5dee0f87d4fc15f2c574f /erts/emulator/drivers
parent423d37395076528866c4b689c0f1e9b72dae58e1 (diff)
parentf47c818746c1df4055b1de8aabf47364f502274c (diff)
downloadotp-670150ff9bfdce856c327fb76c30e58039df2cba.tar.gz
otp-670150ff9bfdce856c327fb76c30e58039df2cba.tar.bz2
otp-670150ff9bfdce856c327fb76c30e58039df2cba.zip
Merge branch 'sv/file-osync/OTP-11498'
* sv/file-osync/OTP-11498: Add sync option to file:open/2 Conflicts: erts/preloaded/ebin/prim_file.beam
Diffstat (limited to 'erts/emulator/drivers')
-rw-r--r--erts/emulator/drivers/common/erl_efile.h1
-rw-r--r--erts/emulator/drivers/unix/unix_efile.c9
-rw-r--r--erts/emulator/drivers/win32/win_efile.c7
3 files changed, 16 insertions, 1 deletions
diff --git a/erts/emulator/drivers/common/erl_efile.h b/erts/emulator/drivers/common/erl_efile.h
index 5387f75efc..95c036db8f 100644
--- a/erts/emulator/drivers/common/erl_efile.h
+++ b/erts/emulator/drivers/common/erl_efile.h
@@ -34,6 +34,7 @@
#define EFILE_COMPRESSED 8
#define EFILE_MODE_EXCL 16
#define EFILE_NO_TRUNCATE 32 /* Special for reopening on VxWorks */
+#define EFILE_MODE_SYNC 64
/*
* Seek modes for efile_seek().
diff --git a/erts/emulator/drivers/unix/unix_efile.c b/erts/emulator/drivers/unix/unix_efile.c
index 55539b44dd..8ffc05da99 100644
--- a/erts/emulator/drivers/unix/unix_efile.c
+++ b/erts/emulator/drivers/unix/unix_efile.c
@@ -405,6 +405,15 @@ efile_openfile(Efile_error* errInfo, /* Where to return error codes. */
mode |= O_EXCL;
}
+ if (flags & EFILE_MODE_SYNC) {
+#ifdef O_SYNC
+ mode |= O_SYNC;
+#else
+ errno = ENOTSUP;
+ return check_error(-1, errInfo);
+#endif
+ }
+
fd = open(name, mode, FILE_MODE);
if (!check_error(fd, errInfo))
diff --git a/erts/emulator/drivers/win32/win_efile.c b/erts/emulator/drivers/win32/win_efile.c
index 319065f57b..d693d7d593 100644
--- a/erts/emulator/drivers/win32/win_efile.c
+++ b/erts/emulator/drivers/win32/win_efile.c
@@ -698,6 +698,7 @@ efile_openfile(Efile_error* errInfo, /* Where to return error codes. */
HANDLE fd; /* Handle to open file. */
DWORD access; /* Access mode: GENERIC_READ, GENERIC_WRITE. */
DWORD crFlags;
+ DWORD flagsAndAttrs = FILE_ATTRIBUTE_NORMAL;
WCHAR *wname = (WCHAR *) name;
switch (flags & (EFILE_MODE_READ|EFILE_MODE_WRITE)) {
@@ -719,6 +720,10 @@ efile_openfile(Efile_error* errInfo, /* Where to return error codes. */
return 0;
}
+ if (flags & EFILE_MODE_SYNC) {
+ flagsAndAttrs = FILE_FLAG_WRITE_THROUGH;
+ }
+
if (flags & EFILE_MODE_APPEND) {
crFlags = OPEN_ALWAYS;
}
@@ -727,7 +732,7 @@ efile_openfile(Efile_error* errInfo, /* Where to return error codes. */
}
fd = CreateFileW(wname, access,
FILE_SHARE_FLAGS,
- NULL, crFlags, FILE_ATTRIBUTE_NORMAL, NULL);
+ NULL, crFlags, flagsAndAttrs, NULL);
/*
* Check for errors.