-/* $Id$
- *
+/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/fs/np/create.c
/* INCLUDES ******************************************************************/
-#include <ddk/ntddk.h>
-
-#include "npfs.h"
-
#define NDEBUG
#include <debug.h>
+#include "npfs.h"
+
/* FUNCTIONS *****************************************************************/
static PNPFS_PIPE
if (Waiter->Fcb->PipeState == FILE_PIPE_LISTENING_STATE)
{
DPRINT("Server found! Fcb %p\n", Waiter->Fcb);
-
+
IoAcquireCancelSpinLock(&oldIrql);
if (!Irp->Cancel)
{
RemoveEntryList(&Waiter->Entry);
Irp = CONTAINING_RECORD(Waiter, IRP, Tail.Overlay.DriverContext);
- Irp->IoStatus.Status = STATUS_PIPE_CONNECTED;
+ Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
break;
NpfsCreate(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
- PIO_STACK_LOCATION IoStack;
+ PEXTENDED_IO_STACK_LOCATION IoStack;
PFILE_OBJECT FileObject;
PNPFS_PIPE Pipe;
PNPFS_FCB ClientFcb;
PNPFS_FCB ServerFcb = NULL;
PNPFS_DEVICE_EXTENSION DeviceExt;
- BOOLEAN SpecialAccess;
DPRINT("NpfsCreate(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
- IoStack = IoGetCurrentIrpStackLocation(Irp);
+ IoStack = (PEXTENDED_IO_STACK_LOCATION)IoGetCurrentIrpStackLocation(Irp);
FileObject = IoStack->FileObject;
DPRINT("FileObject %p\n", FileObject);
DPRINT("FileName %wZ\n", &FileObject->FileName);
Irp->IoStatus.Information = 0;
- SpecialAccess = ((IoStack->Parameters.Create.ShareAccess & 3) == 3);
- if (SpecialAccess)
- {
- DPRINT("NpfsCreate() open client end for special use!\n");
- }
-
/*
* Step 1. Find the pipe we're trying to open.
*/
ClientFcb->Pipe = Pipe;
ClientFcb->PipeEnd = FILE_PIPE_CLIENT_END;
ClientFcb->OtherSide = NULL;
- ClientFcb->PipeState = SpecialAccess ? 0 : FILE_PIPE_DISCONNECTED_STATE;
+ ClientFcb->PipeState = FILE_PIPE_DISCONNECTED_STATE;
InitializeListHead(&ClientFcb->ReadRequestListHead);
DPRINT("Fcb: %x\n", ClientFcb);
* Step 3. Search for listening server FCB.
*/
- if (!SpecialAccess)
+ /*
+ * WARNING: Point of no return! Once we get the server FCB it's
+ * possible that we completed a wait request and so we have to
+ * complete even this request.
+ */
+
+ ServerFcb = NpfsFindListeningServerInstance(Pipe);
+ if (ServerFcb == NULL)
{
+ PLIST_ENTRY CurrentEntry;
+ PNPFS_FCB Fcb;
+
/*
- * WARNING: Point of no return! Once we get the server FCB it's
- * possible that we completed a wait request and so we have to
- * complete even this request.
+ * If no waiting server FCB was found then try to pick
+ * one of the listing server FCB on the pipe.
*/
- ServerFcb = NpfsFindListeningServerInstance(Pipe);
- if (ServerFcb == NULL)
+ CurrentEntry = Pipe->ServerFcbListHead.Flink;
+ while (CurrentEntry != &Pipe->ServerFcbListHead)
{
- PLIST_ENTRY CurrentEntry;
- PNPFS_FCB Fcb;
-
- /*
- * If no waiting server FCB was found then try to pick
- * one of the listing server FCB on the pipe.
- */
-
- CurrentEntry = Pipe->ServerFcbListHead.Flink;
- while (CurrentEntry != &Pipe->ServerFcbListHead)
+ Fcb = CONTAINING_RECORD(CurrentEntry, NPFS_FCB, FcbListEntry);
+ if (Fcb->PipeState == FILE_PIPE_LISTENING_STATE)
{
- Fcb = CONTAINING_RECORD(CurrentEntry, NPFS_FCB, FcbListEntry);
- if (Fcb->PipeState == FILE_PIPE_LISTENING_STATE)
- {
- ServerFcb = Fcb;
- break;
- }
- CurrentEntry = CurrentEntry->Flink;
+ ServerFcb = Fcb;
+ break;
}
+ CurrentEntry = CurrentEntry->Flink;
+ }
- /*
- * No one is listening to me?! I'm so lonely... :(
- */
+ /*
+ * No one is listening to me?! I'm so lonely... :(
+ */
- if (ServerFcb == NULL)
- {
- /* Not found, bail out with error for FILE_OPEN requests. */
- DPRINT("No listening server fcb found!\n");
- if (ClientFcb->Data)
- ExFreePool(ClientFcb->Data);
- KeUnlockMutex(&Pipe->FcbListLock);
- Irp->IoStatus.Status = STATUS_PIPE_BUSY;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_PIPE_BUSY;
- }
- }
- else
+ if (ServerFcb == NULL)
{
- /* Signal the server thread and remove it from the waiter list */
- /* FIXME: Merge this with the NpfsFindListeningServerInstance routine. */
- NpfsSignalAndRemoveListeningServerInstance(Pipe, ServerFcb);
+ /* Not found, bail out with error for FILE_OPEN requests. */
+ DPRINT("No listening server fcb found!\n");
+ if (ClientFcb->Data)
+ ExFreePool(ClientFcb->Data);
+ KeUnlockMutex(&Pipe->FcbListLock);
+ Irp->IoStatus.Status = STATUS_PIPE_NOT_AVAILABLE;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_PIPE_NOT_AVAILABLE;
}
}
- else if (IsListEmpty(&Pipe->ServerFcbListHead))
+ else
{
- DPRINT("No server fcb found!\n");
- KeUnlockMutex(&Pipe->FcbListLock);
- Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_UNSUCCESSFUL;
+ /* Signal the server thread and remove it from the waiter list */
+ /* FIXME: Merge this with the NpfsFindListeningServerInstance routine. */
+ NpfsSignalAndRemoveListeningServerInstance(Pipe, ServerFcb);
}
/*
NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
- PIO_STACK_LOCATION IoStack;
+ PEXTENDED_IO_STACK_LOCATION IoStack;
PFILE_OBJECT FileObject;
PNPFS_DEVICE_EXTENSION DeviceExt;
PNPFS_PIPE Pipe;
DPRINT("NpfsCreateNamedPipe(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
- IoStack = IoGetCurrentIrpStackLocation(Irp);
+ IoStack = (PEXTENDED_IO_STACK_LOCATION)IoGetCurrentIrpStackLocation(Irp);
FileObject = IoStack->FileObject;
DPRINT("FileObject %p\n", FileObject);
DPRINT("Pipe name %wZ\n", &FileObject->FileName);
if (Pipe != NULL)
{
/*
- * Found Pipe with the same name. Check if we are
+ * Found Pipe with the same name. Check if we are
* allowed to use it.
*/
KeUnlockMutex(&DeviceExt->PipeListLock);
return STATUS_NO_MEMORY;
}
- if (RtlCreateUnicodeString(&Pipe->PipeName, FileObject->FileName.Buffer) == FALSE)
+ Pipe->PipeName.Length = FileObject->FileName.Length;
+ Pipe->PipeName.MaximumLength = Pipe->PipeName.Length + sizeof(UNICODE_NULL);
+ Pipe->PipeName.Buffer = ExAllocatePool(NonPagedPool, Pipe->PipeName.MaximumLength);
+ if (Pipe->PipeName.Buffer == NULL)
{
KeUnlockMutex(&DeviceExt->PipeListLock);
ExFreePool(Pipe);
return STATUS_NO_MEMORY;
}
+ RtlCopyUnicodeString(&Pipe->PipeName, &FileObject->FileName);
+
InitializeListHead(&Pipe->ServerFcbListHead);
InitializeListHead(&Pipe->ClientFcbListHead);
InitializeListHead(&Pipe->WaiterListHead);
Pipe->MaximumInstances = Buffer->MaximumInstances;
Pipe->CurrentInstances = 0;
Pipe->TimeOut = Buffer->DefaultTimeout;
- if (!(IoStack->Parameters.Create.Options & FILE_PIPE_OUTBOUND) ||
- IoStack->Parameters.Create.Options & FILE_PIPE_FULL_DUPLEX)
+ if (!(IoStack->Parameters.CreatePipe.Options & FILE_PIPE_OUTBOUND) ||
+ IoStack->Parameters.CreatePipe.Options & FILE_PIPE_FULL_DUPLEX)
{
if (Buffer->InboundQuota == 0)
{
Pipe->InboundQuota = 0;
}
- if (IoStack->Parameters.Create.Options & (FILE_PIPE_FULL_DUPLEX|FILE_PIPE_OUTBOUND))
+ if (IoStack->Parameters.CreatePipe.Options & (FILE_PIPE_FULL_DUPLEX|FILE_PIPE_OUTBOUND))
{
if (Buffer->OutboundQuota == 0)
{
PFILE_OBJECT FileObject;
PNPFS_FCB Fcb, OtherSide;
PNPFS_PIPE Pipe;
- BOOL Server;
+ BOOLEAN Server;
DPRINT("NpfsCleanup(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
{
PLIST_ENTRY Entry;
PNPFS_WAITER_ENTRY WaitEntry = NULL;
- BOOLEAN Complete = FALSE;
+ BOOLEAN Complete = FALSE;
KIRQL oldIrql;
PIRP tmpIrp;
PFILE_OBJECT FileObject;
PNPFS_FCB Fcb;
PNPFS_PIPE Pipe;
- BOOL Server;
+ BOOLEAN Server;
DPRINT("NpfsClose(DeviceObject %p Irp %p)\n", DeviceObject, Irp);