Separated close request
[reactos.git] / reactos / drivers / fs / vfat / create.c
1 /* $Id: create.c,v 1.6 2000/07/07 02:14:14 ekohl Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: services/fs/vfat/create.c
6 * PURPOSE: VFAT Filesystem
7 * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
8
9 */
10
11 /* INCLUDES *****************************************************************/
12
13 #include <ddk/ntddk.h>
14 #include <ddk/cctypes.h>
15 #include <wchar.h>
16 #include <limits.h>
17
18 #define NDEBUG
19 #include <debug.h>
20
21 #include "vfat.h"
22
23 /* FUNCTIONS ****************************************************************/
24
25 BOOLEAN IsLastEntry(PVOID Block, ULONG Offset)
26 /*
27 * FUNCTION: Determine if the given directory entry is the last
28 */
29 {
30 return(((FATDirEntry *)Block)[Offset].Filename[0] == 0);
31 }
32
33 BOOLEAN IsVolEntry(PVOID Block, ULONG Offset)
34 /*
35 * FUNCTION: Determine if the given directory entry is a vol entry
36 */
37 {
38 if( (((FATDirEntry *)Block)[Offset].Attrib)==0x28 ) return TRUE;
39 else return FALSE;
40 }
41
42 BOOLEAN IsDeletedEntry(PVOID Block, ULONG Offset)
43 /*
44 * FUNCTION: Determines if the given entry is a deleted one
45 */
46 {
47 /* Checks special character */
48
49 return ((((FATDirEntry *)Block)[Offset].Filename[0] == 0xe5) || (((FATDirEntry *)Block)[Offset].Filename[0] == 0));
50 }
51
52 BOOLEAN GetEntryName(PVOID Block, PULONG _Offset, PWSTR Name, PULONG _jloop,
53 PDEVICE_EXTENSION DeviceExt, ULONG * _StartingSector)
54 /*
55 * FUNCTION: Retrieves the file name, be it in short or long file name format
56 */
57 {
58 FATDirEntry* test;
59 slot* test2;
60 ULONG Offset = *_Offset;
61 ULONG StartingSector = *_StartingSector;
62 ULONG jloop = *_jloop;
63 ULONG cpos;
64
65 test = (FATDirEntry *)Block;
66 test2 = (slot *)Block;
67
68 *Name = 0;
69
70 if (IsDeletedEntry(Block,Offset))
71 {
72 return(FALSE);
73 }
74
75 if(test2[Offset].attr == 0x0f)
76 {
77 vfat_initstr(Name, 256);
78 vfat_wcsncpy(Name,test2[Offset].name0_4,5);
79 vfat_wcsncat(Name,test2[Offset].name5_10,5,6);
80 vfat_wcsncat(Name,test2[Offset].name11_12,11,2);
81
82 cpos=0;
83 while((test2[Offset].id!=0x41) && (test2[Offset].id!=0x01) &&
84 (test2[Offset].attr>0))
85 {
86 Offset++;
87 if(Offset==ENTRIES_PER_SECTOR) {
88 Offset=0;
89 StartingSector++;//FIXME : nor always the next sector
90 jloop++;
91 VFATReadSectors(DeviceExt->StorageDevice,StartingSector,1,Block);
92 test2 = (slot *)Block;
93 }
94 cpos++;
95 vfat_movstr(Name, 13, 0, cpos*13);
96 vfat_wcsncpy(Name, test2[Offset].name0_4, 5);
97 vfat_wcsncat(Name,test2[Offset].name5_10,5,6);
98 vfat_wcsncat(Name,test2[Offset].name11_12,11,2);
99
100 }
101
102 if (IsDeletedEntry(Block,Offset+1))
103 {
104 Offset++;
105 *_Offset = Offset;
106 *_jloop = jloop;
107 *_StartingSector = StartingSector;
108 return(FALSE);
109 }
110
111 *_Offset = Offset;
112 *_jloop = jloop;
113 *_StartingSector = StartingSector;
114
115 return(TRUE);
116 }
117
118 RtlAnsiToUnicode(Name,test[Offset].Filename,8);
119 if (test[Offset].Ext[0]!=' ')
120 {
121 RtlCatAnsiToUnicode(Name,".",1);
122 }
123 RtlCatAnsiToUnicode(Name,test[Offset].Ext,3);
124
125 *_Offset = Offset;
126
127 return(TRUE);
128 }
129
130 NTSTATUS ReadVolumeLabel(PDEVICE_EXTENSION DeviceExt, PVPB Vpb)
131 /*
132 * FUNCTION: Read the volume label
133 */
134 {
135 ULONG i = 0;
136 ULONG j;
137 ULONG Size;
138 char* block;
139 ULONG StartingSector;
140 ULONG NextCluster;
141
142 Size = DeviceExt->rootDirectorySectors;//FIXME : in fat32, no limit
143 StartingSector = DeviceExt->rootStart;
144 NextCluster=0;
145
146 block = ExAllocatePool(NonPagedPool,BLOCKSIZE);
147 DPRINT("FindFile : start at sector %lx, entry %ld\n",StartingSector,i);
148 for (j=0; j<Size; j++)
149 {
150 VFATReadSectors(DeviceExt->StorageDevice,StartingSector,1,block);
151
152 for (i=0; i<ENTRIES_PER_SECTOR; i++)
153 {
154 if (IsVolEntry((PVOID)block,i))
155 {
156 FATDirEntry *test = (FATDirEntry *)block;
157
158 /* copy volume label */
159 RtlAnsiToUnicode(Vpb->VolumeLabel,test[i].Filename,8);
160 RtlCatAnsiToUnicode(Vpb->VolumeLabel,test[i].Ext,3);
161 Vpb->VolumeLabelLength = wcslen(Vpb->VolumeLabel);
162
163 ExFreePool(block);
164 return(STATUS_SUCCESS);
165 }
166 if (IsLastEntry((PVOID)block,i))
167 {
168 *(Vpb->VolumeLabel) = 0;
169 Vpb->VolumeLabelLength = 0;
170 ExFreePool(block);
171 return(STATUS_UNSUCCESSFUL);
172 }
173 }
174 // not found in this sector, try next :
175
176 /* directory can be fragmented although it is best to keep them
177 unfragmented */
178 StartingSector++;
179 if (DeviceExt->FatType ==FAT32)
180 {
181 if(StartingSector==ClusterToSector(DeviceExt,NextCluster+1))
182 {
183 NextCluster = GetNextCluster(DeviceExt,NextCluster);
184 if (NextCluster == 0||NextCluster==0xffffffff)
185 {
186 *(Vpb->VolumeLabel) = 0;
187 Vpb->VolumeLabelLength = 0;
188 ExFreePool(block);
189 return(STATUS_UNSUCCESSFUL);
190 }
191 StartingSector = ClusterToSector(DeviceExt,NextCluster);
192 }
193 }
194 }
195 *(Vpb->VolumeLabel) = 0;
196 Vpb->VolumeLabelLength = 0;
197 ExFreePool(block);
198 return(STATUS_UNSUCCESSFUL);
199 }
200
201
202 NTSTATUS FindFile(PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
203 PVFATFCB Parent, PWSTR FileToFind,ULONG *StartSector,ULONG *Entry)
204 /*
205 * FUNCTION: Find a file
206 */
207 {
208 ULONG i, j;
209 ULONG Size;
210 char* block;
211 WCHAR name[256];
212 ULONG StartingSector;
213 ULONG NextCluster;
214 WCHAR TempStr[2];
215
216 DPRINT("FindFile(Parent %x, FileToFind '%S')\n",Parent,FileToFind);
217
218 if (wcslen(FileToFind)==0)
219 {
220 CHECKPOINT;
221 TempStr[0] = (WCHAR)'.';
222 TempStr[1] = 0;
223 FileToFind=(PWSTR)&TempStr;
224 }
225 if (Parent != NULL)
226 {
227 DPRINT("Parent->entry.FirstCluster %d\n",Parent->entry.FirstCluster);
228 }
229
230 DPRINT("FindFile '%S'\n", FileToFind);
231 if (Parent == NULL||Parent->entry.FirstCluster==1)
232 {
233 CHECKPOINT;
234 Size = DeviceExt->rootDirectorySectors; /* FIXME : in fat32, no limit */
235 StartingSector = DeviceExt->rootStart;
236 NextCluster=0;
237 if(FileToFind[0]==0 ||(FileToFind[0]=='\\' && FileToFind[1]==0) ||
238 (FileToFind[0]=='.' && FileToFind[1]==0))
239 {
240 /* it's root : complete essentials fields then return ok */
241 CHECKPOINT;
242 memset(Fcb,0,sizeof(VFATFCB));
243 memset(Fcb->entry.Filename,' ',11);
244 Fcb->entry.FileSize=DeviceExt->rootDirectorySectors*BLOCKSIZE;
245 Fcb->entry.Attrib=FILE_ATTRIBUTE_DIRECTORY;
246 if (DeviceExt->FatType == FAT32)
247 Fcb->entry.FirstCluster=2;
248 else
249 Fcb->entry.FirstCluster=1; /* FIXME : is 1 the good value for mark root? */
250 if(StartSector)
251 *StartSector=StartingSector;
252 if(Entry)
253 *Entry=0;
254 return(STATUS_SUCCESS);
255 }
256 }
257 else
258 {
259 DPRINT("Parent->entry.FileSize %x\n",Parent->entry.FileSize);
260
261 Size = ULONG_MAX;
262 if (DeviceExt->FatType == FAT32)
263 NextCluster = Parent->entry.FirstCluster
264 +Parent->entry.FirstClusterHigh*65536;
265 else
266 NextCluster = Parent->entry.FirstCluster;
267 StartingSector = ClusterToSector(DeviceExt, NextCluster);
268 if(Parent->entry.FirstCluster==1 && DeviceExt->FatType!=FAT32)
269 {
270 /* read of root directory in FAT16 or FAT12 */
271 StartingSector=DeviceExt->rootStart;
272 }
273 }
274 CHECKPOINT;
275 block = ExAllocatePool(NonPagedPool,BLOCKSIZE);
276 CHECKPOINT;
277 if (StartSector && (*StartSector)) StartingSector=*StartSector;
278 i=(Entry)?(*Entry):0;
279 DPRINT("FindFile : start at sector %lx, entry %ld\n",StartingSector,i);
280 for (j=0; j<Size; j++)
281 {
282 VFATReadSectors(DeviceExt->StorageDevice,StartingSector,1,block);
283
284 for (i=(Entry)?(*Entry):0; i<ENTRIES_PER_SECTOR; i++)
285 {
286 if (IsVolEntry((PVOID)block,i))
287 continue;
288 if (IsLastEntry((PVOID)block,i))
289 {
290 if(StartSector) *StartSector=StartingSector;
291 if(Entry) *Entry=i;
292 ExFreePool(block);
293 return(STATUS_UNSUCCESSFUL);
294 }
295 if (GetEntryName((PVOID)block,&i,name,&j,DeviceExt,&StartingSector))
296 {
297 DPRINT("Comparing '%S' '%S'\n",name,FileToFind);
298 if (wstrcmpjoki(name,FileToFind))
299 {
300 /* In the case of a long filename, the firstcluster is stored in
301 the next record -- where it's short name is */
302 if(((FATDirEntry *)block)[i].Attrib==0x0f) i++;
303 if( i==(ENTRIES_PER_SECTOR))
304 {
305 /* entry is in next sector */
306 StartingSector++;
307 /* FIXME : treat case of next sector fragmented */
308 VFATReadSectors(DeviceExt->StorageDevice,StartingSector,1,block);
309 i=0;
310 }
311 memcpy(&Fcb->entry,&((FATDirEntry *)block)[i],
312 sizeof(FATDirEntry));
313 vfat_wcsncpy(Fcb->ObjectName,name,MAX_PATH);
314 if(StartSector) *StartSector=StartingSector;
315 if(Entry) *Entry=i;
316 ExFreePool(block);
317 return(STATUS_SUCCESS);
318 }
319 }
320 }
321 /* not found in this sector, try next : */
322
323 /* directory can be fragmented although it is best to keep them
324 unfragmented */
325 if(Entry) *Entry=0;
326 StartingSector++;
327 if ((Parent != NULL && Parent->entry.FirstCluster!=1)
328 || DeviceExt->FatType ==FAT32)
329 {
330 if(StartingSector==ClusterToSector(DeviceExt,NextCluster+1))
331 {
332 NextCluster = GetNextCluster(DeviceExt,NextCluster);
333 if (NextCluster == 0||NextCluster==0xffffffff)
334 {
335 if(StartSector) *StartSector=StartingSector;
336 if(Entry) *Entry=i;
337 ExFreePool(block);
338 return(STATUS_UNSUCCESSFUL);
339 }
340 StartingSector = ClusterToSector(DeviceExt,NextCluster);
341 }
342 }
343 }
344 if(StartSector) *StartSector=StartingSector;
345 if(Entry) *Entry=i;
346 ExFreePool(block);
347 return(STATUS_UNSUCCESSFUL);
348 }
349
350
351
352 NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
353 PWSTR FileName)
354 /*
355 * FUNCTION: Opens a file
356 */
357 {
358 PWSTR current = NULL;
359 PWSTR next;
360 PWSTR string;
361 PVFATFCB ParentFcb;
362 PVFATFCB Fcb,pRelFcb;
363 PVFATFCB Temp;
364 PVFATCCB newCCB,pRelCcb;
365 NTSTATUS Status;
366 PFILE_OBJECT pRelFileObject;
367 PWSTR AbsFileName=NULL;
368 short i,j;
369 PLIST_ENTRY current_entry;
370 KIRQL oldIrql;
371
372 DPRINT("FsdOpenFile(%08lx, %08lx, %S)\n",
373 DeviceExt,
374 FileObject,
375 FileName);
376
377 /* FIXME : treat relative name */
378 if(FileObject->RelatedFileObject)
379 {
380 DbgPrint("try related for %S\n",FileName);
381 pRelFileObject=FileObject->RelatedFileObject;
382 pRelCcb=pRelFileObject->FsContext2;
383 assert(pRelCcb);
384 pRelFcb=pRelCcb->pFcb;
385 assert(pRelFcb);
386 /*
387 * verify related object is a directory and target name don't start with \.
388 */
389 if( !(pRelFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY)
390 || (FileName[0]!= '\\') )
391 {
392 Status=STATUS_INVALID_PARAMETER;
393 return Status;
394 }
395 /* construct absolute path name */
396 AbsFileName=ExAllocatePool(NonPagedPool,MAX_PATH);
397 for (i=0;pRelFcb->PathName[i];i++)
398 AbsFileName[i]=pRelFcb->PathName[i];
399 AbsFileName[i++]='\\';
400 for (j=0;FileName[j]&&i<MAX_PATH;j++)
401 AbsFileName[i++]=FileName[j];
402 assert(i<MAX_PATH);
403 AbsFileName[i]=0;
404 FileName=AbsFileName;
405 }
406
407 /*
408 * try first to find an existing FCB in memory
409 */
410 CHECKPOINT;
411
412 KeAcquireSpinLock(&DeviceExt->FcbListLock, &oldIrql);
413 current_entry = DeviceExt->FcbListHead.Flink;
414 while (current_entry != &DeviceExt->FcbListHead)
415 {
416 Fcb = CONTAINING_RECORD(current_entry, VFATFCB, FcbListEntry);
417
418 DPRINT("Scanning %x\n", Fcb);
419 DPRINT("Scanning %S\n", Fcb->PathName);
420
421 if (DeviceExt==Fcb->pDevExt
422 && wstrcmpi(FileName,Fcb->PathName))
423 {
424 Fcb->RefCount++;
425 KeReleaseSpinLock(&DeviceExt->FcbListLock, oldIrql);
426 FileObject->FsContext =(PVOID) &Fcb->NTRequiredFCB;
427 newCCB = ExAllocatePool(NonPagedPool,sizeof(VFATCCB));
428 memset(newCCB,0,sizeof(VFATCCB));
429 FileObject->FsContext2 = newCCB;
430 newCCB->pFcb=Fcb;
431 newCCB->PtrFileObject=FileObject;
432 if(AbsFileName)ExFreePool(AbsFileName);
433 return(STATUS_SUCCESS);
434 }
435
436 current_entry = current_entry->Flink;
437 }
438 KeReleaseSpinLock(&DeviceExt->FcbListLock, oldIrql);
439
440 CHECKPOINT;
441 DPRINT("FileName %S\n", FileName);
442
443 string = FileName;
444 ParentFcb = NULL;
445 Fcb = ExAllocatePool(NonPagedPool, sizeof(VFATFCB));
446 memset(Fcb,0,sizeof(VFATFCB));
447 Fcb->ObjectName=Fcb->PathName;
448 next = &string[0];
449
450 CHECKPOINT;
451 while (TRUE)
452 {
453 CHECKPOINT;
454 *next = '\\';
455 current = next+1;
456 next = wcschr(next+1,'\\');
457 if (next!=NULL)
458 {
459 *next=0;
460 }
461 else
462 {
463 /* reached the last path component */
464 DPRINT("exiting: current '%S'\n",current);
465 break;
466 }
467
468 DPRINT("current '%S'\n",current);
469 Status = FindFile(DeviceExt,Fcb,ParentFcb,current,NULL,NULL);
470 if (Status != STATUS_SUCCESS)
471 {
472 CHECKPOINT;
473 if (Fcb != NULL)
474 ExFreePool(Fcb);
475 if (ParentFcb != NULL)
476 ExFreePool(ParentFcb);
477 if(AbsFileName)
478 ExFreePool(AbsFileName);
479
480 DPRINT("error STATUS_OBJECT_PATH_NOT_FOUND\n");
481 return STATUS_OBJECT_PATH_NOT_FOUND;
482 }
483 Temp = Fcb;
484 CHECKPOINT;
485 if (ParentFcb == NULL)
486 {
487 CHECKPOINT;
488 Fcb = ExAllocatePool(NonPagedPool,sizeof(VFATFCB));
489 memset(Fcb,0,sizeof(VFATFCB));
490 Fcb->ObjectName=Fcb->PathName;
491 }
492 else
493 Fcb = ParentFcb;
494 CHECKPOINT;
495 ParentFcb = Temp;
496 }
497
498 /* searching for last path component */
499 DPRINT("current '%S'\n",current);
500 Status = FindFile(DeviceExt,Fcb,ParentFcb,current,NULL,NULL);
501 if (Status != STATUS_SUCCESS)
502 {
503 /* file does not exist */
504 CHECKPOINT;
505 if (Fcb != NULL)
506 ExFreePool(Fcb);
507 if (ParentFcb != NULL)
508 ExFreePool(ParentFcb);
509 if(AbsFileName)
510 ExFreePool(AbsFileName);
511
512 return STATUS_OBJECT_NAME_NOT_FOUND;
513 }
514
515 Temp = Fcb;
516 CHECKPOINT;
517 if (ParentFcb == NULL)
518 {
519 CHECKPOINT;
520 Fcb = ExAllocatePool(NonPagedPool,sizeof(VFATFCB));
521 memset(Fcb,0,sizeof(VFATFCB));
522 Fcb->ObjectName=Fcb->PathName;
523 }
524 else
525 Fcb = ParentFcb;
526 CHECKPOINT;
527 ParentFcb = Temp;
528
529
530 CHECKPOINT;
531 FileObject->FsContext =(PVOID) &ParentFcb->NTRequiredFCB;
532 newCCB = ExAllocatePool(NonPagedPool,sizeof(VFATCCB));
533 memset(newCCB,0,sizeof(VFATCCB));
534 FileObject->FsContext2 = newCCB;
535 newCCB->pFcb=ParentFcb;
536 newCCB->PtrFileObject=FileObject;
537 ParentFcb->RefCount++;
538 //FIXME : initialize all fields in FCB and CCB
539
540 KeAcquireSpinLock(&DeviceExt->FcbListLock, &oldIrql);
541 InsertTailList(&DeviceExt->FcbListHead, &ParentFcb->FcbListEntry);
542 KeReleaseSpinLock(&DeviceExt->FcbListLock, oldIrql);
543
544 vfat_wcsncpy(ParentFcb->PathName,FileName,MAX_PATH);
545 ParentFcb->ObjectName=ParentFcb->PathName+(current-FileName);
546 ParentFcb->pDevExt=DeviceExt;
547 DPRINT("file open, fcb=%x\n",ParentFcb);
548 DPRINT("FileSize %d\n",ParentFcb->entry.FileSize);
549 if(Fcb)
550 ExFreePool(Fcb);
551 if(AbsFileName)
552 ExFreePool(AbsFileName);
553 CHECKPOINT;
554
555 return(STATUS_SUCCESS);
556 }
557
558
559 NTSTATUS FsdCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
560 /*
561 * FUNCTION: Create or open a file
562 */
563 {
564 PIO_STACK_LOCATION Stack;
565 PFILE_OBJECT FileObject;
566 NTSTATUS Status=STATUS_SUCCESS;
567 PDEVICE_EXTENSION DeviceExt;
568 ULONG RequestedDisposition,RequestedOptions;
569 PVFATCCB pCcb;
570 PVFATFCB pFcb;
571
572 Stack = IoGetCurrentIrpStackLocation(Irp);
573 assert(Stack);
574 RequestedDisposition = ((Stack->Parameters.Create.Options>>24)&0xff);
575 RequestedOptions=Stack->Parameters.Create.Options&FILE_VALID_OPTION_FLAGS;
576 FileObject = Stack->FileObject;
577 DeviceExt = DeviceObject->DeviceExtension;
578 assert(DeviceExt);
579
580 Status = FsdOpenFile(DeviceExt,FileObject,FileObject->FileName.Buffer);
581
582 CHECKPOINT;
583 Irp->IoStatus.Information = 0;
584 if (Status == STATUS_OBJECT_PATH_NOT_FOUND)
585 {
586 Irp->IoStatus.Status = Status;
587 return Status;
588 }
589
590 CHECKPOINT;
591 if(!NT_SUCCESS(Status))
592 {
593 if(RequestedDisposition==FILE_CREATE
594 ||RequestedDisposition==FILE_OPEN_IF
595 ||RequestedDisposition==FILE_OVERWRITE_IF)
596 {
597 CHECKPOINT;
598 Status=addEntry(DeviceExt,FileObject,RequestedOptions
599 ,(Stack->Parameters.Create.FileAttributes & FILE_ATTRIBUTE_VALID_FLAGS));
600 if(NT_SUCCESS(Status))
601 Irp->IoStatus.Information = FILE_CREATED;
602 // FIXME set size if AllocationSize requested
603 // FIXME set extended attributes ?
604 // FIXME set share access
605 // IoSetShareAccess(DesiredAccess,ShareAccess,FileObject
606 // ,((PVfatCCB)(FileObject->FsContext2))->pFcb->FCBShareAccess);
607 }
608 }
609 else
610 {
611 if(RequestedDisposition==FILE_CREATE)
612 {
613 Irp->IoStatus.Information = FILE_EXISTS;
614 Status=STATUS_OBJECT_NAME_COLLISION;
615 }
616 pCcb=FileObject->FsContext2;
617 pFcb=pCcb->pFcb;
618 if( (RequestedOptions&FILE_NON_DIRECTORY_FILE)
619 && (pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY))
620 {
621 Status=STATUS_FILE_IS_A_DIRECTORY;
622 }
623 if( (RequestedOptions&FILE_DIRECTORY_FILE)
624 && !(pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY))
625 {
626 Status=STATUS_NOT_A_DIRECTORY;
627 }
628 // FIXME : test share access
629 // FIXME : test write access if requested
630 if(!NT_SUCCESS(Status))
631 FsdCloseFile(DeviceExt,FileObject);
632 else Irp->IoStatus.Information = FILE_OPENED;
633 // FIXME : make supersed or overwrite if requested
634 }
635
636 CHECKPOINT;
637 Irp->IoStatus.Status = Status;
638
639 return Status;
640 }
641
642
643 NTSTATUS FsdCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
644 /*
645 * FUNCTION: Create or open a file
646 */
647 {
648 NTSTATUS Status=STATUS_SUCCESS;
649 PDEVICE_EXTENSION DeviceExt;
650
651 assert(DeviceObject);
652 assert(Irp);
653
654 if (DeviceObject->Size==sizeof(DEVICE_OBJECT))
655 {
656 /* DeviceObject represent FileSystem instead of logical volume */
657 DbgPrint("FsdCreate called with file system\n");
658 Irp->IoStatus.Status=Status;
659 Irp->IoStatus.Information=FILE_OPENED;
660 IoCompleteRequest(Irp,IO_NO_INCREMENT);
661 return(Status);
662 }
663
664 DeviceExt = DeviceObject->DeviceExtension;
665 assert(DeviceExt);
666 ExAcquireResourceExclusiveLite(&DeviceExt->DirResource, TRUE);
667
668 Status = FsdCreateFile (DeviceObject, Irp);
669
670 ExReleaseResourceLite(&DeviceExt->DirResource);
671
672 Irp->IoStatus.Status = Status;
673 IoCompleteRequest(Irp, IO_NO_INCREMENT);
674
675 return Status;
676 }
677
678 /* EOF */