mirror of
https://github.com/reactos/reactos.git
synced 2024-07-31 00:28:56 +00:00
[fastfat_new]
- Create root DCB when mounting a volume. svn path=/trunk/; revision=43207
This commit is contained in:
parent
79fe13f7e8
commit
c1d76231a4
|
@ -21,4 +21,107 @@ FatDirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
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 */
|
/* EOF */
|
||||||
|
|
|
@ -72,6 +72,10 @@ FatMapUserBuffer(
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
FatDirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
FatDirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||||
|
|
||||||
|
VOID NTAPI
|
||||||
|
FatCreateRootDcb(IN PFAT_IRP_CONTEXT IrpContext,
|
||||||
|
IN PVCB Vcb);
|
||||||
|
|
||||||
/* -------------------------------------------------------- create.c */
|
/* -------------------------------------------------------- create.c */
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
|
|
|
@ -215,10 +215,21 @@ enum _FCB_NAME_TYPE {
|
||||||
|
|
||||||
typedef struct _FCB_NAME_LINK {
|
typedef struct _FCB_NAME_LINK {
|
||||||
RTL_SPLAY_LINKS Links;
|
RTL_SPLAY_LINKS Links;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
OEM_STRING Ansi;
|
||||||
UNICODE_STRING String;
|
UNICODE_STRING String;
|
||||||
|
} Name;
|
||||||
UCHAR Type;
|
UCHAR Type;
|
||||||
} FCB_NAME_LINK, *PFCB_NAME_LINK;
|
} FCB_NAME_LINK, *PFCB_NAME_LINK;
|
||||||
|
|
||||||
|
typedef enum _FCB_CONDITION
|
||||||
|
{
|
||||||
|
FcbGood,
|
||||||
|
FcbBad,
|
||||||
|
FcbNeedsToBeVerified
|
||||||
|
} FCB_CONDITION;
|
||||||
|
|
||||||
typedef struct _FCB
|
typedef struct _FCB
|
||||||
{
|
{
|
||||||
FSRTL_ADVANCED_FCB_HEADER Header;
|
FSRTL_ADVANCED_FCB_HEADER Header;
|
||||||
|
@ -228,35 +239,47 @@ typedef struct _FCB
|
||||||
* FCB into paged and non paged parts
|
* FCB into paged and non paged parts
|
||||||
* (as it is done in MS implementation
|
* (as it is done in MS implementation
|
||||||
*/
|
*/
|
||||||
FAST_MUTEX HeaderMutex;
|
FAST_MUTEX HeaderMutex; // nonpaged!
|
||||||
SECTION_OBJECT_POINTERS SectionObjectPointers;
|
SECTION_OBJECT_POINTERS SectionObjectPointers;
|
||||||
ERESOURCE Resource;
|
ERESOURCE Resource; // nonpaged!
|
||||||
ERESOURCE PagingIoResource;
|
ERESOURCE PagingIoResource; // nonpaged!
|
||||||
|
|
||||||
FILE_LOCK Lock;
|
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*/
|
/* Reference to the Parent Dcb*/
|
||||||
struct _FCB *ParentFcb;
|
struct _FCB *ParentFcb;
|
||||||
/* Pointer to a Vcb */
|
/* Pointer to a Vcb */
|
||||||
PVCB Vcb;
|
PVCB Vcb;
|
||||||
|
/* Fcb state */
|
||||||
|
ULONG State;
|
||||||
|
/* Fcb condition */
|
||||||
|
FCB_CONDITION Condition;
|
||||||
/* Mcb mapping Vbo->Lbo */
|
/* Mcb mapping Vbo->Lbo */
|
||||||
LARGE_MCB Mcb;
|
LARGE_MCB Mcb;
|
||||||
ULONG FirstCluster;
|
ULONG FirstCluster;
|
||||||
/* Links into FCB Trie */
|
/* Links into FCB Trie */
|
||||||
FCB_NAME_LINK FileName[0x2];
|
FCB_NAME_LINK FileName;
|
||||||
/* Buffer for the short name */
|
/* Buffer for the short name */
|
||||||
WCHAR ShortNameBuffer[0xc];
|
WCHAR ShortNameBuffer[0xc];
|
||||||
/* Full file name */
|
/* Full file name */
|
||||||
UNICODE_STRING FullFileName;
|
UNICODE_STRING FullFileName;
|
||||||
|
/* A copy of fat attribute byte */
|
||||||
|
UCHAR DirentFatFlags;
|
||||||
/* File basic info */
|
/* File basic info */
|
||||||
FILE_BASIC_INFORMATION BasicInfo;
|
FILE_BASIC_INFORMATION BasicInfo;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
/* A list of all FCBs/DCBs opened under this DCB */
|
||||||
|
LIST_ENTRY ParentDcbList;
|
||||||
/* Directory data stream (just handy to have it). */
|
/* Directory data stream (just handy to have it). */
|
||||||
PFILE_OBJECT StreamFileObject;
|
PFILE_OBJECT StreamFileObject;
|
||||||
/* Bitmap to search for free dirents. */
|
/* Bitmap to search for free dirents. */
|
||||||
/* RTL_BITMAP Bitmap; */
|
RTL_BITMAP FreeBitmap;
|
||||||
PRTL_SPLAY_LINKS SplayLinks;
|
PRTL_SPLAY_LINKS SplayLinks;
|
||||||
} Dcb;
|
} Dcb;
|
||||||
};
|
};
|
||||||
|
|
|
@ -124,6 +124,9 @@ FatMountVolume(PFAT_IRP_CONTEXT IrpContext,
|
||||||
Status = FatInitializeVcb(IrpContext, &VolumeDevice->Vcb, TargetDeviceObject, Vpb);
|
Status = FatInitializeVcb(IrpContext, &VolumeDevice->Vcb, TargetDeviceObject, Vpb);
|
||||||
if (!NT_SUCCESS(Status)) goto FatMountVolumeCleanup;
|
if (!NT_SUCCESS(Status)) goto FatMountVolumeCleanup;
|
||||||
|
|
||||||
|
/* Create root DCB for it */
|
||||||
|
FatCreateRootDcb(IrpContext, &VolumeDevice->Vcb);
|
||||||
|
|
||||||
/* Keep trace of media changes */
|
/* Keep trace of media changes */
|
||||||
VolumeDevice->Vcb.MediaChangeCount = MediaChangeCount;
|
VolumeDevice->Vcb.MediaChangeCount = MediaChangeCount;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue