Added some modifications for asyncronous i/o requests (for vfatfs).

svn path=/trunk/; revision=2343
This commit is contained in:
Hartmut Birr 2001-11-02 22:22:33 +00:00
parent ab19671382
commit 2723d14c06
8 changed files with 137 additions and 57 deletions

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.49 2001/11/02 09:17:52 ekohl Exp $
/* $Id: create.c,v 1.50 2001/11/02 22:22:33 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -315,6 +315,7 @@ IoCreateFile(
PIRP Irp;
KEVENT Event;
PIO_STACK_LOCATION StackLoc;
IO_STATUS_BLOCK IoSB;
DPRINT("IoCreateFile(FileHandle %x, DesiredAccess %x, "
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
@ -360,9 +361,11 @@ IoCreateFile(
return (STATUS_UNSUCCESSFUL);
}
Irp->UserIosb = IoStatusBlock; //return iostatus
Irp->UserIosb = &IoSB; //return iostatus
Irp->AssociatedIrp.SystemBuffer = EaBuffer;
Irp->Tail.Overlay.AuxiliaryBuffer = (PCHAR)ExtraCreateParameters;
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
Irp->UserEvent = &Event;
/*
* Get the stack location for the new
@ -407,14 +410,17 @@ IoCreateFile(
KernelMode,
FALSE,
NULL);
Status = IoStatusBlock->Status;
Status = IoSB.Status;
}
if (!NT_SUCCESS(Status))
{
DPRINT("Failing create request with status %x\n", Status);
ZwClose(*FileHandle);
}
if (IoStatusBlock)
{
*IoStatusBlock = IoSB;
}
assert_irql(PASSIVE_LEVEL);
DPRINT("Finished IoCreateFile() (*FileHandle) %x\n", (*FileHandle));

View file

@ -1,4 +1,4 @@
/* $Id: dir.c,v 1.10 2000/03/26 19:38:22 ea Exp $
/* $Id: dir.c,v 1.11 2001/11/02 22:22:33 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -87,6 +87,7 @@ NtQueryDirectoryFile(
NTSTATUS Status;
KEVENT Event;
PIO_STACK_LOCATION IoStack;
IO_STATUS_BLOCK IoSB;
DPRINT("NtQueryDirectoryFile()\n");
@ -113,7 +114,7 @@ NtQueryDirectoryFile(
}
Irp->UserIosb = IoStatusBlock;
Irp->UserIosb = &IoSB;
Irp->UserEvent = &Event;
Irp->UserBuffer=FileInformation;
@ -155,7 +156,11 @@ NtQueryDirectoryFile(
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
}
Status = IoStatusBlock->Status;
Status = IoSB.Status;
}
if (IoStatusBlock)
{
*IoStatusBlock = IoSB;
}
return(Status);
}

View file

@ -1,4 +1,4 @@
/* $Id: file.c,v 1.14 2001/06/12 12:30:36 ekohl Exp $
/* $Id: file.c,v 1.15 2001/11/02 22:22:33 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -40,6 +40,7 @@ NtQueryInformationFile(HANDLE FileHandle,
PIO_STACK_LOCATION StackPtr;
KEVENT Event;
PVOID SystemBuffer;
IO_STATUS_BLOCK IoSB;
assert(IoStatusBlock != NULL);
assert(FileInformation != NULL);
@ -87,7 +88,7 @@ NtQueryInformationFile(HANDLE FileHandle,
}
Irp->AssociatedIrp.SystemBuffer = SystemBuffer;
Irp->UserIosb = IoStatusBlock;
Irp->UserIosb = &IoSB;
Irp->UserEvent = &Event;
StackPtr = IoGetNextIrpStackLocation(Irp);
@ -104,14 +105,18 @@ NtQueryInformationFile(HANDLE FileHandle,
Status = IoCallDriver(FileObject->DeviceObject,
Irp);
if (Status==STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
if (Status==STATUS_PENDING && !(FileObject->Flags & FO_SYNCHRONOUS_IO))
{
KeWaitForSingleObject(&Event,
Executive,
KernelMode,
FALSE,
NULL);
Status = Irp->IoStatus.Status;
Status = IoSB.Status;
}
if (IoStatusBlock)
{
*IoStatusBlock = IoSB;
}
if (NT_SUCCESS(Status))
@ -187,14 +192,14 @@ IoQueryFileInformation(IN PFILE_OBJECT FileObject,
Status = IoCallDriver(FileObject->DeviceObject,
Irp);
if (Status==STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
if (Status==STATUS_PENDING && !(FileObject->Flags & FO_SYNCHRONOUS_IO))
{
KeWaitForSingleObject(&Event,
Executive,
KernelMode,
FALSE,
NULL);
Status = Irp->IoStatus.Status;
Status = IoStatusBlock.Status;
}
if (ReturnedLength != NULL)
@ -222,6 +227,7 @@ NtSetInformationFile(HANDLE FileHandle,
KEVENT Event;
NTSTATUS Status;
PVOID SystemBuffer;
IO_STATUS_BLOCK IoSB;
assert(IoStatusBlock != NULL)
assert(FileInformation != NULL)
@ -280,7 +286,7 @@ NtSetInformationFile(HANDLE FileHandle,
Length);
Irp->AssociatedIrp.SystemBuffer = SystemBuffer;
Irp->UserIosb = IoStatusBlock;
Irp->UserIosb = &IoSB;
Irp->UserEvent = &Event;
StackPtr = IoGetNextIrpStackLocation(Irp);
@ -302,16 +308,19 @@ NtSetInformationFile(HANDLE FileHandle,
DPRINT("FileObject->DeviceObject %x\n", FileObject->DeviceObject);
Status = IoCallDriver(FileObject->DeviceObject,
Irp);
if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
if (Status == STATUS_PENDING && !(FileObject->Flags & FO_SYNCHRONOUS_IO))
{
KeWaitForSingleObject(&Event,
Executive,
KernelMode,
FALSE,
NULL);
Status = Irp->IoStatus.Status;
Status = IoSB.Status;
}
if (IoStatusBlock)
{
*IoStatusBlock = IoSB;
}
ExFreePool(SystemBuffer);
ObDereferenceObject(FileObject);

View file

@ -49,6 +49,7 @@ NtFlushBuffersFile (
PIO_STACK_LOCATION StackPtr;
KEVENT Event;
NTSTATUS Status;
IO_STATUS_BLOCK IoSB;
Status = ObReferenceObjectByHandle(FileHandle,
FILE_WRITE_DATA,
@ -68,7 +69,7 @@ NtFlushBuffersFile (
0,
NULL,
&Event,
IoStatusBlock);
&IoSB);
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->FileObject = FileObject;
@ -77,7 +78,11 @@ NtFlushBuffersFile (
if (Status==STATUS_PENDING)
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
Status = Irp->IoStatus.Status;
Status = IoSB.Status;
}
if (IoStatusBlock)
{
*IoStatusBlock = IoSB;
}
return(Status);
}

View file

@ -1,4 +1,4 @@
/* $Id: fs.c,v 1.18 2001/07/15 15:36:31 ekohl Exp $
/* $Id: fs.c,v 1.19 2001/11/02 22:22:33 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -56,6 +56,7 @@ NtFsControlFile (
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
KEVENT KEvent;
IO_STATUS_BLOCK IoSB;
DPRINT("NtFsControlFile(DeviceHandle %x EventHandle %x ApcRoutine %x "
"ApcContext %x IoStatusBlock %x IoControlCode %x "
@ -89,7 +90,7 @@ NtFsControlFile (
OutputBufferSize,
FALSE,
&KEvent,
IoStatusBlock);
&IoSB);
Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
@ -103,10 +104,14 @@ NtFsControlFile (
StackPtr->MajorFunction = IRP_MJ_FILE_SYSTEM_CONTROL;
Status = IoCallDriver(DeviceObject,Irp);
if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
if (Status == STATUS_PENDING && !(FileObject->Flags & FO_SYNCHRONOUS_IO))
{
KeWaitForSingleObject(&KEvent,Executive,KernelMode,FALSE,NULL);
return(IoStatusBlock->Status);
Status = IoSB.Status;
}
if (IoStatusBlock)
{
*IoStatusBlock = IoSB;
}
return(Status);
}

View file

@ -1,4 +1,4 @@
/* $Id: ioctrl.c,v 1.12 2001/03/21 23:27:18 chorns Exp $
/* $Id: ioctrl.c,v 1.13 2001/11/02 22:22:33 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -39,6 +39,8 @@ NTSTATUS STDCALL NtDeviceIoControlFile (IN HANDLE DeviceHandle,
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
KEVENT KEvent;
PKEVENT ptrEvent;
IO_STATUS_BLOCK IoSB;
DPRINT("NtDeviceIoControlFile(DeviceHandle %x Event %x UserApcRoutine %x "
"UserApcContext %x IoStatusBlock %x IoControlCode %x "
@ -59,6 +61,31 @@ NTSTATUS STDCALL NtDeviceIoControlFile (IN HANDLE DeviceHandle,
{
return(Status);
}
if (Event != NULL)
{
Status = ObReferenceObjectByHandle (Event,
SYNCHRONIZE,
ExEventObjectType,
UserMode,
(PVOID*)&ptrEvent,
NULL);
if (!NT_SUCCESS(Status))
{
ObDereferenceObject(FileObject);
return Status;
}
}
else if (FileObject->Flags & FO_SYNCHRONOUS_IO)
{
ptrEvent = NULL;
}
else
{
KeInitializeEvent (&KEvent,
NotificationEvent,
FALSE);
ptrEvent = &KEvent;
}
DeviceObject = FileObject->DeviceObject;
@ -71,8 +98,8 @@ NTSTATUS STDCALL NtDeviceIoControlFile (IN HANDLE DeviceHandle,
OutputBuffer,
OutputBufferSize,
FALSE,
&KEvent,
IoStatusBlock);
ptrEvent,
Event ? IoStatusBlock : &IoSB);
Irp->Overlay.AsynchronousParameters.UserApcRoutine = UserApcRoutine;
Irp->Overlay.AsynchronousParameters.UserApcContext = UserApcContext;
@ -84,10 +111,14 @@ NTSTATUS STDCALL NtDeviceIoControlFile (IN HANDLE DeviceHandle,
StackPtr->Parameters.DeviceIoControl.OutputBufferLength = OutputBufferSize;
Status = IoCallDriver(DeviceObject,Irp);
if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
if (Event == NULL && Status == STATUS_PENDING && !(FileObject->Flags & FO_SYNCHRONOUS_IO))
{
KeWaitForSingleObject(&KEvent,Executive,KernelMode,FALSE,NULL);
return(IoStatusBlock->Status);
Status = IoSB.Status;
}
if (IoStatusBlock)
{
*IoStatusBlock = IoSB;
}
return(Status);
}

View file

@ -1,4 +1,4 @@
/* $Id: rw.c,v 1.33 2000/10/22 16:36:50 ekohl Exp $
/* $Id: rw.c,v 1.34 2001/11/02 22:22:33 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -54,6 +54,7 @@ NTSTATUS STDCALL NtReadFile(HANDLE FileHandle,
PIO_STACK_LOCATION StackPtr;
PKEVENT ptrEvent = NULL;
KEVENT Event;
IO_STATUS_BLOCK IoSB;
DPRINT("NtReadFile(FileHandle %x Buffer %x Length %x ByteOffset %x, "
"IoStatusBlock %x)\n", FileHandle, Buffer, Length, ByteOffset,
@ -91,16 +92,16 @@ NTSTATUS STDCALL NtReadFile(HANDLE FileHandle,
}
}
else if (FileObject->Flags & FO_SYNCHRONOUS_IO)
{
ptrEvent = NULL;
}
else
{
KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
ptrEvent = &Event;
}
else
{
ptrEvent = NULL;
}
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
FileObject->DeviceObject,
@ -108,7 +109,7 @@ NTSTATUS STDCALL NtReadFile(HANDLE FileHandle,
Length,
ByteOffset,
ptrEvent,
IoStatusBlock);
EventHandle ? IoStatusBlock : &IoSB);
Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
@ -126,8 +127,8 @@ NTSTATUS STDCALL NtReadFile(HANDLE FileHandle,
Status = IoCallDriver(FileObject->DeviceObject,
Irp);
if ((Status == STATUS_PENDING) &&
(FileObject->Flags & FO_SYNCHRONOUS_IO))
if (EventHandle == NULL && Status == STATUS_PENDING &&
!(FileObject->Flags & FO_SYNCHRONOUS_IO))
{
BOOLEAN Alertable;
@ -145,9 +146,12 @@ NTSTATUS STDCALL NtReadFile(HANDLE FileHandle,
KernelMode,
Alertable,
NULL);
Status = IoStatusBlock->Status;
Status = IoSB.Status;
}
if (IoStatusBlock && EventHandle == NULL)
{
*IoStatusBlock = IoSB;
}
return (Status);
}
@ -181,6 +185,7 @@ NTSTATUS STDCALL NtWriteFile(HANDLE FileHandle,
PIO_STACK_LOCATION StackPtr;
KEVENT Event;
PKEVENT ptrEvent;
IO_STATUS_BLOCK IoSB;
DPRINT("NtWriteFile(FileHandle %x, Buffer %x, Length %d)\n",
FileHandle, Buffer, Length);
@ -216,27 +221,24 @@ NTSTATUS STDCALL NtWriteFile(HANDLE FileHandle,
}
}
else if (FileObject->Flags & FO_SYNCHRONOUS_IO)
{
ptrEvent = NULL;
}
else
{
KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
ptrEvent = &Event;
}
else
{
ptrEvent = NULL;
}
KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,
FileObject->DeviceObject,
Buffer,
Length,
ByteOffset,
ptrEvent,
IoStatusBlock);
EventHandle ? IoStatusBlock : &IoSB);
Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
@ -254,15 +256,19 @@ NTSTATUS STDCALL NtWriteFile(HANDLE FileHandle,
StackPtr->Parameters.Write.Key = 0;
}
Status = IoCallDriver(FileObject->DeviceObject, Irp);
if ((Status == STATUS_PENDING) &&
(FileObject->Flags & FO_SYNCHRONOUS_IO))
if (EventHandle == NULL && Status == STATUS_PENDING &&
!(FileObject->Flags & FO_SYNCHRONOUS_IO))
{
KeWaitForSingleObject(&Event,
Executive,
KernelMode,
FALSE,
NULL);
Status = Irp->IoStatus.Status;
Status = IoSB.Status;
}
if (IoStatusBlock && EventHandle == NULL)
{
*IoStatusBlock = IoSB;
}
return(Status);
}

View file

@ -1,4 +1,4 @@
/* $Id: vpb.c,v 1.13 2001/06/12 12:30:36 ekohl Exp $
/* $Id: vpb.c,v 1.14 2001/11/02 22:22:33 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -102,6 +102,7 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle,
NTSTATUS Status;
PIO_STACK_LOCATION StackPtr;
PVOID SystemBuffer;
IO_STATUS_BLOCK IoSB;
assert(IoStatusBlock != NULL);
assert(FsInformation != NULL);
@ -145,7 +146,8 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle,
Irp->AssociatedIrp.SystemBuffer = SystemBuffer;
Irp->UserEvent = &Event;
Irp->UserIosb = IoStatusBlock;
Irp->UserIosb = &IoSB;
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = IRP_MJ_QUERY_VOLUME_INFORMATION;
@ -167,7 +169,7 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle,
KernelMode,
FALSE,
NULL);
Status = IoStatusBlock->Status;
Status = IoSB.Status;
}
DPRINT("Status %x\n", Status);
@ -176,7 +178,11 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle,
DPRINT("Information %lu\n", IoStatusBlock->Information);
MmSafeCopyToUser(FsInformation,
SystemBuffer,
IoStatusBlock->Information);
IoSB.Information);
}
if (IoStatusBlock)
{
*IoStatusBlock = IoSB;
}
ExFreePool(SystemBuffer);
ObDereferenceObject(FileObject);
@ -229,6 +235,7 @@ IoQueryVolumeInformation(IN PFILE_OBJECT FileObject,
Irp->AssociatedIrp.SystemBuffer = FsInformation;
Irp->UserEvent = &Event;
Irp->UserIosb = &IoStatusBlock;
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = IRP_MJ_QUERY_VOLUME_INFORMATION;
@ -278,6 +285,7 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle,
NTSTATUS Status;
PIO_STACK_LOCATION StackPtr;
PVOID SystemBuffer;
IO_STATUS_BLOCK IoSB;
Status = ObReferenceObjectByHandle(FileHandle,
FILE_WRITE_ATTRIBUTES,
@ -319,7 +327,8 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle,
Irp->AssociatedIrp.SystemBuffer = SystemBuffer;
Irp->UserEvent = &Event;
Irp->UserIosb = IoStatusBlock;
Irp->UserIosb = &IoSB;
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = IRP_MJ_SET_VOLUME_INFORMATION;
@ -340,8 +349,12 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle,
KernelMode,
FALSE,
NULL);
Status = IoSB.Status;
}
if (IoStatusBlock)
{
*IoStatusBlock = IoSB;
}
ExFreePool(SystemBuffer);
return(Status);