[3/3] ntdll: Add support for FILE_APPEND_DATA to NtWriteFile. Take 2.
Dmitry Timoshkov
dmitry at baikal.ru
Wed Oct 2 00:02:19 CDT 2013
Please use this version of the patch, previous implementation was incomplete.
---
dlls/kernel32/tests/file.c | 11 -----------
dlls/ntdll/file.c | 15 ++++++++++++++-
dlls/ntdll/tests/file.c | 7 -------
3 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c
index dc69193..866a29a 100644
--- a/dlls/kernel32/tests/file.c
+++ b/dlls/kernel32/tests/file.c
@@ -3986,17 +3986,6 @@ todo_wine
}
else
{
- /* FIXME: remove once Wine is fixed */
- if (!ret && (td[i].access & FILE_APPEND_DATA))
- {
-todo_wine
- ok(ret, "%d: WriteFile error %d\n", i, GetLastError());
-todo_wine
- ok(bytes == 2, "%d: expected 2, got %u\n", i, bytes);
- CloseHandle(hfile);
- continue;
- }
-
ok(ret, "%d: WriteFile error %d\n", i, GetLastError());
ok(bytes == 2, "%d: expected 2, got %u\n", i, bytes);
}
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 62ae135..a8c25d6 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -952,7 +952,8 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
ULONG total = 0;
enum server_fd_type type;
ULONG_PTR cvalue = apc ? 0 : (ULONG_PTR)apc_user;
- BOOL send_completion = FALSE, async_write;
+ BOOL send_completion = FALSE, async_write, append_write = FALSE;
+ LARGE_INTEGER offset_eof;
TRACE("(%p,%p,%p,%p,%p,%p,0x%08x,%p,%p)!\n",
hFile,hEvent,apc,apc_user,io_status,buffer,length,offset,key);
@@ -961,6 +962,12 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
status = server_get_unix_fd( hFile, FILE_WRITE_DATA, &unix_handle,
&needs_close, &type, &options );
+ if (status == STATUS_ACCESS_DENIED)
+ {
+ status = server_get_unix_fd( hFile, FILE_APPEND_DATA, &unix_handle,
+ &needs_close, &type, &options );
+ append_write = TRUE;
+ }
if (status) return status;
if (!virtual_check_buffer_for_read( buffer, length ))
@@ -979,6 +986,12 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
goto done;
}
+ if (append_write)
+ {
+ offset_eof.QuadPart = (LONGLONG)-1; /* FILE_WRITE_TO_END_OF_FILE */
+ offset = &offset_eof;
+ }
+
if (offset && offset->QuadPart != (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */)
{
off_t off = offset->QuadPart;
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 73b4559..3aa9153 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -882,11 +882,8 @@ static void append_file_test(void)
iosb.Information = -1;
offset.QuadPart = 0;
status = pNtWriteFile(handle, NULL, NULL, NULL, &iosb, text + 3, 3, &offset, NULL);
-todo_wine
ok(status == STATUS_SUCCESS, "NtWriteFile error %#x\n", status);
-todo_wine
ok(iosb.Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", iosb.Status);
-todo_wine
ok(iosb.Information == 3, "expected 3, got %lu\n", iosb.Information);
CloseHandle(handle);
@@ -901,10 +898,8 @@ todo_wine
status = pNtReadFile(handle, 0, NULL, NULL, &iosb, buf, sizeof(buf), &offset, NULL);
ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
ok(iosb.Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", iosb.Status);
-todo_wine
ok(iosb.Information == 6, "expected 6, got %lu\n", iosb.Information);
buf[6] = 0;
-todo_wine
ok(memcmp(buf, text, 6) == 0, "wrong file contents: %s\n", buf);
U(iosb).Status = -1;
@@ -922,10 +917,8 @@ todo_wine
status = pNtReadFile(handle, 0, NULL, NULL, &iosb, buf, sizeof(buf), &offset, NULL);
ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
ok(iosb.Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", iosb.Status);
-todo_wine
ok(iosb.Information == 6, "expected 6, got %lu\n", iosb.Information);
buf[6] = 0;
-todo_wine
ok(memcmp(buf, "barbar", 6) == 0, "wrong file contents: %s\n", buf);
CloseHandle(handle);
--
1.8.3.4
More information about the wine-patches
mailing list