mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Changed the initialization for the fat cache in VfatMount().
svn path=/trunk/; revision=2289
This commit is contained in:
parent
12f5d25024
commit
20625a2073
1 changed files with 61 additions and 29 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: iface.c,v 1.57 2001/07/20 08:00:20 ekohl Exp $
|
/* $Id: iface.c,v 1.58 2001/10/10 22:18:58 hbirr Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -8,14 +8,14 @@
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* ?? Created
|
* ?? Created
|
||||||
* 24-10-1998 Fixed bugs in long filename support
|
* 24-10-1998 Fixed bugs in long filename support
|
||||||
* Fixed a bug that prevented unsuccessful file open requests
|
* Fixed a bug that prevented unsuccessful file open requests
|
||||||
* being reported
|
* being reported
|
||||||
* Now works with long filenames that span over a sector
|
* Now works with long filenames that span over a sector
|
||||||
* boundary
|
* boundary
|
||||||
* 28-10-1998 Reads entire FAT into memory
|
* 28-10-1998 Reads entire FAT into memory
|
||||||
* VFatReadSector modified to read in more than one sector at a
|
* VFatReadSector modified to read in more than one sector at a
|
||||||
* time
|
* time
|
||||||
* 7-11-1998 Fixed bug that assumed that directory data could be
|
* 7-11-1998 Fixed bug that assumed that directory data could be
|
||||||
* fragmented
|
* fragmented
|
||||||
* 8-12-1998 Added FAT32 support
|
* 8-12-1998 Added FAT32 support
|
||||||
* Added initial writability functions
|
* Added initial writability functions
|
||||||
|
@ -46,7 +46,7 @@ static NTSTATUS
|
||||||
VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
|
VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
|
||||||
PBOOLEAN RecognizedFS)
|
PBOOLEAN RecognizedFS)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Tests if the device contains a filesystem that can be mounted
|
* FUNCTION: Tests if the device contains a filesystem that can be mounted
|
||||||
* by this fsd
|
* by this fsd
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
@ -162,6 +162,8 @@ VfatMount (PDEVICE_OBJECT DeviceToMount)
|
||||||
PDEVICE_EXTENSION DeviceExt;
|
PDEVICE_EXTENSION DeviceExt;
|
||||||
BOOLEAN RecognizedFS;
|
BOOLEAN RecognizedFS;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
PVFATFCB Fcb;
|
||||||
|
PVFATCCB Ccb;
|
||||||
|
|
||||||
Status = VfatHasFileSystem (DeviceToMount, &RecognizedFS);
|
Status = VfatHasFileSystem (DeviceToMount, &RecognizedFS);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -227,34 +229,65 @@ VfatMount (PDEVICE_OBJECT DeviceToMount)
|
||||||
((struct _BootSector32*)(DeviceExt->Boot))->BootBackup);
|
((struct _BootSector32*)(DeviceExt->Boot))->BootBackup);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DeviceObject->Vpb->Flags |= VPB_MOUNTED;
|
DeviceObject->Vpb->Flags |= VPB_MOUNTED;
|
||||||
DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(DeviceObject,
|
DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(DeviceObject,
|
||||||
DeviceToMount);
|
DeviceToMount);
|
||||||
DeviceExt->StreamStorageDevice = IoCreateStreamFileObject(NULL,
|
|
||||||
DeviceExt->StorageDevice);
|
|
||||||
Status = CcRosInitializeFileCache(DeviceExt->StreamStorageDevice,
|
|
||||||
&DeviceExt->StorageBcb,
|
|
||||||
CACHEPAGESIZE(DeviceExt));
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
/* FIXME: delete device object */
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DeviceExt->FatType == FAT12)
|
DeviceExt->FATFileObject = IoCreateStreamFileObject(NULL, DeviceExt->StorageDevice);
|
||||||
|
Fcb = vfatNewFCB(NULL);
|
||||||
|
if (Fcb == NULL)
|
||||||
|
{
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
}
|
||||||
|
Ccb = ExAllocatePoolWithTag (NonPagedPool, sizeof (VFATCCB), TAG_CCB);
|
||||||
|
if (Ccb == NULL)
|
||||||
|
{
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
}
|
||||||
|
memset(Ccb, 0, sizeof (VFATCCB));
|
||||||
|
DeviceExt->FATFileObject->Flags = DeviceExt->FATFileObject->Flags | FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
|
||||||
|
DeviceExt->FATFileObject->FsContext = (PVOID) &Fcb->RFCB;
|
||||||
|
DeviceExt->FATFileObject->FsContext2 = Ccb;
|
||||||
|
Ccb->pFcb = Fcb;
|
||||||
|
Ccb->PtrFileObject = DeviceExt->FATFileObject;
|
||||||
|
Fcb->FileObject = DeviceExt->FATFileObject;
|
||||||
|
Fcb->pDevExt = (PDEVICE_EXTENSION)DeviceExt->StorageDevice;
|
||||||
|
|
||||||
|
Fcb->Flags = FCB_IS_FAT;
|
||||||
|
|
||||||
|
if (DeviceExt->FatType == FAT32)
|
||||||
|
{
|
||||||
|
Fcb->RFCB.FileSize.QuadPart = ((struct _BootSector32 *)DeviceExt->Boot)->FATSectors32 * BLOCKSIZE;
|
||||||
|
Fcb->RFCB.ValidDataLength.QuadPart = ((struct _BootSector32 *)DeviceExt->Boot)->FATSectors32 * BLOCKSIZE;
|
||||||
|
Fcb->RFCB.AllocationSize.QuadPart = ROUND_UP(((struct _BootSector32 *)DeviceExt->Boot)->FATSectors32 * BLOCKSIZE, CACHEPAGESIZE(DeviceExt));
|
||||||
|
Status = CcRosInitializeFileCache(DeviceExt->FATFileObject, &Fcb->RFCB.Bcb, CACHEPAGESIZE(DeviceExt));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (DeviceExt->FatType == FAT16)
|
||||||
{
|
{
|
||||||
DeviceExt->Fat12StorageDevice =
|
Fcb->RFCB.FileSize.QuadPart = DeviceExt->Boot->FATSectors * BLOCKSIZE;
|
||||||
IoCreateStreamFileObject(NULL, DeviceExt->StorageDevice);
|
Fcb->RFCB.ValidDataLength.QuadPart = DeviceExt->Boot->FATSectors * BLOCKSIZE;
|
||||||
Status = CcRosInitializeFileCache(DeviceExt->Fat12StorageDevice,
|
Fcb->RFCB.AllocationSize.QuadPart = ROUND_UP(DeviceExt->Boot->FATSectors * BLOCKSIZE, CACHEPAGESIZE(DeviceExt));
|
||||||
&DeviceExt->Fat12StorageBcb,
|
Status = CcRosInitializeFileCache(DeviceExt->FATFileObject, &Fcb->RFCB.Bcb, CACHEPAGESIZE(DeviceExt));
|
||||||
PAGESIZE * 3);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
/* FIXME: delete device object */
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Fcb->RFCB.FileSize.QuadPart = DeviceExt->Boot->FATSectors * BLOCKSIZE;
|
||||||
|
Fcb->RFCB.ValidDataLength.QuadPart = DeviceExt->Boot->FATSectors * BLOCKSIZE;
|
||||||
|
Fcb->RFCB.AllocationSize.QuadPart = 2 * PAGESIZE;
|
||||||
|
Status = CcRosInitializeFileCache(DeviceExt->FATFileObject, &Fcb->RFCB.Bcb, 2 * PAGESIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!NT_SUCCESS (Status))
|
||||||
|
{
|
||||||
|
DbgPrint ("CcRosInitializeFileCache failed\n");
|
||||||
|
// KeBugCheck (0);
|
||||||
|
// FIXME: delete device object
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ExInitializeResourceLite(&DeviceExt->DirResource);
|
ExInitializeResourceLite(&DeviceExt->DirResource);
|
||||||
ExInitializeResourceLite(&DeviceExt->FatResource);
|
ExInitializeResourceLite(&DeviceExt->FatResource);
|
||||||
|
|
||||||
|
@ -270,8 +303,7 @@ VfatMount (PDEVICE_OBJECT DeviceToMount)
|
||||||
((struct _BootSector32 *) (DeviceExt->Boot))->VolumeID;
|
((struct _BootSector32 *) (DeviceExt->Boot))->VolumeID;
|
||||||
|
|
||||||
/* read volume label */
|
/* read volume label */
|
||||||
ReadVolumeLabel(DeviceExt,
|
ReadVolumeLabel(DeviceExt, DeviceObject->Vpb);
|
||||||
DeviceObject->Vpb);
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue