2002-03-10 00:29:33 +01:00
|
|
|
/*
|
|
|
|
* Copyright 1999, 2000 Juergen Schmied
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2002-06-14 02:36:20 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2002-06-14 02:36:20 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
2003-06-26 04:08:17 +02:00
|
|
|
#include <assert.h>
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2002-06-14 02:36:20 +02:00
|
|
|
#ifdef HAVE_SYS_ERRNO_H
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#endif
|
2004-04-07 05:58:55 +02:00
|
|
|
#ifdef HAVE_LINUX_MAJOR_H
|
|
|
|
# include <linux/major.h>
|
|
|
|
#endif
|
2004-04-06 06:19:41 +02:00
|
|
|
#ifdef HAVE_SYS_STATVFS_H
|
|
|
|
# include <sys/statvfs.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
|
|
# include <sys/param.h>
|
|
|
|
#endif
|
|
|
|
#ifdef STATFS_DEFINED_BY_SYS_VFS
|
|
|
|
# include <sys/vfs.h>
|
|
|
|
#else
|
|
|
|
# ifdef STATFS_DEFINED_BY_SYS_MOUNT
|
|
|
|
# include <sys/mount.h>
|
|
|
|
# else
|
|
|
|
# ifdef STATFS_DEFINED_BY_SYS_STATFS
|
|
|
|
# include <sys/statfs.h>
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
#endif
|
2003-01-07 21:36:20 +01:00
|
|
|
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2002-08-27 03:13:58 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2002-06-14 02:36:20 +02:00
|
|
|
#include "wine/server.h"
|
2003-06-26 04:08:17 +02:00
|
|
|
#include "async.h"
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
#include "ntdll_misc.h"
|
1999-03-09 18:47:51 +01:00
|
|
|
|
2002-09-13 00:07:02 +02:00
|
|
|
#include "winternl.h"
|
2002-05-09 21:40:30 +02:00
|
|
|
#include "winioctl.h"
|
1999-03-09 18:47:51 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtOpenFile [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwOpenFile [NTDLL.@]
|
2003-07-19 00:55:28 +02:00
|
|
|
*
|
|
|
|
* Open a file.
|
|
|
|
*
|
|
|
|
* PARAMS
|
2004-04-13 01:31:09 +02:00
|
|
|
* handle [O] Variable that receives the file handle on return
|
|
|
|
* access [I] Access desired by the caller to the file
|
|
|
|
* attr [I] Structue describing the file to be opened
|
|
|
|
* io [O] Receives details about the result of the operation
|
|
|
|
* sharing [I] Type of shared access the caller requires
|
|
|
|
* options [I] Options for the file open
|
2003-07-19 00:55:28 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: 0. FileHandle and IoStatusBlock are updated.
|
|
|
|
* Failure: An NTSTATUS error code describing the error.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2004-04-13 01:31:09 +02:00
|
|
|
NTSTATUS WINAPI NtOpenFile( PHANDLE handle, ACCESS_MASK access,
|
|
|
|
POBJECT_ATTRIBUTES attr, PIO_STATUS_BLOCK io,
|
|
|
|
ULONG sharing, ULONG options )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2004-04-13 01:31:09 +02:00
|
|
|
return NtCreateFile( handle, access, attr, io, NULL, 0,
|
|
|
|
sharing, FILE_OPEN, options, NULL, 0 );
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtCreateFile [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwCreateFile [NTDLL.@]
|
2003-07-19 00:55:28 +02:00
|
|
|
*
|
|
|
|
* Either create a new file or directory, or open an existing file, device,
|
|
|
|
* directory or volume.
|
|
|
|
*
|
|
|
|
* PARAMS
|
2004-04-13 01:31:09 +02:00
|
|
|
* handle [O] Points to a variable which receives the file handle on return
|
|
|
|
* access [I] Desired access to the file
|
|
|
|
* attr [I] Structure describing the file
|
|
|
|
* io [O] Receives information about the operation on return
|
|
|
|
* alloc_size [I] Initial size of the file in bytes
|
|
|
|
* attributes [I] Attributes to create the file with
|
|
|
|
* sharing [I] Type of shared access the caller would like to the file
|
|
|
|
* disposition [I] Specifies what to do, depending on whether the file already exists
|
|
|
|
* options [I] Options for creating a new file
|
|
|
|
* ea_buffer [I] Undocumented
|
|
|
|
* ea_length [I] Undocumented
|
2003-07-19 00:55:28 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2004-04-13 01:31:09 +02:00
|
|
|
* Success: 0. handle and io are updated.
|
2003-07-19 00:55:28 +02:00
|
|
|
* Failure: An NTSTATUS error code describing the error.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2004-04-13 01:31:09 +02:00
|
|
|
NTSTATUS WINAPI NtCreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATTRIBUTES attr,
|
|
|
|
PIO_STATUS_BLOCK io, PLARGE_INTEGER alloc_size,
|
|
|
|
ULONG attributes, ULONG sharing, ULONG disposition,
|
|
|
|
ULONG options, PVOID ea_buffer, ULONG ea_length )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2004-04-13 01:31:09 +02:00
|
|
|
ANSI_STRING unix_name;
|
|
|
|
|
|
|
|
TRACE("handle=%p access=%08lx name=%s objattr=%08lx root=%p sec=%p io=%p alloc_size=%p\n"
|
|
|
|
"attr=%08lx sharing=%08lx disp=%ld options=%08lx ea=%p.0x%08lx\n",
|
|
|
|
handle, access, debugstr_us(attr->ObjectName), attr->Attributes,
|
|
|
|
attr->RootDirectory, attr->SecurityDescriptor, io, alloc_size,
|
|
|
|
attributes, sharing, disposition, options, ea_buffer, ea_length );
|
|
|
|
|
|
|
|
if (attr->RootDirectory)
|
|
|
|
{
|
|
|
|
FIXME( "RootDirectory %p not supported\n", attr->RootDirectory );
|
|
|
|
return STATUS_OBJECT_NAME_NOT_FOUND;
|
|
|
|
}
|
|
|
|
if (alloc_size) FIXME( "alloc_size not supported\n" );
|
|
|
|
|
|
|
|
if (!(io->u.Status = DIR_nt_to_unix( attr->ObjectName, &unix_name,
|
|
|
|
(disposition == FILE_OPEN || disposition == FILE_OVERWRITE),
|
|
|
|
!(attr->Attributes & OBJ_CASE_INSENSITIVE) )))
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( create_file )
|
|
|
|
{
|
|
|
|
req->access = access;
|
|
|
|
req->inherit = (attr->Attributes & OBJ_INHERIT) != 0;
|
|
|
|
req->sharing = sharing;
|
|
|
|
req->create = disposition;
|
|
|
|
req->options = options;
|
|
|
|
req->attrs = attributes;
|
|
|
|
wine_server_add_data( req, unix_name.Buffer, unix_name.Length );
|
|
|
|
io->u.Status = wine_server_call( req );
|
|
|
|
*handle = reply->handle;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
RtlFreeAnsiString( &unix_name );
|
|
|
|
}
|
|
|
|
else WARN("%s not found (%lx)\n", debugstr_us(attr->ObjectName), io->u.Status );
|
|
|
|
return io->u.Status;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
2003-06-26 04:08:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* Asynchronous file I/O *
|
|
|
|
*/
|
|
|
|
static DWORD fileio_get_async_count(const async_private *ovp);
|
|
|
|
static void CALLBACK fileio_call_completion_func(ULONG_PTR data);
|
|
|
|
static void fileio_async_cleanup(async_private *ovp);
|
|
|
|
|
|
|
|
static async_ops fileio_async_ops =
|
|
|
|
{
|
|
|
|
fileio_get_async_count, /* get_count */
|
|
|
|
fileio_call_completion_func, /* call_completion */
|
|
|
|
fileio_async_cleanup /* cleanup */
|
|
|
|
};
|
|
|
|
|
|
|
|
static async_ops fileio_nocomp_async_ops =
|
|
|
|
{
|
|
|
|
fileio_get_async_count, /* get_count */
|
|
|
|
NULL, /* call_completion */
|
|
|
|
fileio_async_cleanup /* cleanup */
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct async_fileio
|
|
|
|
{
|
|
|
|
struct async_private async;
|
|
|
|
PIO_APC_ROUTINE apc;
|
|
|
|
void* apc_user;
|
|
|
|
char *buffer;
|
|
|
|
unsigned int count;
|
|
|
|
unsigned long offset;
|
|
|
|
enum fd_type fd_type;
|
|
|
|
} async_fileio;
|
|
|
|
|
|
|
|
static DWORD fileio_get_async_count(const struct async_private *ovp)
|
|
|
|
{
|
|
|
|
async_fileio *fileio = (async_fileio*) ovp;
|
|
|
|
|
|
|
|
if (fileio->count < fileio->async.iosb->Information)
|
|
|
|
return 0;
|
|
|
|
return fileio->count - fileio->async.iosb->Information;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CALLBACK fileio_call_completion_func(ULONG_PTR data)
|
|
|
|
{
|
|
|
|
async_fileio *ovp = (async_fileio*) data;
|
|
|
|
TRACE("data: %p\n", ovp);
|
|
|
|
|
|
|
|
ovp->apc( ovp->apc_user, ovp->async.iosb, ovp->async.iosb->Information );
|
|
|
|
|
|
|
|
fileio_async_cleanup( &ovp->async );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fileio_async_cleanup( struct async_private *ovp )
|
|
|
|
{
|
2004-03-12 02:59:35 +01:00
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, ovp );
|
2003-06-26 04:08:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILE_GetNtStatus(void)
|
|
|
|
*
|
|
|
|
* Retrieve the Nt Status code from errno.
|
|
|
|
* Try to be consistent with FILE_SetDosError().
|
|
|
|
*/
|
2004-03-16 02:32:02 +01:00
|
|
|
NTSTATUS FILE_GetNtStatus(void)
|
2003-06-26 04:08:17 +02:00
|
|
|
{
|
|
|
|
int err = errno;
|
|
|
|
DWORD nt;
|
|
|
|
|
|
|
|
TRACE( "errno = %d\n", errno );
|
|
|
|
switch (err)
|
|
|
|
{
|
|
|
|
case EAGAIN: nt = STATUS_SHARING_VIOLATION; break;
|
|
|
|
case EBADF: nt = STATUS_INVALID_HANDLE; break;
|
|
|
|
case ENOSPC: nt = STATUS_DISK_FULL; break;
|
|
|
|
case EPERM:
|
|
|
|
case EROFS:
|
|
|
|
case EACCES: nt = STATUS_ACCESS_DENIED; break;
|
2004-04-13 01:31:09 +02:00
|
|
|
case ENOENT: nt = STATUS_OBJECT_NAME_NOT_FOUND; break;
|
2003-06-26 04:08:17 +02:00
|
|
|
case EISDIR: nt = STATUS_FILE_IS_A_DIRECTORY; break;
|
|
|
|
case EMFILE:
|
|
|
|
case ENFILE: nt = STATUS_NO_MORE_FILES; break;
|
|
|
|
case EINVAL:
|
|
|
|
case ENOTEMPTY: nt = STATUS_DIRECTORY_NOT_EMPTY; break;
|
|
|
|
case EPIPE: nt = STATUS_PIPE_BROKEN; break;
|
2004-03-09 02:03:03 +01:00
|
|
|
case EIO: nt = STATUS_DEVICE_NOT_READY; break;
|
2003-06-26 04:08:17 +02:00
|
|
|
case ENOEXEC: /* ?? */
|
|
|
|
case ESPIPE: /* ?? */
|
|
|
|
case EEXIST: /* ?? */
|
|
|
|
default:
|
|
|
|
FIXME( "Converting errno %d to STATUS_UNSUCCESSFUL\n", err );
|
|
|
|
nt = STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
return nt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILE_AsyncReadService (INTERNAL)
|
|
|
|
*
|
|
|
|
* This function is called while the client is waiting on the
|
|
|
|
* server, so we can't make any server calls here.
|
|
|
|
*/
|
|
|
|
static void FILE_AsyncReadService(async_private *ovp)
|
2002-06-14 02:36:20 +02:00
|
|
|
{
|
2003-06-26 04:08:17 +02:00
|
|
|
async_fileio *fileio = (async_fileio*) ovp;
|
|
|
|
IO_STATUS_BLOCK* io_status = fileio->async.iosb;
|
|
|
|
int result;
|
|
|
|
int already = io_status->Information;
|
|
|
|
|
|
|
|
TRACE("%p %p\n", io_status, fileio->buffer );
|
|
|
|
|
|
|
|
/* check to see if the data is ready (non-blocking) */
|
|
|
|
|
|
|
|
if ( fileio->fd_type == FD_TYPE_SOCKET )
|
|
|
|
result = read(ovp->fd, &fileio->buffer[already], fileio->count - already);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = pread(ovp->fd, &fileio->buffer[already], fileio->count - already,
|
|
|
|
fileio->offset + already);
|
|
|
|
if ((result < 0) && (errno == ESPIPE))
|
|
|
|
result = read(ovp->fd, &fileio->buffer[already], fileio->count - already);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((result < 0) && ((errno == EAGAIN) || (errno == EINTR)))
|
|
|
|
{
|
|
|
|
TRACE("Deferred read %d\n",errno);
|
|
|
|
io_status->u.Status = STATUS_PENDING;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check to see if the transfer is complete */
|
|
|
|
if (result < 0)
|
2002-06-14 02:36:20 +02:00
|
|
|
{
|
2003-06-26 04:08:17 +02:00
|
|
|
io_status->u.Status = FILE_GetNtStatus();
|
|
|
|
return;
|
2002-06-14 02:36:20 +02:00
|
|
|
}
|
2003-06-26 04:08:17 +02:00
|
|
|
else if (result == 0)
|
|
|
|
{
|
|
|
|
io_status->u.Status = io_status->Information ? STATUS_SUCCESS : STATUS_END_OF_FILE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
io_status->Information += result;
|
|
|
|
if (io_status->Information >= fileio->count || fileio->fd_type == FD_TYPE_SOCKET )
|
|
|
|
io_status->u.Status = STATUS_SUCCESS;
|
|
|
|
else
|
|
|
|
io_status->u.Status = STATUS_PENDING;
|
|
|
|
|
|
|
|
TRACE("read %d more bytes %ld/%d so far\n",
|
|
|
|
result, io_status->Information, fileio->count);
|
2002-06-14 02:36:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtReadFile [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwReadFile [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*
|
2003-07-19 00:55:28 +02:00
|
|
|
* Read from an open file handle.
|
2002-06-14 02:36:20 +02:00
|
|
|
*
|
2003-07-19 00:55:28 +02:00
|
|
|
* PARAMS
|
|
|
|
* FileHandle [I] Handle returned from ZwOpenFile() or ZwCreateFile()
|
|
|
|
* Event [I] Event to signal upon completion (or NULL)
|
|
|
|
* ApcRoutine [I] Callback to call upon completion (or NULL)
|
|
|
|
* ApcContext [I] Context for ApcRoutine (or NULL)
|
|
|
|
* IoStatusBlock [O] Receives information about the operation on return
|
|
|
|
* Buffer [O] Destination for the data read
|
|
|
|
* Length [I] Size of Buffer
|
|
|
|
* ByteOffset [O] Destination for the new file pointer position (or NULL)
|
|
|
|
* Key [O] Function unknown (may be NULL)
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: 0. IoStatusBlock is updated, and the Information member contains
|
|
|
|
* The number of bytes read.
|
|
|
|
* Failure: An NTSTATUS error code describing the error.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2003-07-19 00:55:28 +02:00
|
|
|
NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
|
|
|
|
PIO_APC_ROUTINE apc, void* apc_user,
|
2003-06-26 04:08:17 +02:00
|
|
|
PIO_STATUS_BLOCK io_status, void* buffer, ULONG length,
|
|
|
|
PLARGE_INTEGER offset, PULONG key)
|
2002-06-14 02:36:20 +02:00
|
|
|
{
|
2003-06-26 04:08:17 +02:00
|
|
|
int unix_handle, flags;
|
|
|
|
enum fd_type type;
|
|
|
|
|
|
|
|
TRACE("(%p,%p,%p,%p,%p,%p,0x%08lx,%p,%p),partial stub!\n",
|
|
|
|
hFile,hEvent,apc,apc_user,io_status,buffer,length,offset,key);
|
|
|
|
|
|
|
|
io_status->Information = 0;
|
2003-12-02 00:01:12 +01:00
|
|
|
io_status->u.Status = wine_server_handle_to_fd( hFile, GENERIC_READ, &unix_handle, &type, &flags );
|
2003-06-26 04:08:17 +02:00
|
|
|
if (io_status->u.Status) return io_status->u.Status;
|
|
|
|
|
2003-12-02 00:01:12 +01:00
|
|
|
if (flags & FD_FLAG_RECV_SHUTDOWN)
|
|
|
|
{
|
|
|
|
wine_server_release_fd( hFile, unix_handle );
|
|
|
|
return STATUS_PIPE_DISCONNECTED;
|
|
|
|
}
|
|
|
|
|
2003-06-26 04:08:17 +02:00
|
|
|
if (flags & FD_FLAG_TIMEOUT)
|
|
|
|
{
|
|
|
|
if (hEvent)
|
|
|
|
{
|
|
|
|
/* this shouldn't happen, but check it */
|
|
|
|
FIXME("NIY-hEvent\n");
|
2003-12-02 00:01:12 +01:00
|
|
|
wine_server_release_fd( hFile, unix_handle );
|
2003-06-26 04:08:17 +02:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
io_status->u.Status = NtCreateEvent(&hEvent, SYNCHRONIZE, NULL, 0, 0);
|
2003-12-02 00:01:12 +01:00
|
|
|
if (io_status->u.Status)
|
|
|
|
{
|
|
|
|
wine_server_release_fd( hFile, unix_handle );
|
|
|
|
return io_status->u.Status;
|
|
|
|
}
|
2003-06-26 04:08:17 +02:00
|
|
|
}
|
2003-07-19 00:55:28 +02:00
|
|
|
|
2003-06-26 04:08:17 +02:00
|
|
|
if (flags & (FD_FLAG_OVERLAPPED|FD_FLAG_TIMEOUT))
|
|
|
|
{
|
|
|
|
async_fileio* ovp;
|
2003-07-11 23:44:17 +02:00
|
|
|
NTSTATUS ret;
|
2003-06-26 04:08:17 +02:00
|
|
|
|
2004-03-12 02:59:35 +01:00
|
|
|
if (!(ovp = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(async_fileio))))
|
2003-12-02 00:01:12 +01:00
|
|
|
{
|
|
|
|
wine_server_release_fd( hFile, unix_handle );
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
2003-06-26 04:08:17 +02:00
|
|
|
ovp->async.ops = (apc ? &fileio_async_ops : &fileio_nocomp_async_ops );
|
|
|
|
ovp->async.handle = hFile;
|
2003-12-02 00:01:12 +01:00
|
|
|
ovp->async.fd = unix_handle; /* FIXME */
|
2003-06-26 04:08:17 +02:00
|
|
|
ovp->async.type = ASYNC_TYPE_READ;
|
|
|
|
ovp->async.func = FILE_AsyncReadService;
|
|
|
|
ovp->async.event = hEvent;
|
|
|
|
ovp->async.iosb = io_status;
|
|
|
|
ovp->count = length;
|
2003-11-11 22:57:07 +01:00
|
|
|
if ( offset == NULL )
|
|
|
|
ovp->offset = 0;
|
|
|
|
else
|
|
|
|
{
|
2004-01-23 02:51:33 +01:00
|
|
|
ovp->offset = offset->u.LowPart;
|
|
|
|
if (offset->u.HighPart) FIXME("NIY-high part\n");
|
2003-11-11 22:57:07 +01:00
|
|
|
}
|
2003-06-26 04:08:17 +02:00
|
|
|
ovp->apc = apc;
|
|
|
|
ovp->apc_user = apc_user;
|
|
|
|
ovp->buffer = buffer;
|
|
|
|
ovp->fd_type = type;
|
|
|
|
|
|
|
|
io_status->Information = 0;
|
2003-07-11 23:44:17 +02:00
|
|
|
ret = register_new_async(&ovp->async);
|
|
|
|
if (ret != STATUS_SUCCESS)
|
|
|
|
return ret;
|
2003-08-18 21:45:53 +02:00
|
|
|
if (flags & FD_FLAG_TIMEOUT)
|
|
|
|
{
|
|
|
|
NtWaitForSingleObject(hEvent, TRUE, NULL);
|
|
|
|
NtClose(hEvent);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LARGE_INTEGER timeout;
|
|
|
|
|
|
|
|
/* let some APC be run, this will read some already pending data */
|
2004-01-23 02:51:33 +01:00
|
|
|
timeout.u.LowPart = timeout.u.HighPart = 0;
|
2003-08-18 21:45:53 +02:00
|
|
|
NtDelayExecution( TRUE, &timeout );
|
|
|
|
}
|
2003-06-26 04:08:17 +02:00
|
|
|
return io_status->u.Status;
|
|
|
|
}
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case FD_TYPE_SMB:
|
|
|
|
FIXME("NIY-SMB\n");
|
2003-10-08 05:51:31 +02:00
|
|
|
/* FIXME */
|
2003-12-02 00:01:12 +01:00
|
|
|
/* return SMB_ReadFile(hFile, unix_handle, buffer, length, io_status); */
|
|
|
|
wine_server_release_fd( hFile, unix_handle );
|
2003-10-08 05:51:31 +02:00
|
|
|
return STATUS_INVALID_HANDLE;
|
2003-06-26 04:08:17 +02:00
|
|
|
|
|
|
|
case FD_TYPE_DEFAULT:
|
2003-12-02 00:01:12 +01:00
|
|
|
/* normal unix file */
|
2003-06-26 04:08:17 +02:00
|
|
|
break;
|
2002-06-14 02:36:20 +02:00
|
|
|
|
2003-06-26 04:08:17 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unsupported type of fd %d\n", type);
|
2003-12-02 00:01:12 +01:00
|
|
|
wine_server_release_fd( hFile, unix_handle );
|
2003-06-26 04:08:17 +02:00
|
|
|
return STATUS_INVALID_HANDLE;
|
|
|
|
}
|
2002-06-14 02:36:20 +02:00
|
|
|
|
2003-06-26 04:08:17 +02:00
|
|
|
if (offset)
|
|
|
|
{
|
|
|
|
FILE_POSITION_INFORMATION fpi;
|
2002-06-14 02:36:20 +02:00
|
|
|
|
2003-06-26 04:08:17 +02:00
|
|
|
fpi.CurrentByteOffset = *offset;
|
|
|
|
io_status->u.Status = NtSetInformationFile(hFile, io_status, &fpi, sizeof(fpi),
|
|
|
|
FilePositionInformation);
|
|
|
|
if (io_status->u.Status)
|
|
|
|
{
|
2003-12-02 00:01:12 +01:00
|
|
|
wine_server_release_fd( hFile, unix_handle );
|
2003-06-26 04:08:17 +02:00
|
|
|
return io_status->u.Status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* code for synchronous reads */
|
|
|
|
while ((io_status->Information = read( unix_handle, buffer, length )) == -1)
|
|
|
|
{
|
|
|
|
if ((errno == EAGAIN) || (errno == EINTR)) continue;
|
|
|
|
if (errno == EFAULT) FIXME( "EFAULT handling broken for now\n" );
|
|
|
|
io_status->u.Status = FILE_GetNtStatus();
|
|
|
|
break;
|
|
|
|
}
|
2003-12-02 00:01:12 +01:00
|
|
|
wine_server_release_fd( hFile, unix_handle );
|
2003-06-26 04:08:17 +02:00
|
|
|
return io_status->u.Status;
|
|
|
|
}
|
2002-06-14 02:36:20 +02:00
|
|
|
|
2003-06-26 04:08:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FILE_AsyncWriteService (INTERNAL)
|
|
|
|
*
|
|
|
|
* This function is called while the client is waiting on the
|
|
|
|
* server, so we can't make any server calls here.
|
|
|
|
*/
|
|
|
|
static void FILE_AsyncWriteService(struct async_private *ovp)
|
|
|
|
{
|
|
|
|
async_fileio *fileio = (async_fileio *) ovp;
|
|
|
|
PIO_STATUS_BLOCK io_status = fileio->async.iosb;
|
|
|
|
int result;
|
|
|
|
int already = io_status->Information;
|
2002-06-14 02:36:20 +02:00
|
|
|
|
2003-06-26 04:08:17 +02:00
|
|
|
TRACE("(%p %p)\n",io_status,fileio->buffer);
|
2002-06-14 02:36:20 +02:00
|
|
|
|
2003-06-26 04:08:17 +02:00
|
|
|
/* write some data (non-blocking) */
|
2002-06-14 02:36:20 +02:00
|
|
|
|
2003-06-26 04:08:17 +02:00
|
|
|
if ( fileio->fd_type == FD_TYPE_SOCKET )
|
|
|
|
result = write(ovp->fd, &fileio->buffer[already], fileio->count - already);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = pwrite(ovp->fd, &fileio->buffer[already], fileio->count - already,
|
|
|
|
fileio->offset + already);
|
|
|
|
if ((result < 0) && (errno == ESPIPE))
|
|
|
|
result = write(ovp->fd, &fileio->buffer[already], fileio->count - already);
|
|
|
|
}
|
2002-06-14 02:36:20 +02:00
|
|
|
|
2003-06-26 04:08:17 +02:00
|
|
|
if ((result < 0) && ((errno == EAGAIN) || (errno == EINTR)))
|
|
|
|
{
|
|
|
|
io_status->u.Status = STATUS_PENDING;
|
|
|
|
return;
|
|
|
|
}
|
2002-06-14 02:36:20 +02:00
|
|
|
|
2003-06-26 04:08:17 +02:00
|
|
|
/* check to see if the transfer is complete */
|
|
|
|
if (result < 0)
|
|
|
|
{
|
|
|
|
io_status->u.Status = FILE_GetNtStatus();
|
|
|
|
return;
|
|
|
|
}
|
2002-06-14 02:36:20 +02:00
|
|
|
|
2003-06-26 04:08:17 +02:00
|
|
|
io_status->Information += result;
|
|
|
|
io_status->u.Status = (io_status->Information < fileio->count) ? STATUS_PENDING : STATUS_SUCCESS;
|
|
|
|
TRACE("wrote %d more bytes %ld/%d so far\n",result,io_status->Information,fileio->count);
|
2002-06-14 02:36:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtWriteFile [NTDLL.@]
|
|
|
|
* ZwWriteFile [NTDLL.@]
|
|
|
|
*
|
2003-07-19 00:55:28 +02:00
|
|
|
* Write to an open file handle.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* FileHandle [I] Handle returned from ZwOpenFile() or ZwCreateFile()
|
|
|
|
* Event [I] Event to signal upon completion (or NULL)
|
|
|
|
* ApcRoutine [I] Callback to call upon completion (or NULL)
|
|
|
|
* ApcContext [I] Context for ApcRoutine (or NULL)
|
|
|
|
* IoStatusBlock [O] Receives information about the operation on return
|
|
|
|
* Buffer [I] Source for the data to write
|
|
|
|
* Length [I] Size of Buffer
|
|
|
|
* ByteOffset [O] Destination for the new file pointer position (or NULL)
|
|
|
|
* Key [O] Function unknown (may be NULL)
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: 0. IoStatusBlock is updated, and the Information member contains
|
|
|
|
* The number of bytes written.
|
|
|
|
* Failure: An NTSTATUS error code describing the error.
|
2002-06-14 02:36:20 +02:00
|
|
|
*/
|
2003-06-26 04:08:17 +02:00
|
|
|
NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
|
|
|
|
PIO_APC_ROUTINE apc, void* apc_user,
|
|
|
|
PIO_STATUS_BLOCK io_status,
|
|
|
|
const void* buffer, ULONG length,
|
|
|
|
PLARGE_INTEGER offset, PULONG key)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2003-06-26 04:08:17 +02:00
|
|
|
int unix_handle, flags;
|
|
|
|
enum fd_type type;
|
|
|
|
|
|
|
|
TRACE("(%p,%p,%p,%p,%p,%p,0x%08lx,%p,%p)!\n",
|
|
|
|
hFile,hEvent,apc,apc_user,io_status,buffer,length,offset,key);
|
|
|
|
|
|
|
|
TRACE("(%p,%p,%p,%p,%p,%p,0x%08lx,%p,%p),partial stub!\n",
|
|
|
|
hFile,hEvent,apc,apc_user,io_status,buffer,length,offset,key);
|
|
|
|
|
|
|
|
io_status->Information = 0;
|
2003-12-02 00:01:12 +01:00
|
|
|
io_status->u.Status = wine_server_handle_to_fd( hFile, GENERIC_WRITE, &unix_handle, &type, &flags );
|
2003-06-26 04:08:17 +02:00
|
|
|
if (io_status->u.Status) return io_status->u.Status;
|
|
|
|
|
2003-12-02 00:01:12 +01:00
|
|
|
if (flags & FD_FLAG_SEND_SHUTDOWN)
|
|
|
|
{
|
|
|
|
wine_server_release_fd( hFile, unix_handle );
|
|
|
|
return STATUS_PIPE_DISCONNECTED;
|
|
|
|
}
|
|
|
|
|
2003-06-26 04:08:17 +02:00
|
|
|
if (flags & (FD_FLAG_OVERLAPPED|FD_FLAG_TIMEOUT))
|
|
|
|
{
|
|
|
|
async_fileio* ovp;
|
2003-07-11 23:44:17 +02:00
|
|
|
NTSTATUS ret;
|
2003-06-26 04:08:17 +02:00
|
|
|
|
2004-03-12 02:59:35 +01:00
|
|
|
if (!(ovp = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(async_fileio))))
|
2003-12-02 00:01:12 +01:00
|
|
|
{
|
|
|
|
wine_server_release_fd( hFile, unix_handle );
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
2003-06-26 04:08:17 +02:00
|
|
|
ovp->async.ops = (apc ? &fileio_async_ops : &fileio_nocomp_async_ops );
|
|
|
|
ovp->async.handle = hFile;
|
2003-12-02 00:01:12 +01:00
|
|
|
ovp->async.fd = unix_handle; /* FIXME */
|
2003-06-26 04:08:17 +02:00
|
|
|
ovp->async.type = ASYNC_TYPE_WRITE;
|
|
|
|
ovp->async.func = FILE_AsyncWriteService;
|
|
|
|
ovp->async.event = hEvent;
|
|
|
|
ovp->async.iosb = io_status;
|
|
|
|
ovp->count = length;
|
2004-01-09 21:09:08 +01:00
|
|
|
if (offset) {
|
2004-01-23 02:51:33 +01:00
|
|
|
ovp->offset = offset->u.LowPart;
|
|
|
|
if (offset->u.HighPart) FIXME("NIY-high part\n");
|
2004-01-09 21:09:08 +01:00
|
|
|
} else {
|
|
|
|
ovp->offset = 0;
|
|
|
|
}
|
2003-06-26 04:08:17 +02:00
|
|
|
ovp->apc = apc;
|
|
|
|
ovp->apc_user = apc_user;
|
|
|
|
ovp->buffer = (void*)buffer;
|
|
|
|
ovp->fd_type = type;
|
|
|
|
|
|
|
|
io_status->Information = 0;
|
2003-07-11 23:44:17 +02:00
|
|
|
ret = register_new_async(&ovp->async);
|
|
|
|
if (ret != STATUS_SUCCESS)
|
|
|
|
return ret;
|
2003-08-18 21:45:53 +02:00
|
|
|
if (flags & FD_FLAG_TIMEOUT)
|
|
|
|
{
|
|
|
|
NtWaitForSingleObject(hEvent, TRUE, NULL);
|
|
|
|
NtClose(hEvent);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LARGE_INTEGER timeout;
|
|
|
|
|
|
|
|
/* let some APC be run, this will write as much data as possible */
|
2004-01-23 02:51:33 +01:00
|
|
|
timeout.u.LowPart = timeout.u.HighPart = 0;
|
2003-08-18 21:45:53 +02:00
|
|
|
NtDelayExecution( TRUE, &timeout );
|
|
|
|
}
|
2003-06-26 04:08:17 +02:00
|
|
|
return io_status->u.Status;
|
|
|
|
}
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case FD_TYPE_SMB:
|
|
|
|
FIXME("NIY-SMB\n");
|
2003-12-02 00:01:12 +01:00
|
|
|
wine_server_release_fd( hFile, unix_handle );
|
2003-06-26 04:08:17 +02:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
|
|
|
|
case FD_TYPE_DEFAULT:
|
|
|
|
/* normal unix files */
|
|
|
|
if (unix_handle == -1) return STATUS_INVALID_HANDLE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unsupported type of fd %d\n", type);
|
2003-12-02 00:01:12 +01:00
|
|
|
wine_server_release_fd( hFile, unix_handle );
|
2003-06-26 04:08:17 +02:00
|
|
|
return STATUS_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (offset)
|
|
|
|
{
|
|
|
|
FILE_POSITION_INFORMATION fpi;
|
|
|
|
|
|
|
|
fpi.CurrentByteOffset = *offset;
|
2003-07-19 00:55:28 +02:00
|
|
|
io_status->u.Status = NtSetInformationFile(hFile, io_status, &fpi, sizeof(fpi),
|
2003-06-26 04:08:17 +02:00
|
|
|
FilePositionInformation);
|
|
|
|
if (io_status->u.Status)
|
|
|
|
{
|
2003-12-02 00:01:12 +01:00
|
|
|
wine_server_release_fd( hFile, unix_handle );
|
2003-06-26 04:08:17 +02:00
|
|
|
return io_status->u.Status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* synchronous file write */
|
|
|
|
while ((io_status->Information = write( unix_handle, buffer, length )) == -1)
|
|
|
|
{
|
|
|
|
if ((errno == EAGAIN) || (errno == EINTR)) continue;
|
|
|
|
if (errno == EFAULT) FIXME( "EFAULT handling broken for now\n" );
|
|
|
|
if (errno == ENOSPC) io_status->u.Status = STATUS_DISK_FULL;
|
|
|
|
else io_status->u.Status = FILE_GetNtStatus();
|
|
|
|
break;
|
|
|
|
}
|
2003-12-02 00:01:12 +01:00
|
|
|
wine_server_release_fd( hFile, unix_handle );
|
2003-06-26 04:08:17 +02:00
|
|
|
return io_status->u.Status;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtDeviceIoControlFile [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwDeviceIoControlFile [NTDLL.@]
|
2003-07-19 00:55:28 +02:00
|
|
|
*
|
|
|
|
* Perform an I/O control operation on an open file handle.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* DeviceHandle [I] Handle returned from ZwOpenFile() or ZwCreateFile()
|
|
|
|
* Event [I] Event to signal upon completion (or NULL)
|
|
|
|
* ApcRoutine [I] Callback to call upon completion (or NULL)
|
|
|
|
* ApcContext [I] Context for ApcRoutine (or NULL)
|
|
|
|
* IoStatusBlock [O] Receives information about the operation on return
|
|
|
|
* IoControlCode [I] Control code for the operation to perform
|
|
|
|
* InputBuffer [I] Source for any input data required (or NULL)
|
|
|
|
* InputBufferSize [I] Size of InputBuffer
|
|
|
|
* OutputBuffer [O] Source for any output data returned (or NULL)
|
|
|
|
* OutputBufferSize [I] Size of OutputBuffer
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: 0. IoStatusBlock is updated.
|
|
|
|
* Failure: An NTSTATUS error code describing the error.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2003-06-24 21:28:21 +02:00
|
|
|
NTSTATUS WINAPI NtDeviceIoControlFile(HANDLE DeviceHandle, HANDLE hEvent,
|
|
|
|
PIO_APC_ROUTINE UserApcRoutine,
|
|
|
|
PVOID UserApcContext,
|
|
|
|
PIO_STATUS_BLOCK IoStatusBlock,
|
|
|
|
ULONG IoControlCode,
|
|
|
|
PVOID InputBuffer,
|
|
|
|
ULONG InputBufferSize,
|
|
|
|
PVOID OutputBuffer,
|
|
|
|
ULONG OutputBufferSize)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2003-06-24 21:28:21 +02:00
|
|
|
TRACE("(%p,%p,%p,%p,%p,0x%08lx,%p,0x%08lx,%p,0x%08lx)\n",
|
|
|
|
DeviceHandle, hEvent, UserApcRoutine, UserApcContext,
|
|
|
|
IoStatusBlock, IoControlCode,
|
|
|
|
InputBuffer, InputBufferSize, OutputBuffer, OutputBufferSize);
|
|
|
|
|
2004-03-05 00:00:18 +01:00
|
|
|
if (CDROM_DeviceIoControl(DeviceHandle, hEvent,
|
2003-10-08 04:59:22 +02:00
|
|
|
UserApcRoutine, UserApcContext,
|
|
|
|
IoStatusBlock, IoControlCode,
|
|
|
|
InputBuffer, InputBufferSize,
|
|
|
|
OutputBuffer, OutputBufferSize) == STATUS_NO_SUCH_DEVICE)
|
2003-06-24 21:28:21 +02:00
|
|
|
{
|
2003-10-08 04:59:22 +02:00
|
|
|
/* it wasn't a CDROM */
|
|
|
|
FIXME("Unimplemented dwIoControlCode=%08lx\n", IoControlCode);
|
|
|
|
IoStatusBlock->u.Status = STATUS_NOT_IMPLEMENTED;
|
|
|
|
IoStatusBlock->Information = 0;
|
|
|
|
if (hEvent) NtSetEvent(hEvent, NULL);
|
2003-06-24 21:28:21 +02:00
|
|
|
}
|
2003-10-08 04:59:22 +02:00
|
|
|
return IoStatusBlock->u.Status;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtFsControlFile [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwFsControlFile [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtFsControlFile(
|
|
|
|
IN HANDLE DeviceHandle,
|
|
|
|
IN HANDLE Event OPTIONAL,
|
|
|
|
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
|
|
|
|
IN PVOID ApcContext OPTIONAL,
|
|
|
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
|
|
|
IN ULONG IoControlCode,
|
|
|
|
IN PVOID InputBuffer,
|
|
|
|
IN ULONG InputBufferSize,
|
|
|
|
OUT PVOID OutputBuffer,
|
|
|
|
IN ULONG OutputBufferSize)
|
|
|
|
{
|
2002-12-05 20:56:15 +01:00
|
|
|
FIXME("(%p,%p,%p,%p,%p,0x%08lx,%p,0x%08lx,%p,0x%08lx): stub\n",
|
1999-03-09 18:47:51 +01:00
|
|
|
DeviceHandle,Event,ApcRoutine,ApcContext,IoStatusBlock,IoControlCode,
|
|
|
|
InputBuffer,InputBufferSize,OutputBuffer,OutputBufferSize);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtSetVolumeInformationFile [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwSetVolumeInformationFile [NTDLL.@]
|
2003-07-19 00:55:28 +02:00
|
|
|
*
|
|
|
|
* Set volume information for an open file handle.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* FileHandle [I] Handle returned from ZwOpenFile() or ZwCreateFile()
|
|
|
|
* IoStatusBlock [O] Receives information about the operation on return
|
|
|
|
* FsInformation [I] Source for volume information
|
|
|
|
* Length [I] Size of FsInformation
|
|
|
|
* FsInformationClass [I] Type of volume information to set
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: 0. IoStatusBlock is updated.
|
|
|
|
* Failure: An NTSTATUS error code describing the error.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtSetVolumeInformationFile(
|
|
|
|
IN HANDLE FileHandle,
|
1999-07-31 19:32:05 +02:00
|
|
|
PIO_STATUS_BLOCK IoStatusBlock,
|
|
|
|
PVOID FsInformation,
|
|
|
|
ULONG Length,
|
2002-06-01 01:06:46 +02:00
|
|
|
FS_INFORMATION_CLASS FsInformationClass)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2002-12-05 20:56:15 +01:00
|
|
|
FIXME("(%p,%p,%p,0x%08lx,0x%08x) stub\n",
|
1999-07-31 19:32:05 +02:00
|
|
|
FileHandle,IoStatusBlock,FsInformation,Length,FsInformationClass);
|
1999-03-09 18:47:51 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtQueryInformationFile [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwQueryInformationFile [NTDLL.@]
|
2003-07-19 00:55:28 +02:00
|
|
|
*
|
|
|
|
* Get information about an open file handle.
|
|
|
|
*
|
|
|
|
* PARAMS
|
2004-04-08 06:39:59 +02:00
|
|
|
* hFile [I] Handle returned from ZwOpenFile() or ZwCreateFile()
|
|
|
|
* io [O] Receives information about the operation on return
|
|
|
|
* ptr [O] Destination for file information
|
|
|
|
* len [I] Size of FileInformation
|
|
|
|
* class [I] Type of file information to get
|
2003-07-19 00:55:28 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: 0. IoStatusBlock and FileInformation are updated.
|
|
|
|
* Failure: An NTSTATUS error code describing the error.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2004-04-08 06:39:59 +02:00
|
|
|
NTSTATUS WINAPI NtQueryInformationFile( HANDLE hFile, PIO_STATUS_BLOCK io,
|
|
|
|
PVOID ptr, LONG len, FILE_INFORMATION_CLASS class )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2004-04-08 06:39:59 +02:00
|
|
|
int fd;
|
|
|
|
|
|
|
|
TRACE("(%p,%p,%p,0x%08lx,0x%08x)\n", hFile, io, ptr, len, class);
|
2003-06-24 04:32:01 +02:00
|
|
|
|
2004-04-08 06:39:59 +02:00
|
|
|
io->Information = 0;
|
|
|
|
if ((io->u.Status = wine_server_handle_to_fd( hFile, 0, &fd, NULL, NULL )))
|
|
|
|
return io->u.Status;
|
2003-06-24 04:32:01 +02:00
|
|
|
|
|
|
|
switch (class)
|
|
|
|
{
|
|
|
|
case FileBasicInformation:
|
|
|
|
{
|
2004-04-08 06:39:59 +02:00
|
|
|
FILE_BASIC_INFORMATION *info = ptr;
|
2003-06-24 04:32:01 +02:00
|
|
|
|
2004-04-08 06:39:59 +02:00
|
|
|
if (len < sizeof(*info)) io->u.Status = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
else
|
2003-06-24 04:32:01 +02:00
|
|
|
{
|
2004-04-08 06:39:59 +02:00
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
if (fstat( fd, &st ) == -1)
|
|
|
|
io->u.Status = FILE_GetNtStatus();
|
|
|
|
else if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode))
|
|
|
|
io->u.Status = STATUS_INVALID_INFO_CLASS;
|
|
|
|
else
|
2003-06-24 04:32:01 +02:00
|
|
|
{
|
2004-04-08 06:39:59 +02:00
|
|
|
if (S_ISDIR(st.st_mode)) info->FileAttributes = FILE_ATTRIBUTE_DIRECTORY;
|
|
|
|
else info->FileAttributes = FILE_ATTRIBUTE_ARCHIVE;
|
|
|
|
if (!(st.st_mode & S_IWUSR)) info->FileAttributes |= FILE_ATTRIBUTE_READONLY;
|
|
|
|
RtlSecondsSince1970ToTime( st.st_mtime, &info->CreationTime);
|
|
|
|
RtlSecondsSince1970ToTime( st.st_mtime, &info->LastWriteTime);
|
|
|
|
RtlSecondsSince1970ToTime( st.st_ctime, &info->ChangeTime);
|
|
|
|
RtlSecondsSince1970ToTime( st.st_atime, &info->LastAccessTime);
|
2003-06-24 04:32:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FileStandardInformation:
|
|
|
|
{
|
2004-04-08 06:39:59 +02:00
|
|
|
FILE_STANDARD_INFORMATION *info = ptr;
|
2003-06-24 04:32:01 +02:00
|
|
|
|
2004-04-08 06:39:59 +02:00
|
|
|
if (len < sizeof(*info)) io->u.Status = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
else
|
2003-06-24 04:32:01 +02:00
|
|
|
{
|
2004-04-08 06:39:59 +02:00
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
if (fstat( fd, &st ) == -1) io->u.Status = FILE_GetNtStatus();
|
|
|
|
else
|
2003-06-24 04:32:01 +02:00
|
|
|
{
|
2004-04-08 06:39:59 +02:00
|
|
|
if ((info->Directory = S_ISDIR(st.st_mode)))
|
2003-06-24 04:32:01 +02:00
|
|
|
{
|
2004-04-08 06:39:59 +02:00
|
|
|
info->AllocationSize.QuadPart = 0;
|
|
|
|
info->EndOfFile.QuadPart = 0;
|
|
|
|
info->NumberOfLinks = 1;
|
|
|
|
info->DeletePending = FALSE;
|
2003-06-24 04:32:01 +02:00
|
|
|
}
|
2004-04-08 06:39:59 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
info->AllocationSize.QuadPart = (ULONGLONG)st.st_blocks * 512;
|
|
|
|
info->EndOfFile.QuadPart = st.st_size;
|
|
|
|
info->NumberOfLinks = st.st_nlink;
|
|
|
|
info->DeletePending = FALSE; /* FIXME */
|
|
|
|
}
|
|
|
|
io->Information = sizeof(*info);
|
2003-06-24 04:32:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FilePositionInformation:
|
|
|
|
{
|
2004-04-08 06:39:59 +02:00
|
|
|
FILE_POSITION_INFORMATION *info = ptr;
|
2003-06-24 04:32:01 +02:00
|
|
|
|
2004-04-08 06:39:59 +02:00
|
|
|
if (len < sizeof(*info)) io->u.Status = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
else
|
2003-06-24 04:32:01 +02:00
|
|
|
{
|
2004-04-08 00:02:09 +02:00
|
|
|
off_t res = lseek( fd, 0, SEEK_CUR );
|
2004-04-08 06:39:59 +02:00
|
|
|
if (res == (off_t)-1) io->u.Status = FILE_GetNtStatus();
|
2004-04-08 00:02:09 +02:00
|
|
|
else
|
2003-06-24 04:32:01 +02:00
|
|
|
{
|
2004-04-08 06:39:59 +02:00
|
|
|
info->CurrentByteOffset.QuadPart = res;
|
|
|
|
io->Information = sizeof(*info);
|
2003-06-24 04:32:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Unsupported class (%d)\n", class);
|
2004-04-08 06:39:59 +02:00
|
|
|
io->u.Status = STATUS_NOT_IMPLEMENTED;
|
|
|
|
break;
|
2003-06-24 04:32:01 +02:00
|
|
|
}
|
2004-04-08 06:39:59 +02:00
|
|
|
wine_server_release_fd( hFile, fd );
|
|
|
|
return io->u.Status;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtSetInformationFile [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwSetInformationFile [NTDLL.@]
|
2003-07-19 00:55:28 +02:00
|
|
|
*
|
|
|
|
* Set information about an open file handle.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* FileHandle [I] Handle returned from ZwOpenFile() or ZwCreateFile()
|
|
|
|
* IoStatusBlock [O] Receives information about the operation on return
|
|
|
|
* FileInformation [I] Source for file information
|
|
|
|
* Length [I] Size of FileInformation
|
|
|
|
* FileInformationClass [I] Type of file information to set
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: 0. IoStatusBlock is updated.
|
|
|
|
* Failure: An NTSTATUS error code describing the error.
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2003-06-24 04:32:01 +02:00
|
|
|
NTSTATUS WINAPI NtSetInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io_status,
|
2003-07-19 00:55:28 +02:00
|
|
|
PVOID ptr, ULONG len,
|
2003-06-24 04:32:01 +02:00
|
|
|
FILE_INFORMATION_CLASS class)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2003-06-24 04:32:01 +02:00
|
|
|
NTSTATUS status = STATUS_INVALID_PARAMETER_3;
|
|
|
|
|
|
|
|
TRACE("(%p,%p,%p,0x%08lx,0x%08x)\n", hFile, io_status, ptr, len, class);
|
|
|
|
|
|
|
|
switch (class)
|
2003-07-19 00:55:28 +02:00
|
|
|
{
|
2003-06-24 04:32:01 +02:00
|
|
|
case FilePositionInformation:
|
|
|
|
if (len >= sizeof(FILE_POSITION_INFORMATION))
|
|
|
|
{
|
2004-04-08 00:02:09 +02:00
|
|
|
int fd;
|
2003-06-24 04:32:01 +02:00
|
|
|
FILE_POSITION_INFORMATION* fpi = (FILE_POSITION_INFORMATION*)ptr;
|
|
|
|
|
2004-04-08 00:02:09 +02:00
|
|
|
if (!(status = wine_server_handle_to_fd( hFile, 0, &fd, NULL, NULL )))
|
2003-06-24 04:32:01 +02:00
|
|
|
{
|
2004-04-08 00:02:09 +02:00
|
|
|
if (lseek( fd, fpi->CurrentByteOffset.QuadPart, SEEK_SET ) == (off_t)-1)
|
|
|
|
status = FILE_GetNtStatus();
|
|
|
|
wine_server_release_fd( hFile, fd );
|
2003-06-24 04:32:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Unsupported class (%d)\n", class);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
io_status->u.Status = status;
|
|
|
|
io_status->Information = 0;
|
|
|
|
return status;
|
1999-03-09 18:47:51 +01:00
|
|
|
}
|
|
|
|
|
2004-04-06 06:19:41 +02:00
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtQueryVolumeInformationFile [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwQueryVolumeInformationFile [NTDLL.@]
|
2003-07-19 00:55:28 +02:00
|
|
|
*
|
|
|
|
* Get volume information for an open file handle.
|
|
|
|
*
|
|
|
|
* PARAMS
|
2004-04-06 06:19:41 +02:00
|
|
|
* handle [I] Handle returned from ZwOpenFile() or ZwCreateFile()
|
|
|
|
* io [O] Receives information about the operation on return
|
|
|
|
* buffer [O] Destination for volume information
|
|
|
|
* length [I] Size of FsInformation
|
|
|
|
* info_class [I] Type of volume information to set
|
2003-07-19 00:55:28 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2004-04-06 06:19:41 +02:00
|
|
|
* Success: 0. io and buffer are updated.
|
2003-07-19 00:55:28 +02:00
|
|
|
* Failure: An NTSTATUS error code describing the error.
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
2004-04-06 06:19:41 +02:00
|
|
|
NTSTATUS WINAPI NtQueryVolumeInformationFile( HANDLE handle, PIO_STATUS_BLOCK io,
|
|
|
|
PVOID buffer, ULONG length,
|
|
|
|
FS_INFORMATION_CLASS info_class )
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
2004-04-06 06:19:41 +02:00
|
|
|
int fd;
|
2004-04-07 05:58:55 +02:00
|
|
|
struct stat st;
|
2002-05-09 21:40:30 +02:00
|
|
|
|
2004-04-07 01:13:47 +02:00
|
|
|
if ((io->u.Status = wine_server_handle_to_fd( handle, 0, &fd, NULL, NULL )) != STATUS_SUCCESS)
|
2004-04-06 06:19:41 +02:00
|
|
|
return io->u.Status;
|
2002-05-09 21:40:30 +02:00
|
|
|
|
2004-04-06 06:19:41 +02:00
|
|
|
io->u.Status = STATUS_NOT_IMPLEMENTED;
|
|
|
|
io->Information = 0;
|
2002-05-09 21:40:30 +02:00
|
|
|
|
2004-04-06 06:19:41 +02:00
|
|
|
switch( info_class )
|
|
|
|
{
|
|
|
|
case FileFsVolumeInformation:
|
|
|
|
FIXME( "%p: volume info not supported\n", handle );
|
|
|
|
break;
|
|
|
|
case FileFsLabelInformation:
|
|
|
|
FIXME( "%p: label info not supported\n", handle );
|
|
|
|
break;
|
|
|
|
case FileFsSizeInformation:
|
|
|
|
if (length < sizeof(FILE_FS_SIZE_INFORMATION))
|
|
|
|
io->u.Status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FILE_FS_SIZE_INFORMATION *info = buffer;
|
2004-04-07 05:58:55 +02:00
|
|
|
struct statvfs stvfs;
|
2002-05-09 21:40:30 +02:00
|
|
|
|
2004-04-07 05:58:55 +02:00
|
|
|
if (fstat( fd, &st ) < 0)
|
|
|
|
{
|
|
|
|
io->u.Status = FILE_GetNtStatus();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode))
|
|
|
|
{
|
|
|
|
io->u.Status = STATUS_INVALID_DEVICE_REQUEST;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (fstatvfs( fd, &stvfs ) < 0) io->u.Status = FILE_GetNtStatus();
|
2004-04-06 06:19:41 +02:00
|
|
|
else
|
|
|
|
{
|
2004-04-07 05:58:55 +02:00
|
|
|
info->TotalAllocationUnits.QuadPart = stvfs.f_blocks;
|
|
|
|
info->AvailableAllocationUnits.QuadPart = stvfs.f_bavail;
|
2004-04-06 06:19:41 +02:00
|
|
|
info->SectorsPerAllocationUnit = 1;
|
2004-04-07 05:58:55 +02:00
|
|
|
info->BytesPerSector = stvfs.f_frsize;
|
2004-04-06 06:19:41 +02:00
|
|
|
io->Information = sizeof(*info);
|
|
|
|
io->u.Status = STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FileFsDeviceInformation:
|
|
|
|
if (length < sizeof(FILE_FS_DEVICE_INFORMATION))
|
|
|
|
io->u.Status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FILE_FS_DEVICE_INFORMATION *info = buffer;
|
|
|
|
|
|
|
|
#if defined(linux) && defined(HAVE_FSTATFS)
|
|
|
|
struct statfs stfs;
|
|
|
|
|
|
|
|
info->Characteristics = 0;
|
2004-04-07 05:58:55 +02:00
|
|
|
|
|
|
|
if (fstat( fd, &st ) < 0)
|
2004-04-06 06:19:41 +02:00
|
|
|
{
|
2004-04-07 05:58:55 +02:00
|
|
|
io->u.Status = FILE_GetNtStatus();
|
2004-04-06 06:19:41 +02:00
|
|
|
break;
|
|
|
|
}
|
2004-04-07 05:58:55 +02:00
|
|
|
if (S_ISCHR( st.st_mode ))
|
|
|
|
{
|
|
|
|
switch(major(st.st_rdev))
|
|
|
|
{
|
|
|
|
case MEM_MAJOR:
|
|
|
|
info->DeviceType = FILE_DEVICE_NULL;
|
|
|
|
break;
|
|
|
|
case TTY_MAJOR:
|
|
|
|
info->DeviceType = FILE_DEVICE_SERIAL_PORT;
|
|
|
|
break;
|
|
|
|
case LP_MAJOR:
|
|
|
|
info->DeviceType = FILE_DEVICE_PARALLEL_PORT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
info->DeviceType = FILE_DEVICE_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (S_ISBLK( st.st_mode ))
|
|
|
|
{
|
|
|
|
info->DeviceType = FILE_DEVICE_DISK;
|
|
|
|
}
|
|
|
|
else if (S_ISFIFO( st.st_mode ) || S_ISSOCK( st.st_mode ))
|
|
|
|
{
|
|
|
|
info->DeviceType = FILE_DEVICE_NAMED_PIPE;
|
|
|
|
}
|
|
|
|
else /* regular file or directory */
|
|
|
|
{
|
|
|
|
info->Characteristics |= FILE_DEVICE_IS_MOUNTED;
|
|
|
|
|
|
|
|
/* check for floppy disk */
|
|
|
|
if (major(st.st_dev) == FLOPPY_MAJOR)
|
|
|
|
info->Characteristics |= FILE_REMOVABLE_MEDIA;
|
|
|
|
|
|
|
|
if (fstatfs( fd, &stfs ) < 0) stfs.f_type = 0;
|
|
|
|
switch (stfs.f_type)
|
|
|
|
{
|
|
|
|
case 0x9660: /* iso9660 */
|
|
|
|
case 0x15013346: /* udf */
|
|
|
|
info->DeviceType = FILE_DEVICE_CD_ROM_FILE_SYSTEM;
|
|
|
|
info->Characteristics |= FILE_REMOVABLE_MEDIA|FILE_READ_ONLY_DEVICE;
|
|
|
|
break;
|
|
|
|
case 0x6969: /* nfs */
|
|
|
|
case 0x517B: /* smbfs */
|
|
|
|
case 0x564c: /* ncpfs */
|
|
|
|
info->DeviceType = FILE_DEVICE_NETWORK_FILE_SYSTEM;
|
|
|
|
info->Characteristics |= FILE_REMOTE_DEVICE;
|
|
|
|
break;
|
|
|
|
case 0x01021994: /* tmpfs */
|
|
|
|
case 0x28cd3d45: /* cramfs */
|
|
|
|
case 0x1373: /* devfs */
|
|
|
|
case 0x9fa0: /* procfs */
|
|
|
|
info->DeviceType = FILE_DEVICE_VIRTUAL_DISK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
info->DeviceType = FILE_DEVICE_DISK_FILE_SYSTEM;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-04-06 06:19:41 +02:00
|
|
|
#else
|
|
|
|
static int warned;
|
|
|
|
if (!warned++) FIXME( "device info not supported on this platform\n" );
|
|
|
|
info->DeviceType = FILE_DEVICE_DISK_FILE_SYSTEM;
|
|
|
|
info->Characteristics = 0;
|
|
|
|
#endif
|
|
|
|
io->Information = sizeof(*info);
|
|
|
|
io->u.Status = STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FileFsAttributeInformation:
|
|
|
|
FIXME( "%p: attribute info not supported\n", handle );
|
|
|
|
break;
|
|
|
|
case FileFsControlInformation:
|
|
|
|
FIXME( "%p: control info not supported\n", handle );
|
|
|
|
break;
|
|
|
|
case FileFsFullSizeInformation:
|
|
|
|
FIXME( "%p: full size info not supported\n", handle );
|
|
|
|
break;
|
|
|
|
case FileFsObjectIdInformation:
|
|
|
|
FIXME( "%p: object id info not supported\n", handle );
|
|
|
|
break;
|
|
|
|
case FileFsMaximumInformation:
|
|
|
|
FIXME( "%p: maximum info not supported\n", handle );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
io->u.Status = STATUS_INVALID_PARAMETER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
wine_server_release_fd( handle, fd );
|
|
|
|
return io->u.Status;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
2003-04-22 06:04:17 +02:00
|
|
|
|
2004-04-06 06:19:41 +02:00
|
|
|
|
2003-04-22 06:04:17 +02:00
|
|
|
/******************************************************************
|
|
|
|
* NtFlushBuffersFile (NTDLL.@)
|
2003-07-19 00:55:28 +02:00
|
|
|
*
|
|
|
|
* Flush any buffered data on an open file handle.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* FileHandle [I] Handle returned from ZwOpenFile() or ZwCreateFile()
|
|
|
|
* IoStatusBlock [O] Receives information about the operation on return
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: 0. IoStatusBlock is updated.
|
|
|
|
* Failure: An NTSTATUS error code describing the error.
|
2003-04-22 06:04:17 +02:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtFlushBuffersFile( HANDLE hFile, IO_STATUS_BLOCK* IoStatusBlock )
|
|
|
|
{
|
|
|
|
NTSTATUS ret;
|
2003-05-15 06:22:45 +02:00
|
|
|
HANDLE hEvent = NULL;
|
|
|
|
|
2003-04-22 06:04:17 +02:00
|
|
|
SERVER_START_REQ( flush_file )
|
|
|
|
{
|
|
|
|
req->handle = hFile;
|
|
|
|
ret = wine_server_call( req );
|
2003-05-15 06:22:45 +02:00
|
|
|
hEvent = reply->event;
|
2003-04-22 06:04:17 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2003-06-26 04:08:17 +02:00
|
|
|
if (!ret && hEvent)
|
2003-05-15 06:22:45 +02:00
|
|
|
{
|
|
|
|
ret = NtWaitForSingleObject( hEvent, FALSE, NULL );
|
|
|
|
NtClose( hEvent );
|
|
|
|
}
|
2003-04-22 06:04:17 +02:00
|
|
|
return ret;
|
|
|
|
}
|
2003-06-24 04:32:01 +02:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* NtLockFile (NTDLL.@)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtLockFile( HANDLE hFile, HANDLE lock_granted_event,
|
2003-07-19 00:55:28 +02:00
|
|
|
PIO_APC_ROUTINE apc, void* apc_user,
|
|
|
|
PIO_STATUS_BLOCK io_status, PLARGE_INTEGER offset,
|
2003-06-24 04:32:01 +02:00
|
|
|
PLARGE_INTEGER count, ULONG* key, BOOLEAN dont_wait,
|
|
|
|
BOOLEAN exclusive )
|
|
|
|
{
|
|
|
|
NTSTATUS ret;
|
|
|
|
HANDLE handle;
|
|
|
|
BOOLEAN async;
|
|
|
|
|
|
|
|
if (apc || io_status || key)
|
|
|
|
{
|
|
|
|
FIXME("Unimplemented yet parameter\n");
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( lock_file )
|
|
|
|
{
|
|
|
|
req->handle = hFile;
|
2004-01-23 02:51:33 +01:00
|
|
|
req->offset_low = offset->u.LowPart;
|
|
|
|
req->offset_high = offset->u.HighPart;
|
|
|
|
req->count_low = count->u.LowPart;
|
|
|
|
req->count_high = count->u.HighPart;
|
2003-06-24 04:32:01 +02:00
|
|
|
req->shared = !exclusive;
|
|
|
|
req->wait = !dont_wait;
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
handle = reply->handle;
|
|
|
|
async = reply->overlapped;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
if (ret != STATUS_PENDING)
|
|
|
|
{
|
|
|
|
if (!ret && lock_granted_event) NtSetEvent(lock_granted_event, NULL);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (async)
|
|
|
|
{
|
|
|
|
FIXME( "Async I/O lock wait not implemented, might deadlock\n" );
|
|
|
|
if (handle) NtClose( handle );
|
|
|
|
return STATUS_PENDING;
|
|
|
|
}
|
|
|
|
if (handle)
|
|
|
|
{
|
|
|
|
NtWaitForSingleObject( handle, FALSE, NULL );
|
|
|
|
NtClose( handle );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LARGE_INTEGER time;
|
|
|
|
|
|
|
|
/* Unix lock conflict, sleep a bit and retry */
|
|
|
|
time.QuadPart = 100 * (ULONGLONG)10000;
|
|
|
|
time.QuadPart = -time.QuadPart;
|
2003-06-30 23:00:15 +02:00
|
|
|
NtDelayExecution( FALSE, &time );
|
2003-06-24 04:32:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* NtUnlockFile (NTDLL.@)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtUnlockFile( HANDLE hFile, PIO_STATUS_BLOCK io_status,
|
|
|
|
PLARGE_INTEGER offset, PLARGE_INTEGER count,
|
|
|
|
PULONG key )
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE( "%p %lx%08lx %lx%08lx\n",
|
2004-01-23 02:51:33 +01:00
|
|
|
hFile, offset->u.HighPart, offset->u.LowPart, count->u.HighPart, count->u.LowPart );
|
2003-06-24 04:32:01 +02:00
|
|
|
|
|
|
|
if (io_status || key)
|
|
|
|
{
|
|
|
|
FIXME("Unimplemented yet parameter\n");
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
SERVER_START_REQ( unlock_file )
|
|
|
|
{
|
|
|
|
req->handle = hFile;
|
2004-01-23 02:51:33 +01:00
|
|
|
req->offset_low = offset->u.LowPart;
|
|
|
|
req->offset_high = offset->u.HighPart;
|
|
|
|
req->count_low = count->u.LowPart;
|
|
|
|
req->count_high = count->u.HighPart;
|
2003-06-24 04:32:01 +02:00
|
|
|
status = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return status;
|
|
|
|
}
|