Rob Shearman : ntdll: The FileMailslotSetInformation and FileCompletionInformation cases of NtSetInformationFile don 't need the fd.
Alexandre Julliard
julliard at winehq.org
Tue Feb 5 06:34:20 CST 2008
Module: wine
Branch: master
Commit: e70848ed01496dc16ca92b51f15346b8423b64f0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e70848ed01496dc16ca92b51f15346b8423b64f0
Author: Rob Shearman <rob at codeweavers.com>
Date: Mon Feb 4 20:18:27 2008 +0000
ntdll: The FileMailslotSetInformation and FileCompletionInformation cases of NtSetInformationFile don't need the fd.
So don't do an extra server call to get the fd to avoid a performance
penalty and to make these cases work when an fd isn't available.
---
dlls/ntdll/file.c | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 5a99616..843f3f0 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -1578,9 +1578,6 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
TRACE("(%p,%p,%p,0x%08x,0x%08x)\n", handle, io, ptr, len, class);
- if ((io->u.Status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL )))
- return io->u.Status;
-
io->u.Status = STATUS_SUCCESS;
switch (class)
{
@@ -1590,6 +1587,9 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
struct stat st;
const FILE_BASIC_INFORMATION *info = ptr;
+ if ((io->u.Status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL )))
+ return io->u.Status;
+
if (info->LastAccessTime.QuadPart || info->LastWriteTime.QuadPart)
{
ULONGLONG sec, nsec;
@@ -1641,6 +1641,8 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
if (fchmod( fd, st.st_mode ) == -1) io->u.Status = FILE_GetNtStatus();
}
}
+
+ if (needs_close) close( fd );
}
else io->u.Status = STATUS_INVALID_PARAMETER_3;
break;
@@ -1650,8 +1652,13 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
{
const FILE_POSITION_INFORMATION *info = ptr;
+ if ((io->u.Status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL )))
+ return io->u.Status;
+
if (lseek( fd, info->CurrentByteOffset.QuadPart, SEEK_SET ) == (off_t)-1)
io->u.Status = FILE_GetNtStatus();
+
+ if (needs_close) close( fd );
}
else io->u.Status = STATUS_INVALID_PARAMETER_3;
break;
@@ -1662,6 +1669,9 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
struct stat st;
const FILE_END_OF_FILE_INFORMATION *info = ptr;
+ if ((io->u.Status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL )))
+ return io->u.Status;
+
/* first try normal truncate */
if (ftruncate( fd, (off_t)info->EndOfFile.QuadPart ) != -1) break;
@@ -1676,6 +1686,8 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
ftruncate( fd, (off_t)info->EndOfFile.QuadPart ) != -1) break;
}
io->u.Status = FILE_GetNtStatus();
+
+ if (needs_close) close( fd );
}
else io->u.Status = STATUS_INVALID_PARAMETER_3;
break;
@@ -1717,7 +1729,6 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
io->u.Status = STATUS_NOT_IMPLEMENTED;
break;
}
- if (needs_close) close( fd );
io->Information = 0;
return io->u.Status;
}
More information about the wine-cvs
mailing list