From fb1c02d7d1b7e9132fbb960b5186f90ec093ac24 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Mon, 3 Jan 2005 13:50:04 +0000 Subject: [PATCH] Clean up the pipe type and mode mess. svn path=/trunk/; revision=12754 --- reactos/drivers/fs/np/create.c | 10 +-- reactos/drivers/fs/np/fsctrl.c | 125 ++++++++------------------------- reactos/drivers/fs/np/npfs.h | 6 +- reactos/drivers/fs/np/rw.c | 6 +- 4 files changed, 42 insertions(+), 105 deletions(-) diff --git a/reactos/drivers/fs/np/create.c b/reactos/drivers/fs/np/create.c index cdbef4032ce..ef5e5e2294b 100644 --- a/reactos/drivers/fs/np/create.c +++ b/reactos/drivers/fs/np/create.c @@ -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; diff --git a/reactos/drivers/fs/np/fsctrl.c b/reactos/drivers/fs/np/fsctrl.c index f0d9d5c4433..0e8e2633b54 100644 --- a/reactos/drivers/fs/np/fsctrl.c +++ b/reactos/drivers/fs/np/fsctrl.c @@ -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; } diff --git a/reactos/drivers/fs/np/npfs.h b/reactos/drivers/fs/np/npfs.h index db552a55ec2..f7e70f463ca 100644 --- a/reactos/drivers/fs/np/npfs.h +++ b/reactos/drivers/fs/np/npfs.h @@ -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; diff --git a/reactos/drivers/fs/np/rw.c b/reactos/drivers/fs/np/rw.c index 3d9c4cdd3fa..aab1872ff03 100644 --- a/reactos/drivers/fs/np/rw.c +++ b/reactos/drivers/fs/np/rw.c @@ -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)