Author: fireball Date: Mon Sep 28 20:04:31 2009 New Revision: 43207
URL: http://svn.reactos.org/svn/reactos?rev=43207&view=rev Log: [fastfat_new] - Create root DCB when mounting a volume.
Modified: trunk/reactos/drivers/filesystems/fastfat_new/dir.c trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h trunk/reactos/drivers/filesystems/fastfat_new/fatstruc.h trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c
Modified: trunk/reactos/drivers/filesystems/fastfat_new/dir.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat... ============================================================================== --- trunk/reactos/drivers/filesystems/fastfat_new/dir.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/fastfat_new/dir.c [iso-8859-1] Mon Sep 28 20:04:31 2009 @@ -21,4 +21,107 @@ 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 */
Modified: trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat... ============================================================================== --- trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h [iso-8859-1] Mon Sep 28 20:04:31 2009 @@ -71,6 +71,10 @@
NTSTATUS NTAPI FatDirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp); + +VOID NTAPI +FatCreateRootDcb(IN PFAT_IRP_CONTEXT IrpContext, + IN PVCB Vcb);
/* -------------------------------------------------------- create.c */
Modified: trunk/reactos/drivers/filesystems/fastfat_new/fatstruc.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat... ============================================================================== --- trunk/reactos/drivers/filesystems/fastfat_new/fatstruc.h [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/fastfat_new/fatstruc.h [iso-8859-1] Mon Sep 28 20:04:31 2009 @@ -215,9 +215,20 @@
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 { @@ -228,35 +239,47 @@ * 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; };
Modified: trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat... ============================================================================== --- trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c [iso-8859-1] Mon Sep 28 20:04:31 2009 @@ -124,6 +124,9 @@ 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;