Clean up the pipe type and mode mess.

svn path=/trunk/; revision=12754
This commit is contained in:
Eric Kohl 2005-01-03 13:50:04 +00:00
parent 896ba320b8
commit fb1c02d7d1
4 changed files with 42 additions and 105 deletions

View file

@ -320,11 +320,11 @@ NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
InitializeListHead(&Pipe->ClientFcbListHead);
KeInitializeMutex(&Pipe->FcbListLock, 0);
Pipe->PipeType = Buffer->NamedPipeType ? FILE_PIPE_MESSAGE_TYPE : FILE_PIPE_BYTE_STREAM_TYPE;
Pipe->PipeWriteMode = Buffer->NamedPipeType ? FILE_PIPE_MESSAGE_MODE : FILE_PIPE_BYTE_STREAM_MODE;
Pipe->PipeReadMode = Buffer->ReadMode ? FILE_PIPE_MESSAGE_MODE : FILE_PIPE_BYTE_STREAM_MODE;
Pipe->PipeBlockMode = Buffer->CompletionMode;
Pipe->PipeConfiguration = IoStack->Parameters.Create.Options & 0x3;
Pipe->PipeType = Buffer->NamedPipeType;
Pipe->WriteMode = Buffer->ReadMode;
Pipe->ReadMode = Buffer->ReadMode;
Pipe->CompletionMode = Buffer->CompletionMode;
Pipe->PipeConfiguration = IoStack->Parameters.CreatePipe.Options & 0x3;
Pipe->MaximumInstances = Buffer->MaximumInstances;
Pipe->CurrentInstances = 0;
Pipe->TimeOut = Buffer->DefaultTimeout;

View file

