[3/6] ntdll: Make NtWriteFile handle special offset -2 same way as -1.
Dmitry Timoshkov
dmitry at baikal.ru
Fri Sep 6 03:04:40 CDT 2013
---
dlls/ntdll/file.c | 45 +++++++++++++++++++++++++++------------------
1 file changed, 27 insertions(+), 18 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 9d5b02a..68700a3 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -961,36 +961,45 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
if (type == FD_TYPE_FILE)
{
+ LARGE_INTEGER off;
+
if (!(options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT)) && !offset)
{
status = STATUS_INVALID_PARAMETER;
goto done;
}
- if (offset && offset->QuadPart == (LONGLONG)-1 /* FILE_WRITE_TO_END_OF_FILE */)
- offset->QuadPart = lseek( unix_handle, 0, SEEK_END );
+ if (offset)
+ {
+ if (offset->QuadPart == (LONGLONG)-1 /* FILE_WRITE_TO_END_OF_FILE */)
+ offset->QuadPart = lseek( unix_handle, 0, SEEK_END );
+ else if (offset->QuadPart == (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */)
+ offset->QuadPart = lseek( unix_handle, 0, SEEK_CUR );
+ }
+ else
+ {
+ off.QuadPart = lseek( unix_handle, 0, SEEK_CUR );
+ offset = &off;
+ }
- if (offset && offset->QuadPart != (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */)
+ /* async I/O doesn't make sense on regular files */
+ while ((result = pwrite( unix_handle, buffer, length, offset->QuadPart )) == -1)
{
- /* async I/O doesn't make sense on regular files */
- while ((result = pwrite( unix_handle, buffer, length, offset->QuadPart )) == -1)
+ if (errno != EINTR)
{
- if (errno != EINTR)
- {
- if (errno == EFAULT) status = STATUS_INVALID_USER_BUFFER;
- else status = FILE_GetNtStatus();
- goto done;
- }
+ if (errno == EFAULT) status = STATUS_INVALID_USER_BUFFER;
+ else status = FILE_GetNtStatus();
+ goto done;
}
+ }
- if (options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT))
- /* update file pointer position */
- lseek( unix_handle, offset->QuadPart + result, SEEK_SET );
+ if (options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT))
+ /* update file pointer position */
+ lseek( unix_handle, offset->QuadPart + result, SEEK_SET );
- total = result;
- status = STATUS_SUCCESS;
- goto done;
- }
+ total = result;
+ status = STATUS_SUCCESS;
+ goto done;
}
for (;;)
--
1.8.3.4
More information about the wine-patches
mailing list