2 * PROJECT: ReactOS FAT file system driver
3 * LICENSE: GNU GPLv3 as published by the Free Software Foundation
4 * FILE: drivers/filesystems/fastfat/dir.c
5 * PURPOSE: Directory Control
6 * PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
9 /* INCLUDES *****************************************************************/
14 /* FUNCTIONS *****************************************************************/
18 FatDirectoryControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
20 DPRINT1("FatDirectoryControl()\n");
21 return STATUS_NOT_IMPLEMENTED
;
26 FatCreateRootDcb(IN PFAT_IRP_CONTEXT IrpContext
,
31 /* Make sure it's not already created */
32 ASSERT(!Vcb
->RootDcb
);
34 /* Allocate the DCB */
35 Dcb
= FsRtlAllocatePoolWithTag(NonPagedPool
,
40 RtlZeroMemory(Dcb
, sizeof(FCB
));
42 /* Assign it to the VCB */
46 Dcb
->Header
.NodeTypeCode
= FAT_NTC_ROOT_DCB
;
47 Dcb
->Header
.NodeByteSize
= sizeof(FCB
);
49 /* FCB is in a good condition */
50 Dcb
->Condition
= FcbGood
;
52 /* Initialize FCB's resource */
53 Dcb
->Header
.Resource
= &Dcb
->Resource
;
54 ExInitializeResourceLite(&Dcb
->Resource
);
56 /* Initialize Paging Io resource*/
57 Dcb
->Header
.PagingIoResource
= &Dcb
->PagingIoResource
;
58 ExInitializeResourceLite(&Dcb
->PagingIoResource
);
60 /* Initialize a list of parent DCBs*/
61 InitializeListHead(&Dcb
->ParentDcbLinks
);
66 /* Initialize parent's DCB list */
67 InitializeListHead(&Dcb
->Dcb
.ParentDcbList
);
69 /* Initialize the full file name */
70 Dcb
->FullFileName
.Buffer
= L
"\\";
71 Dcb
->FullFileName
.Length
= 1 * sizeof(WCHAR
);
72 Dcb
->FullFileName
.MaximumLength
= 2 * sizeof(WCHAR
);
74 Dcb
->ShortName
.Name
.Ansi
.Buffer
= "\\";
75 Dcb
->ShortName
.Name
.Ansi
.Length
= 1;
76 Dcb
->ShortName
.Name
.Ansi
.MaximumLength
= 2 * sizeof(CHAR
);
78 /* Fill dirent attribute byte copy */
79 Dcb
->DirentFatFlags
= FILE_ATTRIBUTE_DIRECTORY
;
81 /* Initialize advanced FCB header fields */
82 ExInitializeFastMutex(&Dcb
->HeaderMutex
);
83 FsRtlSetupAdvancedHeader(&Dcb
->Header
, &Dcb
->HeaderMutex
);
86 FsRtlInitializeLargeMcb(&Dcb
->Mcb
, NonPagedPool
);
88 /* Set up first cluster field depending on FAT type */
89 if (TRUE
/*FatIsFat32(Vcb)*/)
91 /* First cluster is really the first cluster of this volume */
92 Dcb
->FirstClusterOfFile
= Vcb
->Bpb
.RootDirFirstCluster
;
94 /* Calculate size of FAT32 root dir */
95 Dcb
->Header
.AllocationSize
.LowPart
= 0xFFFFFFFF;
96 //FatLookupFileAllocationSize(IrpContext, Dcb);
97 DPRINT1("Calculation of a size of a root dir is missing!\n");
99 Dcb
->Header
.FileSize
.QuadPart
= Dcb
->Header
.AllocationSize
.QuadPart
;
108 FatRootDirectoryLbo(&Vcb
->Bpb
),
109 FatRootDirectorySize(&Vcb
->Bpb
));
111 /* Set a real size of the root directory */
112 Dcb
->Header
.FileSize
.QuadPart
= FatRootDirectorySize(&Vcb
->Bpb
);
113 Dcb
->Header
.AllocationSize
.QuadPart
= Dcb
->Header
.FileSize
.QuadPart
;
118 /* Initialize free dirent bitmap */
119 RtlInitializeBitMap(&Dcb
->Dcb
.FreeBitmap
, NULL
, 0);
121 /* Fill the dirent bitmap */
122 DPRINT1("Filling the free dirent bitmap is missing\n");
123 //FatCheckFreeDirentBitmap( IrpContext, Dcb );
128 FatCreateDcb(IN PFAT_IRP_CONTEXT IrpContext
,
131 IN FF_FILE
*FileHandle
)
135 /* Allocate it and zero it */
136 Fcb
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(FCB
), TAG_FCB
);
137 RtlZeroMemory(Fcb
, sizeof(FCB
));
140 Fcb
->Header
.NodeTypeCode
= FAT_NTC_DCB
;
141 Fcb
->Header
.NodeByteSize
= sizeof(FCB
);
142 Fcb
->Condition
= FcbGood
;
144 /* Initialize resources */
145 Fcb
->Header
.Resource
= &Fcb
->Resource
;
146 ExInitializeResourceLite(Fcb
->Header
.Resource
);
148 Fcb
->Header
.PagingIoResource
= &Fcb
->PagingIoResource
;
149 ExInitializeResourceLite(Fcb
->Header
.PagingIoResource
);
151 /* Initialize mutexes */
152 Fcb
->Header
.FastMutex
= &Fcb
->HeaderMutex
;
153 ExInitializeFastMutex(&Fcb
->HeaderMutex
);
154 FsRtlSetupAdvancedHeader(&Fcb
->Header
, &Fcb
->HeaderMutex
);
156 /* Insert into parent's DCB list */
157 InsertHeadList(&ParentDcb
->Dcb
.ParentDcbList
, &Fcb
->ParentDcbLinks
);
160 Fcb
->ParentFcb
= ParentDcb
;
163 /* Initialize parent dcb list */
164 InitializeListHead(&Fcb
->Dcb
.ParentDcbList
);
166 /* Set FullFAT handle */
167 Fcb
->FatHandle
= FileHandle
;
172 FatSetFcbNames(IrpContext
, Fcb
);
174 /* Ensure the full name is set */
175 FatSetFullFileNameInFcb(IrpContext
, Fcb
);
183 FatiOpenExistingDcb(IN PFAT_IRP_CONTEXT IrpContext
,
184 IN PFILE_OBJECT FileObject
,
187 IN PACCESS_MASK DesiredAccess
,
188 IN USHORT ShareAccess
,
189 IN ULONG CreateDisposition
,
190 IN BOOLEAN NoEaKnowledge
,
191 IN BOOLEAN DeleteOnClose
)
193 IO_STATUS_BLOCK Iosb
= {{0}};
195 Iosb
.Status
= STATUS_NOT_IMPLEMENTED
;