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

View file

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

View file

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

View file

@ -30,9 +30,9 @@ typedef struct _MSFS_MAILSLOT
{ {
UNICODE_STRING Name; UNICODE_STRING Name;
LIST_ENTRY MailslotListEntry; LIST_ENTRY MailslotListEntry;
KSPIN_LOCK FcbListLock; KSPIN_LOCK CcbListLock;
LIST_ENTRY FcbListHead; LIST_ENTRY CcbListHead;
struct _MSFS_FCB *ServerFcb; struct _MSFS_CCB *ServerCcb;
ULONG ReferenceCount; ULONG ReferenceCount;
LARGE_INTEGER TimeOut; LARGE_INTEGER TimeOut;
KEVENT MessageEvent; KEVENT MessageEvent;
@ -42,11 +42,11 @@ typedef struct _MSFS_MAILSLOT
LIST_ENTRY MessageListHead; LIST_ENTRY MessageListHead;
} MSFS_MAILSLOT, *PMSFS_MAILSLOT; } MSFS_MAILSLOT, *PMSFS_MAILSLOT;
typedef struct _MSFS_FCB typedef struct _MSFS_CCB
{ {
LIST_ENTRY FcbListEntry; LIST_ENTRY CcbListEntry;
PMSFS_MAILSLOT Mailslot; PMSFS_MAILSLOT Mailslot;
} MSFS_FCB, *PMSFS_FCB; } MSFS_CCB, *PMSFS_CCB;
typedef struct _MSFS_MESSAGE typedef struct _MSFS_MESSAGE
{ {

View file

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