sync with trunk (r46275)
[reactos.git] / drivers / filesystems / fastfat_new / dir.c
1 /*
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)
7 */
8
9 /* INCLUDES *****************************************************************/
10
11 #define NDEBUG
12 #include "fastfat.h"
13
14 /* FUNCTIONS *****************************************************************/
15
16 NTSTATUS
17 NTAPI
18 FatDirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
19 {
20 DPRINT1("FatDirectoryControl()\n");
21 return STATUS_NOT_IMPLEMENTED;
22 }
23
24 VOID
25 NTAPI
26 FatCreateRootDcb(IN PFAT_IRP_CONTEXT IrpContext,
27 IN PVCB Vcb)
28 {
29 PFCB Dcb;
30
31 /* Make sure it's not already created */
32 ASSERT(!Vcb->RootDcb);
33
34 /* Allocate the DCB */
35 Dcb = FsRtlAllocatePoolWithTag(NonPagedPool,
36 sizeof(FCB),
37 TAG_FCB);
38
39 /* Zero it */
40 RtlZeroMemory(Dcb, sizeof(FCB));
41
42 /* Assign it to the VCB */
43 Vcb->RootDcb = Dcb;
44
45 /* Set its header */
46 Dcb->Header.NodeTypeCode = FAT_NTC_ROOT_DCB;
47 Dcb->Header.NodeByteSize = sizeof(FCB);
48
49 /* FCB is in a good condition */
50 Dcb->Condition = FcbGood;
51
52 /* Initialize FCB's resource */
53 Dcb->Header.Resource = &Dcb->Resource;
54 ExInitializeResourceLite(&Dcb->Resource);
55
56 /* Initialize Paging Io resource*/
57 Dcb->Header.PagingIoResource = &Dcb->PagingIoResource;
58 ExInitializeResourceLite(&Dcb->PagingIoResource);
59
60 /* Initialize a list of parent DCBs*/
61 InitializeListHead(&Dcb->ParentDcbLinks);
62
63 /* Set VCB */
64 Dcb->Vcb = Vcb;
65
66 /* Initialize parent's DCB list */
67 InitializeListHead(&Dcb->Dcb.ParentDcbList);
68
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);
73
74 Dcb->ShortName.Name.Ansi.Buffer = "\\";
75 Dcb->ShortName.Name.Ansi.Length = 1;
76 Dcb->ShortName.Name.Ansi.MaximumLength = 2 * sizeof(CHAR);
77
78 /* Fill dirent attribute byte copy */
79 Dcb->DirentFatFlags = FILE_ATTRIBUTE_DIRECTORY;
80
81 /* Initialize advanced FCB header fields */
82 ExInitializeFastMutex(&Dcb->HeaderMutex);
83 FsRtlSetupAdvancedHeader(&Dcb->Header, &Dcb->HeaderMutex);
84
85 /* Initialize MCB */
86 FsRtlInitializeLargeMcb(&Dcb->Mcb, NonPagedPool);
87
88 /* Set up first cluster field depending on FAT type */
89 if (TRUE/*FatIsFat32(Vcb)*/)
90 {
91 /* First cluster is really the first cluster of this volume */
92 Dcb->FirstClusterOfFile = Vcb->Bpb.RootDirFirstCluster;
93
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");
98
99 Dcb->Header.FileSize.QuadPart = Dcb->Header.AllocationSize.QuadPart;
100 }
101 else
102 {
103 #if 0
104 /* Add MCB entry */
105 FatAddMcbEntry(Vcb,
106 &Dcb->Mcb,
107 0,
108 FatRootDirectoryLbo(&Vcb->Bpb),
109 FatRootDirectorySize(&Vcb->Bpb));
110
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;
114 #endif
115 UNIMPLEMENTED;
116 }
117
118 /* Initialize free dirent bitmap */
119 RtlInitializeBitMap(&Dcb->Dcb.FreeBitmap, NULL, 0);
120
121 /* Fill the dirent bitmap */
122 DPRINT1("Filling the free dirent bitmap is missing\n");
123 //FatCheckFreeDirentBitmap( IrpContext, Dcb );
124 }
125
126 PFCB
127 NTAPI
128 FatCreateDcb(IN PFAT_IRP_CONTEXT IrpContext,
129 IN PVCB Vcb,
130 IN PFCB ParentDcb,
131 IN FF_FILE *FileHandle)
132 {
133 PFCB Fcb;
134
135 /* Allocate it and zero it */
136 Fcb = ExAllocatePoolWithTag(NonPagedPool, sizeof(FCB), TAG_FCB);
137 RtlZeroMemory(Fcb, sizeof(FCB));
138
139 /* Set node types */
140 Fcb->Header.NodeTypeCode = FAT_NTC_DCB;
141 Fcb->Header.NodeByteSize = sizeof(FCB);
142 Fcb->Condition = FcbGood;
143
144 /* Initialize resources */
145 Fcb->Header.Resource = &Fcb->Resource;
146 ExInitializeResourceLite(Fcb->Header.Resource);
147
148 Fcb->Header.PagingIoResource = &Fcb->PagingIoResource;
149 ExInitializeResourceLite(Fcb->Header.PagingIoResource);
150
151 /* Initialize mutexes */
152 Fcb->Header.FastMutex = &Fcb->HeaderMutex;
153 ExInitializeFastMutex(&Fcb->HeaderMutex);
154 FsRtlSetupAdvancedHeader(&Fcb->Header, &Fcb->HeaderMutex);
155
156 /* Insert into parent's DCB list */
157 InsertHeadList(&ParentDcb->Dcb.ParentDcbList, &Fcb->ParentDcbLinks);
158
159 /* Set backlinks */
160 Fcb->ParentFcb = ParentDcb;
161 Fcb->Vcb = Vcb;
162
163 /* Initialize parent dcb list */
164 InitializeListHead(&Fcb->Dcb.ParentDcbList);
165
166 /* Set FullFAT handle */
167 Fcb->FatHandle = FileHandle;
168
169 /* Set names */
170 if (FileHandle)
171 {
172 FatSetFcbNames(IrpContext, Fcb);
173
174 /* Ensure the full name is set */
175 FatSetFullFileNameInFcb(IrpContext, Fcb);
176 }
177
178 return Fcb;
179 }
180
181 IO_STATUS_BLOCK
182 NTAPI
183 FatiOpenExistingDcb(IN PFAT_IRP_CONTEXT IrpContext,
184 IN PFILE_OBJECT FileObject,
185 IN PVCB Vcb,
186 IN PFCB Dcb,
187 IN PACCESS_MASK DesiredAccess,
188 IN USHORT ShareAccess,
189 IN ULONG CreateDisposition,
190 IN BOOLEAN NoEaKnowledge,
191 IN BOOLEAN DeleteOnClose)
192 {
193 IO_STATUS_BLOCK Iosb = {{0}};
194
195 Iosb.Status = STATUS_NOT_IMPLEMENTED;
196 UNIMPLEMENTED;
197
198 return Iosb;
199 }
200
201 /* EOF */