[msfs] Mail slot file system driver bring up 2/2:

- Don't allow to create two mail slots with the same name
- Pass a timeout return status when no message are found after waiting
- Clients aren't allowed to query mail slot info, this works now - add the code back

svn path=/trunk/; revision=44533
This commit is contained in:
Gregor Schneider 2009-12-11 09:45:07 +00:00
parent 6a29ad7b49
commit 174afbb80c
3 changed files with 48 additions and 18 deletions

View file

@ -16,6 +16,7 @@
/* FUNCTIONS *****************************************************************/
/* Creates the client side */
NTSTATUS DEFAULTAPI
MsfsCreate(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
@ -99,6 +100,7 @@ MsfsCreate(PDEVICE_OBJECT DeviceObject,
}
/* Creates the server side */
NTSTATUS DEFAULTAPI
MsfsCreateMailslot(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
@ -197,7 +199,14 @@ MsfsCreateMailslot(PDEVICE_OBJECT DeviceObject,
ExFreePool(Fcb->Name.Buffer);
ExFreePool(Fcb);
Fcb = current;
KeUnlockMutex(&DeviceExtension->FcbListLock);
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_UNSUCCESSFUL;
}
else
{

View file

@ -95,6 +95,19 @@ MsfsQueryInformation(PDEVICE_OBJECT DeviceObject,
DPRINT("Mailslot name: %wZ\n", &Fcb->Name);
/* querying information is not permitted on client side */
if (Fcb->ServerCcb != Ccb)
{
Status = STATUS_ACCESS_DENIED;
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
BufferLength = IoStack->Parameters.QueryFile.Length;

View file

@ -62,25 +62,33 @@ MsfsRead(PDEVICE_OBJECT DeviceObject,
KernelMode,
FALSE,
&Fcb->TimeOut);
if ((NT_SUCCESS(Status)) && (Fcb->MessageCount > 0))
if (NT_SUCCESS(Status))
{
/* copy current message into buffer */
Message = CONTAINING_RECORD(Fcb->MessageListHead.Flink,
MSFS_MESSAGE,
MessageListEntry);
memcpy(Buffer, &Message->Buffer, min(Message->Size,Length));
LengthRead = Message->Size;
KeAcquireSpinLock(&Fcb->MessageListLock, &oldIrql);
RemoveHeadList(&Fcb->MessageListHead);
KeReleaseSpinLock(&Fcb->MessageListLock, oldIrql);
ExFreePool(Message);
Fcb->MessageCount--;
if (Fcb->MessageCount == 0)
if (Fcb->MessageCount > 0)
{
KeClearEvent(&Fcb->MessageEvent);
/* copy current message into buffer */
Message = CONTAINING_RECORD(Fcb->MessageListHead.Flink,
MSFS_MESSAGE,
MessageListEntry);
memcpy(Buffer, &Message->Buffer, min(Message->Size,Length));
LengthRead = Message->Size;
KeAcquireSpinLock(&Fcb->MessageListLock, &oldIrql);
RemoveHeadList(&Fcb->MessageListHead);
KeReleaseSpinLock(&Fcb->MessageListLock, oldIrql);
ExFreePool(Message);
Fcb->MessageCount--;
if (Fcb->MessageCount == 0)
{
KeClearEvent(&Fcb->MessageEvent);
}
}
else if (Fcb->TimeOut.QuadPart != 0LL)
{
/* No message found after waiting */
Status = STATUS_IO_TIMEOUT;
}
}