@ -217,64 +217,31 @@ static NTSTATUS
NpfsGetState(PIRP Irp,
PIO_STACK_LOCATION IrpSp)
{
ULONG OutputBufferLength;
PNPFS_GET_STATE Reply;
NTSTATUS Status;
PNPFS_PIPE Pipe;
PNPFS_FCB Fcb;
OutputBufferLength = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
/* Validate parameters */
if (OutputBufferLength >= sizeof(NPFS_GET_STATE))
if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(NPFS_GET_STATE))
{
Fcb = IrpSp->FileObject->FsContext;
Reply = (PNPFS_GET_STATE)Irp->AssociatedIrp.SystemBuffer;
Pipe = Fcb->Pipe;
if (Pipe->PipeWriteMode == FILE_PIPE_MESSAGE_MODE)
{
Reply->WriteModeMessage = TRUE;
}
else
{
Reply->WriteModeMessage = FALSE;
DPRINT("Status (0x%X).\n", STATUS_INVALID_PARAMETER);
return STATUS_INVALID_PARAMETER;
}
if (Pipe->PipeReadMode == FILE_PIPE_MESSAGE_MODE)
{
Reply->ReadModeMessage = TRUE;
}
else
{
Reply->ReadModeMessage = FALSE;
}
Fcb = IrpSp->FileObject->FsContext;
Reply = (PNPFS_GET_STATE)Irp->AssociatedIrp.SystemBuffer;
Pipe = Fcb->Pipe;
if (Pipe->PipeBlockMode == FILE_PIPE_QUEUE_OPERATION)
{
Reply->NonBlocking = TRUE;
}
else
{
Reply->NonBlocking = FALSE;
}
Reply->WriteModeMessage = (Pipe->WriteMode == FILE_PIPE_MESSAGE_MODE);
Reply->ReadModeMessage = (Pipe->ReadMode == FILE_PIPE_MESSAGE_MODE);
Reply->NonBlocking = (Pipe->CompletionMode == FILE_PIPE_QUEUE_OPERATION);
Reply->InBufferSize = Pipe->InboundQuota;
Reply->OutBufferSize = Pipe->OutboundQuota;
Reply->Timeout = Pipe->TimeOut;
Reply->InBufferSize = Pipe->InboundQuota;
DPRINT("Status (0x%X).\n", STATUS_SUCCESS);
Reply->OutBufferSize = Pipe->OutboundQuota;
Reply->Timeout = Pipe->TimeOut;
Status = STATUS_SUCCESS;
}
else
{
Status = STATUS_INVALID_PARAMETER;
}
DPRINT("Status (0x%X).\n", Status);
return Status;
return STATUS_SUCCESS;
}
@ -290,64 +257,34 @@ static NTSTATUS
NpfsSetState(PIRP Irp,
PIO_STACK_LOCATION IrpSp)
{
ULONG InputBufferLength;
PNPFS_SET_STATE Request;
PNPFS_PIPE Pipe;
NTSTATUS Status;
PNPFS_FCB Fcb;
InputBufferLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
/* Validate parameters */
if (InputBufferLength >= sizeof(NPFS_SET_STATE))
{
Fcb = IrpSp->FileObject->FsContext;
Request = (PNPFS_SET_STATE)Irp->AssociatedIrp.SystemBuffer;
Pipe = Fcb->Pipe;
if (Request->WriteModeMessage)
if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(NPFS_SET_STATE))
{
Pipe->PipeWriteMode = FILE_PIPE_MESSAGE_MODE;
}
else
{
Pipe->PipeWriteMode = FILE_PIPE_BYTE_STREAM_MODE;
DPRINT("Status (0x%X).\n", STATUS_INVALID_PARAMETER);
return STATUS_INVALID_PARAMETER;
}
if (Request->ReadModeMessage)
{
Pipe->PipeReadMode = FILE_PIPE_MESSAGE_MODE;
}
else
{
Pipe->PipeReadMode = FILE_PIPE_BYTE_STREAM_MODE;
}
Fcb = IrpSp->FileObject->FsContext;
Request = (PNPFS_SET_STATE)Irp->AssociatedIrp.SystemBuffer;
Pipe = Fcb->Pipe;
if (Request->NonBlocking)
{
Pipe->PipeBlockMode = FILE_PIPE_QUEUE_OPERATION;
}
else
{
Pipe->PipeBlockMode = FILE_PIPE_COMPLETE_OPERATION;
}
Pipe->WriteMode =
Request->WriteModeMessage ? FILE_PIPE_MESSAGE_MODE : FILE_PIPE_BYTE_STREAM_MODE;
Pipe->ReadMode =
Request->WriteModeMessage ? FILE_PIPE_MESSAGE_MODE : FILE_PIPE_BYTE_STREAM_MODE;
Pipe->CompletionMode =
Request->NonBlocking ? FILE_PIPE_QUEUE_OPERATION : FILE_PIPE_COMPLETE_OPERATION;
Pipe->InboundQuota = Request->InBufferSize;
Pipe->OutboundQuota = Request->OutBufferSize;
Pipe->TimeOut = Request->Timeout;
Pipe->InboundQuota = Request->InBufferSize;
DPRINT("Status (0x%X).\n", STATUS_SUCCESS);
Pipe->OutboundQuota = Request->OutBufferSize;
Pipe->TimeOut = Request->Timeout;
Status = STATUS_SUCCESS;
}
else
{
Status = STATUS_INVALID_PARAMETER;
}
DPRINT("Status (0x%X).\n", Status);
return Status;
return STATUS_SUCCESS;
}

View file

@ -26,9 +26,9 @@ typedef struct _NPFS_PIPE
LIST_ENTRY ServerFcbListHead;
LIST_ENTRY ClientFcbListHead;
ULONG PipeType;
ULONG PipeReadMode;
ULONG PipeWriteMode;
ULONG PipeBlockMode;
ULONG ReadMode;
ULONG WriteMode;
ULONG CompletionMode;
ULONG PipeConfiguration;
ULONG MaximumInstances;
ULONG CurrentInstances;

View file

@ -1,4 +1,4 @@
/* $Id: rw.c,v 1.16 2004/12/30 16:15:10 ekohl Exp $
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -168,7 +168,7 @@ NpfsRead(PDEVICE_OBJECT DeviceObject,
KeAcquireSpinLock(&ReadFcb->DataListLock, &OldIrql);
}
if (Pipe->PipeReadMode == FILE_PIPE_BYTE_STREAM_MODE)
if (Pipe->ReadMode == FILE_PIPE_BYTE_STREAM_MODE)
{
DPRINT("Byte stream mode\n");
/* Byte stream mode */
@ -363,7 +363,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
KeAcquireSpinLock(&Fcb->DataListLock, &OldIrql);
}
if (Pipe->PipeWriteMode == FILE_PIPE_BYTE_STREAM_MODE)
if (Pipe->WriteMode == FILE_PIPE_BYTE_STREAM_MODE)
{
DPRINT("Byte stream mode\n");
while (Length > 0 && Fcb->WriteQuotaAvailable > 0)