The MSFS_FCB struct is actually a CCB (Context Control Block) instead of an FCB (File Control Block). Rename it accordingly and store pointers to it in FileObject->FsContext2 instead of FileObject->FsContext.

svn path=/trunk/; revision=21813
This commit is contained in:
Eric Kohl 2006-05-06 15:37:40 +00:00
parent 6d2a7a72b1
commit 0d5cf488c4
5 changed files with 63 additions and 63 deletions

View file

@ -25,7 +25,7 @@ MsfsCreate(PDEVICE_OBJECT DeviceObject,
PFILE_OBJECT FileObject;
PMSFS_DEVICE_EXTENSION DeviceExtension;
PMSFS_MAILSLOT Mailslot;
PMSFS_FCB Fcb;
PMSFS_CCB Ccb;
PMSFS_MAILSLOT current = NULL;
PLIST_ENTRY current_entry;
KIRQL oldIrql;
@ -38,8 +38,8 @@ MsfsCreate(PDEVICE_OBJECT DeviceObject,
DPRINT("Mailslot name: %wZ\n", &FileObject->FileName);
Fcb = ExAllocatePool(NonPagedPool, sizeof(MSFS_FCB));
if (Fcb == NULL)
Ccb = ExAllocatePool(NonPagedPool, sizeof(MSFS_CCB));
if (Ccb == NULL)
{
Irp->IoStatus.Status = STATUS_NO_MEMORY;
Irp->IoStatus.Information = 0;
@ -67,7 +67,7 @@ MsfsCreate(PDEVICE_OBJECT DeviceObject,
if (current_entry == &DeviceExtension->MailslotListHead)
{
ExFreePool(Fcb);
ExFreePool(Ccb);
KeUnlockMutex(&DeviceExtension->MailslotListLock);
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
@ -80,17 +80,17 @@ MsfsCreate(PDEVICE_OBJECT DeviceObject,
Mailslot = current;
KeAcquireSpinLock(&Mailslot->FcbListLock, &oldIrql);
InsertTailList(&Mailslot->FcbListHead, &Fcb->FcbListEntry);
KeReleaseSpinLock(&Mailslot->FcbListLock, oldIrql);
KeAcquireSpinLock(&Mailslot->CcbListLock, &oldIrql);
InsertTailList(&Mailslot->CcbListHead, &Ccb->CcbListEntry);
KeReleaseSpinLock(&Mailslot->CcbListLock, oldIrql);
Mailslot->ReferenceCount++;
Fcb->Mailslot = Mailslot;
Ccb->Mailslot = Mailslot;
KeUnlockMutex(&DeviceExtension->MailslotListLock);
FileObject->FsContext = Fcb;
FileObject->FsContext2 = Ccb;
FileObject->Flags |= FO_MAILSLOT;
Irp->IoStatus.Status = STATUS_SUCCESS;
@ -110,7 +110,7 @@ MsfsCreateMailslot(PDEVICE_OBJECT DeviceObject,
PFILE_OBJECT FileObject;
PMSFS_DEVICE_EXTENSION DeviceExtension;
PMSFS_MAILSLOT Mailslot;
PMSFS_FCB Fcb;
PMSFS_CCB Ccb;
KIRQL oldIrql;
PLIST_ENTRY current_entry;
PMSFS_MAILSLOT current;
@ -153,8 +153,8 @@ MsfsCreateMailslot(PDEVICE_OBJECT DeviceObject,
RtlCopyUnicodeString(&Mailslot->Name, &FileObject->FileName);
Fcb = ExAllocatePool(NonPagedPool, sizeof(MSFS_FCB));
if (Fcb == NULL)
Ccb = ExAllocatePool(NonPagedPool, sizeof(MSFS_CCB));
if (Ccb == NULL)
{
ExFreePool(Mailslot);
@ -167,8 +167,8 @@ MsfsCreateMailslot(PDEVICE_OBJECT DeviceObject,
}
Mailslot->ReferenceCount = 0;
InitializeListHead(&Mailslot->FcbListHead);
KeInitializeSpinLock(&Mailslot->FcbListLock);
InitializeListHead(&Mailslot->CcbListHead);
KeInitializeSpinLock(&Mailslot->CcbListLock);
Mailslot->MaxMessageSize = Buffer->MaximumMessageSize;
Mailslot->MessageCount = 0;
@ -209,17 +209,17 @@ MsfsCreateMailslot(PDEVICE_OBJECT DeviceObject,
&Mailslot->MailslotListEntry);
}
KeAcquireSpinLock(&Mailslot->FcbListLock, &oldIrql);
InsertTailList(&Mailslot->FcbListHead, &Fcb->FcbListEntry);
KeReleaseSpinLock(&Mailslot->FcbListLock, oldIrql);
KeAcquireSpinLock(&Mailslot->CcbListLock, &oldIrql);
InsertTailList(&Mailslot->CcbListHead, &Ccb->CcbListEntry);
KeReleaseSpinLock(&Mailslot->CcbListLock, oldIrql);
Mailslot->ReferenceCount++;
Mailslot->ServerFcb = Fcb;
Fcb->Mailslot = Mailslot;
Mailslot->ServerCcb = Ccb;
Ccb->Mailslot = Mailslot;
KeUnlockMutex(&DeviceExtension->MailslotListLock);
FileObject->FsContext = Fcb;
FileObject->FsContext2 = Ccb;
FileObject->Flags |= FO_MAILSLOT;
Irp->IoStatus.Status = STATUS_SUCCESS;
@ -239,7 +239,7 @@ MsfsClose(PDEVICE_OBJECT DeviceObject,
PFILE_OBJECT FileObject;
PMSFS_DEVICE_EXTENSION DeviceExtension;
PMSFS_MAILSLOT Mailslot;
PMSFS_FCB Fcb;
PMSFS_CCB Ccb;
PMSFS_MESSAGE Message;
KIRQL oldIrql;
@ -263,13 +263,13 @@ MsfsClose(PDEVICE_OBJECT DeviceObject,
return(STATUS_SUCCESS);
}
Fcb = FileObject->FsContext;
Mailslot = Fcb->Mailslot;
Ccb = FileObject->FsContext2;
Mailslot = Ccb->Mailslot;
DPRINT("Mailslot name: %wZ\n", &Mailslot->Name);
Mailslot->ReferenceCount--;
if (Mailslot->ServerFcb == Fcb)
if (Mailslot->ServerCcb == Ccb)
{
/* delete all messages from message-list */
KeAcquireSpinLock(&Mailslot->MessageListLock, &oldIrql);
@ -285,14 +285,14 @@ MsfsClose(PDEVICE_OBJECT DeviceObject,
Mailslot->MessageCount = 0;
KeReleaseSpinLock(&Mailslot->MessageListLock, oldIrql);
Mailslot->ServerFcb = NULL;
Mailslot->ServerCcb = NULL;
}
KeAcquireSpinLock(&Mailslot->FcbListLock, &oldIrql);
RemoveEntryList(&Fcb->FcbListEntry);
KeReleaseSpinLock(&Mailslot->FcbListLock, oldIrql);
ExFreePool(Fcb);
FileObject->FsContext = NULL;
KeAcquireSpinLock(&Mailslot->CcbListLock, &oldIrql);
RemoveEntryList(&Ccb->CcbListEntry);
KeReleaseSpinLock(&Mailslot->CcbListLock, oldIrql);
ExFreePool(Ccb);
FileObject->FsContext2 = NULL;
if (Mailslot->ReferenceCount == 0)
{

View file

@ -18,7 +18,7 @@
/* FUNCTIONS *****************************************************************/
static NTSTATUS
MsfsQueryMailslotInformation(PMSFS_FCB Fcb,
MsfsQueryMailslotInformation(PMSFS_CCB Ccb,
PFILE_MAILSLOT_QUERY_INFORMATION Buffer,
PULONG BufferLength)
{
@ -28,7 +28,7 @@ MsfsQueryMailslotInformation(PMSFS_FCB Fcb,
if (*BufferLength < sizeof(FILE_MAILSLOT_QUERY_INFORMATION))
return(STATUS_BUFFER_OVERFLOW);
Mailslot = Fcb->Mailslot;
Mailslot = Ccb->Mailslot;
Buffer->MaximumMessageSize = Mailslot->MaxMessageSize;
Buffer->ReadTimeout = Mailslot->TimeOut;
@ -37,7 +37,7 @@ MsfsQueryMailslotInformation(PMSFS_FCB Fcb,
Buffer->MessagesAvailable = Mailslot->MessageCount;
if (Mailslot->MessageCount == 0)
{
Buffer->NextMessageSize = 0;
Buffer->NextMessageSize = MAILSLOT_NO_MESSAGE;
}
else
{
@ -53,14 +53,14 @@ MsfsQueryMailslotInformation(PMSFS_FCB Fcb,
static NTSTATUS
MsfsSetMailslotInformation(PMSFS_FCB Fcb,
MsfsSetMailslotInformation(PMSFS_CCB Ccb,
PFILE_MAILSLOT_SET_INFORMATION Buffer,
PULONG BufferLength)
{
if (*BufferLength < sizeof(FILE_MAILSLOT_SET_INFORMATION))
return(STATUS_BUFFER_OVERFLOW);
Fcb->Mailslot->TimeOut = *Buffer->ReadTimeout;
Ccb->Mailslot->TimeOut = *Buffer->ReadTimeout;
return(STATUS_SUCCESS);
}
@ -74,7 +74,7 @@ MsfsQueryInformation(PDEVICE_OBJECT DeviceObject,
FILE_INFORMATION_CLASS FileInformationClass;
PFILE_OBJECT FileObject;
PMSFS_DEVICE_EXTENSION DeviceExtension;
PMSFS_FCB Fcb;
PMSFS_CCB Ccb;
PMSFS_MAILSLOT Mailslot;
PVOID SystemBuffer;
ULONG BufferLength;
@ -86,13 +86,13 @@ MsfsQueryInformation(PDEVICE_OBJECT DeviceObject,
FileInformationClass = IoStack->Parameters.QueryFile.FileInformationClass;
DeviceExtension = DeviceObject->DeviceExtension;
FileObject = IoStack->FileObject;
Fcb = (PMSFS_FCB)FileObject->FsContext;
Mailslot = Fcb->Mailslot;
Ccb = (PMSFS_CCB)FileObject->FsContext2;
Mailslot = Ccb->Mailslot;
DPRINT("Mailslot name: %wZ\n", &Mailslot->Name);
/* querying information is not permitted on client side */
if (Fcb->Mailslot->ServerFcb != Fcb)
if (Ccb->Mailslot->ServerCcb != Ccb)
{
Status = STATUS_ACCESS_DENIED;
@ -111,7 +111,7 @@ MsfsQueryInformation(PDEVICE_OBJECT DeviceObject,
switch (FileInformationClass)
{
case FileMailslotQueryInformation:
Status = MsfsQueryMailslotInformation(Fcb,
Status = MsfsQueryMailslotInformation(Ccb,
SystemBuffer,
&BufferLength);
break;
@ -139,7 +139,7 @@ MsfsSetInformation(PDEVICE_OBJECT DeviceObject,
PIO_STACK_LOCATION IoStack;
FILE_INFORMATION_CLASS FileInformationClass;
PFILE_OBJECT FileObject;
PMSFS_FCB Fcb;
PMSFS_CCB Ccb;
PMSFS_MAILSLOT Mailslot;
PVOID SystemBuffer;
ULONG BufferLength;
@ -150,13 +150,13 @@ MsfsSetInformation(PDEVICE_OBJECT DeviceObject,
IoStack = IoGetCurrentIrpStackLocation (Irp);
FileInformationClass = IoStack->Parameters.QueryFile.FileInformationClass;
FileObject = IoStack->FileObject;
Fcb = (PMSFS_FCB)FileObject->FsContext;
Mailslot = Fcb->Mailslot;
Ccb = (PMSFS_CCB)FileObject->FsContext2;
Mailslot = Ccb->Mailslot;
DPRINT("Mailslot name: %wZ\n", &Mailslot->Name);
/* setting information is not permitted on client side */
if (Fcb->Mailslot->ServerFcb != Fcb)
if (Ccb->Mailslot->ServerCcb != Ccb)
{
Status = STATUS_ACCESS_DENIED;
@ -178,7 +178,7 @@ MsfsSetInformation(PDEVICE_OBJECT DeviceObject,
switch (FileInformationClass)
{
case FileMailslotSetInformation:
Status = MsfsSetMailslotInformation(Fcb,
Status = MsfsSetMailslotInformation(Ccb,
SystemBuffer,
&BufferLength);
break;

View file

@ -24,15 +24,15 @@ MsfsFileSystemControl(PDEVICE_OBJECT DeviceObject,
PIO_STACK_LOCATION IoStack;
PFILE_OBJECT FileObject;
PMSFS_MAILSLOT Mailslot;
PMSFS_FCB Fcb;
PMSFS_CCB Ccb;
NTSTATUS Status;
DPRINT1("MsfsFileSystemControl(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
IoStack = IoGetCurrentIrpStackLocation(Irp);
FileObject = IoStack->FileObject;
Fcb = FileObject->FsContext;
Mailslot = Fcb->Mailslot;
Ccb = FileObject->FsContext2;
Mailslot = Ccb->Mailslot;
DPRINT1("Mailslot name: %wZ\n", &Mailslot->Name);

View file

@ -4,7 +4,7 @@
#include <ntifs.h>
#include <ndk/ntndk.h>
/*
/*
* FIXME: GCC doesn't have a working option for defaulting to a calling
* convention. It will always default to cdecl. The MS DDK was designed
* for compilers which support this option, and thus some of their headers
@ -30,9 +30,9 @@ typedef struct _MSFS_MAILSLOT
{
UNICODE_STRING Name;
LIST_ENTRY MailslotListEntry;
KSPIN_LOCK FcbListLock;
LIST_ENTRY FcbListHead;
struct _MSFS_FCB *ServerFcb;
KSPIN_LOCK CcbListLock;
LIST_ENTRY CcbListHead;
struct _MSFS_CCB *ServerCcb;
ULONG ReferenceCount;
LARGE_INTEGER TimeOut;
KEVENT MessageEvent;
@ -42,11 +42,11 @@ typedef struct _MSFS_MAILSLOT
LIST_ENTRY MessageListHead;
} MSFS_MAILSLOT, *PMSFS_MAILSLOT;
typedef struct _MSFS_FCB
typedef struct _MSFS_CCB
{
LIST_ENTRY FcbListEntry;
LIST_ENTRY CcbListEntry;
PMSFS_MAILSLOT Mailslot;
} MSFS_FCB, *PMSFS_FCB;
} MSFS_CCB, *PMSFS_CCB;
typedef struct _MSFS_MESSAGE
{

View file

@ -24,7 +24,7 @@ MsfsRead(PDEVICE_OBJECT DeviceObject,
PIO_STACK_LOCATION IoStack;
PFILE_OBJECT FileObject;
PMSFS_MAILSLOT Mailslot;
PMSFS_FCB Fcb;
PMSFS_CCB Ccb;
PMSFS_MESSAGE Message;
KIRQL oldIrql;
ULONG Length;
@ -36,13 +36,13 @@ MsfsRead(PDEVICE_OBJECT DeviceObject,
IoStack = IoGetCurrentIrpStackLocation (Irp);
FileObject = IoStack->FileObject;
Fcb = (PMSFS_FCB)FileObject->FsContext;
Mailslot = Fcb->Mailslot;
Ccb = (PMSFS_CCB)FileObject->FsContext2;
Mailslot = Ccb->Mailslot;
DPRINT("MailslotName: %wZ\n", &Mailslot->Name);
/* reading is not permitted on client side */
if (Fcb->Mailslot->ServerFcb != Fcb)
if (Ccb->Mailslot->ServerCcb != Ccb)
{
Irp->IoStatus.Status = STATUS_ACCESS_DENIED;
Irp->IoStatus.Information = 0;
@ -100,7 +100,7 @@ MsfsWrite(PDEVICE_OBJECT DeviceObject,
PIO_STACK_LOCATION IoStack;
PFILE_OBJECT FileObject;
PMSFS_MAILSLOT Mailslot;
PMSFS_FCB Fcb;
PMSFS_CCB Ccb;
PMSFS_MESSAGE Message;
KIRQL oldIrql;
ULONG Length;
@ -110,13 +110,13 @@ MsfsWrite(PDEVICE_OBJECT DeviceObject,
IoStack = IoGetCurrentIrpStackLocation (Irp);
FileObject = IoStack->FileObject;
Fcb = (PMSFS_FCB)FileObject->FsContext;
Mailslot = Fcb->Mailslot;
Ccb = (PMSFS_CCB)FileObject->FsContext2;
Mailslot = Ccb->Mailslot;
DPRINT("MailslotName: %wZ\n", &Mailslot->Name);
/* writing is not permitted on server side */
if (Fcb->Mailslot->ServerFcb == Fcb)
if (Ccb->Mailslot->ServerCcb == Ccb)
{
Irp->IoStatus.Status = STATUS_ACCESS_DENIED;
Irp->IoStatus.Information = 0;