Author: tfaber Date: Sat Sep 29 08:19:24 2012 New Revision: 57419
URL: http://svn.reactos.org/svn/reactos?rev=57419&view=rev Log: [NPFS] - Fix return status if no listening server found in NpfsCreate - Do not use obsolete function MmGetSystemAddressForMdl - Fix a few MSVC/GCC 4.7 warnings - Correctly handle device/root FCB allocation failure - Fix type of NPFS_CCB::RefCount
Modified: trunk/reactos/drivers/filesystems/npfs/create.c trunk/reactos/drivers/filesystems/npfs/dirctl.c trunk/reactos/drivers/filesystems/npfs/finfo.c trunk/reactos/drivers/filesystems/npfs/fsctrl.c trunk/reactos/drivers/filesystems/npfs/npfs.c trunk/reactos/drivers/filesystems/npfs/npfs.h trunk/reactos/drivers/filesystems/npfs/rw.c trunk/reactos/drivers/filesystems/npfs/volume.c
Modified: trunk/reactos/drivers/filesystems/npfs/create.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/cr... ============================================================================== --- trunk/reactos/drivers/filesystems/npfs/create.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/npfs/create.c [iso-8859-1] Sat Sep 29 08:19:24 2012 @@ -1,7 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel -* FILE: drivers/fs/np/create.c +* FILE: drivers/filesystems/npfs/create.c * PURPOSE: Named pipe filesystem * PROGRAMMER: David Welch welch@cwcom.net */ @@ -49,6 +49,7 @@
Ccb->RefCount = 1; Ccb->Type = Type; + // FIXME: why does this function not reference Fcb? Ccb->Fcb = Fcb; Ccb->OtherSide = NULL;
@@ -60,7 +61,7 @@ NpfsReferenceCcb(PNPFS_CCB Ccb) { ASSERT(Ccb->RefCount > 0); - InterlockedIncrement((PLONG)&Ccb->RefCount); + InterlockedIncrement(&Ccb->RefCount); }
static @@ -69,7 +70,7 @@ { /* Decrement reference count */ ASSERT(Ccb->RefCount > 0); - if (InterlockedDecrement((PLONG)&Ccb->RefCount) == 0) + if (InterlockedDecrement(&Ccb->RefCount) == 0) { /* Its zero, delete CCB */ ExFreePoolWithTag(Ccb, TAG_NPFS_CCB); @@ -249,9 +250,9 @@ PNPFS_CCB ClientCcb; PNPFS_CCB ServerCcb = NULL; PNPFS_VCB Vcb; - ACCESS_MASK DesiredAccess; NTSTATUS Status; #ifndef USING_PROPER_NPFS_WAIT_SEMANTICS + ACCESS_MASK DesiredAccess; BOOLEAN SpecialAccess; #endif
@@ -262,7 +263,9 @@ FileObject = IoStack->FileObject; RelatedFileObject = FileObject->RelatedFileObject; FileName = &FileObject->FileName; +#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS DesiredAccess = IoStack->Parameters.CreatePipe.SecurityContext->DesiredAccess; +#endif
DPRINT("FileObject %p\n", FileObject); DPRINT("FileName %wZ\n", &FileObject->FileName); @@ -444,9 +447,9 @@ NpfsDereferenceCcb(ClientCcb); KeUnlockMutex(&Fcb->CcbListLock); NpfsDereferenceFcb(Fcb); - Irp->IoStatus.Status = STATUS_OBJECT_PATH_NOT_FOUND; + Irp->IoStatus.Status = STATUS_OBJECT_NAME_NOT_FOUND; IoCompleteRequest(Irp, IO_NO_INCREMENT); - return STATUS_OBJECT_PATH_NOT_FOUND; + return STATUS_OBJECT_NAME_NOT_FOUND; } } else
Modified: trunk/reactos/drivers/filesystems/npfs/dirctl.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/di... ============================================================================== --- trunk/reactos/drivers/filesystems/npfs/dirctl.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/npfs/dirctl.c [iso-8859-1] Sat Sep 29 08:19:24 2012 @@ -1,7 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel - * FILE: drivers/filesastems/npfs/dirctl.c + * FILE: drivers/filesystems/npfs/dirctl.c * PURPOSE: Named pipe filesystem * PROGRAMMER: Eric Kohl */ @@ -55,7 +55,8 @@ /* Determine Buffer for result */ if (Irp->MdlAddress) { - Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress); + Buffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, + NormalPagePriority); } else { @@ -298,6 +299,8 @@ NTSTATUS Status; ULONG Size = 0;
+ UNREFERENCED_PARAMETER(DeviceObject); + DPRINT("NpfsDirectoryControl() called\n");
IoStack = IoGetCurrentIrpStackLocation(Irp);
Modified: trunk/reactos/drivers/filesystems/npfs/finfo.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/fi... ============================================================================== --- trunk/reactos/drivers/filesystems/npfs/finfo.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/npfs/finfo.c [iso-8859-1] Sat Sep 29 08:19:24 2012 @@ -1,7 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel -* FILE: drivers/fs/np/finfo.c +* FILE: drivers/filesystems/npfs/finfo.c * PURPOSE: Named pipe filesystem * PROGRAMMER: Eric Kohl */ @@ -24,6 +24,9 @@ { PNPFS_FCB Fcb; PFILE_PIPE_INFORMATION Request; + + UNREFERENCED_PARAMETER(DeviceObject); + DPRINT("NpfsSetPipeInformation()\n");
if (*BufferLength < sizeof(FILE_PIPE_INFORMATION)) @@ -48,7 +51,7 @@ { Fcb->ClientReadMode = Request->ReadMode; } - else + else { Fcb->ServerReadMode = Request->ReadMode; } @@ -68,6 +71,9 @@ { PNPFS_FCB Fcb; PFILE_PIPE_REMOTE_INFORMATION Request; + + UNREFERENCED_PARAMETER(DeviceObject); + DPRINT("NpfsSetPipeRemoteInformation()\n");
if (*BufferLength < sizeof(FILE_PIPE_REMOTE_INFORMATION)) @@ -97,6 +103,9 @@ { PNPFS_FCB Fcb; ULONG ConnectionSideReadMode; + + UNREFERENCED_PARAMETER(DeviceObject); + DPRINT("NpfsQueryPipeInformation()\n");
if (*BufferLength < sizeof(FILE_PIPE_INFORMATION)) @@ -132,6 +141,9 @@ PULONG BufferLength) { PNPFS_FCB Fcb; + + UNREFERENCED_PARAMETER(DeviceObject); + DPRINT("NpfsQueryPipeRemoteInformation()\n");
if (*BufferLength < sizeof(FILE_PIPE_REMOTE_INFORMATION)) @@ -164,6 +176,8 @@ PULONG BufferLength) { PNPFS_FCB Fcb; + + UNREFERENCED_PARAMETER(DeviceObject);
DPRINT("NpfsQueryLocalPipeInformation()\n");
Modified: trunk/reactos/drivers/filesystems/npfs/fsctrl.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/fs... ============================================================================== --- trunk/reactos/drivers/filesystems/npfs/fsctrl.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/npfs/fsctrl.c [iso-8859-1] Sat Sep 29 08:19:24 2012 @@ -1,7 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel -* FILE: drivers/fs/np/fsctrl.c +* FILE: drivers/filesystems/npfs/fsctrl.c * PURPOSE: Named pipe filesystem * PROGRAMMER: David Welch welch@cwcom.net * Eric Kohl @@ -25,6 +25,8 @@ IN PIRP Irp) { PNPFS_WAITER_ENTRY Waiter; + + UNREFERENCED_PARAMETER(DeviceObject);
Waiter = (PNPFS_WAITER_ENTRY)&Irp->Tail.Overlay.DriverContext;
@@ -795,6 +797,7 @@ PIRP Irp) { /* FIXME: Implement */ + UNREFERENCED_PARAMETER(DeviceObject);
Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = 0;
Modified: trunk/reactos/drivers/filesystems/npfs/npfs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/np... ============================================================================== --- trunk/reactos/drivers/filesystems/npfs/npfs.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/npfs/npfs.c [iso-8859-1] Sat Sep 29 08:19:24 2012 @@ -1,7 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel -* FILE: drivers/fs/np/mount.c +* FILE: drivers/filesystems/npfs/npfs.c * PURPOSE: Named pipe filesystem * PROGRAMMER: David Welch welch@cwcom.net */ @@ -24,6 +24,8 @@ PNPFS_VCB Vcb; PNPFS_FCB Fcb; NTSTATUS Status; + + UNREFERENCED_PARAMETER(RegistryPath);
DPRINT("Named Pipe FSD 0.0.2\n");
@@ -87,6 +89,12 @@
/* Create the device FCB */ Fcb = ExAllocatePoolWithTag(NonPagedPool, sizeof(NPFS_FCB), TAG_NPFS_FCB); + if (!Fcb) + { + DPRINT1("Out of memory for device FCB!\n"); + IoDeleteDevice(DeviceObject); + return STATUS_INSUFFICIENT_RESOURCES; + } Fcb->Type = FCB_DEVICE; Fcb->Vcb = Vcb; Fcb->RefCount = 1; @@ -94,6 +102,13 @@
/* Create the root directory FCB */ Fcb = ExAllocatePoolWithTag(NonPagedPool, sizeof(NPFS_FCB), TAG_NPFS_FCB); + if (!Fcb) + { + DPRINT1("Out of memory for root FCB!\n"); + IoDeleteDevice(DeviceObject); + ExFreePoolWithTag(Vcb->DeviceFcb, TAG_NPFS_FCB); + return STATUS_INSUFFICIENT_RESOURCES; + } Fcb->Type = FCB_DIRECTORY; Fcb->Vcb = Vcb; Fcb->RefCount = 1;
Modified: trunk/reactos/drivers/filesystems/npfs/npfs.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/np... ============================================================================== --- trunk/reactos/drivers/filesystems/npfs/npfs.h [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/npfs/npfs.h [iso-8859-1] Sat Sep 29 08:19:24 2012 @@ -95,7 +95,7 @@ ULONG PipeState; ULONG ReadDataAvailable; ULONG WriteQuotaAvailable; - ULONG RefCount; + volatile LONG RefCount;
LIST_ENTRY ReadRequestListHead;
Modified: trunk/reactos/drivers/filesystems/npfs/rw.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/rw... ============================================================================== --- trunk/reactos/drivers/filesystems/npfs/rw.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/npfs/rw.c [iso-8859-1] Sat Sep 29 08:19:24 2012 @@ -1,7 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel -* FILE: drivers/fs/np/rw.c +* FILE: drivers/filesystems/npfs/rw.c * PURPOSE: Named pipe filesystem * PROGRAMMER: David Welch welch@cwcom.net * Michael Martin @@ -115,6 +115,7 @@ } }
+static KSTART_ROUTINE NpfsWaiterThread; static VOID NTAPI NpfsWaiterThread(PVOID InitContext) { @@ -175,7 +176,7 @@ } else { - /* someone has add a new wait request or cancelled an old one */ + /* someone has added a new wait request or cancelled an old one */ Irp = NULL;
/* Look for cancelled requests */ @@ -183,16 +184,16 @@ { if (ThreadContext->WaitIrpArray[i] == NULL) { - ThreadContext->Count--; - ThreadContext->Vcb->EmptyWaiterCount++; - ThreadContext->WaitObjectArray[i] = ThreadContext->WaitObjectArray[ThreadContext->Count]; - ThreadContext->WaitIrpArray[i] = ThreadContext->WaitIrpArray[ThreadContext->Count]; + ThreadContext->Count--; + ThreadContext->Vcb->EmptyWaiterCount++; + ThreadContext->WaitObjectArray[i] = ThreadContext->WaitObjectArray[ThreadContext->Count]; + ThreadContext->WaitIrpArray[i] = ThreadContext->WaitIrpArray[ThreadContext->Count]; } } } if (ThreadContext->Count == 1 && ThreadContext->Vcb->EmptyWaiterCount >= MAXIMUM_WAIT_OBJECTS) { - /* it exist an other thread with empty wait slots, we can remove our thread from the list */ + /* there is another thread with empty wait slots, we can remove our thread from the list */ RemoveEntryList(&ThreadContext->ListEntry); ExFreePoolWithTag(ThreadContext, TAG_NPFS_THREAD_CONTEXT); KeUnlockMutex(&ThreadContext->Vcb->PipeListLock); @@ -416,10 +417,11 @@
while (1) { - Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress); + Buffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, + NormalPagePriority); Information = Irp->IoStatus.Information; Length = IoGetCurrentIrpStackLocation(Irp)->Parameters.Read.Length; - ASSERT (Information <= Length); + ASSERT(Information <= Length); Buffer = (PVOID)((ULONG_PTR)Buffer + Information); Length -= Information; Status = STATUS_SUCCESS; @@ -443,7 +445,8 @@ { break; } - if (((Ccb->PipeState != FILE_PIPE_CONNECTED_STATE) || (!Ccb->OtherSide)) && (Ccb->ReadDataAvailable == 0)) + ASSERT(Ccb->ReadDataAvailable == 0); + if ((Ccb->PipeState != FILE_PIPE_CONNECTED_STATE) || (!Ccb->OtherSide)) { DPRINT("PipeState: %x\n", Ccb->PipeState); Status = STATUS_PIPE_BROKEN; @@ -556,7 +559,7 @@ { ULONG NextMessageLength = 0;
- /*First get the size of the message */ + /* First get the size of the message */ memcpy(&NextMessageLength, Ccb->ReadPtr, sizeof(NextMessageLength));
if ((NextMessageLength == 0) || (NextMessageLength > Ccb->ReadDataAvailable)) @@ -579,7 +582,7 @@ /* Client only requested part of the message */ { /* Calculate the remaining message new size */ - ULONG NewMessageSize = NextMessageLength-CopyLength; + ULONG NewMessageSize = NextMessageLength - CopyLength;
/* Update ReadPtr to point to new Message size location */ Ccb->ReadPtr = (PVOID)((ULONG_PTR)Ccb->ReadPtr + CopyLength); @@ -616,7 +619,7 @@
Ccb->ReadDataAvailable -= CopyLength;
- if ((ULONG)Ccb->WriteQuotaAvailable > (ULONG)Ccb->MaxDataLength) ASSERT(FALSE); + ASSERT(Ccb->WriteQuotaAvailable <= Ccb->MaxDataLength); }
if (Information > 0) @@ -740,6 +743,8 @@ ULONG CopyLength; ULONG TempLength;
+ UNREFERENCED_PARAMETER(DeviceObject); + DPRINT("NpfsWrite()\n");
IoStack = IoGetCurrentIrpStackLocation(Irp); @@ -794,7 +799,7 @@ }
Status = STATUS_SUCCESS; - Buffer = MmGetSystemAddressForMdlSafe (Irp->MdlAddress, NormalPagePriority); + Buffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
if (!Buffer) { @@ -813,7 +818,7 @@ HexDump(Buffer, Length); #endif
- while(1) + while (1) { if (ReaderCcb->WriteQuotaAvailable == 0) {
Modified: trunk/reactos/drivers/filesystems/npfs/volume.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/vo... ============================================================================== --- trunk/reactos/drivers/filesystems/npfs/volume.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/npfs/volume.c [iso-8859-1] Sat Sep 29 08:19:24 2012 @@ -1,7 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel -* FILE: drivers/fs/npfs/volume.c +* FILE: drivers/filesystems/npfs/volume.c * PURPOSE: Named pipe filesystem * PROGRAMMER: Eric Kohl */