Commit e70848ed authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

ntdll: The FileMailslotSetInformation and FileCompletionInformation cases of…

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.
parent ffc251f5
...@@ -1578,9 +1578,6 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io, ...@@ -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); 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; io->u.Status = STATUS_SUCCESS;
switch (class) switch (class)
{ {
...@@ -1590,6 +1587,9 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io, ...@@ -1590,6 +1587,9 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
struct stat st; struct stat st;
const FILE_BASIC_INFORMATION *info = ptr; 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) if (info->LastAccessTime.QuadPart || info->LastWriteTime.QuadPart)
{ {
ULONGLONG sec, nsec; ULONGLONG sec, nsec;
...@@ -1641,6 +1641,8 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io, ...@@ -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 (fchmod( fd, st.st_mode ) == -1) io->u.Status = FILE_GetNtStatus();
} }
} }
if (needs_close) close( fd );
} }
else io->u.Status = STATUS_INVALID_PARAMETER_3; else io->u.Status = STATUS_INVALID_PARAMETER_3;
break; break;
...@@ -1650,8 +1652,13 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io, ...@@ -1650,8 +1652,13 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
{ {
const FILE_POSITION_INFORMATION *info = ptr; 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) if (lseek( fd, info->CurrentByteOffset.QuadPart, SEEK_SET ) == (off_t)-1)
io->u.Status = FILE_GetNtStatus(); io->u.Status = FILE_GetNtStatus();
if (needs_close) close( fd );
} }
else io->u.Status = STATUS_INVALID_PARAMETER_3; else io->u.Status = STATUS_INVALID_PARAMETER_3;
break; break;
...@@ -1662,6 +1669,9 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io, ...@@ -1662,6 +1669,9 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
struct stat st; struct stat st;
const FILE_END_OF_FILE_INFORMATION *info = ptr; 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 */ /* first try normal truncate */
if (ftruncate( fd, (off_t)info->EndOfFile.QuadPart ) != -1) break; if (ftruncate( fd, (off_t)info->EndOfFile.QuadPart ) != -1) break;
...@@ -1676,6 +1686,8 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io, ...@@ -1676,6 +1686,8 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
ftruncate( fd, (off_t)info->EndOfFile.QuadPart ) != -1) break; ftruncate( fd, (off_t)info->EndOfFile.QuadPart ) != -1) break;
} }
io->u.Status = FILE_GetNtStatus(); io->u.Status = FILE_GetNtStatus();
if (needs_close) close( fd );
} }
else io->u.Status = STATUS_INVALID_PARAMETER_3; else io->u.Status = STATUS_INVALID_PARAMETER_3;
break; break;
...@@ -1717,7 +1729,6 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io, ...@@ -1717,7 +1729,6 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
io->u.Status = STATUS_NOT_IMPLEMENTED; io->u.Status = STATUS_NOT_IMPLEMENTED;
break; break;
} }
if (needs_close) close( fd );
io->Information = 0; io->Information = 0;
return io->u.Status; return io->u.Status;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment