- Ntoskrnl uses for all access to internal structures the SectionObjectPointers from file object.

- The bcb field is removed from the REACTOS_COMMON_FCB_HEADER structure.
- FSD's store the pointer to the fcb in FsContext from file object. There is no pointer from ccb to the fcb.

svn path=/trunk/; revision=4145
This commit is contained in:
Hartmut Birr 2003-02-13 22:24:19 +00:00
parent 44e85c2846
commit 1c043c1647
34 changed files with 292 additions and 285 deletions

View file

@ -193,7 +193,6 @@ typedef struct _FCB
typedef struct _CCB
{
PFCB Fcb;
LIST_ENTRY NextCCB;
PFILE_OBJECT PtrFileObject;
LARGE_INTEGER CurrentByteOffset;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: cleanup.c,v 1.2 2003/01/02 16:01:21 hbirr Exp $
/* $Id: cleanup.c,v 1.3 2003/02/13 22:24:15 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -45,23 +45,16 @@ CdfsCleanupFile(PDEVICE_EXTENSION DeviceExt,
* FUNCTION: Cleans up after a file has been closed.
*/
{
PCCB Ccb;
DPRINT("CdfsCleanupFile(DeviceExt %x, FileObject %x)\n",
DeviceExt,
FileObject);
Ccb = (PCCB) (FileObject->FsContext2);
if (Ccb == NULL)
{
return STATUS_SUCCESS;
}
/* Uninitialize file cache if initialized for this file object. */
if (Ccb->Fcb->RFCB.Bcb != NULL)
if (FileObject->SectionObjectPointers && FileObject->SectionObjectPointers->SharedCacheMap)
{
CcRosReleaseFileCache (FileObject, Ccb->Fcb->RFCB.Bcb);
CcRosReleaseFileCache (FileObject);
}
return STATUS_SUCCESS;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: close.c,v 1.5 2002/09/15 22:21:40 hbirr Exp $
/* $Id: close.c,v 1.6 2003/02/13 22:24:15 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -66,8 +66,7 @@ CdfsCloseFile(PDEVICE_EXTENSION DeviceExt,
// This a FO, that was created outside from FSD.
// Some FO's are created with IoCreateStreamFileObject() insid from FSD.
// This FO's don't have a FileName.
CdfsReleaseFCB(DeviceExt,
Ccb->Fcb);
CdfsReleaseFCB(DeviceExt, FileObject->FsContext);
}
if (Ccb->DirectorySearchPattern)

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: create.c,v 1.7 2002/09/15 22:21:40 hbirr Exp $
/* $Id: create.c,v 1.8 2003/02/13 22:24:15 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -45,12 +45,9 @@ CdfsMakeAbsoluteFilename(PFILE_OBJECT pFileObject,
{
PWSTR rcName;
PFCB Fcb;
PCCB Ccb;
DPRINT("try related for %S\n", pRelativeFileName);
Ccb = pFileObject->FsContext2;
assert(Ccb);
Fcb = Ccb->Fcb;
Fcb = pFileObject->FsContext;
assert(Fcb);
/* verify related object is a directory and target name
@ -169,7 +166,6 @@ CdfsCreateFile(PDEVICE_OBJECT DeviceObject,
ULONG RequestedDisposition;
ULONG RequestedOptions;
PFCB Fcb;
PCCB Ccb;
// PWSTR FileName;
NTSTATUS Status;
@ -200,8 +196,7 @@ CdfsCreateFile(PDEVICE_OBJECT DeviceObject,
if (NT_SUCCESS(Status))
{
Ccb = FileObject->FsContext2;
Fcb = Ccb->Fcb;
Fcb = FileObject->FsContext;
/*
* Check the file has the requested attributes
*/

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: dirctl.c,v 1.11 2002/09/14 13:10:45 guido Exp $
/* $Id: dirctl.c,v 1.12 2003/02/13 22:24:15 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -555,7 +555,7 @@ CdfsQueryDirectory(PDEVICE_OBJECT DeviceObject,
FileObject = Stack->FileObject;
Ccb = (PCCB)FileObject->FsContext2;
Fcb = Ccb->Fcb;
Fcb = (PFCB)FileObject->FsContext;
/* Obtain the callers parameters */
BufferLength = Stack->Parameters.QueryDirectory.Length;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: fcb.c,v 1.11 2002/10/01 19:27:16 chorns Exp $
/* $Id: fcb.c,v 1.12 2003/02/13 22:24:15 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -187,7 +187,7 @@ CdfsGrabFCBFromTable(PDEVICE_EXTENSION Vcb,
if (FileName == NULL || *FileName == 0)
{
DPRINT("Return FCB for stream file object\n");
Fcb = ((PCCB)Vcb->StreamFileObject->FsContext2)->Fcb;
Fcb = Vcb->StreamFileObject->FsContext;
Fcb->RefCount++;
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
return(Fcb);
@ -237,15 +237,13 @@ CdfsFCBInitializeCache(PVCB Vcb,
FileObject->Flags = FileObject->Flags | FO_FCB_IS_VALID |
FO_DIRECT_CACHE_PAGING_READ;
FileObject->SectionObjectPointers = &Fcb->SectionObjectPointers;
FileObject->FsContext = (PVOID) &Fcb->RFCB;
FileObject->FsContext = Fcb;
FileObject->FsContext2 = newCCB;
newCCB->Fcb = Fcb;
newCCB->PtrFileObject = FileObject;
Fcb->FileObject = FileObject;
Fcb->DevExt = Vcb;
Status = CcRosInitializeFileCache(FileObject,
&Fcb->RFCB.Bcb,
PAGE_SIZE);
if (!NT_SUCCESS(Status))
{
@ -417,16 +415,14 @@ CdfsAttachFCBToFileObject(PDEVICE_EXTENSION Vcb,
FileObject->Flags = FileObject->Flags | FO_FCB_IS_VALID |
FO_DIRECT_CACHE_PAGING_READ;
FileObject->SectionObjectPointers = &Fcb->SectionObjectPointers;
FileObject->FsContext = (PVOID)&Fcb->RFCB;
FileObject->FsContext = Fcb;
FileObject->FsContext2 = newCCB;
newCCB->Fcb = Fcb;
newCCB->PtrFileObject = FileObject;
Fcb->DevExt = Vcb;
if (CdfsFCBIsDirectory(Fcb))
{
Status = CcRosInitializeFileCache(FileObject,
&Fcb->RFCB.Bcb,
PAGE_SIZE);
if (!NT_SUCCESS(Status))
{

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: fsctl.c,v 1.12 2002/10/01 19:27:16 chorns Exp $
/* $Id: fsctl.c,v 1.13 2003/02/13 22:24:15 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -379,12 +379,11 @@ CdfsMountVolume(PDEVICE_OBJECT DeviceObject,
sizeof(CCB));
DeviceExt->StreamFileObject->Flags = DeviceExt->StreamFileObject->Flags | FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
DeviceExt->StreamFileObject->FsContext = (PVOID)&Fcb->RFCB;
DeviceExt->StreamFileObject->FsContext = Fcb;
DeviceExt->StreamFileObject->FsContext2 = Ccb;
DeviceExt->StreamFileObject->SectionObjectPointers = &Fcb->SectionObjectPointers;
DeviceExt->StreamFileObject->PrivateCacheMap = NULL;
DeviceExt->StreamFileObject->Vpb = DeviceExt->Vpb;
Ccb->Fcb = Fcb;
Ccb->PtrFileObject = DeviceExt->StreamFileObject;
Fcb->FileObject = DeviceExt->StreamFileObject;
Fcb->DevExt = (PDEVICE_EXTENSION)DeviceExt->StorageDevice;
@ -398,7 +397,6 @@ CdfsMountVolume(PDEVICE_OBJECT DeviceObject,
Fcb->Entry.DataLengthL = (DeviceExt->CdInfo.VolumeSpaceSize + DeviceExt->CdInfo.VolumeOffset) * BLOCKSIZE;
Status = CcRosInitializeFileCache(DeviceExt->StreamFileObject,
&Fcb->RFCB.Bcb,
PAGE_SIZE);
if (!NT_SUCCESS (Status))
{

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: rw.c,v 1.9 2003/01/02 16:02:02 hbirr Exp $
/* $Id: rw.c,v 1.10 2003/02/13 22:24:15 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -71,7 +71,7 @@ CdfsReadFile(PDEVICE_EXTENSION DeviceExt,
return(STATUS_SUCCESS);
Ccb = (PCCB)FileObject->FsContext2;
Fcb = Ccb->Fcb;
Fcb = (PFCB)FileObject->FsContext;
if (ReadOffset >= Fcb->Entry.DataLengthL)
return(STATUS_END_OF_FILE);
@ -87,7 +87,7 @@ CdfsReadFile(PDEVICE_EXTENSION DeviceExt,
Length = Fcb->Entry.DataLengthL - ReadOffset;
if (FileObject->PrivateCacheMap == NULL)
{
CcRosInitializeFileCache(FileObject, &Fcb->RFCB.Bcb, PAGE_SIZE);
CcRosInitializeFileCache(FileObject, PAGE_SIZE);
}
FileOffset.QuadPart = (LONGLONG)ReadOffset;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: create.c,v 1.1 2002/06/25 22:23:05 ekohl Exp $
/* $Id: create.c,v 1.2 2003/02/13 22:24:16 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -44,12 +44,9 @@ NtfsMakeAbsoluteFilename(PFILE_OBJECT pFileObject,
{
PWSTR rcName;
PFCB Fcb;
PCCB Ccb;
DPRINT("try related for %S\n", pRelativeFileName);
Ccb = pFileObject->FsContext2;
assert(Ccb);
Fcb = Ccb->Fcb;
Fcb = pFileObject->FsContext;
assert(Fcb);
/* verify related object is a directory and target name

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: dirctl.c,v 1.4 2003/01/17 18:51:13 ekohl Exp $
/* $Id: dirctl.c,v 1.5 2003/02/13 22:24:16 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -505,7 +505,7 @@ NtfsQueryDirectory(PDEVICE_OBJECT DeviceObject,
FileObject = Stack->FileObject;
Ccb = (PCCB)FileObject->FsContext2;
Fcb = Ccb->Fcb;
Fcb = (PFCB)FileObject->FsContext;
/* Obtain the callers parameters */
BufferLength = Stack->Parameters.QueryDirectory.Length;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: fcb.c,v 1.4 2002/10/01 19:27:17 chorns Exp $
/* $Id: fcb.c,v 1.5 2003/02/13 22:24:16 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -153,7 +153,7 @@ NtfsReleaseFCB(PDEVICE_EXTENSION Vcb,
if (Fcb->RefCount <= 0 && !NtfsFCBIsDirectory(Fcb))
{
RemoveEntryList(&Fcb->FcbListEntry);
CcRosReleaseFileCache(NULL, Fcb->RFCB.Bcb);
CcRosReleaseFileCache(Fcb->FileObject);
NtfsDestroyFCB(Fcb);
}
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
@ -186,7 +186,7 @@ NtfsGrabFCBFromTable(PDEVICE_EXTENSION Vcb,
if (FileName == NULL || *FileName == 0)
{
DPRINT("Return FCB for stream file object\n");
Fcb = ((PCCB)Vcb->StreamFileObject->FsContext2)->Fcb;
Fcb = Vcb->StreamFileObject->FsContext;
Fcb->RefCount++;
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
return(Fcb);
@ -236,15 +236,13 @@ NtfsFCBInitializeCache(PVCB Vcb,
FileObject->Flags = FileObject->Flags | FO_FCB_IS_VALID |
FO_DIRECT_CACHE_PAGING_READ;
FileObject->SectionObjectPointers = &Fcb->SectionObjectPointers;
FileObject->FsContext = (PVOID) &Fcb->RFCB;
FileObject->FsContext = Fcb;
FileObject->FsContext2 = newCCB;
newCCB->Fcb = Fcb;
newCCB->PtrFileObject = FileObject;
Fcb->FileObject = FileObject;
Fcb->DevExt = Vcb;
Status = CcRosInitializeFileCache(FileObject,
&Fcb->RFCB.Bcb,
CACHEPAGESIZE(Vcb));
if (!NT_SUCCESS(Status))
{
@ -409,16 +407,14 @@ NtfsAttachFCBToFileObject(PDEVICE_EXTENSION Vcb,
FileObject->Flags = FileObject->Flags | FO_FCB_IS_VALID |
FO_DIRECT_CACHE_PAGING_READ;
FileObject->SectionObjectPointers = &Fcb->SectionObjectPointers;
FileObject->FsContext = (PVOID)&Fcb->RFCB;
FileObject->FsContext = Fcb;
FileObject->FsContext2 = newCCB;
newCCB->Fcb = Fcb;
newCCB->PtrFileObject = FileObject;
Fcb->DevExt = Vcb;
if (!(Fcb->Flags & FCB_CACHE_INITIALIZED))
{
Status = CcRosInitializeFileCache(FileObject,
&Fcb->RFCB.Bcb,
CACHEPAGESIZE(Vcb));
if (!NT_SUCCESS(Status))
{

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: fsctl.c,v 1.4 2002/09/08 10:22:11 chorns Exp $
/* $Id: fsctl.c,v 1.5 2003/02/13 22:24:16 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -275,12 +275,11 @@ NtfsMountVolume(PDEVICE_OBJECT DeviceObject,
sizeof(CCB));
DeviceExt->StreamFileObject->Flags = DeviceExt->StreamFileObject->Flags | FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
DeviceExt->StreamFileObject->FsContext = (PVOID)&Fcb->RFCB;
DeviceExt->StreamFileObject->FsContext = Fcb;
DeviceExt->StreamFileObject->FsContext2 = Ccb;
DeviceExt->StreamFileObject->SectionObjectPointers = &Fcb->SectionObjectPointers;
DeviceExt->StreamFileObject->PrivateCacheMap = NULL;
DeviceExt->StreamFileObject->Vpb = DeviceExt->Vpb;
Ccb->Fcb = Fcb;
Ccb->PtrFileObject = DeviceExt->StreamFileObject;
Fcb->FileObject = DeviceExt->StreamFileObject;
Fcb->DevExt = (PDEVICE_EXTENSION)DeviceExt->StorageDevice;
@ -295,7 +294,6 @@ NtfsMountVolume(PDEVICE_OBJECT DeviceObject,
// Fcb->Entry.DataLengthL = DeviceExt->CdInfo.VolumeSpaceSize * BLOCKSIZE;
Status = CcRosInitializeFileCache(DeviceExt->StreamFileObject,
&Fcb->RFCB.Bcb,
CACHEPAGESIZE(DeviceExt));
if (!NT_SUCCESS (Status))
{

View file

@ -106,7 +106,6 @@ typedef struct _FCB
typedef struct _CCB
{
PFCB Fcb;
LIST_ENTRY NextCCB;
PFILE_OBJECT PtrFileObject;
LARGE_INTEGER CurrentByteOffset;

View file

@ -1,4 +1,4 @@
/* $Id: cleanup.c,v 1.10 2003/01/25 15:55:07 hbirr Exp $
/* $Id: cleanup.c,v 1.11 2003/02/13 22:24:16 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -24,7 +24,6 @@ VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
* FUNCTION: Cleans up after a file has been closed.
*/
{
PVFATCCB pCcb;
PVFATFCB pFcb;
PDEVICE_EXTENSION DeviceExt = IrpContext->DeviceExt;
PFILE_OBJECT FileObject = IrpContext->FileObject;
@ -33,13 +32,9 @@ VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
DeviceExt, FileObject);
/* FIXME: handle file/directory deletion here */
pCcb = (PVFATCCB) (FileObject->FsContext2);
if (pCcb == NULL)
pFcb = (PVFATFCB) FileObject->FsContext;
if (pFcb)
{
return STATUS_SUCCESS;
}
pFcb = pCcb->pFcb;
if (!(pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY) &&
FsRtlAreThereCurrentFileLocks(&pFcb->FileLock))
{
@ -47,16 +42,15 @@ VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
FsRtlFastUnlockAll(&pFcb->FileLock,
FileObject,
IoGetRequestorProcess(IrpContext->Irp),
NULL
);
NULL);
}
/* Uninitialize file cache if initialized for this file object. */
if (pFcb->RFCB.Bcb != NULL)
if (FileObject->PrivateCacheMap)
{
CcRosReleaseFileCache (FileObject, pFcb->RFCB.Bcb);
CcRosReleaseFileCache (FileObject);
}
}
return STATUS_SUCCESS;
}

View file

@ -1,4 +1,4 @@
/* $Id: close.c,v 1.16 2003/01/11 15:56:43 hbirr Exp $
/* $Id: close.c,v 1.17 2003/02/13 22:24:16 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -33,13 +33,13 @@ VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
/* FIXME : update entry in directory? */
pCcb = (PVFATCCB) (FileObject->FsContext2);
pFcb = (PVFATFCB) (FileObject->FsContext);
DPRINT ("pCcb %x\n", pCcb);
if (pCcb == NULL)
if (pFcb == NULL)
{
return STATUS_SUCCESS;
}
pFcb = pCcb->pFcb;
if (pFcb->Flags & FCB_IS_VOLUME)
{
DPRINT1("Volume\n");
@ -58,15 +58,21 @@ VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
delEntry (DeviceExt, FileObject);
}
else
{
Status = STATUS_DELETE_PENDING;
}
FileObject->FsContext2 = NULL;
}
vfatReleaseFCB (DeviceExt, pFcb);
}
else
FileObject->FsContext2 = NULL;
FileObject->FsContext2 = NULL;
FileObject->FsContext = NULL;
FileObject->SectionObjectPointers = NULL;
if (pCcb)
{
vfatDestroyCCB(pCcb);
}
return Status;
}

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: create.c,v 1.53 2003/01/19 01:06:45 gvg Exp $
/* $Id: create.c,v 1.54 2003/02/13 22:24:16 hbirr Exp $
*
* PROJECT: ReactOS kernel
* FILE: services/fs/vfat/create.c
@ -364,12 +364,9 @@ vfatMakeAbsoluteFilename (PFILE_OBJECT pFileObject,
{
PWSTR rcName;
PVFATFCB fcb;
PVFATCCB ccb;
DPRINT ("try related for %S\n", pRelativeFileName);
ccb = pFileObject->FsContext2;
assert (ccb);
fcb = ccb->pFcb;
fcb = pFileObject->FsContext;
assert (fcb);
/* verify related object is a directory and target name
@ -600,11 +597,8 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
memset(pCcb, 0, sizeof(VFATCCB));
FileObject->Flags |= FO_FCB_IS_VALID;
FileObject->SectionObjectPointers = &pFcb->SectionObjectPointers;
FileObject->FsContext = (PVOID) &pFcb->RFCB;
FileObject->FsContext = pFcb;
FileObject->FsContext2 = pCcb;
pCcb->pFcb = pFcb;
pCcb->PtrFileObject = FileObject;
pFcb->pDevExt = DeviceExt;
pFcb->RefCount++;
Irp->IoStatus.Information = FILE_OPENED;
@ -654,8 +648,7 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
Attributes & FILE_ATTRIBUTE_VALID_FLAGS);
if (NT_SUCCESS (Status))
{
pCcb = FileObject->FsContext2;
pFcb = pCcb->pFcb;
pFcb = FileObject->FsContext;
Irp->IoStatus.Information = FILE_CREATED;
VfatSetAllocationSizeInformation(FileObject,
pFcb,
@ -689,8 +682,7 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
return(STATUS_OBJECT_NAME_COLLISION);
}
pCcb = FileObject->FsContext2;
pFcb = pCcb->pFcb;
pFcb = FileObject->FsContext;
/*
* Check the file has the requested attributes

View file

@ -1,5 +1,5 @@
/*
* $Id: dir.c,v 1.27 2002/11/11 21:49:18 hbirr Exp $
* $Id: dir.c,v 1.28 2003/02/13 22:24:16 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -209,7 +209,7 @@ NTSTATUS DoQuery (PVFAT_IRP_CONTEXT IrpContext)
BOOLEAN First = FALSE;
pCcb = (PVFATCCB) IrpContext->FileObject->FsContext2;
pFcb = pCcb->pFcb;
pFcb = (PVFATFCB) IrpContext->FileObject->FsContext;
if (!ExAcquireResourceSharedLite(&pFcb->MainResource, IrpContext->Flags & IRPCONTEXT_CANWAIT))
{

View file

@ -1,4 +1,4 @@
/* $Id: dirwr.c,v 1.34 2003/01/11 15:57:55 hbirr Exp $
/* $Id: dirwr.c,v 1.35 2003/02/13 22:24:16 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -45,7 +45,7 @@ VfatUpdateEntry (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT pFileObject)
DPRINT ("updEntry PathFileName \'%S\'\n",
((PVFATCCB)(pFileObject->FsContext2))->pFcb->PathName);
pFcb = ((PVFATCCB)(pFileObject->FsContext2))->pFcb;
pFcb = (PVFATFCB)pFileObject->FsContext;
assert (pFcb);
pDirFcb = pFcb->parentFcb;
assert (pDirFcb);
@ -559,7 +559,7 @@ VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
CcSetDirtyPinnedData(Context, NULL);
CcUnpinData(Context);
// FEXME: check status
// FIXME: check status
vfatMakeFCBFromDirEntry (DeviceExt, pDirFcb, FileName, pEntry,
start, start + nbSlots - 1, &newFCB);
vfatAttachFCBToFileObject (DeviceExt, newFCB, pFileObject);
@ -635,7 +635,7 @@ delEntry (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT pFileObject)
}
return status;
}
pName = ((PVFATCCB)(pFileObject->FsContext2))->pFcb->ObjectName;
pName = ((PVFATFCB)pFileObject->FsContext)->ObjectName;
if (*pName == L'\\')
{
pName ++;

View file

@ -1,4 +1,4 @@
/* $Id: fcb.c,v 1.26 2003/01/25 15:55:07 hbirr Exp $
/* $Id: fcb.c,v 1.27 2003/02/13 22:24:16 hbirr Exp $
*
*
* FILE: fcb.c
@ -156,12 +156,13 @@ vfatReleaseFCB(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
if (vfatFCBIsDirectory(pFCB))
{
/* Uninitialize file cache if initialized for this file object. */
if (pFCB->RFCB.Bcb != NULL)
if (pFCB->FileObject->SectionObjectPointers->SharedCacheMap)
{
CcRosReleaseFileCache(pFCB->FileObject, pFCB->RFCB.Bcb);
CcRosReleaseFileCache(pFCB->FileObject);
}
vfatDestroyCCB(pFCB->FileObject->FsContext2);
pFCB->FileObject->FsContext2 = NULL;
pFCB->FileObject->FsContext = NULL;
ObDereferenceObject(pFCB->FileObject);
}
vfatDestroyFCB (pFCB);
@ -185,7 +186,6 @@ vfatAddFCBToTable(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
Index = pFCB->Hash.Hash % FCB_HASH_TABLE_SIZE;
ShortIndex = pFCB->ShortHash.Hash % FCB_HASH_TABLE_SIZE;
KeAcquireSpinLock (&pVCB->FcbListLock, &oldIrql);
pFCB->pDevExt = pVCB;
InsertTailList (&pVCB->FcbListHead, &pFCB->FcbListEntry);
pFCB->Hash.next = pVCB->FcbHashTable[Index];
@ -287,19 +287,15 @@ vfatFCBInitializeCacheFromVolume (PVCB vcb, PVFATFCB fcb)
fileObject->Flags |= FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
fileObject->SectionObjectPointers = &fcb->SectionObjectPointers;
fileObject->FsContext = (PVOID) &fcb->RFCB;
fileObject->FsContext = fcb;
fileObject->FsContext2 = newCCB;
newCCB->pFcb = fcb;
newCCB->PtrFileObject = fileObject;
fcb->FileObject = fileObject;
fcb->pDevExt = vcb;
fileCacheQuantum = (vcb->FatInfo.BytesPerCluster >= PAGE_SIZE) ?
vcb->FatInfo.BytesPerCluster : PAGE_SIZE;
status = CcRosInitializeFileCache (fileObject,
&fcb->RFCB.Bcb,
fileCacheQuantum);
if (!NT_SUCCESS (status))
{
@ -331,7 +327,6 @@ vfatMakeRootFCB(PDEVICE_EXTENSION pVCB)
CurrentCluster = FirstCluster = pVCB->FatInfo.RootCluster;
FCB->entry.FirstCluster = FirstCluster & 0xffff;
FCB->entry.FirstClusterHigh = FirstCluster >> 16;
CurrentCluster = FirstCluster;
while (CurrentCluster != 0xffffffff && NT_SUCCESS(Status))
{
@ -469,11 +464,8 @@ vfatAttachFCBToFileObject (PDEVICE_EXTENSION vcb,
fileObject->Flags = fileObject->Flags | FO_FCB_IS_VALID |
FO_DIRECT_CACHE_PAGING_READ;
fileObject->SectionObjectPointers = &fcb->SectionObjectPointers;
fileObject->FsContext = (PVOID) &fcb->RFCB;
fileObject->FsContext = fcb;
fileObject->FsContext2 = newCCB;
newCCB->pFcb = fcb;
newCCB->PtrFileObject = fileObject;
fcb->pDevExt = vcb;
DPRINT ("file open: fcb:%x file size: %d\n", fcb, fcb->entry.FileSize);
return STATUS_SUCCESS;

View file

@ -1,4 +1,4 @@
/* $Id: finfo.c,v 1.26 2003/01/28 16:48:03 hbirr Exp $
/* $Id: finfo.c,v 1.27 2003/02/13 22:24:16 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -553,7 +553,7 @@ NTSTATUS VfatQueryInformation(PVFAT_IRP_CONTEXT IrpContext)
/* INITIALIZATION */
FileInformationClass = IrpContext->Stack->Parameters.QueryFile.FileInformationClass;
FCB = ((PVFATCCB) IrpContext->FileObject->FsContext2)->pFcb;
FCB = (PVFATFCB) IrpContext->FileObject->FsContext;
SystemBuffer = IrpContext->Irp->AssociatedIrp.SystemBuffer;
BufferLength = IrpContext->Stack->Parameters.QueryFile.Length;
@ -654,7 +654,7 @@ NTSTATUS VfatSetInformation(PVFAT_IRP_CONTEXT IrpContext)
/* INITIALIZATION */
FileInformationClass =
IrpContext->Stack->Parameters.SetFile.FileInformationClass;
FCB = ((PVFATCCB) IrpContext->FileObject->FsContext2)->pFcb;
FCB = (PVFATFCB) IrpContext->FileObject->FsContext;
SystemBuffer = IrpContext->Irp->AssociatedIrp.SystemBuffer;
DPRINT("FileInformationClass %d\n", FileInformationClass);

View file

@ -1,4 +1,4 @@
/* $Id: flush.c,v 1.1 2003/02/09 18:02:55 hbirr Exp $
/* $Id: flush.c,v 1.2 2003/02/13 22:24:17 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -36,7 +36,6 @@ NTSTATUS VfatFlushVolume(PDEVICE_EXTENSION DeviceExt, PVFATFCB VolumeFcb)
{
PLIST_ENTRY ListEntry;
PVFATFCB Fcb;
PVFATCCB Ccb;
NTSTATUS Status, ReturnStatus = STATUS_SUCCESS;
DPRINT("VfatFlushVolume(DeviceExt %x, FatFcb %x)\n", DeviceExt, VolumeFcb);
@ -54,11 +53,10 @@ NTSTATUS VfatFlushVolume(PDEVICE_EXTENSION DeviceExt, PVFATFCB VolumeFcb)
DPRINT1("VfatFlushFile failed, status = %x\n", Status);
ReturnStatus = Status;
}
/* FIXME: Stop flushing if this a removable media and the media was removed */
/* FIXME: Stop flushing if this is a removable media and the media was removed */
}
Ccb = (PVFATCCB) DeviceExt->FATFileObject->FsContext2;
Fcb = Ccb->pFcb;
Fcb = (PVFATFCB) DeviceExt->FATFileObject->FsContext;
ExAcquireResourceExclusiveLite(&DeviceExt->FatResource, TRUE);
Status = VfatFlushFile(DeviceExt, Fcb);
@ -79,7 +77,6 @@ NTSTATUS VfatFlush(PVFAT_IRP_CONTEXT IrpContext)
{
NTSTATUS Status;
PVFATFCB Fcb;
PVFATCCB Ccb;
/*
* This request is not allowed on the main device object.
*/
@ -89,9 +86,7 @@ NTSTATUS VfatFlush(PVFAT_IRP_CONTEXT IrpContext)
goto ByeBye;
}
Ccb = (PVFATCCB) IrpContext->FileObject->FsContext2;
assert(Ccb);
Fcb = Ccb->pFcb;
Fcb = (PVFATFCB)IrpContext->FileObject->FsContext;
assert(Fcb);
if (Fcb->Flags & FCB_IS_VOLUME)

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: fsctl.c,v 1.13 2003/02/09 18:02:55 hbirr Exp $
/* $Id: fsctl.c,v 1.14 2003/02/13 22:24:17 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -301,15 +301,12 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
wcscpy(Fcb->PathName, L"$$Fat$$");
Fcb->ObjectName = Fcb->PathName;
DeviceExt->FATFileObject->Flags = DeviceExt->FATFileObject->Flags | FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
DeviceExt->FATFileObject->FsContext = (PVOID) &Fcb->RFCB;
DeviceExt->FATFileObject->FsContext = Fcb;
DeviceExt->FATFileObject->FsContext2 = Ccb;
DeviceExt->FATFileObject->SectionObjectPointers = &Fcb->SectionObjectPointers;
DeviceExt->FATFileObject->PrivateCacheMap = NULL;
DeviceExt->FATFileObject->Vpb = DeviceObject->Vpb;
Ccb->pFcb = Fcb;
Ccb->PtrFileObject = DeviceExt->FATFileObject;
Fcb->FileObject = DeviceExt->FATFileObject;
Fcb->pDevExt = (PDEVICE_EXTENSION)DeviceExt->StorageDevice;
Fcb->Flags = FCB_IS_FAT;
@ -319,11 +316,11 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
if (DeviceExt->FatInfo.FatType != FAT12)
{
Status = CcRosInitializeFileCache(DeviceExt->FATFileObject, &Fcb->RFCB.Bcb, CACHEPAGESIZE(DeviceExt));
Status = CcRosInitializeFileCache(DeviceExt->FATFileObject, CACHEPAGESIZE(DeviceExt));
}
else
{
Status = CcRosInitializeFileCache(DeviceExt->FATFileObject, &Fcb->RFCB.Bcb, 2 * PAGE_SIZE);
Status = CcRosInitializeFileCache(DeviceExt->FATFileObject, 2 * PAGE_SIZE);
}
if (!NT_SUCCESS (Status))
{
@ -349,7 +346,6 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
VolumeFcb->RFCB.FileSize.QuadPart = DeviceExt->FatInfo.Sectors * DeviceExt->FatInfo.BytesPerSector;
VolumeFcb->RFCB.ValidDataLength = VolumeFcb->RFCB.FileSize;
VolumeFcb->RFCB.AllocationSize = VolumeFcb->RFCB.FileSize;
VolumeFcb->pDevExt = (PDEVICE_EXTENSION)DeviceExt->StorageDevice;
DeviceExt->VolumeFcb = VolumeFcb;
ExAcquireResourceExclusiveLite(&VfatGlobalData->VolumeListLock, TRUE);

View file

@ -1,4 +1,4 @@
/* $Id: misc.c,v 1.6 2003/02/09 18:02:55 hbirr Exp $
/* $Id: misc.c,v 1.7 2003/02/13 22:24:17 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -71,15 +71,13 @@ NTSTATUS VfatLockControl(
)
{
PVFATFCB Fcb;
PVFATCCB Ccb;
NTSTATUS Status;
DPRINT("VfatLockControl(IrpContext %x)\n", IrpContext);
assert(IrpContext);
Ccb = (PVFATCCB)IrpContext->FileObject->FsContext2;
Fcb = Ccb->pFcb;
Fcb = (PVFATFCB)IrpContext->FileObject->FsContext;
if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
{
@ -119,8 +117,6 @@ NTSTATUS STDCALL VfatBuildRequest (
assert (DeviceObject);
assert (Irp);
FsRtlEnterFileSystem();
IrpContext = VfatAllocateIrpContext(DeviceObject, Irp);
if (IrpContext == NULL)
{
@ -130,9 +126,20 @@ NTSTATUS STDCALL VfatBuildRequest (
}
else
{
Status = VfatDispatchRequest (IrpContext);
if (KeGetCurrentIrql() <= PASSIVE_LEVEL)
{
FsRtlEnterFileSystem();
}
else
{
DPRINT1("Vfat is entered at irql = %d\n", KeGetCurrentIrql());
}
Status = VfatDispatchRequest (IrpContext);
if (KeGetCurrentIrql() <= PASSIVE_LEVEL)
{
FsRtlExitFileSystem();
}
}
return Status;
}

View file

@ -1,5 +1,5 @@
/* $Id: rw.c,v 1.54 2003/01/25 15:55:07 hbirr Exp $
/* $Id: rw.c,v 1.55 2003/02/13 22:24:17 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -290,7 +290,7 @@ VfatReadFileData (PVFAT_IRP_CONTEXT IrpContext, PVOID Buffer,
*LengthRead = 0;
Ccb = (PVFATCCB)IrpContext->FileObject->FsContext2;
Fcb = Ccb->pFcb;
Fcb = IrpContext->FileObject->FsContext;
BytesPerSector = DeviceExt->FatInfo.BytesPerSector;
BytesPerCluster = DeviceExt->FatInfo.BytesPerCluster;
@ -451,7 +451,7 @@ NTSTATUS VfatWriteFileData(PVFAT_IRP_CONTEXT IrpContext,
assert (IrpContext->FileObject->FsContext2 != NULL);
Ccb = (PVFATCCB)IrpContext->FileObject->FsContext2;
Fcb = Ccb->pFcb;
Fcb = IrpContext->FileObject->FsContext;
BytesPerCluster = DeviceExt->FatInfo.BytesPerCluster;
BytesPerSector = DeviceExt->FatInfo.BytesPerSector;
@ -580,7 +580,6 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
{
NTSTATUS Status;
PVFATFCB Fcb;
PVFATCCB Ccb;
ULONG Length;
ULONG ReturnedLength = 0;
PERESOURCE Resource = NULL;
@ -605,9 +604,7 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
assert(IrpContext->DeviceExt);
assert(IrpContext->FileObject);
Ccb = (PVFATCCB) IrpContext->FileObject->FsContext2;
assert(Ccb);
Fcb = Ccb->pFcb;
Fcb = IrpContext->FileObject->FsContext;
assert(Fcb);
DPRINT("<%S>\n", Fcb->PathName);
@ -711,7 +708,7 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
{
CacheSize = PAGE_SIZE;
}
CcRosInitializeFileCache(IrpContext->FileObject, &Fcb->RFCB.Bcb, CacheSize);
CcRosInitializeFileCache(IrpContext->FileObject, CacheSize);
}
if (!CcCopyRead(IrpContext->FileObject, &ByteOffset, Length,
IrpContext->Flags & IRPCONTEXT_CANWAIT, Buffer,
@ -805,7 +802,6 @@ ByeBye:
NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext)
{
PVFATCCB Ccb;
PVFATFCB Fcb;
PERESOURCE Resource = NULL;
LARGE_INTEGER ByteOffset;
@ -832,9 +828,7 @@ NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext)
assert(IrpContext->DeviceExt);
assert(IrpContext->FileObject);
Ccb = (PVFATCCB) IrpContext->FileObject->FsContext2;
assert(Ccb);
Fcb = Ccb->pFcb;
Fcb = IrpContext->FileObject->FsContext;
assert(Fcb);
DPRINT("<%S>\n", Fcb->PathName);
@ -988,7 +982,7 @@ NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext)
{
CacheSize = PAGE_SIZE;
}
CcRosInitializeFileCache(IrpContext->FileObject, &Fcb->RFCB.Bcb, CacheSize);
CcRosInitializeFileCache(IrpContext->FileObject, CacheSize);
}
if (ByteOffset.QuadPart > OldFileSize.QuadPart)
{

View file

@ -1,4 +1,4 @@
/* $Id: vfat.h,v 1.55 2003/02/09 18:02:55 hbirr Exp $ */
/* $Id: vfat.h,v 1.56 2003/02/13 22:24:17 hbirr Exp $ */
#include <ddk/ntifs.h>
@ -181,28 +181,56 @@ extern PVFAT_GLOBAL_DATA VfatGlobalData;
typedef struct _VFATFCB
{
/* FCB header required by ROS/NT */
REACTOS_COMMON_FCB_HEADER RFCB;
SECTION_OBJECT_POINTERS SectionObjectPointers;
ERESOURCE MainResource;
ERESOURCE PagingIoResource;
/* end FCB header required by ROS/NT */
/* */
FATDirEntry entry;
/* point on filename (250 chars max) in PathName */
WCHAR *ObjectName;
/* path+filename 260 max */
WCHAR PathName[MAX_PATH];
/* short file name */
WCHAR ShortName[14];
/* */
LONG RefCount;
PDEVICE_EXTENSION pDevExt;
/* List of FCB's for this volume */
LIST_ENTRY FcbListEntry;
/* pointer to the parent fcb */
struct _VFATFCB* parentFcb;
/* Flags for the fcb */
ULONG Flags;
/* pointer to the file object which has initialized the fcb */
PFILE_OBJECT FileObject;
/* Directory index for the short name entry */
ULONG dirIndex;
/* Directory index where the long name starts */
ULONG startIndex;
ERESOURCE PagingIoResource;
ERESOURCE MainResource;
ULONG TimerCount;
/* Share access for the file object */
SHARE_ACCESS FCBShareAccess;
/* Entry into the hash table for the path + long name */
HASHENTRY Hash;
/* Entry into the hash table for the path + short name */
HASHENTRY ShortHash;
/* List of byte-range locks for this file */
FILE_LOCK FileLock;
/* Structure members used only for paging files. */
@ -212,9 +240,6 @@ typedef struct _VFATFCB
typedef struct _VFATCCB
{
VFATFCB * pFcb;
LIST_ENTRY NextCCB;
PFILE_OBJECT PtrFileObject;
LARGE_INTEGER CurrentByteOffset;
/* for DirectoryControl */
ULONG Entry;

View file

@ -77,7 +77,6 @@ typedef struct _REACTOS_COMMON_FCB_HEADER
{
CSHORT NodeTypeCode;
CSHORT NodeByteSize;
struct _BCB* Bcb;
LARGE_INTEGER AllocationSize;
LARGE_INTEGER FileSize;
LARGE_INTEGER ValidDataLength;

View file

@ -1,15 +1,11 @@
#ifndef __INCLUDE_DDK_NTIFS_H
#define __INCLUDE_DDK_NTIFS_H
struct _BCB;
NTSTATUS STDCALL
CcRosInitializeFileCache (PFILE_OBJECT FileObject,
struct _BCB** Bcb,
ULONG CacheSegmentSize);
NTSTATUS STDCALL
CcRosReleaseFileCache (PFILE_OBJECT FileObject,
struct _BCB* Bcb);
CcRosReleaseFileCache (PFILE_OBJECT FileObject);
#include <ddk/cctypes.h>

View file

@ -1,4 +1,4 @@
/* $Id: copy.c,v 1.13 2002/10/01 19:27:20 chorns Exp $
/* $Id: copy.c,v 1.14 2003/02/13 22:24:18 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -268,7 +268,7 @@ CcCopyRead (IN PFILE_OBJECT FileObject,
FileObject, (ULONG)FileOffset->QuadPart, Length, Wait,
Buffer, IoStatus);
Bcb = ((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->Bcb;
Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
ReadOffset = FileOffset->QuadPart;
DPRINT("AllocationSize %d, FileSize %d\n",
@ -369,7 +369,7 @@ CcCopyWrite (IN PFILE_OBJECT FileObject,
"Length %d, Wait %d, Buffer %x)\n",
FileObject, (ULONG)FileOffset->QuadPart, Length, Wait, Buffer);
Bcb = ((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->Bcb;
Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
WriteOffset = (ULONG)FileOffset->QuadPart;
if (!Wait)
@ -472,9 +472,6 @@ CcZeroData (IN PFILE_OBJECT FileObject,
Length = EndOffset->u.LowPart - StartOffset->u.LowPart;
/*
* FIXME: NT uses the shared cache map field for cached/non cached detection
*/
if (FileObject->SectionObjectPointers->SharedCacheMap == NULL)
{
/* File is not cached */
@ -535,7 +532,7 @@ CcZeroData (IN PFILE_OBJECT FileObject,
PHYSICAL_ADDRESS page;
Start = StartOffset->u.LowPart;
Bcb = ((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->Bcb;
Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
if (Wait)
{
/* testing, if the requested datas are available */

View file

@ -13,6 +13,14 @@
/* GLOBALS *******************************************************************/
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
#define ROUND_DOWN(N, S) (((N) % (S)) ? ROUND_UP(N, S) - S : N)
extern FAST_MUTEX ViewLock;
extern ULONG DirtyPageCount;
NTSTATUS CcRosInternalFreeCacheSegment(PCACHE_SEGMENT CacheSeg);
/* FUNCTIONS *****************************************************************/
/**********************************************************************
@ -73,6 +81,8 @@ CcSetFileSizes (IN PFILE_OBJECT FileObject,
PBCB Bcb;
PLIST_ENTRY current_entry;
PCACHE_SEGMENT current;
LIST_ENTRY FreeListHead;
NTSTATUS Status;
DPRINT("CcSetFileSizes(FileObject %x, FileSizes %x)\n",
FileObject, FileSizes);
@ -81,31 +91,66 @@ CcSetFileSizes (IN PFILE_OBJECT FileObject,
(ULONG)FileSizes->FileSize.QuadPart,
(ULONG)FileSizes->ValidDataLength.QuadPart);
Bcb = ((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->Bcb;
DPRINT("Bcb 0x%.08x\n", Bcb);
KeAcquireSpinLock(&Bcb->BcbLock, &oldirql);
Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
assert(Bcb);
if (FileSizes->AllocationSize.QuadPart < Bcb->AllocationSize.QuadPart)
{
InitializeListHead(&FreeListHead);
ExAcquireFastMutex(&ViewLock);
KeAcquireSpinLock(&Bcb->BcbLock, &oldirql);
current_entry = Bcb->BcbSegmentListHead.Flink;
while (current_entry != &Bcb->BcbSegmentListHead)
{
current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT,
BcbSegmentListEntry);
current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, BcbSegmentListEntry);
current_entry = current_entry->Flink;
if (current->FileOffset > FileSizes->AllocationSize.QuadPart)
{
if (current->ReferenceCount == 0 || (current->ReferenceCount == 1 && current->Dirty))
{
RemoveEntryList(&current->BcbSegmentListEntry);
RemoveEntryList(&current->CacheSegmentListEntry);
RemoveEntryList(&current->CacheSegmentLRUListEntry);
if (current->Dirty)
{
RemoveEntryList(&current->DirtySegmentListEntry);
DirtyPageCount -= Bcb->CacheSegmentSize / PAGE_SIZE;
}
InsertHeadList(&FreeListHead, &current->BcbSegmentListEntry);
}
else
{
DPRINT1("Anyone has referenced a cache segment behind the new size.\n");
KeBugCheck(0);
}
}
}
Bcb->AllocationSize = FileSizes->AllocationSize;
Bcb->FileSize = FileSizes->FileSize;
KeReleaseSpinLock(&Bcb->BcbLock, oldirql);
CcRosFreeCacheSegment(Bcb, current);
ExReleaseFastMutex(&ViewLock);
current_entry = FreeListHead.Flink;
while(current_entry != &FreeListHead)
{
current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, BcbSegmentListEntry);
current_entry = current_entry->Flink;
Status = CcRosInternalFreeCacheSegment(current);
if (!NT_SUCCESS(Status))
{
DPRINT1("CcRosInternalFreeCacheSegment failed, status = %x\n");
KeBugCheck(0);
}
}
}
else
{
KeAcquireSpinLock(&Bcb->BcbLock, &oldirql);
current_entry = Bcb->BcbSegmentListHead.Flink;
}
}
}
Bcb->AllocationSize = FileSizes->AllocationSize;
Bcb->FileSize = FileSizes->FileSize;
KeReleaseSpinLock(&Bcb->BcbLock, oldirql);
}
}

View file

@ -1,4 +1,4 @@
/* $Id: pin.c,v 1.10 2003/01/11 15:22:31 hbirr Exp $
/* $Id: pin.c,v 1.11 2003/02/13 22:24:18 hbirr Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -51,7 +51,7 @@ CcMapData (IN PFILE_OBJECT FileObject,
Length, Wait, pBcb, pBuffer);
ReadOffset = FileOffset->QuadPart;
Bcb = ((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->Bcb;
Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
assert(Bcb);
DPRINT("AllocationSize %d, FileSize %d\n",

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: view.c,v 1.56 2003/01/30 18:30:53 hbirr Exp $
/* $Id: view.c,v 1.57 2003/02/13 22:24:18 hbirr Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/view.c
@ -82,9 +82,9 @@ static LIST_ENTRY DirtySegmentListHead;
static LIST_ENTRY CacheSegmentListHead;
static LIST_ENTRY CacheSegmentLRUListHead;
static LIST_ENTRY ClosedListHead;
static ULONG DirtyPageCount=0;
ULONG DirtyPageCount=0;
static FAST_MUTEX ViewLock;
FAST_MUTEX ViewLock;
#ifdef CACHE_BITMAP
#define CI_CACHESEG_MAPPING_REGION_SIZE (128*1024*1024)
@ -994,18 +994,19 @@ VOID CcRosDereferenceCache(PFILE_OBJECT FileObject)
}
NTSTATUS STDCALL
CcRosReleaseFileCache(PFILE_OBJECT FileObject, PBCB Bcb)
CcRosReleaseFileCache(PFILE_OBJECT FileObject)
/*
* FUNCTION: Called by the file system when a handle to a file object
* has been closed.
*/
{
assert(Bcb);
PBCB Bcb;
ExAcquireFastMutex(&ViewLock);
if (FileObject->SectionObjectPointers->SharedCacheMap != NULL)
{
Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
if (FileObject->PrivateCacheMap != NULL)
{
FileObject->PrivateCacheMap = NULL;
@ -1033,52 +1034,53 @@ CcRosReleaseFileCache(PFILE_OBJECT FileObject, PBCB Bcb)
NTSTATUS STDCALL
CcRosInitializeFileCache(PFILE_OBJECT FileObject,
PBCB* Bcb,
ULONG CacheSegmentSize)
/*
* FUNCTION: Initializes a BCB for a file object
*/
{
PBCB Bcb;
DPRINT("CcRosInitializeFileCache(FileObject %x, *Bcb %x, CacheSegmentSize %d)\n",
FileObject, Bcb, CacheSegmentSize);
ExAcquireFastMutex(&ViewLock);
if (*Bcb == NULL)
Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
if (Bcb == NULL)
{
(*Bcb) = ExAllocateFromNPagedLookasideList(&BcbLookasideList);
if ((*Bcb) == NULL)
Bcb = ExAllocateFromNPagedLookasideList(&BcbLookasideList);
if (Bcb == NULL)
{
ExReleaseFastMutex(&ViewLock);
return(STATUS_UNSUCCESSFUL);
}
memset((*Bcb), 0, sizeof(BCB));
memset(Bcb, 0, sizeof(BCB));
ObReferenceObjectByPointer(FileObject,
FILE_ALL_ACCESS,
NULL,
KernelMode);
(*Bcb)->FileObject = FileObject;
(*Bcb)->CacheSegmentSize = CacheSegmentSize;
Bcb->FileObject = FileObject;
Bcb->CacheSegmentSize = CacheSegmentSize;
if (FileObject->FsContext)
{
(*Bcb)->AllocationSize =
Bcb->AllocationSize =
((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->AllocationSize;
(*Bcb)->FileSize =
Bcb->FileSize =
((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->FileSize;
}
KeInitializeSpinLock(&(*Bcb)->BcbLock);
InitializeListHead(&(*Bcb)->BcbSegmentListHead);
FileObject->SectionObjectPointers->SharedCacheMap = *Bcb;
KeInitializeSpinLock(&Bcb->BcbLock);
InitializeListHead(&Bcb->BcbSegmentListHead);
FileObject->SectionObjectPointers->SharedCacheMap = Bcb;
}
if (FileObject->PrivateCacheMap == NULL)
{
FileObject->PrivateCacheMap = *Bcb;
(*Bcb)->RefCount++;
FileObject->PrivateCacheMap = Bcb;
Bcb->RefCount++;
}
if ((*Bcb)->BcbRemoveListEntry.Flink != NULL)
if (Bcb->BcbRemoveListEntry.Flink != NULL)
{
RemoveEntryList(&(*Bcb)->BcbRemoveListEntry);
(*Bcb)->BcbRemoveListEntry.Flink = NULL;
RemoveEntryList(&Bcb->BcbRemoveListEntry);
Bcb->BcbRemoveListEntry.Flink = NULL;
}
ExReleaseFastMutex(&ViewLock);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: section.c,v 1.103 2003/01/11 15:31:05 hbirr Exp $
/* $Id: section.c,v 1.104 2003/02/13 22:24:18 hbirr Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/section.c
@ -269,7 +269,7 @@ MmUnsharePageEntrySectionSegment(PSECTION_OBJECT Section,
if (SHARE_COUNT_FROM_SSE(Entry) == 0)
{
PFILE_OBJECT FileObject;
PREACTOS_COMMON_FCB_HEADER Fcb;
PBCB Bcb;
SWAPENTRY SavedSwapEntry;
PHYSICAL_ADDRESS Page;
@ -277,13 +277,13 @@ MmUnsharePageEntrySectionSegment(PSECTION_OBJECT Section,
FileObject = Section->FileObject;
if (FileObject != NULL)
{
Fcb = (PREACTOS_COMMON_FCB_HEADER)FileObject->FsContext;
Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
if (FileObject->Flags & FO_DIRECT_CACHE_PAGING_READ &&
(Offset % PAGE_SIZE) == 0)
{
NTSTATUS Status;
Status = CcRosUnmapCacheSegment(Fcb->Bcb, Offset, Dirty);
Status = CcRosUnmapCacheSegment(Bcb, Offset, Dirty);
if (!NT_SUCCESS(Status))
{
KeBugCheck(0);
@ -324,12 +324,12 @@ MiReadPage(PMEMORY_AREA MemoryArea,
PCACHE_SEGMENT CacheSeg;
PFILE_OBJECT FileObject;
NTSTATUS Status;
PREACTOS_COMMON_FCB_HEADER Fcb;
PBCB Bcb;
FileObject = MemoryArea->Data.SectionData.Section->FileObject;
Fcb = (PREACTOS_COMMON_FCB_HEADER)FileObject->FsContext;
Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
assert(Fcb->Bcb);
assert(Bcb);
/*
* If the file system is letting us go directly to the cache and the
@ -346,7 +346,7 @@ MiReadPage(PMEMORY_AREA MemoryArea,
* filesystems do because it is safe for us to use an offset with a
* alignment less than the file system block size.
*/
Status = CcRosGetCacheSegment(Fcb->Bcb,
Status = CcRosGetCacheSegment(Bcb,
Offset->u.LowPart,
&BaseOffset,
&BaseAddress,
@ -365,7 +365,7 @@ MiReadPage(PMEMORY_AREA MemoryArea,
Status = ReadCacheSegment(CacheSeg);
if (!NT_SUCCESS(Status))
{
CcRosReleaseCacheSegment(Fcb->Bcb, CacheSeg, FALSE, FALSE, FALSE);
CcRosReleaseCacheSegment(Bcb, CacheSeg, FALSE, FALSE, FALSE);
return Status;
}
}
@ -377,7 +377,7 @@ MiReadPage(PMEMORY_AREA MemoryArea,
(*Page) = Addr;
MmReferencePage((*Page));
CcRosReleaseCacheSegment(Fcb->Bcb, CacheSeg, TRUE, FALSE, TRUE);
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, TRUE);
}
else
{
@ -393,7 +393,7 @@ MiReadPage(PMEMORY_AREA MemoryArea,
return(Status);
}
Status = CcRosGetCacheSegment(Fcb->Bcb,
Status = CcRosGetCacheSegment(Bcb,
Offset->u.LowPart,
&BaseOffset,
&BaseAddress,
@ -412,7 +412,7 @@ MiReadPage(PMEMORY_AREA MemoryArea,
Status = ReadCacheSegment(CacheSeg);
if (!NT_SUCCESS(Status))
{
CcRosReleaseCacheSegment(Fcb->Bcb, CacheSeg, FALSE, FALSE, FALSE);
CcRosReleaseCacheSegment(Bcb, CacheSeg, FALSE, FALSE, FALSE);
return Status;
}
}
@ -425,8 +425,8 @@ MiReadPage(PMEMORY_AREA MemoryArea,
else
{
memcpy(PageAddr, BaseAddress + Offset->u.LowPart - BaseOffset, OffsetInPage);
CcRosReleaseCacheSegment(Fcb->Bcb, CacheSeg, TRUE, FALSE, FALSE);
Status = CcRosGetCacheSegment(Fcb->Bcb,
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
Status = CcRosGetCacheSegment(Bcb,
Offset->u.LowPart + OffsetInPage,
&BaseOffset,
&BaseAddress,
@ -446,14 +446,14 @@ MiReadPage(PMEMORY_AREA MemoryArea,
Status = ReadCacheSegment(CacheSeg);
if (!NT_SUCCESS(Status))
{
CcRosReleaseCacheSegment(Fcb->Bcb, CacheSeg, FALSE, FALSE, FALSE);
CcRosReleaseCacheSegment(Bcb, CacheSeg, FALSE, FALSE, FALSE);
ExUnmapPage(PageAddr);
return Status;
}
}
memcpy(PageAddr + OffsetInPage, BaseAddress, PAGE_SIZE - OffsetInPage);
}
CcRosReleaseCacheSegment(Fcb->Bcb, CacheSeg, TRUE, FALSE, FALSE);
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
ExUnmapPage(PageAddr);
}
return(STATUS_SUCCESS);
@ -1571,7 +1571,7 @@ MmWritePageSectionView(PMADDRESS_SPACE AddressSpace,
BOOLEAN Private;
NTSTATUS Status;
PFILE_OBJECT FileObject;
PREACTOS_COMMON_FCB_HEADER Fcb = NULL;
PBCB Bcb = NULL;
BOOLEAN DirectMapped;
Address = (PVOID)PAGE_ROUND_DOWN(Address);
@ -1583,7 +1583,7 @@ MmWritePageSectionView(PMADDRESS_SPACE AddressSpace,
DirectMapped = FALSE;
if (FileObject != NULL)
{
Fcb = (PREACTOS_COMMON_FCB_HEADER)FileObject->FsContext;
Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
/*
* If the file system is letting us go directly to the cache and the
@ -1654,7 +1654,7 @@ MmWritePageSectionView(PMADDRESS_SPACE AddressSpace,
if (DirectMapped && !Private)
{
assert(SwapEntry == 0);
CcRosMarkDirtyCacheSegment(Fcb->Bcb, Offset.u.LowPart);
CcRosMarkDirtyCacheSegment(Bcb, Offset.u.LowPart);
PageOp->Status = STATUS_SUCCESS;
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
MmReleasePageOp(PageOp);
@ -2940,7 +2940,7 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
PMEMORY_AREA MArea;
ULONG Entry;
PFILE_OBJECT FileObject;
PREACTOS_COMMON_FCB_HEADER Fcb;
PBCB Bcb;
ULONG Offset;
SWAPENTRY SavedSwapEntry;
PMM_PAGEOP PageOp;
@ -2978,8 +2978,8 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
if (PhysAddr.QuadPart == PAGE_FROM_SSE(Entry) && Dirty)
{
FileObject = MemoryArea->Data.SectionData.Section->FileObject;
Fcb = (PREACTOS_COMMON_FCB_HEADER)FileObject->FsContext;
CcRosMarkDirtyCacheSegment(Fcb->Bcb, Offset);
Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
CcRosMarkDirtyCacheSegment(Bcb, Offset);
assert(SwapEntry == 0);
}
}
@ -3232,6 +3232,7 @@ NtExtendSection(IN HANDLE SectionHandle,
IN ULONG NewMaximumSize)
{
UNIMPLEMENTED;
return(STATUS_NOT_IMPLEMENTED);
}

View file

@ -1,14 +1,12 @@
; $Id: ntoskrnl.def,v 1.146 2003/01/07 17:48:11 robd Exp $
; $Id: ntoskrnl.def,v 1.147 2003/02/13 22:24:19 hbirr Exp $
;
; reactos/ntoskrnl/ntoskrnl.def
;
; ReactOS Operating System
;
EXPORTS
CcRosInitializeFileCache@12
;CcRosRequestCacheSegment@20
;CcRosReleaseCacheSegment@12
CcRosReleaseFileCache@8
CcRosInitializeFileCache@8
CcRosReleaseFileCache@4
CcCopyRead@24
CcCopyWrite@20
CcFlushCache@16

View file

@ -1,15 +1,13 @@
; $Id: ntoskrnl.edf,v 1.132 2003/01/07 17:48:11 robd Exp $
; $Id: ntoskrnl.edf,v 1.133 2003/02/13 22:24:19 hbirr Exp $
;
; reactos/ntoskrnl/ntoskrnl.def
;
; ReactOS Operating System
;
EXPORTS
CcRosInitializeFileCache=CcRosInitializeFileCache@12
CcRosInitializeFileCache=CcRosInitializeFileCache@8
CcMdlReadComplete=CcMdlReadComplete@8
;CcRosRequestCacheSegment=CcRosRequestCacheSegment@20
;CcRosReleaseCacheSegment=CcRosReleaseCacheSegment@12
CcRosReleaseFileCache=CcRosReleaseFileCache@8
CcRosReleaseFileCache=CcRosReleaseFileCache@4
CcCopyRead=CcCopyRead@24
CcCopyWrite=CcCopyWrite@20
CcFlushCache=CcFlushCache@16