mirror of
https://github.com/reactos/reactos.git
synced 2024-08-01 00:58:16 +00:00
[fastfat_new]
- Start integrating FullFAT library. - Current state is that it's able to mount a FAT volume. svn path=/trunk/; revision=43222
This commit is contained in:
parent
f1ee7979a1
commit
5f9e1cd8f9
|
@ -3,6 +3,8 @@
|
|||
#include <debug.h>
|
||||
#include <pseh/pseh2.h>
|
||||
|
||||
#include "fullfat.h"
|
||||
|
||||
#include <fat.h>
|
||||
#include <fatstruc.h>
|
||||
|
||||
|
@ -151,6 +153,14 @@ FatDecodeFileObject(IN PFILE_OBJECT FileObject,
|
|||
OUT PFCB *FcbOrDcb,
|
||||
OUT PCCB *Ccb);
|
||||
|
||||
/* --------------------------------------------------------- fullfat.c */
|
||||
|
||||
FF_T_SINT32
|
||||
FatWriteBlocks(FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam);
|
||||
|
||||
FF_T_SINT32
|
||||
FatReadBlocks(FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam);
|
||||
|
||||
/* --------------------------------------------------------- lock.c */
|
||||
|
||||
NTSTATUS NTAPI
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
<module name="fastfatn" type="kernelmodedriver" installbase="system32/drivers" installname="fastfatn.sys">
|
||||
<bootstrap installbase="$(CDOUTPUT)" />
|
||||
<include base="fastfatn">.</include>
|
||||
<include base="ReactOS">include/reactos/libs/fullfat</include>
|
||||
<library>ntoskrnl</library>
|
||||
<library>hal</library>
|
||||
<library>pseh</library>
|
||||
<library>fullfat</library>
|
||||
<file>blockdev.c</file>
|
||||
<file>cleanup.c</file>
|
||||
<file>close.c</file>
|
||||
|
@ -21,6 +23,7 @@
|
|||
<file>finfo.c</file>
|
||||
<file>flush.c</file>
|
||||
<file>fsctl.c</file>
|
||||
<file>fullfat.c</file>
|
||||
<file>lock.c</file>
|
||||
<file>rw.c</file>
|
||||
<file>shutdown.c</file>
|
||||
|
|
|
@ -35,6 +35,10 @@ typedef struct _FAT_GLOBAL_DATA
|
|||
BOOLEAN Win31FileSystem;
|
||||
/* Jan 1, 1980 System Time */
|
||||
LARGE_INTEGER DefaultFileTime;
|
||||
|
||||
/* FullFAT integration */
|
||||
FF_IOMAN *Ioman;
|
||||
FF_ERROR FF_Error;
|
||||
} FAT_GLOBAL_DATA;
|
||||
|
||||
typedef struct _FAT_PAGE_CONTEXT
|
||||
|
@ -175,6 +179,9 @@ typedef struct _VCB
|
|||
struct _FCB *RootDcb;
|
||||
|
||||
ULONG MediaChangeCount;
|
||||
|
||||
/* FullFAT integration */
|
||||
FF_IOMAN *Ioman;
|
||||
} VCB, *PVCB;
|
||||
|
||||
#define VcbToVolumeDeviceObject(xVcb) \
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "fastfat.h"
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Locates FCB by the supplied name in the cache trie of fcbs.
|
||||
*
|
||||
|
@ -325,4 +325,5 @@ FatOpenFcb(
|
|||
&Context.ShortName, &LongFileName);
|
||||
return Status;
|
||||
}
|
||||
#endif
|
||||
/* EOF */
|
||||
|
|
|
@ -58,6 +58,8 @@ FatMountVolume(PFAT_IRP_CONTEXT IrpContext,
|
|||
DISK_GEOMETRY DiskGeometry;
|
||||
ULONG MediaChangeCount = 0;
|
||||
PVOLUME_DEVICE_OBJECT VolumeDevice;
|
||||
VCB *Vcb;
|
||||
FF_ERROR Error;
|
||||
|
||||
DPRINT1("FatMountVolume()\n");
|
||||
|
||||
|
@ -81,6 +83,9 @@ FatMountVolume(PFAT_IRP_CONTEXT IrpContext,
|
|||
/* Remove unmounted VCBs */
|
||||
FatiCleanVcbs(IrpContext);
|
||||
|
||||
/* Acquire the global exclusive lock */
|
||||
FatAcquireExclusiveGlobal(IrpContext);
|
||||
|
||||
/* Create a new volume device object */
|
||||
Status = IoCreateDevice(FatGlobalData.DriverObject,
|
||||
sizeof(VOLUME_DEVICE_OBJECT) - sizeof(DEVICE_OBJECT),
|
||||
|
@ -90,7 +95,13 @@ FatMountVolume(PFAT_IRP_CONTEXT IrpContext,
|
|||
FALSE,
|
||||
(PDEVICE_OBJECT *)&VolumeDevice);
|
||||
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Release the global lock */
|
||||
FatReleaseGlobal(IrpContext);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Match alignment requirements */
|
||||
if (TargetDeviceObject->AlignmentRequirement > VolumeDevice->DeviceObject.AlignmentRequirement)
|
||||
|
@ -124,14 +135,53 @@ FatMountVolume(PFAT_IRP_CONTEXT IrpContext,
|
|||
Status = FatInitializeVcb(IrpContext, &VolumeDevice->Vcb, TargetDeviceObject, Vpb);
|
||||
if (!NT_SUCCESS(Status)) goto FatMountVolumeCleanup;
|
||||
|
||||
Vcb = &VolumeDevice->Vcb;
|
||||
|
||||
/* Initialize FullFAT library */
|
||||
Vcb->Ioman = FF_CreateIOMAN(NULL,
|
||||
8192,
|
||||
VolumeDevice->DeviceObject.SectorSize,
|
||||
&Error);
|
||||
|
||||
ASSERT(Vcb->Ioman);
|
||||
|
||||
/* Register block device read/write functions */
|
||||
Error = FF_RegisterBlkDevice(Vcb->Ioman,
|
||||
VolumeDevice->DeviceObject.SectorSize,
|
||||
(FF_WRITE_BLOCKS)FatWriteBlocks,
|
||||
(FF_READ_BLOCKS)FatReadBlocks,
|
||||
Vcb);
|
||||
|
||||
if (Error)
|
||||
{
|
||||
DPRINT1("Registering block device with FullFAT failed with error %d\n", Error);
|
||||
FF_DestroyIOMAN(Vcb->Ioman);
|
||||
goto FatMountVolumeCleanup;
|
||||
}
|
||||
|
||||
/* Mount the volume using FullFAT */
|
||||
if(FF_MountPartition(Vcb->Ioman, 0))
|
||||
{
|
||||
DPRINT1("Partition mounting failed\n");
|
||||
FF_DestroyIOMAN(Vcb->Ioman);
|
||||
goto FatMountVolumeCleanup;
|
||||
}
|
||||
|
||||
// TODO: Read BPB and store it in Vcb->Bpb
|
||||
|
||||
/* Create root DCB for it */
|
||||
FatCreateRootDcb(IrpContext, &VolumeDevice->Vcb);
|
||||
|
||||
/* Keep trace of media changes */
|
||||
VolumeDevice->Vcb.MediaChangeCount = MediaChangeCount;
|
||||
|
||||
//ObDereferenceObject(TargetDeviceObject);
|
||||
|
||||
/* Release the global lock */
|
||||
FatReleaseGlobal(IrpContext);
|
||||
|
||||
/* Notify about volume mount */
|
||||
FsRtlNotifyVolumeEvent(VolumeDevice->Vcb.StreamFileObject, FSRTL_VOLUME_MOUNT);
|
||||
//FsRtlNotifyVolumeEvent(VolumeDevice->Vcb.StreamFileObject, FSRTL_VOLUME_MOUNT);
|
||||
|
||||
/* Return success */
|
||||
return STATUS_SUCCESS;
|
||||
|
@ -141,6 +191,10 @@ FatMountVolumeCleanup:
|
|||
|
||||
/* Unwind the routine actions */
|
||||
IoDeleteDevice((PDEVICE_OBJECT)VolumeDevice);
|
||||
|
||||
/* Release the global lock */
|
||||
FatReleaseGlobal(IrpContext);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
|
75
reactos/drivers/filesystems/fastfat_new/fullfat.c
Normal file
75
reactos/drivers/filesystems/fastfat_new/fullfat.c
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* PROJECT: ReactOS FAT file system driver
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: drivers/filesystems/fastfat/fullfat.c
|
||||
* PURPOSE: FullFAT integration routines
|
||||
* PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#define NDEBUG
|
||||
#include "fastfat.h"
|
||||
|
||||
/* GLOBALS ******************************************************************/
|
||||
|
||||
#define TAG_FULLFAT 'FLUF'
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
VOID *
|
||||
FF_Malloc(FF_T_UINT32 allocSize)
|
||||
{
|
||||
return ExAllocatePoolWithTag(PagedPool, allocSize, TAG_FULLFAT);
|
||||
}
|
||||
|
||||
VOID
|
||||
FF_Free(VOID *pBuffer)
|
||||
{
|
||||
return ExFreePoolWithTag(pBuffer, TAG_FULLFAT);
|
||||
}
|
||||
|
||||
FF_T_SINT32
|
||||
FatWriteBlocks(FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam)
|
||||
{
|
||||
DPRINT1("FatWriteBlocks %p %d %d %p\n", pBuffer, SectorAddress, Count, pParam);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
FF_T_SINT32
|
||||
FatReadBlocks(FF_T_UINT8 *DestBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam)
|
||||
{
|
||||
LARGE_INTEGER Offset;
|
||||
PVOID Buffer;
|
||||
PVCB Vcb = (PVCB)pParam;
|
||||
PBCB Bcb;
|
||||
ULONG SectorSize = 512; // FIXME: hardcoding 512 is bad
|
||||
|
||||
DPRINT1("FatReadBlocks %p %d %d %p\n", DestBuffer, SectorAddress, Count, pParam);
|
||||
|
||||
/* Calculate the offset */
|
||||
Offset.QuadPart = Int32x32To64(SectorAddress, SectorSize);
|
||||
|
||||
if (!CcMapData(Vcb->StreamFileObject,
|
||||
&Offset,
|
||||
Count * SectorSize,
|
||||
TRUE,
|
||||
&Bcb,
|
||||
&Buffer))
|
||||
{
|
||||
/* Mapping failed */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy data to the buffer */
|
||||
RtlCopyMemory(DestBuffer, Buffer, Count * SectorSize);
|
||||
|
||||
/* Unpin unneeded data */
|
||||
CcUnpinData(Bcb);
|
||||
|
||||
/* Return amount of read data in sectors */
|
||||
return Count;
|
||||
}
|
||||
|
||||
/* EOF */
|
Loading…
Reference in a new issue