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); InitializeListHead(&Pipe->ClientFcbListHead);
KeInitializeMutex(&Pipe->FcbListLock, 0); KeInitializeMutex(&Pipe->FcbListLock, 0);
Pipe->PipeType = Buffer->NamedPipeType ? FILE_PIPE_MESSAGE_TYPE : FILE_PIPE_BYTE_STREAM_TYPE; Pipe->PipeType = Buffer->NamedPipeType;
Pipe->PipeWriteMode = Buffer->NamedPipeType ? FILE_PIPE_MESSAGE_MODE : FILE_PIPE_BYTE_STREAM_MODE; Pipe->WriteMode = Buffer->ReadMode;
Pipe->PipeReadMode = Buffer->ReadMode ? FILE_PIPE_MESSAGE_MODE : FILE_PIPE_BYTE_STREAM_MODE; Pipe->ReadMode = Buffer->ReadMode;
Pipe->PipeBlockMode = Buffer->CompletionMode; Pipe->CompletionMode = Buffer->CompletionMode;
Pipe->PipeConfiguration = IoStack->Parameters.Create.Options & 0x3; Pipe->PipeConfiguration = IoStack->Parameters.CreatePipe.Options & 0x3;
Pipe->MaximumInstances = Buffer->MaximumInstances; Pipe->MaximumInstances = Buffer->MaximumInstances;
Pipe->CurrentInstances = 0; Pipe->CurrentInstances = 0;
Pipe->TimeOut = Buffer->DefaultTimeout; Pipe->TimeOut = Buffer->DefaultTimeout;

View file

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

View file

@ -26,9 +26,9 @@ typedef struct _NPFS_PIPE
LIST_ENTRY ServerFcbListHead; LIST_ENTRY ServerFcbListHead;
LIST_ENTRY ClientFcbListHead; LIST_ENTRY ClientFcbListHead;
ULONG PipeType; ULONG PipeType;
ULONG PipeReadMode; ULONG ReadMode;
ULONG PipeWriteMode; ULONG WriteMode;
ULONG PipeBlockMode; ULONG CompletionMode;
ULONG PipeConfiguration; ULONG PipeConfiguration;
ULONG MaximumInstances; ULONG MaximumInstances;
ULONG CurrentInstances; 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -168,7 +168,7 @@ NpfsRead(PDEVICE_OBJECT DeviceObject,
KeAcquireSpinLock(&ReadFcb->DataListLock, &OldIrql); 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"); DPRINT("Byte stream mode\n");
/* Byte stream mode */ /* Byte stream mode */
@ -363,7 +363,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
KeAcquireSpinLock(&Fcb->DataListLock, &OldIrql); 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"); DPRINT("Byte stream mode\n");
while (Length > 0 && Fcb->WriteQuotaAvailable > 0) while (Length > 0 && Fcb->WriteQuotaAvailable > 0)