[fastfat_new]

- Create root DCB when mounting a volume.

svn path=/trunk/; revision=43207
This commit is contained in:
Aleksey Bragin 2009-09-28 18:04:31 +00:00
parent 79fe13f7e8
commit c1d76231a4
4 changed files with 139 additions and 6 deletions

View file

@ -21,4 +21,107 @@ FatDirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
return STATUS_NOT_IMPLEMENTED;
}
VOID
NTAPI
FatCreateRootDcb(IN PFAT_IRP_CONTEXT IrpContext,
IN PVCB Vcb)
{
PFCB Dcb;
/* Make sure it's not already created */
ASSERT(!Vcb->RootDcb);
/* Allocate the DCB */
Dcb = FsRtlAllocatePoolWithTag(NonPagedPool,
sizeof(FCB),
TAG_FCB);
/* Zero it */
RtlZeroMemory(Dcb, sizeof(FCB));
/* Assign it to the VCB */
Vcb->RootDcb = Dcb;
/* Set its header */
Dcb->Header.NodeTypeCode = FAT_NTC_ROOT_DCB;
Dcb->Header.NodeByteSize = sizeof(FCB);
/* FCB is in a good condition */
Dcb->Condition = FcbGood;
/* Initialize FCB's resource */
Dcb->Header.Resource = &Dcb->Resource;
ExInitializeResourceLite(&Dcb->Resource);
/* Initialize Paging Io resource*/
Dcb->Header.PagingIoResource = &Dcb->PagingIoResource;
ExInitializeResourceLite(&Dcb->PagingIoResource);
/* Initialize a list of parent DCBs*/
InitializeListHead(&Dcb->ParentDcbLinks);
/* Set VCB */
Dcb->Vcb = Vcb;
/* Initialize parent's DCB list */
InitializeListHead(&Dcb->Dcb.ParentDcbList);
/* Initialize the full file name */
Dcb->FullFileName.Buffer = L"\\";
Dcb->FullFileName.Length = 1 * sizeof(WCHAR);
Dcb->FullFileName.MaximumLength = 2 * sizeof(WCHAR);
Dcb->FileName.Name.Ansi.Buffer = "\\";
Dcb->FileName.Name.Ansi.Length = 1;
Dcb->FileName.Name.Ansi.MaximumLength = 2 * sizeof(CHAR);
/* Fill dirent attribute byte copy */
Dcb->DirentFatFlags = FILE_ATTRIBUTE_DIRECTORY;
/* Initialize advanced FCB header fields */
ExInitializeFastMutex(&Dcb->HeaderMutex);
FsRtlSetupAdvancedHeader(&Dcb->Header, &Dcb->HeaderMutex);
/* Initialize MCB */
FsRtlInitializeLargeMcb(&Dcb->Mcb, NonPagedPool);
/* Set up first cluster field depending on FAT type */
if (TRUE/*FatIsFat32(Vcb)*/)
{
/* First cluster is really the first cluster of this volume */
Dcb->FirstClusterOfFile = Vcb->Bpb.RootDirFirstCluster;
/* Calculate size of FAT32 root dir */
Dcb->Header.AllocationSize.LowPart = 0xFFFFFFFF;
//FatLookupFileAllocationSize(IrpContext, Dcb);
DPRINT1("Calculation of a size of a root dir is missing!\n");
Dcb->Header.FileSize.QuadPart = Dcb->Header.AllocationSize.QuadPart;
}
else
{
#if 0
/* Add MCB entry */
FatAddMcbEntry(Vcb,
&Dcb->Mcb,
0,
FatRootDirectoryLbo(&Vcb->Bpb),
FatRootDirectorySize(&Vcb->Bpb));
/* Set a real size of the root directory */
Dcb->Header.FileSize.QuadPart = FatRootDirectorySize(&Vcb->Bpb);
Dcb->Header.AllocationSize.QuadPart = Dcb->Header.FileSize.QuadPart;
#endif
UNIMPLEMENTED;
}
/* Initialize free dirent bitmap */
RtlInitializeBitMap(&Dcb->Dcb.FreeBitmap, NULL, 0);
/* Fill the dirent bitmap */
DPRINT1("Filling the free dirent bitmap is missing\n");
//FatCheckFreeDirentBitmap( IrpContext, Dcb );
}
/* EOF */

