-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport
O_APPEND
implementation fix (#321)
Ref: ocaml/ocaml#13326
- Loading branch information
Showing
6 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
packages/ocaml-windows32/ocaml-windows32.4.14.1/files/patches/windows-append.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
diff --git a/otherlibs/win32unix/open.c b/otherlibs/win32unix/open.c | ||
index 5a56d92dc5..c324ce0ea2 100644 | ||
--- a/otherlibs/win32unix/open.c | ||
+++ b/otherlibs/win32unix/open.c | ||
@@ -24,7 +24,7 @@ | ||
|
||
static int open_access_flags[15] = { | ||
GENERIC_READ, GENERIC_WRITE, GENERIC_READ|GENERIC_WRITE, | ||
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
+ 0, FILE_APPEND_DATA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
}; | ||
|
||
static int open_create_flags[15] = { | ||
@@ -46,6 +46,7 @@ CAMLprim value unix_open(value path, value flags, value perm) | ||
int fileaccess, createflags, fileattrib, filecreate, sharemode, cloexec; | ||
SECURITY_ATTRIBUTES attr; | ||
HANDLE h; | ||
+ DWORD dwMoved; | ||
wchar_t * wpath; | ||
|
||
caml_unix_check_path(path, "open"); | ||
@@ -87,5 +88,15 @@ CAMLprim value unix_open(value path, value flags, value perm) | ||
win32_maperr(GetLastError()); | ||
uerror("open", path); | ||
} | ||
+ | ||
+ if (fileaccess & FILE_APPEND_DATA) { | ||
+ dwMoved = SetFilePointer(h, 0, NULL, FILE_END); | ||
+ if (dwMoved == INVALID_SET_FILE_POINTER) { | ||
+ win32_maperr(GetLastError()); | ||
+ CloseHandle(h); | ||
+ uerror("open", path); | ||
+ } | ||
+ } | ||
+ | ||
return win_alloc_handle(h); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/ocaml-windows64/ocaml-windows64.4.14.1/files/patches/windows-append.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
diff --git a/otherlibs/win32unix/open.c b/otherlibs/win32unix/open.c | ||
index 5a56d92dc5..c324ce0ea2 100644 | ||
--- a/otherlibs/win32unix/open.c | ||
+++ b/otherlibs/win32unix/open.c | ||
@@ -24,7 +24,7 @@ | ||
|
||
static int open_access_flags[15] = { | ||
GENERIC_READ, GENERIC_WRITE, GENERIC_READ|GENERIC_WRITE, | ||
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
+ 0, FILE_APPEND_DATA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
}; | ||
|
||
static int open_create_flags[15] = { | ||
@@ -46,6 +46,7 @@ CAMLprim value unix_open(value path, value flags, value perm) | ||
int fileaccess, createflags, fileattrib, filecreate, sharemode, cloexec; | ||
SECURITY_ATTRIBUTES attr; | ||
HANDLE h; | ||
+ DWORD dwMoved; | ||
wchar_t * wpath; | ||
|
||
caml_unix_check_path(path, "open"); | ||
@@ -87,5 +88,15 @@ CAMLprim value unix_open(value path, value flags, value perm) | ||
win32_maperr(GetLastError()); | ||
uerror("open", path); | ||
} | ||
+ | ||
+ if (fileaccess & FILE_APPEND_DATA) { | ||
+ dwMoved = SetFilePointer(h, 0, NULL, FILE_END); | ||
+ if (dwMoved == INVALID_SET_FILE_POINTER) { | ||
+ win32_maperr(GetLastError()); | ||
+ CloseHandle(h); | ||
+ uerror("open", path); | ||
+ } | ||
+ } | ||
+ | ||
return win_alloc_handle(h); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/ocaml-windows64/ocaml-windows64.5.1.1/files/patches/windows-append.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
diff --git a/otherlibs/unix/open_win32.c b/otherlibs/unix/open_win32.c | ||
index b4e02aefe9..726080d6b1 100644 | ||
--- a/otherlibs/unix/open_win32.c | ||
+++ b/otherlibs/unix/open_win32.c | ||
@@ -24,7 +24,7 @@ | ||
|
||
static int open_access_flags[15] = { | ||
GENERIC_READ, GENERIC_WRITE, GENERIC_READ|GENERIC_WRITE, | ||
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
+ 0, FILE_APPEND_DATA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
}; | ||
|
||
static int open_create_flags[15] = { | ||
@@ -46,6 +46,7 @@ CAMLprim value caml_unix_open(value path, value flags, value perm) | ||
int fileaccess, createflags, fileattrib, filecreate, sharemode, cloexec; | ||
SECURITY_ATTRIBUTES attr; | ||
HANDLE h; | ||
+ DWORD dwMoved; | ||
wchar_t * wpath; | ||
|
||
caml_unix_check_path(path, "open"); | ||
@@ -87,5 +88,15 @@ CAMLprim value caml_unix_open(value path, value flags, value perm) | ||
caml_win32_maperr(GetLastError()); | ||
caml_uerror("open", path); | ||
} | ||
+ | ||
+ if (fileaccess & FILE_APPEND_DATA) { | ||
+ dwMoved = SetFilePointer(h, 0, NULL, FILE_END); | ||
+ if (dwMoved == INVALID_SET_FILE_POINTER) { | ||
+ caml_win32_maperr(GetLastError()); | ||
+ CloseHandle(h); | ||
+ caml_uerror("open", path); | ||
+ } | ||
+ } | ||
+ | ||
return caml_win32_alloc_handle(h); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters