- 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 typedef struct _CCB
{ {
PFCB Fcb;
LIST_ENTRY NextCCB; LIST_ENTRY NextCCB;
PFILE_OBJECT PtrFileObject; PFILE_OBJECT PtrFileObject;
LARGE_INTEGER CurrentByteOffset; LARGE_INTEGER CurrentByteOffset;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -45,23 +45,16 @@ CdfsCleanupFile(PDEVICE_EXTENSION DeviceExt,
* FUNCTION: Cleans up after a file has been closed. * FUNCTION: Cleans up after a file has been closed.
*/ */
{ {
PCCB Ccb;
DPRINT("CdfsCleanupFile(DeviceExt %x, FileObject %x)\n", DPRINT("CdfsCleanupFile(DeviceExt %x, FileObject %x)\n",
DeviceExt, DeviceExt,
FileObject); FileObject);
Ccb = (PCCB) (FileObject->FsContext2);
if (Ccb == NULL)
{
return STATUS_SUCCESS;
}
/* Uninitialize file cache if initialized for this file object. */ /* 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; return STATUS_SUCCESS;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -46,7 +46,7 @@ CdfsCloseFile(PDEVICE_EXTENSION DeviceExt,
*/ */
{ {
PCCB Ccb; PCCB Ccb;
DPRINT("CdfsCloseFile(DeviceExt %x, FileObject %x)\n", DPRINT("CdfsCloseFile(DeviceExt %x, FileObject %x)\n",
DeviceExt, DeviceExt,
FileObject); FileObject);
@ -66,8 +66,7 @@ CdfsCloseFile(PDEVICE_EXTENSION DeviceExt,
// This a FO, that was created outside from FSD. // This a FO, that was created outside from FSD.
// Some FO's are created with IoCreateStreamFileObject() insid from FSD. // Some FO's are created with IoCreateStreamFileObject() insid from FSD.
// This FO's don't have a FileName. // This FO's don't have a FileName.
CdfsReleaseFCB(DeviceExt, CdfsReleaseFCB(DeviceExt, FileObject->FsContext);
Ccb->Fcb);
} }
if (Ccb->DirectorySearchPattern) if (Ccb->DirectorySearchPattern)

View file

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

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -555,7 +555,7 @@ CdfsQueryDirectory(PDEVICE_OBJECT DeviceObject,
FileObject = Stack->FileObject; FileObject = Stack->FileObject;
Ccb = (PCCB)FileObject->FsContext2; Ccb = (PCCB)FileObject->FsContext2;
Fcb = Ccb->Fcb; Fcb = (PFCB)FileObject->FsContext;
/* Obtain the callers parameters */ /* Obtain the callers parameters */
BufferLength = Stack->Parameters.QueryDirectory.Length; BufferLength = Stack->Parameters.QueryDirectory.Length;

View file

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

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -379,12 +379,11 @@ CdfsMountVolume(PDEVICE_OBJECT DeviceObject,
sizeof(CCB)); sizeof(CCB));
DeviceExt->StreamFileObject->Flags = DeviceExt->StreamFileObject->Flags | FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ; 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->FsContext2 = Ccb;
DeviceExt->StreamFileObject->SectionObjectPointers = &Fcb->SectionObjectPointers; DeviceExt->StreamFileObject->SectionObjectPointers = &Fcb->SectionObjectPointers;
DeviceExt->StreamFileObject->PrivateCacheMap = NULL; DeviceExt->StreamFileObject->PrivateCacheMap = NULL;
DeviceExt->StreamFileObject->Vpb = DeviceExt->Vpb; DeviceExt->StreamFileObject->Vpb = DeviceExt->Vpb;
Ccb->Fcb = Fcb;
Ccb->PtrFileObject = DeviceExt->StreamFileObject; Ccb->PtrFileObject = DeviceExt->StreamFileObject;
Fcb->FileObject = DeviceExt->StreamFileObject; Fcb->FileObject = DeviceExt->StreamFileObject;
Fcb->DevExt = (PDEVICE_EXTENSION)DeviceExt->StorageDevice; Fcb->DevExt = (PDEVICE_EXTENSION)DeviceExt->StorageDevice;
@ -398,7 +397,6 @@ CdfsMountVolume(PDEVICE_OBJECT DeviceObject,
Fcb->Entry.DataLengthL = (DeviceExt->CdInfo.VolumeSpaceSize + DeviceExt->CdInfo.VolumeOffset) * BLOCKSIZE; Fcb->Entry.DataLengthL = (DeviceExt->CdInfo.VolumeSpaceSize + DeviceExt->CdInfo.VolumeOffset) * BLOCKSIZE;
Status = CcRosInitializeFileCache(DeviceExt->StreamFileObject, Status = CcRosInitializeFileCache(DeviceExt->StreamFileObject,
&Fcb->RFCB.Bcb,
PAGE_SIZE); PAGE_SIZE);
if (!NT_SUCCESS (Status)) if (!NT_SUCCESS (Status))
{ {

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -71,7 +71,7 @@ CdfsReadFile(PDEVICE_EXTENSION DeviceExt,
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
Ccb = (PCCB)FileObject->FsContext2; Ccb = (PCCB)FileObject->FsContext2;
Fcb = Ccb->Fcb; Fcb = (PFCB)FileObject->FsContext;
if (ReadOffset >= Fcb->Entry.DataLengthL) if (ReadOffset >= Fcb->Entry.DataLengthL)
return(STATUS_END_OF_FILE); return(STATUS_END_OF_FILE);
@ -87,7 +87,7 @@ CdfsReadFile(PDEVICE_EXTENSION DeviceExt,
Length = Fcb->Entry.DataLengthL - ReadOffset; Length = Fcb->Entry.DataLengthL - ReadOffset;
if (FileObject->PrivateCacheMap == NULL) if (FileObject->PrivateCacheMap == NULL)
{ {
CcRosInitializeFileCache(FileObject, &Fcb->RFCB.Bcb, PAGE_SIZE); CcRosInitializeFileCache(FileObject, PAGE_SIZE);
} }
FileOffset.QuadPart = (LONGLONG)ReadOffset; FileOffset.QuadPart = (LONGLONG)ReadOffset;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -44,12 +44,9 @@ NtfsMakeAbsoluteFilename(PFILE_OBJECT pFileObject,
{ {
PWSTR rcName; PWSTR rcName;
PFCB Fcb; PFCB Fcb;
PCCB Ccb;
DPRINT("try related for %S\n", pRelativeFileName); DPRINT("try related for %S\n", pRelativeFileName);
Ccb = pFileObject->FsContext2; Fcb = pFileObject->FsContext;
assert(Ccb);
Fcb = Ccb->Fcb;
assert(Fcb); assert(Fcb);
/* verify related object is a directory and target name /* 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 * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -505,7 +505,7 @@ NtfsQueryDirectory(PDEVICE_OBJECT DeviceObject,
FileObject = Stack->FileObject; FileObject = Stack->FileObject;
Ccb = (PCCB)FileObject->FsContext2; Ccb = (PCCB)FileObject->FsContext2;
Fcb = Ccb->Fcb; Fcb = (PFCB)FileObject->FsContext;
/* Obtain the callers parameters */ /* Obtain the callers parameters */
BufferLength = Stack->Parameters.QueryDirectory.Length; BufferLength = Stack->Parameters.QueryDirectory.Length;

View file

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

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -275,12 +275,11 @@ NtfsMountVolume(PDEVICE_OBJECT DeviceObject,
sizeof(CCB)); sizeof(CCB));
DeviceExt->StreamFileObject->Flags = DeviceExt->StreamFileObject->Flags | FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ; 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->FsContext2 = Ccb;
DeviceExt->StreamFileObject->SectionObjectPointers = &Fcb->SectionObjectPointers; DeviceExt->StreamFileObject->SectionObjectPointers = &Fcb->SectionObjectPointers;
DeviceExt->StreamFileObject->PrivateCacheMap = NULL; DeviceExt->StreamFileObject->PrivateCacheMap = NULL;
DeviceExt->StreamFileObject->Vpb = DeviceExt->Vpb; DeviceExt->StreamFileObject->Vpb = DeviceExt->Vpb;
Ccb->Fcb = Fcb;
Ccb->PtrFileObject = DeviceExt->StreamFileObject; Ccb->PtrFileObject = DeviceExt->StreamFileObject;
Fcb->FileObject = DeviceExt->StreamFileObject; Fcb->FileObject = DeviceExt->StreamFileObject;
Fcb->DevExt = (PDEVICE_EXTENSION)DeviceExt->StorageDevice; Fcb->DevExt = (PDEVICE_EXTENSION)DeviceExt->StorageDevice;
@ -295,7 +294,6 @@ NtfsMountVolume(PDEVICE_OBJECT DeviceObject,
// Fcb->Entry.DataLengthL = DeviceExt->CdInfo.VolumeSpaceSize * BLOCKSIZE; // Fcb->Entry.DataLengthL = DeviceExt->CdInfo.VolumeSpaceSize * BLOCKSIZE;
Status = CcRosInitializeFileCache(DeviceExt->StreamFileObject, Status = CcRosInitializeFileCache(DeviceExt->StreamFileObject,
&Fcb->RFCB.Bcb,
CACHEPAGESIZE(DeviceExt)); CACHEPAGESIZE(DeviceExt));
if (!NT_SUCCESS (Status)) if (!NT_SUCCESS (Status))
{ {

View file

@ -106,7 +106,6 @@ typedef struct _FCB
typedef struct _CCB typedef struct _CCB
{ {
PFCB Fcb;
LIST_ENTRY NextCCB; LIST_ENTRY NextCCB;
PFILE_OBJECT PtrFileObject; PFILE_OBJECT PtrFileObject;
LARGE_INTEGER CurrentByteOffset; 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -24,7 +24,6 @@ VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
* FUNCTION: Cleans up after a file has been closed. * FUNCTION: Cleans up after a file has been closed.
*/ */
{ {
PVFATCCB pCcb;
PVFATFCB pFcb; PVFATFCB pFcb;
PDEVICE_EXTENSION DeviceExt = IrpContext->DeviceExt; PDEVICE_EXTENSION DeviceExt = IrpContext->DeviceExt;
PFILE_OBJECT FileObject = IrpContext->FileObject; PFILE_OBJECT FileObject = IrpContext->FileObject;
@ -33,30 +32,25 @@ VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
DeviceExt, FileObject); DeviceExt, FileObject);
/* FIXME: handle file/directory deletion here */ /* FIXME: handle file/directory deletion here */
pCcb = (PVFATCCB) (FileObject->FsContext2); pFcb = (PVFATFCB) FileObject->FsContext;
if (pCcb == NULL) if (pFcb)
{
return STATUS_SUCCESS;
}
pFcb = pCcb->pFcb;
if (!(pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY) &&
FsRtlAreThereCurrentFileLocks(&pFcb->FileLock))
{ {
/* remove all locks this process have on this file */ if (!(pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY) &&
FsRtlFastUnlockAll(&pFcb->FileLock, FsRtlAreThereCurrentFileLocks(&pFcb->FileLock))
FileObject, {
IoGetRequestorProcess(IrpContext->Irp), /* remove all locks this process have on this file */
NULL FsRtlFastUnlockAll(&pFcb->FileLock,
); FileObject,
} IoGetRequestorProcess(IrpContext->Irp),
NULL);
}
/* Uninitialize file cache if initialized for this file object. */ /* 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; 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -33,13 +33,13 @@ VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
/* FIXME : update entry in directory? */ /* FIXME : update entry in directory? */
pCcb = (PVFATCCB) (FileObject->FsContext2); pCcb = (PVFATCCB) (FileObject->FsContext2);
pFcb = (PVFATFCB) (FileObject->FsContext);
DPRINT ("pCcb %x\n", pCcb); if (pFcb == NULL)
if (pCcb == NULL)
{ {
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
pFcb = pCcb->pFcb;
if (pFcb->Flags & FCB_IS_VOLUME) if (pFcb->Flags & FCB_IS_VOLUME)
{ {
DPRINT1("Volume\n"); DPRINT1("Volume\n");
@ -58,15 +58,21 @@ VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
delEntry (DeviceExt, FileObject); delEntry (DeviceExt, FileObject);
} }
else else
Status = STATUS_DELETE_PENDING; {
Status = STATUS_DELETE_PENDING;
}
} }
FileObject->FsContext2 = NULL;
vfatReleaseFCB (DeviceExt, pFcb); vfatReleaseFCB (DeviceExt, pFcb);
} }
else
FileObject->FsContext2 = NULL; FileObject->FsContext2 = NULL;
FileObject->FsContext = NULL;
FileObject->SectionObjectPointers = NULL;
vfatDestroyCCB(pCcb); if (pCcb)
{
vfatDestroyCCB(pCcb);
}
return Status; return Status;
} }

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * PROJECT: ReactOS kernel
* FILE: services/fs/vfat/create.c * FILE: services/fs/vfat/create.c
@ -364,12 +364,9 @@ vfatMakeAbsoluteFilename (PFILE_OBJECT pFileObject,
{ {
PWSTR rcName; PWSTR rcName;
PVFATFCB fcb; PVFATFCB fcb;
PVFATCCB ccb;
DPRINT ("try related for %S\n", pRelativeFileName); DPRINT ("try related for %S\n", pRelativeFileName);
ccb = pFileObject->FsContext2; fcb = pFileObject->FsContext;
assert (ccb);
fcb = ccb->pFcb;
assert (fcb); assert (fcb);
/* verify related object is a directory and target name /* verify related object is a directory and target name
@ -600,11 +597,8 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
memset(pCcb, 0, sizeof(VFATCCB)); memset(pCcb, 0, sizeof(VFATCCB));
FileObject->Flags |= FO_FCB_IS_VALID; FileObject->Flags |= FO_FCB_IS_VALID;
FileObject->SectionObjectPointers = &pFcb->SectionObjectPointers; FileObject->SectionObjectPointers = &pFcb->SectionObjectPointers;
FileObject->FsContext = (PVOID) &pFcb->RFCB; FileObject->FsContext = pFcb;
FileObject->FsContext2 = pCcb; FileObject->FsContext2 = pCcb;
pCcb->pFcb = pFcb;
pCcb->PtrFileObject = FileObject;
pFcb->pDevExt = DeviceExt;
pFcb->RefCount++; pFcb->RefCount++;
Irp->IoStatus.Information = FILE_OPENED; Irp->IoStatus.Information = FILE_OPENED;
@ -654,8 +648,7 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
Attributes & FILE_ATTRIBUTE_VALID_FLAGS); Attributes & FILE_ATTRIBUTE_VALID_FLAGS);
if (NT_SUCCESS (Status)) if (NT_SUCCESS (Status))
{ {
pCcb = FileObject->FsContext2; pFcb = FileObject->FsContext;
pFcb = pCcb->pFcb;
Irp->IoStatus.Information = FILE_CREATED; Irp->IoStatus.Information = FILE_CREATED;
VfatSetAllocationSizeInformation(FileObject, VfatSetAllocationSizeInformation(FileObject,
pFcb, pFcb,
@ -689,8 +682,7 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
return(STATUS_OBJECT_NAME_COLLISION); return(STATUS_OBJECT_NAME_COLLISION);
} }
pCcb = FileObject->FsContext2; pFcb = FileObject->FsContext;
pFcb = pCcb->pFcb;
/* /*
* Check the file has the requested attributes * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -209,7 +209,7 @@ NTSTATUS DoQuery (PVFAT_IRP_CONTEXT IrpContext)
BOOLEAN First = FALSE; BOOLEAN First = FALSE;
pCcb = (PVFATCCB) IrpContext->FileObject->FsContext2; pCcb = (PVFATCCB) IrpContext->FileObject->FsContext2;
pFcb = pCcb->pFcb; pFcb = (PVFATFCB) IrpContext->FileObject->FsContext;
if (!ExAcquireResourceSharedLite(&pFcb->MainResource, IrpContext->Flags & IRPCONTEXT_CANWAIT)) 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -45,7 +45,7 @@ VfatUpdateEntry (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT pFileObject)
DPRINT ("updEntry PathFileName \'%S\'\n", DPRINT ("updEntry PathFileName \'%S\'\n",
((PVFATCCB)(pFileObject->FsContext2))->pFcb->PathName); ((PVFATCCB)(pFileObject->FsContext2))->pFcb->PathName);
pFcb = ((PVFATCCB)(pFileObject->FsContext2))->pFcb; pFcb = (PVFATFCB)pFileObject->FsContext;
assert (pFcb); assert (pFcb);
pDirFcb = pFcb->parentFcb; pDirFcb = pFcb->parentFcb;
assert (pDirFcb); assert (pDirFcb);
@ -559,7 +559,7 @@ VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
CcSetDirtyPinnedData(Context, NULL); CcSetDirtyPinnedData(Context, NULL);
CcUnpinData(Context); CcUnpinData(Context);
// FEXME: check status // FIXME: check status
vfatMakeFCBFromDirEntry (DeviceExt, pDirFcb, FileName, pEntry, vfatMakeFCBFromDirEntry (DeviceExt, pDirFcb, FileName, pEntry,
start, start + nbSlots - 1, &newFCB); start, start + nbSlots - 1, &newFCB);
vfatAttachFCBToFileObject (DeviceExt, newFCB, pFileObject); vfatAttachFCBToFileObject (DeviceExt, newFCB, pFileObject);
@ -635,7 +635,7 @@ delEntry (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT pFileObject)
} }
return status; return status;
} }
pName = ((PVFATCCB)(pFileObject->FsContext2))->pFcb->ObjectName; pName = ((PVFATFCB)pFileObject->FsContext)->ObjectName;
if (*pName == L'\\') if (*pName == L'\\')
{ {
pName ++; 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 * FILE: fcb.c
@ -156,12 +156,13 @@ vfatReleaseFCB(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
if (vfatFCBIsDirectory(pFCB)) if (vfatFCBIsDirectory(pFCB))
{ {
/* Uninitialize file cache if initialized for this file object. */ /* 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); vfatDestroyCCB(pFCB->FileObject->FsContext2);
pFCB->FileObject->FsContext2 = NULL; pFCB->FileObject->FsContext2 = NULL;
pFCB->FileObject->FsContext = NULL;
ObDereferenceObject(pFCB->FileObject); ObDereferenceObject(pFCB->FileObject);
} }
vfatDestroyFCB (pFCB); vfatDestroyFCB (pFCB);
@ -185,7 +186,6 @@ vfatAddFCBToTable(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
Index = pFCB->Hash.Hash % FCB_HASH_TABLE_SIZE; Index = pFCB->Hash.Hash % FCB_HASH_TABLE_SIZE;
ShortIndex = pFCB->ShortHash.Hash % FCB_HASH_TABLE_SIZE; ShortIndex = pFCB->ShortHash.Hash % FCB_HASH_TABLE_SIZE;
KeAcquireSpinLock (&pVCB->FcbListLock, &oldIrql); KeAcquireSpinLock (&pVCB->FcbListLock, &oldIrql);
pFCB->pDevExt = pVCB;
InsertTailList (&pVCB->FcbListHead, &pFCB->FcbListEntry); InsertTailList (&pVCB->FcbListHead, &pFCB->FcbListEntry);
pFCB->Hash.next = pVCB->FcbHashTable[Index]; 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->Flags |= FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
fileObject->SectionObjectPointers = &fcb->SectionObjectPointers; fileObject->SectionObjectPointers = &fcb->SectionObjectPointers;
fileObject->FsContext = (PVOID) &fcb->RFCB; fileObject->FsContext = fcb;
fileObject->FsContext2 = newCCB; fileObject->FsContext2 = newCCB;
newCCB->pFcb = fcb;
newCCB->PtrFileObject = fileObject;
fcb->FileObject = fileObject; fcb->FileObject = fileObject;
fcb->pDevExt = vcb;
fileCacheQuantum = (vcb->FatInfo.BytesPerCluster >= PAGE_SIZE) ? fileCacheQuantum = (vcb->FatInfo.BytesPerCluster >= PAGE_SIZE) ?
vcb->FatInfo.BytesPerCluster : PAGE_SIZE; vcb->FatInfo.BytesPerCluster : PAGE_SIZE;
status = CcRosInitializeFileCache (fileObject, status = CcRosInitializeFileCache (fileObject,
&fcb->RFCB.Bcb,
fileCacheQuantum); fileCacheQuantum);
if (!NT_SUCCESS (status)) if (!NT_SUCCESS (status))
{ {
@ -331,7 +327,6 @@ vfatMakeRootFCB(PDEVICE_EXTENSION pVCB)
CurrentCluster = FirstCluster = pVCB->FatInfo.RootCluster; CurrentCluster = FirstCluster = pVCB->FatInfo.RootCluster;
FCB->entry.FirstCluster = FirstCluster & 0xffff; FCB->entry.FirstCluster = FirstCluster & 0xffff;
FCB->entry.FirstClusterHigh = FirstCluster >> 16; FCB->entry.FirstClusterHigh = FirstCluster >> 16;
CurrentCluster = FirstCluster;
while (CurrentCluster != 0xffffffff && NT_SUCCESS(Status)) while (CurrentCluster != 0xffffffff && NT_SUCCESS(Status))
{ {
@ -469,11 +464,8 @@ vfatAttachFCBToFileObject (PDEVICE_EXTENSION vcb,
fileObject->Flags = fileObject->Flags | FO_FCB_IS_VALID | fileObject->Flags = fileObject->Flags | FO_FCB_IS_VALID |
FO_DIRECT_CACHE_PAGING_READ; FO_DIRECT_CACHE_PAGING_READ;
fileObject->SectionObjectPointers = &fcb->SectionObjectPointers; fileObject->SectionObjectPointers = &fcb->SectionObjectPointers;
fileObject->FsContext = (PVOID) &fcb->RFCB; fileObject->FsContext = fcb;
fileObject->FsContext2 = newCCB; 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); DPRINT ("file open: fcb:%x file size: %d\n", fcb, fcb->entry.FileSize);
return STATUS_SUCCESS; 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -553,7 +553,7 @@ NTSTATUS VfatQueryInformation(PVFAT_IRP_CONTEXT IrpContext)
/* INITIALIZATION */ /* INITIALIZATION */
FileInformationClass = IrpContext->Stack->Parameters.QueryFile.FileInformationClass; FileInformationClass = IrpContext->Stack->Parameters.QueryFile.FileInformationClass;
FCB = ((PVFATCCB) IrpContext->FileObject->FsContext2)->pFcb; FCB = (PVFATFCB) IrpContext->FileObject->FsContext;
SystemBuffer = IrpContext->Irp->AssociatedIrp.SystemBuffer; SystemBuffer = IrpContext->Irp->AssociatedIrp.SystemBuffer;
BufferLength = IrpContext->Stack->Parameters.QueryFile.Length; BufferLength = IrpContext->Stack->Parameters.QueryFile.Length;
@ -654,7 +654,7 @@ NTSTATUS VfatSetInformation(PVFAT_IRP_CONTEXT IrpContext)
/* INITIALIZATION */ /* INITIALIZATION */
FileInformationClass = FileInformationClass =
IrpContext->Stack->Parameters.SetFile.FileInformationClass; IrpContext->Stack->Parameters.SetFile.FileInformationClass;
FCB = ((PVFATCCB) IrpContext->FileObject->FsContext2)->pFcb; FCB = (PVFATFCB) IrpContext->FileObject->FsContext;
SystemBuffer = IrpContext->Irp->AssociatedIrp.SystemBuffer; SystemBuffer = IrpContext->Irp->AssociatedIrp.SystemBuffer;
DPRINT("FileInformationClass %d\n", FileInformationClass); 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -36,7 +36,6 @@ NTSTATUS VfatFlushVolume(PDEVICE_EXTENSION DeviceExt, PVFATFCB VolumeFcb)
{ {
PLIST_ENTRY ListEntry; PLIST_ENTRY ListEntry;
PVFATFCB Fcb; PVFATFCB Fcb;
PVFATCCB Ccb;
NTSTATUS Status, ReturnStatus = STATUS_SUCCESS; NTSTATUS Status, ReturnStatus = STATUS_SUCCESS;
DPRINT("VfatFlushVolume(DeviceExt %x, FatFcb %x)\n", DeviceExt, VolumeFcb); 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); DPRINT1("VfatFlushFile failed, status = %x\n", Status);
ReturnStatus = 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 = (PVFATFCB) DeviceExt->FATFileObject->FsContext;
Fcb = Ccb->pFcb;
ExAcquireResourceExclusiveLite(&DeviceExt->FatResource, TRUE); ExAcquireResourceExclusiveLite(&DeviceExt->FatResource, TRUE);
Status = VfatFlushFile(DeviceExt, Fcb); Status = VfatFlushFile(DeviceExt, Fcb);
@ -79,7 +77,6 @@ NTSTATUS VfatFlush(PVFAT_IRP_CONTEXT IrpContext)
{ {
NTSTATUS Status; NTSTATUS Status;
PVFATFCB Fcb; PVFATFCB Fcb;
PVFATCCB Ccb;
/* /*
* This request is not allowed on the main device object. * This request is not allowed on the main device object.
*/ */
@ -89,9 +86,7 @@ NTSTATUS VfatFlush(PVFAT_IRP_CONTEXT IrpContext)
goto ByeBye; goto ByeBye;
} }
Ccb = (PVFATCCB) IrpContext->FileObject->FsContext2; Fcb = (PVFATFCB)IrpContext->FileObject->FsContext;
assert(Ccb);
Fcb = Ccb->pFcb;
assert(Fcb); assert(Fcb);
if (Fcb->Flags & FCB_IS_VOLUME) if (Fcb->Flags & FCB_IS_VOLUME)

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -301,15 +301,12 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
wcscpy(Fcb->PathName, L"$$Fat$$"); wcscpy(Fcb->PathName, L"$$Fat$$");
Fcb->ObjectName = Fcb->PathName; Fcb->ObjectName = Fcb->PathName;
DeviceExt->FATFileObject->Flags = DeviceExt->FATFileObject->Flags | FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ; 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->FsContext2 = Ccb;
DeviceExt->FATFileObject->SectionObjectPointers = &Fcb->SectionObjectPointers; DeviceExt->FATFileObject->SectionObjectPointers = &Fcb->SectionObjectPointers;
DeviceExt->FATFileObject->PrivateCacheMap = NULL; DeviceExt->FATFileObject->PrivateCacheMap = NULL;
DeviceExt->FATFileObject->Vpb = DeviceObject->Vpb; DeviceExt->FATFileObject->Vpb = DeviceObject->Vpb;
Ccb->pFcb = Fcb;
Ccb->PtrFileObject = DeviceExt->FATFileObject;
Fcb->FileObject = DeviceExt->FATFileObject; Fcb->FileObject = DeviceExt->FATFileObject;
Fcb->pDevExt = (PDEVICE_EXTENSION)DeviceExt->StorageDevice;
Fcb->Flags = FCB_IS_FAT; Fcb->Flags = FCB_IS_FAT;
@ -319,11 +316,11 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
if (DeviceExt->FatInfo.FatType != FAT12) if (DeviceExt->FatInfo.FatType != FAT12)
{ {
Status = CcRosInitializeFileCache(DeviceExt->FATFileObject, &Fcb->RFCB.Bcb, CACHEPAGESIZE(DeviceExt)); Status = CcRosInitializeFileCache(DeviceExt->FATFileObject, CACHEPAGESIZE(DeviceExt));
} }
else else
{ {
Status = CcRosInitializeFileCache(DeviceExt->FATFileObject, &Fcb->RFCB.Bcb, 2 * PAGE_SIZE); Status = CcRosInitializeFileCache(DeviceExt->FATFileObject, 2 * PAGE_SIZE);
} }
if (!NT_SUCCESS (Status)) 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.FileSize.QuadPart = DeviceExt->FatInfo.Sectors * DeviceExt->FatInfo.BytesPerSector;
VolumeFcb->RFCB.ValidDataLength = VolumeFcb->RFCB.FileSize; VolumeFcb->RFCB.ValidDataLength = VolumeFcb->RFCB.FileSize;
VolumeFcb->RFCB.AllocationSize = VolumeFcb->RFCB.FileSize; VolumeFcb->RFCB.AllocationSize = VolumeFcb->RFCB.FileSize;
VolumeFcb->pDevExt = (PDEVICE_EXTENSION)DeviceExt->StorageDevice;
DeviceExt->VolumeFcb = VolumeFcb; DeviceExt->VolumeFcb = VolumeFcb;
ExAcquireResourceExclusiveLite(&VfatGlobalData->VolumeListLock, TRUE); 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -71,15 +71,13 @@ NTSTATUS VfatLockControl(
) )
{ {
PVFATFCB Fcb; PVFATFCB Fcb;
PVFATCCB Ccb;
NTSTATUS Status; NTSTATUS Status;
DPRINT("VfatLockControl(IrpContext %x)\n", IrpContext); DPRINT("VfatLockControl(IrpContext %x)\n", IrpContext);
assert(IrpContext); assert(IrpContext);
Ccb = (PVFATCCB)IrpContext->FileObject->FsContext2; Fcb = (PVFATFCB)IrpContext->FileObject->FsContext;
Fcb = Ccb->pFcb;
if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject) if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
{ {
@ -119,8 +117,6 @@ NTSTATUS STDCALL VfatBuildRequest (
assert (DeviceObject); assert (DeviceObject);
assert (Irp); assert (Irp);
FsRtlEnterFileSystem();
IrpContext = VfatAllocateIrpContext(DeviceObject, Irp); IrpContext = VfatAllocateIrpContext(DeviceObject, Irp);
if (IrpContext == NULL) if (IrpContext == NULL)
{ {
@ -130,9 +126,20 @@ NTSTATUS STDCALL VfatBuildRequest (
} }
else else
{ {
if (KeGetCurrentIrql() <= PASSIVE_LEVEL)
{
FsRtlEnterFileSystem();
}
else
{
DPRINT1("Vfat is entered at irql = %d\n", KeGetCurrentIrql());
}
Status = VfatDispatchRequest (IrpContext); Status = VfatDispatchRequest (IrpContext);
if (KeGetCurrentIrql() <= PASSIVE_LEVEL)
{
FsRtlExitFileSystem();
}
} }
FsRtlExitFileSystem();
return Status; 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -290,7 +290,7 @@ VfatReadFileData (PVFAT_IRP_CONTEXT IrpContext, PVOID Buffer,
*LengthRead = 0; *LengthRead = 0;
Ccb = (PVFATCCB)IrpContext->FileObject->FsContext2; Ccb = (PVFATCCB)IrpContext->FileObject->FsContext2;
Fcb = Ccb->pFcb; Fcb = IrpContext->FileObject->FsContext;
BytesPerSector = DeviceExt->FatInfo.BytesPerSector; BytesPerSector = DeviceExt->FatInfo.BytesPerSector;
BytesPerCluster = DeviceExt->FatInfo.BytesPerCluster; BytesPerCluster = DeviceExt->FatInfo.BytesPerCluster;
@ -451,7 +451,7 @@ NTSTATUS VfatWriteFileData(PVFAT_IRP_CONTEXT IrpContext,
assert (IrpContext->FileObject->FsContext2 != NULL); assert (IrpContext->FileObject->FsContext2 != NULL);
Ccb = (PVFATCCB)IrpContext->FileObject->FsContext2; Ccb = (PVFATCCB)IrpContext->FileObject->FsContext2;
Fcb = Ccb->pFcb; Fcb = IrpContext->FileObject->FsContext;
BytesPerCluster = DeviceExt->FatInfo.BytesPerCluster; BytesPerCluster = DeviceExt->FatInfo.BytesPerCluster;
BytesPerSector = DeviceExt->FatInfo.BytesPerSector; BytesPerSector = DeviceExt->FatInfo.BytesPerSector;
@ -580,7 +580,6 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
{ {
NTSTATUS Status; NTSTATUS Status;
PVFATFCB Fcb; PVFATFCB Fcb;
PVFATCCB Ccb;
ULONG Length; ULONG Length;
ULONG ReturnedLength = 0; ULONG ReturnedLength = 0;
PERESOURCE Resource = NULL; PERESOURCE Resource = NULL;
@ -605,9 +604,7 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
assert(IrpContext->DeviceExt); assert(IrpContext->DeviceExt);
assert(IrpContext->FileObject); assert(IrpContext->FileObject);
Ccb = (PVFATCCB) IrpContext->FileObject->FsContext2; Fcb = IrpContext->FileObject->FsContext;
assert(Ccb);
Fcb = Ccb->pFcb;
assert(Fcb); assert(Fcb);
DPRINT("<%S>\n", Fcb->PathName); DPRINT("<%S>\n", Fcb->PathName);
@ -711,7 +708,7 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
{ {
CacheSize = PAGE_SIZE; CacheSize = PAGE_SIZE;
} }
CcRosInitializeFileCache(IrpContext->FileObject, &Fcb->RFCB.Bcb, CacheSize); CcRosInitializeFileCache(IrpContext->FileObject, CacheSize);
} }
if (!CcCopyRead(IrpContext->FileObject, &ByteOffset, Length, if (!CcCopyRead(IrpContext->FileObject, &ByteOffset, Length,
IrpContext->Flags & IRPCONTEXT_CANWAIT, Buffer, IrpContext->Flags & IRPCONTEXT_CANWAIT, Buffer,
@ -805,7 +802,6 @@ ByeBye:
NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext) NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext)
{ {
PVFATCCB Ccb;
PVFATFCB Fcb; PVFATFCB Fcb;
PERESOURCE Resource = NULL; PERESOURCE Resource = NULL;
LARGE_INTEGER ByteOffset; LARGE_INTEGER ByteOffset;
@ -832,9 +828,7 @@ NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext)
assert(IrpContext->DeviceExt); assert(IrpContext->DeviceExt);
assert(IrpContext->FileObject); assert(IrpContext->FileObject);
Ccb = (PVFATCCB) IrpContext->FileObject->FsContext2; Fcb = IrpContext->FileObject->FsContext;
assert(Ccb);
Fcb = Ccb->pFcb;
assert(Fcb); assert(Fcb);
DPRINT("<%S>\n", Fcb->PathName); DPRINT("<%S>\n", Fcb->PathName);
@ -988,7 +982,7 @@ NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext)
{ {
CacheSize = PAGE_SIZE; CacheSize = PAGE_SIZE;
} }
CcRosInitializeFileCache(IrpContext->FileObject, &Fcb->RFCB.Bcb, CacheSize); CcRosInitializeFileCache(IrpContext->FileObject, CacheSize);
} }
if (ByteOffset.QuadPart > OldFileSize.QuadPart) 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> #include <ddk/ntifs.h>
@ -181,28 +181,56 @@ extern PVFAT_GLOBAL_DATA VfatGlobalData;
typedef struct _VFATFCB typedef struct _VFATFCB
{ {
/* FCB header required by ROS/NT */
REACTOS_COMMON_FCB_HEADER RFCB; REACTOS_COMMON_FCB_HEADER RFCB;
SECTION_OBJECT_POINTERS SectionObjectPointers; SECTION_OBJECT_POINTERS SectionObjectPointers;
ERESOURCE MainResource;
ERESOURCE PagingIoResource;
/* end FCB header required by ROS/NT */
/* */
FATDirEntry entry; FATDirEntry entry;
/* point on filename (250 chars max) in PathName */ /* point on filename (250 chars max) in PathName */
WCHAR *ObjectName; WCHAR *ObjectName;
/* path+filename 260 max */ /* path+filename 260 max */
WCHAR PathName[MAX_PATH]; WCHAR PathName[MAX_PATH];
/* short file name */
WCHAR ShortName[14]; WCHAR ShortName[14];
/* */
LONG RefCount; LONG RefCount;
PDEVICE_EXTENSION pDevExt;
/* List of FCB's for this volume */
LIST_ENTRY FcbListEntry; LIST_ENTRY FcbListEntry;
/* pointer to the parent fcb */
struct _VFATFCB* parentFcb; struct _VFATFCB* parentFcb;
/* Flags for the fcb */
ULONG Flags; ULONG Flags;
/* pointer to the file object which has initialized the fcb */
PFILE_OBJECT FileObject; PFILE_OBJECT FileObject;
/* Directory index for the short name entry */
ULONG dirIndex; ULONG dirIndex;
/* Directory index where the long name starts */
ULONG startIndex; ULONG startIndex;
ERESOURCE PagingIoResource;
ERESOURCE MainResource; /* Share access for the file object */
ULONG TimerCount;
SHARE_ACCESS FCBShareAccess; SHARE_ACCESS FCBShareAccess;
/* Entry into the hash table for the path + long name */
HASHENTRY Hash; HASHENTRY Hash;
/* Entry into the hash table for the path + short name */
HASHENTRY ShortHash; HASHENTRY ShortHash;
/* List of byte-range locks for this file */
FILE_LOCK FileLock; FILE_LOCK FileLock;
/* Structure members used only for paging files. */ /* Structure members used only for paging files. */
@ -212,9 +240,6 @@ typedef struct _VFATFCB
typedef struct _VFATCCB typedef struct _VFATCCB
{ {
VFATFCB * pFcb;
LIST_ENTRY NextCCB;
PFILE_OBJECT PtrFileObject;
LARGE_INTEGER CurrentByteOffset; LARGE_INTEGER CurrentByteOffset;
/* for DirectoryControl */ /* for DirectoryControl */
ULONG Entry; ULONG Entry;

View file

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

View file

@ -1,15 +1,11 @@
#ifndef __INCLUDE_DDK_NTIFS_H #ifndef __INCLUDE_DDK_NTIFS_H
#define __INCLUDE_DDK_NTIFS_H #define __INCLUDE_DDK_NTIFS_H
struct _BCB;
NTSTATUS STDCALL NTSTATUS STDCALL
CcRosInitializeFileCache (PFILE_OBJECT FileObject, CcRosInitializeFileCache (PFILE_OBJECT FileObject,
struct _BCB** Bcb,
ULONG CacheSegmentSize); ULONG CacheSegmentSize);
NTSTATUS STDCALL NTSTATUS STDCALL
CcRosReleaseFileCache (PFILE_OBJECT FileObject, CcRosReleaseFileCache (PFILE_OBJECT FileObject);
struct _BCB* Bcb);
#include <ddk/cctypes.h> #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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -268,7 +268,7 @@ CcCopyRead (IN PFILE_OBJECT FileObject,
FileObject, (ULONG)FileOffset->QuadPart, Length, Wait, FileObject, (ULONG)FileOffset->QuadPart, Length, Wait,
Buffer, IoStatus); Buffer, IoStatus);
Bcb = ((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->Bcb; Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
ReadOffset = FileOffset->QuadPart; ReadOffset = FileOffset->QuadPart;
DPRINT("AllocationSize %d, FileSize %d\n", DPRINT("AllocationSize %d, FileSize %d\n",
@ -369,7 +369,7 @@ CcCopyWrite (IN PFILE_OBJECT FileObject,
"Length %d, Wait %d, Buffer %x)\n", "Length %d, Wait %d, Buffer %x)\n",
FileObject, (ULONG)FileOffset->QuadPart, Length, Wait, Buffer); FileObject, (ULONG)FileOffset->QuadPart, Length, Wait, Buffer);
Bcb = ((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->Bcb; Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
WriteOffset = (ULONG)FileOffset->QuadPart; WriteOffset = (ULONG)FileOffset->QuadPart;
if (!Wait) if (!Wait)
@ -472,9 +472,6 @@ CcZeroData (IN PFILE_OBJECT FileObject,
Length = EndOffset->u.LowPart - StartOffset->u.LowPart; 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) if (FileObject->SectionObjectPointers->SharedCacheMap == NULL)
{ {
/* File is not cached */ /* File is not cached */
@ -535,7 +532,7 @@ CcZeroData (IN PFILE_OBJECT FileObject,
PHYSICAL_ADDRESS page; PHYSICAL_ADDRESS page;
Start = StartOffset->u.LowPart; Start = StartOffset->u.LowPart;
Bcb = ((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->Bcb; Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
if (Wait) if (Wait)
{ {
/* testing, if the requested datas are available */ /* testing, if the requested datas are available */

View file

@ -13,6 +13,14 @@
/* GLOBALS *******************************************************************/ /* 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 *****************************************************************/ /* FUNCTIONS *****************************************************************/
/********************************************************************** /**********************************************************************
@ -73,6 +81,8 @@ CcSetFileSizes (IN PFILE_OBJECT FileObject,
PBCB Bcb; PBCB Bcb;
PLIST_ENTRY current_entry; PLIST_ENTRY current_entry;
PCACHE_SEGMENT current; PCACHE_SEGMENT current;
LIST_ENTRY FreeListHead;
NTSTATUS Status;
DPRINT("CcSetFileSizes(FileObject %x, FileSizes %x)\n", DPRINT("CcSetFileSizes(FileObject %x, FileSizes %x)\n",
FileObject, FileSizes); FileObject, FileSizes);
@ -81,31 +91,66 @@ CcSetFileSizes (IN PFILE_OBJECT FileObject,
(ULONG)FileSizes->FileSize.QuadPart, (ULONG)FileSizes->FileSize.QuadPart,
(ULONG)FileSizes->ValidDataLength.QuadPart); (ULONG)FileSizes->ValidDataLength.QuadPart);
Bcb = ((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->Bcb; Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
assert(Bcb);
DPRINT("Bcb 0x%.08x\n", Bcb);
KeAcquireSpinLock(&Bcb->BcbLock, &oldirql);
if (FileSizes->AllocationSize.QuadPart < Bcb->AllocationSize.QuadPart) if (FileSizes->AllocationSize.QuadPart < Bcb->AllocationSize.QuadPart)
{ {
current_entry = Bcb->BcbSegmentListHead.Flink; InitializeListHead(&FreeListHead);
while (current_entry != &Bcb->BcbSegmentListHead) ExAcquireFastMutex(&ViewLock);
{ KeAcquireSpinLock(&Bcb->BcbLock, &oldirql);
current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT,
BcbSegmentListEntry); current_entry = Bcb->BcbSegmentListHead.Flink;
current_entry = current_entry->Flink; while (current_entry != &Bcb->BcbSegmentListHead)
if (current->FileOffset > FileSizes->AllocationSize.QuadPart) {
{ current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, BcbSegmentListEntry);
KeReleaseSpinLock(&Bcb->BcbLock, oldirql); current_entry = current_entry->Flink;
CcRosFreeCacheSegment(Bcb, current); if (current->FileOffset > FileSizes->AllocationSize.QuadPart)
KeAcquireSpinLock(&Bcb->BcbLock, &oldirql); {
current_entry = Bcb->BcbSegmentListHead.Flink; if (current->ReferenceCount == 0 || (current->ReferenceCount == 1 && current->Dirty))
} {
} RemoveEntryList(&current->BcbSegmentListEntry);
} RemoveEntryList(&current->CacheSegmentListEntry);
Bcb->AllocationSize = FileSizes->AllocationSize; RemoveEntryList(&current->CacheSegmentLRUListEntry);
Bcb->FileSize = FileSizes->FileSize; if (current->Dirty)
KeReleaseSpinLock(&Bcb->BcbLock, oldirql); {
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);
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);
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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -51,7 +51,7 @@ CcMapData (IN PFILE_OBJECT FileObject,
Length, Wait, pBcb, pBuffer); Length, Wait, pBcb, pBuffer);
ReadOffset = FileOffset->QuadPart; ReadOffset = FileOffset->QuadPart;
Bcb = ((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->Bcb; Bcb = FileObject->SectionObjectPointers->SharedCacheMap;
assert(Bcb); assert(Bcb);
DPRINT("AllocationSize %d, FileSize %d\n", DPRINT("AllocationSize %d, FileSize %d\n",

View file

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

View file

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