View file

@ -72,6 +72,10 @@ FatMapUserBuffer(
NTSTATUS NTAPI
FatDirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
VOID NTAPI
FatCreateRootDcb(IN PFAT_IRP_CONTEXT IrpContext,
IN PVCB Vcb);
/* -------------------------------------------------------- create.c */
NTSTATUS NTAPI

View file

@ -215,10 +215,21 @@ enum _FCB_NAME_TYPE {
typedef struct _FCB_NAME_LINK {
RTL_SPLAY_LINKS Links;
UNICODE_STRING String;
union
{
OEM_STRING Ansi;
UNICODE_STRING String;
} Name;
UCHAR Type;
} FCB_NAME_LINK, *PFCB_NAME_LINK;
typedef enum _FCB_CONDITION
{
FcbGood,
FcbBad,
FcbNeedsToBeVerified
} FCB_CONDITION;
typedef struct _FCB
{
FSRTL_ADVANCED_FCB_HEADER Header;
@ -228,35 +239,47 @@ typedef struct _FCB
* FCB into paged and non paged parts
* (as it is done in MS implementation
*/
FAST_MUTEX HeaderMutex;
FAST_MUTEX HeaderMutex; // nonpaged!
SECTION_OBJECT_POINTERS SectionObjectPointers;
ERESOURCE Resource;
ERESOURCE PagingIoResource;
ERESOURCE Resource; // nonpaged!
ERESOURCE PagingIoResource; // nonpaged!
FILE_LOCK Lock;
/* First cluster in the fat allocation chain */
ULONG FirstClusterOfFile;
/* A list of all FCBs of that DCB */
LIST_ENTRY ParentDcbLinks;
/* Reference to the Parent Dcb*/
struct _FCB *ParentFcb;
/* Pointer to a Vcb */
PVCB Vcb;
/* Fcb state */
ULONG State;
/* Fcb condition */
FCB_CONDITION Condition;
/* Mcb mapping Vbo->Lbo */
LARGE_MCB Mcb;
ULONG FirstCluster;
/* Links into FCB Trie */
FCB_NAME_LINK FileName[0x2];
FCB_NAME_LINK FileName;
/* Buffer for the short name */
WCHAR ShortNameBuffer[0xc];
/* Full file name */
UNICODE_STRING FullFileName;
/* A copy of fat attribute byte */
UCHAR DirentFatFlags;
/* File basic info */
FILE_BASIC_INFORMATION BasicInfo;
union
{
struct
{
/* A list of all FCBs/DCBs opened under this DCB */
LIST_ENTRY ParentDcbList;
/* Directory data stream (just handy to have it). */
PFILE_OBJECT StreamFileObject;
/* Bitmap to search for free dirents. */
/* RTL_BITMAP Bitmap; */
RTL_BITMAP FreeBitmap;
PRTL_SPLAY_LINKS SplayLinks;
} Dcb;
};

View file

@ -124,6 +124,9 @@ FatMountVolume(PFAT_IRP_CONTEXT IrpContext,
Status = FatInitializeVcb(IrpContext, &VolumeDevice->Vcb, TargetDeviceObject, Vpb);
if (!NT_SUCCESS(Status)) goto FatMountVolumeCleanup;
/* Create root DCB for it */
FatCreateRootDcb(IrpContext, &VolumeDevice->Vcb);
/* Keep trace of media changes */
VolumeDevice->Vcb.MediaChangeCount = MediaChangeCount;