- 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

svn path=/trunk/; revision=57419
This commit is contained in:
Thomas Faber 2012-09-29 08:19:24 +00:00
parent ca666fb5a8
commit fccc5788cc
8 changed files with 72 additions and 29 deletions

View file

@ -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 @@ NpfsAllocateCcb(CCB_TYPE Type, PNPFS_FCB Fcb)
Ccb->RefCount = 1;
Ccb->Type = Type;
// FIXME: why does this function not reference Fcb?
Ccb->Fcb = Fcb;
Ccb->OtherSide = NULL;
@ -60,7 +61,7 @@ VOID
NpfsReferenceCcb(PNPFS_CCB Ccb)
{
ASSERT(Ccb->RefCount > 0);
InterlockedIncrement((PLONG)&Ccb->RefCount);
InterlockedIncrement(&Ccb->RefCount);
}
static
@ -69,7 +70,7 @@ NpfsDereferenceCcb(PNPFS_CCB Ccb)
{
/* 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 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
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 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
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 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
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

View file

@ -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 @@ NpfsQueryDirectory(PNPFS_CCB Ccb,
/* Determine Buffer for result */
if (Irp->MdlAddress)
{
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
Buffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress,
NormalPagePriority);
}
else
{
@ -298,6 +299,8 @@ NpfsDirectoryControl(PDEVICE_OBJECT DeviceObject,
NTSTATUS Status;
ULONG Size = 0;
UNREFERENCED_PARAMETER(DeviceObject);
DPRINT("NpfsDirectoryControl() called\n");
IoStack = IoGetCurrentIrpStackLocation(Irp);

View file

@ -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 @@ NpfsSetPipeInformation(PDEVICE_OBJECT DeviceObject,
{
PNPFS_FCB Fcb;
PFILE_PIPE_INFORMATION Request;
UNREFERENCED_PARAMETER(DeviceObject);
DPRINT("NpfsSetPipeInformation()\n");
if (*BufferLength < sizeof(FILE_PIPE_INFORMATION))
@ -48,7 +51,7 @@ NpfsSetPipeInformation(PDEVICE_OBJECT DeviceObject,
{
Fcb->ClientReadMode = Request->ReadMode;
}
else
else
{
Fcb->ServerReadMode = Request->ReadMode;
}
@ -68,6 +71,9 @@ NpfsSetPipeRemoteInformation(PDEVICE_OBJECT DeviceObject,
{
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 @@ NpfsQueryPipeInformation(PDEVICE_OBJECT DeviceObject,
{
PNPFS_FCB Fcb;
ULONG ConnectionSideReadMode;
UNREFERENCED_PARAMETER(DeviceObject);
DPRINT("NpfsQueryPipeInformation()\n");
if (*BufferLength < sizeof(FILE_PIPE_INFORMATION))
@ -132,6 +141,9 @@ NpfsQueryPipeRemoteInformation(PDEVICE_OBJECT DeviceObject,
PULONG BufferLength)
{
PNPFS_FCB Fcb;
UNREFERENCED_PARAMETER(DeviceObject);
DPRINT("NpfsQueryPipeRemoteInformation()\n");
if (*BufferLength < sizeof(FILE_PIPE_REMOTE_INFORMATION))
@ -165,6 +177,8 @@ NpfsQueryLocalPipeInformation(PDEVICE_OBJECT DeviceObject,
{
PNPFS_FCB Fcb;
UNREFERENCED_PARAMETER(DeviceObject);
DPRINT("NpfsQueryLocalPipeInformation()\n");
if (*BufferLength < sizeof(FILE_PIPE_REMOTE_INFORMATION))

View file

@ -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
@ -26,6 +26,8 @@ NpfsListeningCancelRoutine(IN PDEVICE_OBJECT DeviceObject,
{
PNPFS_WAITER_ENTRY Waiter;
UNREFERENCED_PARAMETER(DeviceObject);
Waiter = (PNPFS_WAITER_ENTRY)&Irp->Tail.Overlay.DriverContext;
DPRINT("NpfsListeningCancelRoutine() called for <%wZ>\n",
@ -795,6 +797,7 @@ NpfsFlushBuffers(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
/* FIXME: Implement */
UNREFERENCED_PARAMETER(DeviceObject);
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;

View file

@ -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>
*/
@ -25,6 +25,8 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
PNPFS_FCB Fcb;
NTSTATUS Status;
UNREFERENCED_PARAMETER(RegistryPath);
DPRINT("Named Pipe FSD 0.0.2\n");
ASSERT (sizeof(NPFS_CONTEXT) <= FIELD_OFFSET(IRP, Tail.Overlay.DriverContext));
@ -87,6 +89,12 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
/* 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 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
/* 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;

View file

@ -95,7 +95,7 @@ typedef struct _NPFS_CCB
ULONG PipeState;
ULONG ReadDataAvailable;
ULONG WriteQuotaAvailable;
ULONG RefCount;
volatile LONG RefCount;
LIST_ENTRY ReadRequestListHead;

View file

@ -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 @@ NpfsReadWriteCancelRoutine(IN PDEVICE_OBJECT DeviceObject,
}
}
static KSTART_ROUTINE NpfsWaiterThread;
static VOID NTAPI
NpfsWaiterThread(PVOID InitContext)
{
@ -175,7 +176,7 @@ NpfsWaiterThread(PVOID InitContext)
}
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 @@ NpfsWaiterThread(PVOID InitContext)
{
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 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
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 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
{
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 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
{
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 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
/* 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 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
Ccb->ReadDataAvailable -= CopyLength;
if ((ULONG)Ccb->WriteQuotaAvailable > (ULONG)Ccb->MaxDataLength) ASSERT(FALSE);
ASSERT(Ccb->WriteQuotaAvailable <= Ccb->MaxDataLength);
}
if (Information > 0)
@ -740,6 +743,8 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
ULONG CopyLength;
ULONG TempLength;
UNREFERENCED_PARAMETER(DeviceObject);
DPRINT("NpfsWrite()\n");
IoStack = IoGetCurrentIrpStackLocation(Irp);
@ -794,7 +799,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
}
Status = STATUS_SUCCESS;
Buffer = MmGetSystemAddressForMdlSafe (Irp->MdlAddress, NormalPagePriority);
Buffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
if (!Buffer)
{
@ -813,7 +818,7 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
HexDump(Buffer, Length);
#endif
while(1)
while (1)
{
if (ReaderCcb->WriteQuotaAvailable == 0)
{

View file

@ -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
*/