ReactOS  0.4.14-dev-114-gc8cbd56
create.c
Go to the documentation of this file.
1 /*
2  * ReactOS kernel
3  * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 /*
20  * PROJECT: ReactOS kernel
21  * FILE: drivers/filesystems/fastfat/create.c
22  * PURPOSE: VFAT Filesystem
23  * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
24  * Pierre Schweitzer (pierre@reactos.org)
25  */
26 
27 /* INCLUDES *****************************************************************/
28 
29 #include "vfat.h"
30 
31 #define NDEBUG
32 #include <debug.h>
33 
34 /* FUNCTIONS *****************************************************************/
35 
36 VOID
38  PFAT_DIR_ENTRY pEntry,
39  PUNICODE_STRING NameU)
40 {
41  OEM_STRING StringA;
42  USHORT Length;
43  CHAR cString[12];
44 
45  RtlCopyMemory(cString, pEntry->ShortName, 11);
46  cString[11] = 0;
47  if (cString[0] == 0x05)
48  {
49  cString[0] = 0xe5;
50  }
51 
52  StringA.Buffer = cString;
53  for (StringA.Length = 0;
54  StringA.Length < 8 && StringA.Buffer[StringA.Length] != ' ';
55  StringA.Length++);
56  StringA.MaximumLength = StringA.Length;
57 
58  RtlOemStringToUnicodeString(NameU, &StringA, FALSE);
59 
61  {
62  RtlDowncaseUnicodeString(NameU, NameU, FALSE);
63  }
64 
65  if (cString[8] != ' ')
66  {
67  Length = NameU->Length;
68  NameU->Buffer += Length / sizeof(WCHAR);
69  if (!FAT_ENTRY_VOLUME(pEntry))
70  {
71  Length += sizeof(WCHAR);
72  NameU->Buffer[0] = L'.';
73  NameU->Buffer++;
74  }
75  NameU->Length = 0;
76  NameU->MaximumLength -= Length;
77 
78  StringA.Buffer = &cString[8];
79  for (StringA.Length = 0;
80  StringA.Length < 3 && StringA.Buffer[StringA.Length] != ' ';
81  StringA.Length++);
82  StringA.MaximumLength = StringA.Length;
83  RtlOemStringToUnicodeString(NameU, &StringA, FALSE);
85  {
86  RtlDowncaseUnicodeString(NameU, NameU, FALSE);
87  }
88  NameU->Buffer -= Length / sizeof(WCHAR);
89  NameU->Length += Length;
90  NameU->MaximumLength += Length;
91  }
92 
93  NameU->Buffer[NameU->Length / sizeof(WCHAR)] = 0;
94  DPRINT("'%wZ'\n", NameU);
95 }
96 
97 /*
98  * FUNCTION: Find a file
99  */
100 NTSTATUS
102  PDEVICE_EXTENSION DeviceExt,
104  PUNICODE_STRING FileToFindU,
106  BOOLEAN First)
107 {
108  PWCHAR PathNameBuffer;
109  USHORT PathNameBufferLength;
111  PVOID Context = NULL;
112  PVOID Page;
113  PVFATFCB rcFcb;
114  BOOLEAN Found;
115  UNICODE_STRING PathNameU;
116  UNICODE_STRING FileToFindUpcase;
117  BOOLEAN WildCard;
118  BOOLEAN IsFatX = vfatVolumeIsFatX(DeviceExt);
119 
120  DPRINT("FindFile(Parent %p, FileToFind '%wZ', DirIndex: %u)\n",
121  Parent, FileToFindU, DirContext->DirIndex);
122  DPRINT("FindFile: Path %wZ\n",&Parent->PathNameU);
123 
124  PathNameBufferLength = LONGNAME_MAX_LENGTH * sizeof(WCHAR);
125  PathNameBuffer = ExAllocatePoolWithTag(NonPagedPool, PathNameBufferLength + sizeof(WCHAR), TAG_NAME);
126  if (!PathNameBuffer)
127  {
129  }
130 
131  PathNameU.Buffer = PathNameBuffer;
132  PathNameU.Length = 0;
133  PathNameU.MaximumLength = PathNameBufferLength;
134 
135  DirContext->LongNameU.Length = 0;
136  DirContext->ShortNameU.Length = 0;
137 
138  WildCard = FsRtlDoesNameContainWildCards(FileToFindU);
139 
140  if (WildCard == FALSE)
141  {
142  /* if there is no '*?' in the search name, than look first for an existing fcb */
143  RtlCopyUnicodeString(&PathNameU, &Parent->PathNameU);
144  if (!vfatFCBIsRoot(Parent))
145  {
146  PathNameU.Buffer[PathNameU.Length / sizeof(WCHAR)] = L'\\';
147  PathNameU.Length += sizeof(WCHAR);
148  }
149  RtlAppendUnicodeStringToString(&PathNameU, FileToFindU);
150  PathNameU.Buffer[PathNameU.Length / sizeof(WCHAR)] = 0;
151  rcFcb = vfatGrabFCBFromTable(DeviceExt, &PathNameU);
152  if (rcFcb)
153  {
154  ULONG startIndex = rcFcb->startIndex;
155  if (IsFatX && !vfatFCBIsRoot(Parent))
156  {
157  startIndex += 2;
158  }
159  if(startIndex >= DirContext->DirIndex)
160  {
161  RtlCopyUnicodeString(&DirContext->LongNameU, &rcFcb->LongNameU);
162  RtlCopyUnicodeString(&DirContext->ShortNameU, &rcFcb->ShortNameU);
163  RtlCopyMemory(&DirContext->DirEntry, &rcFcb->entry, sizeof(DIR_ENTRY));
164  DirContext->StartIndex = rcFcb->startIndex;
165  DirContext->DirIndex = rcFcb->dirIndex;
166  DPRINT("FindFile: new Name %wZ, DirIndex %u (%u)\n",
167  &DirContext->LongNameU, DirContext->DirIndex, DirContext->StartIndex);
169  }
170  else
171  {
172  DPRINT("FCB not found for %wZ\n", &PathNameU);
174  }
175  vfatReleaseFCB(DeviceExt, rcFcb);
176  ExFreePoolWithTag(PathNameBuffer, TAG_NAME);
177  return Status;
178  }
179  }
180 
181  /* FsRtlIsNameInExpression need the searched string to be upcase,
182  * even if IgnoreCase is specified */
183  Status = RtlUpcaseUnicodeString(&FileToFindUpcase, FileToFindU, TRUE);
184  if (!NT_SUCCESS(Status))
185  {
186  ExFreePoolWithTag(PathNameBuffer, TAG_NAME);
187  return Status;
188  }
189 
190  while (TRUE)
191  {
192  Status = VfatGetNextDirEntry(DeviceExt, &Context, &Page, Parent, DirContext, First);
193  First = FALSE;
195  {
196  break;
197  }
198  if (ENTRY_VOLUME(IsFatX, &DirContext->DirEntry))
199  {
200  DirContext->DirIndex++;
201  continue;
202  }
203  if (DirContext->LongNameU.Length == 0 ||
204  DirContext->ShortNameU.Length == 0)
205  {
206  DPRINT1("WARNING: File system corruption detected. You may need to run a disk repair utility.\n");
208  {
209  ASSERT(DirContext->LongNameU.Length != 0 &&
210  DirContext->ShortNameU.Length != 0);
211  }
212  DirContext->DirIndex++;
213  continue;
214  }
215  if (WildCard)
216  {
217  Found = FsRtlIsNameInExpression(&FileToFindUpcase, &DirContext->LongNameU, TRUE, NULL) ||
218  FsRtlIsNameInExpression(&FileToFindUpcase, &DirContext->ShortNameU, TRUE, NULL);
219  }
220  else
221  {
222  Found = FsRtlAreNamesEqual(&DirContext->LongNameU, FileToFindU, TRUE, NULL) ||
223  FsRtlAreNamesEqual(&DirContext->ShortNameU, FileToFindU, TRUE, NULL);
224  }
225 
226  if (Found)
227  {
228  if (WildCard)
229  {
230  RtlCopyUnicodeString(&PathNameU, &Parent->PathNameU);
231  if (!vfatFCBIsRoot(Parent))
232  {
233  PathNameU.Buffer[PathNameU.Length / sizeof(WCHAR)] = L'\\';
234  PathNameU.Length += sizeof(WCHAR);
235  }
236  RtlAppendUnicodeStringToString(&PathNameU, &DirContext->LongNameU);
237  PathNameU.Buffer[PathNameU.Length / sizeof(WCHAR)] = 0;
238  rcFcb = vfatGrabFCBFromTable(DeviceExt, &PathNameU);
239  if (rcFcb != NULL)
240  {
241  RtlCopyMemory(&DirContext->DirEntry, &rcFcb->entry, sizeof(DIR_ENTRY));
242  vfatReleaseFCB(DeviceExt, rcFcb);
243  }
244  }
245  DPRINT("%u\n", DirContext->LongNameU.Length);
246  DPRINT("FindFile: new Name %wZ, DirIndex %u\n",
247  &DirContext->LongNameU, DirContext->DirIndex);
248 
249  if (Context)
250  {
252  }
253  RtlFreeUnicodeString(&FileToFindUpcase);
254  ExFreePoolWithTag(PathNameBuffer, TAG_NAME);
255  return STATUS_SUCCESS;
256  }
257  DirContext->DirIndex++;
258  }
259 
260  if (Context)
261  {
263  }
264 
265  RtlFreeUnicodeString(&FileToFindUpcase);
266  ExFreePoolWithTag(PathNameBuffer, TAG_NAME);
267  return Status;
268 }
269 
270 /*
271  * FUNCTION: Opens a file
272  */
273 static
274 NTSTATUS
276  PDEVICE_EXTENSION DeviceExt,
277  PUNICODE_STRING PathNameU,
279  ULONG RequestedDisposition,
280  ULONG RequestedOptions,
282 {
283  PVFATFCB Fcb;
285 
286  DPRINT("VfatOpenFile(%p, '%wZ', %p, %p)\n", DeviceExt, PathNameU, FileObject, ParentFcb);
287 
288  if (FileObject->RelatedFileObject)
289  {
290  DPRINT("'%wZ'\n", &FileObject->RelatedFileObject->FileName);
291 
292  *ParentFcb = FileObject->RelatedFileObject->FsContext;
293  }
294  else
295  {
296  *ParentFcb = NULL;
297  }
298 
299  if (!DeviceExt->FatInfo.FixedMedia)
300  {
301  Status = VfatBlockDeviceIoControl(DeviceExt->StorageDevice,
303  NULL,
304  0,
305  NULL,
306  0,
307  FALSE);
308  if (!NT_SUCCESS(Status))
309  {
310  DPRINT("Status %lx\n", Status);
311  *ParentFcb = NULL;
312  return Status;
313  }
314  }
315 
316  if (*ParentFcb)
317  {
318  vfatGrabFCB(DeviceExt, *ParentFcb);
319  }
320 
321  /* try first to find an existing FCB in memory */
322  DPRINT("Checking for existing FCB in memory\n");
323 
324  Status = vfatGetFCBForFile(DeviceExt, ParentFcb, &Fcb, PathNameU);
325  if (!NT_SUCCESS(Status))
326  {
327  DPRINT ("Could not make a new FCB, status: %x\n", Status);
328  return Status;
329  }
330 
331  /* Fail, if we try to overwrite an existing directory */
332  if ((!BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE) && vfatFCBIsDirectory(Fcb)) &&
333  (RequestedDisposition == FILE_OVERWRITE ||
334  RequestedDisposition == FILE_OVERWRITE_IF ||
335  RequestedDisposition == FILE_SUPERSEDE))
336  {
337  vfatReleaseFCB(DeviceExt, Fcb);
339  }
340 
342  {
343  vfatReleaseFCB(DeviceExt, Fcb);
344  return STATUS_DELETE_PENDING;
345  }
346 
347  /* Fail, if we try to overwrite a read-only file */
348  if (vfatFCBIsReadOnly(Fcb) &&
349  (RequestedDisposition == FILE_OVERWRITE ||
350  RequestedDisposition == FILE_OVERWRITE_IF))
351  {
352  vfatReleaseFCB(DeviceExt, Fcb);
353  return STATUS_ACCESS_DENIED;
354  }
355 
356  if (vfatFCBIsReadOnly(Fcb) &&
357  (RequestedOptions & FILE_DELETE_ON_CLOSE))
358  {
359  vfatReleaseFCB(DeviceExt, Fcb);
360  return STATUS_CANNOT_DELETE;
361  }
362 
363  if ((vfatFCBIsRoot(Fcb) ||
364  (Fcb->LongNameU.Length == sizeof(WCHAR) && Fcb->LongNameU.Buffer[0] == L'.') ||
365  (Fcb->LongNameU.Length == 2 * sizeof(WCHAR) && Fcb->LongNameU.Buffer[0] == L'.' && Fcb->LongNameU.Buffer[1] == L'.')) &&
366  BooleanFlagOn(RequestedOptions, FILE_DELETE_ON_CLOSE))
367  {
368  // we cannot delete a '.', '..' or the root directory
369  vfatReleaseFCB(DeviceExt, Fcb);
370  return STATUS_CANNOT_DELETE;
371  }
372 
373  /* If that one was marked for closing, remove it */
375  {
376  BOOLEAN ConcurrentDeletion;
377  PVFAT_CLOSE_CONTEXT CloseContext;
378 
379  /* Get the context */
380  CloseContext = Fcb->CloseContext;
381  /* Is someone already taking over? */
382  if (CloseContext != NULL)
383  {
384  ConcurrentDeletion = FALSE;
385  /* Lock list */
387  /* Check whether it was already removed, if not, do it */
388  if (!IsListEmpty(&CloseContext->CloseListEntry))
389  {
390  RemoveEntryList(&CloseContext->CloseListEntry);
392  ConcurrentDeletion = TRUE;
393  }
395 
396  /* It's not delayed anymore! */
398  /* Release the extra reference (would have been removed by IRP_MJ_CLOSE) */
399  vfatReleaseFCB(DeviceExt, Fcb);
400  Fcb->CloseContext = NULL;
401  /* If no concurrent deletion, free work item */
402  if (!ConcurrentDeletion)
403  {
404  ExFreeToPagedLookasideList(&VfatGlobalData->CloseContextLookasideList, CloseContext);
405  }
406  }
407 
408  DPRINT("Reusing delayed close FCB for %wZ\n", &Fcb->PathNameU);
409  }
410 
411  DPRINT("Attaching FCB to fileObject\n");
413  if (!NT_SUCCESS(Status))
414  {
415  vfatReleaseFCB(DeviceExt, Fcb);
416  }
417  return Status;
418 }
419 
420 /*
421  * FUNCTION: Create or open a file
422  */
423 static NTSTATUS
426  PIRP Irp)
427 {
428  PIO_STACK_LOCATION Stack;
431  PDEVICE_EXTENSION DeviceExt;
432  ULONG RequestedDisposition, RequestedOptions;
433  PVFATFCB pFcb = NULL;
435  PVFATCCB pCcb = NULL;
436  PWCHAR c, last;
437  BOOLEAN PagingFileCreate;
438  BOOLEAN Dots;
439  BOOLEAN OpenTargetDir;
440  BOOLEAN TrailingBackslash;
441  UNICODE_STRING FileNameU;
442  UNICODE_STRING PathNameU;
444 
445  /* Unpack the various parameters. */
447  RequestedDisposition = ((Stack->Parameters.Create.Options >> 24) & 0xff);
448  RequestedOptions = Stack->Parameters.Create.Options & FILE_VALID_OPTION_FLAGS;
449  PagingFileCreate = BooleanFlagOn(Stack->Flags, SL_OPEN_PAGING_FILE);
450  OpenTargetDir = BooleanFlagOn(Stack->Flags, SL_OPEN_TARGET_DIRECTORY);
451 
452  FileObject = Stack->FileObject;
453  DeviceExt = DeviceObject->DeviceExtension;
454 
456  {
457  return STATUS_NOT_IMPLEMENTED;
458  }
459 
460  /* Check their validity. */
461  if (BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE) &&
462  RequestedDisposition == FILE_SUPERSEDE)
463  {
465  }
466 
467  if (BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE) &&
468  BooleanFlagOn(RequestedOptions, FILE_NON_DIRECTORY_FILE))
469  {
471  }
472 
473  /* Deny create if the volume is locked */
474  if (BooleanFlagOn(DeviceExt->Flags, VCB_VOLUME_LOCKED))
475  {
476  return STATUS_ACCESS_DENIED;
477  }
478 
479  /* This a open operation for the volume itself */
480  if (FileObject->FileName.Length == 0 &&
481  (FileObject->RelatedFileObject == NULL ||
482  FileObject->RelatedFileObject->FsContext2 != NULL ||
483  FileObject->RelatedFileObject->FsContext == DeviceExt->VolumeFcb))
484  {
485  DPRINT("Volume opening\n");
486 
487  if (RequestedDisposition != FILE_OPEN &&
488  RequestedDisposition != FILE_OPEN_IF)
489  {
490  return STATUS_ACCESS_DENIED;
491  }
492 
493  if (BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE) &&
494  (FileObject->RelatedFileObject == NULL || FileObject->RelatedFileObject->FsContext2 == NULL || FileObject->RelatedFileObject->FsContext == DeviceExt->VolumeFcb))
495  {
496  return STATUS_NOT_A_DIRECTORY;
497  }
498 
499  if (OpenTargetDir)
500  {
502  }
503 
504  if (BooleanFlagOn(RequestedOptions, FILE_DELETE_ON_CLOSE))
505  {
506  return STATUS_CANNOT_DELETE;
507  }
508 
509  vfatAddToStat(DeviceExt, Fat.CreateHits, 1);
510 
511  pFcb = DeviceExt->VolumeFcb;
512 
513  if (pFcb->OpenHandleCount == 0)
514  {
515  IoSetShareAccess(Stack->Parameters.Create.SecurityContext->DesiredAccess,
516  Stack->Parameters.Create.ShareAccess,
517  FileObject,
518  &pFcb->FCBShareAccess);
519  }
520  else
521  {
522  Status = IoCheckShareAccess(Stack->Parameters.Create.SecurityContext->DesiredAccess,
523  Stack->Parameters.Create.ShareAccess,
524  FileObject,
525  &pFcb->FCBShareAccess,
526  TRUE);
527  if (!NT_SUCCESS(Status))
528  {
529  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
530  return Status;
531  }
532  }
533 
534  vfatAttachFCBToFileObject(DeviceExt, pFcb, FileObject);
535  DeviceExt->OpenHandleCount++;
536  pFcb->OpenHandleCount++;
537  vfatAddToStat(DeviceExt, Fat.SuccessfulCreates, 1);
538 
539  Irp->IoStatus.Information = FILE_OPENED;
540  return STATUS_SUCCESS;
541  }
542 
543  if (FileObject->RelatedFileObject != NULL &&
544  FileObject->RelatedFileObject->FsContext == DeviceExt->VolumeFcb)
545  {
548  }
549 
550  /* Check for illegal characters and illegal dot sequences in the file name */
551  PathNameU = FileObject->FileName;
552  c = PathNameU.Buffer + PathNameU.Length / sizeof(WCHAR);
553  last = c - 1;
554 
555  Dots = TRUE;
556  while (c-- > PathNameU.Buffer)
557  {
558  if (*c == L'\\' || c == PathNameU.Buffer)
559  {
560  if (Dots && last > c)
561  {
563  }
564  if (*c == L'\\' && (c - 1) > PathNameU.Buffer &&
565  *(c - 1) == L'\\')
566  {
568  }
569 
570  last = c - 1;
571  Dots = TRUE;
572  }
573  else if (*c != L'.')
574  {
575  Dots = FALSE;
576  }
577 
578  if (*c != '\\' && vfatIsLongIllegal(*c))
579  {
581  }
582  }
583 
584  /* Check if we try to open target directory of root dir */
585  if (OpenTargetDir && FileObject->RelatedFileObject == NULL && PathNameU.Length == sizeof(WCHAR) &&
586  PathNameU.Buffer[0] == L'\\')
587  {
589  }
590 
591  if (FileObject->RelatedFileObject && PathNameU.Length >= sizeof(WCHAR) && PathNameU.Buffer[0] == L'\\')
592  {
594  }
595 
596  TrailingBackslash = FALSE;
597  if (PathNameU.Length > sizeof(WCHAR) && PathNameU.Buffer[PathNameU.Length/sizeof(WCHAR)-1] == L'\\')
598  {
599  PathNameU.Length -= sizeof(WCHAR);
600  TrailingBackslash = TRUE;
601  }
602 
603  if (PathNameU.Length > sizeof(WCHAR) && PathNameU.Buffer[PathNameU.Length/sizeof(WCHAR)-1] == L'\\')
604  {
606  }
607 
608  /* Try opening the file. */
609  if (!OpenTargetDir)
610  {
611  vfatAddToStat(DeviceExt, Fat.CreateHits, 1);
612 
613  Status = VfatOpenFile(DeviceExt, &PathNameU, FileObject, RequestedDisposition, RequestedOptions, &ParentFcb);
614  }
615  else
616  {
617  PVFATFCB TargetFcb;
619 
620  vfatAddToStat(DeviceExt, Fat.CreateHits, 1);
621 
622  ParentFcb = (FileObject->RelatedFileObject != NULL) ? FileObject->RelatedFileObject->FsContext : NULL;
623  if (ParentFcb)
624  {
625  vfatGrabFCB(DeviceExt, ParentFcb);
626  }
627 
628  Status = vfatGetFCBForFile(DeviceExt, &ParentFcb, &TargetFcb, &PathNameU);
629  if (NT_SUCCESS(Status))
630  {
631  vfatReleaseFCB(DeviceExt, TargetFcb);
632  Irp->IoStatus.Information = FILE_EXISTS;
633  }
634  else
635  {
636  Irp->IoStatus.Information = FILE_DOES_NOT_EXIST;
637  }
638 
639  idx = FileObject->FileName.Length / sizeof(WCHAR) - 1;
640 
641  /* Skip trailing \ - if any */
642  if (PathNameU.Buffer[idx] == L'\\')
643  {
644  --idx;
645  PathNameU.Length -= sizeof(WCHAR);
646  }
647 
648  /* Get file name */
649  while (idx >= 0 && PathNameU.Buffer[idx] != L'\\')
650  {
651  --idx;
652  }
653 
654  if (idx > 0 || PathNameU.Buffer[0] == L'\\')
655  {
656  /* We don't want to include / in the name */
657  FileNameLen = PathNameU.Length - ((idx + 1) * sizeof(WCHAR));
658 
659  /* Update FO just to keep file name */
660  /* Skip first slash */
661  ++idx;
663  RtlMoveMemory(&PathNameU.Buffer[0], &PathNameU.Buffer[idx], FileObject->FileName.Length);
664 #if 0
665  /* Terminate the string at the last backslash */
666  PathNameU.Buffer[idx + 1] = UNICODE_NULL;
667  PathNameU.Length = (idx + 1) * sizeof(WCHAR);
668  PathNameU.MaximumLength = PathNameU.Length + sizeof(WCHAR);
669 
670  /* Update the file object as well */
671  FileObject->FileName.Length = PathNameU.Length;
673 #endif
674  }
675  else
676  {
677  /* This is a relative open and we have only the filename, so open the parent directory
678  * It is in RelatedFileObject
679  */
680  ASSERT(FileObject->RelatedFileObject != NULL);
681 
682  /* No need to modify the FO, it already has the name */
683  }
684 
685  /* We're done with opening! */
686  if (ParentFcb != NULL)
687  {
689  }
690 
691  if (NT_SUCCESS(Status))
692  {
693  pFcb = FileObject->FsContext;
694  ASSERT(pFcb == ParentFcb);
695 
696  if (pFcb->OpenHandleCount == 0)
697  {
698  IoSetShareAccess(Stack->Parameters.Create.SecurityContext->DesiredAccess,
699  Stack->Parameters.Create.ShareAccess,
700  FileObject,
701  &pFcb->FCBShareAccess);
702  }
703  else
704  {
705  Status = IoCheckShareAccess(Stack->Parameters.Create.SecurityContext->DesiredAccess,
706  Stack->Parameters.Create.ShareAccess,
707  FileObject,
708  &pFcb->FCBShareAccess,
709  FALSE);
710  if (!NT_SUCCESS(Status))
711  {
712  VfatCloseFile(DeviceExt, FileObject);
713  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
714  return Status;
715  }
716  }
717 
718  pCcb = FileObject->FsContext2;
719  if (BooleanFlagOn(RequestedOptions, FILE_DELETE_ON_CLOSE))
720  {
721  pCcb->Flags |= CCB_DELETE_ON_CLOSE;
722  }
723 
724  pFcb->OpenHandleCount++;
725  DeviceExt->OpenHandleCount++;
726  }
727  else if (ParentFcb != NULL)
728  {
729  vfatReleaseFCB(DeviceExt, ParentFcb);
730  }
731 
732  if (NT_SUCCESS(Status))
733  {
734  vfatAddToStat(DeviceExt, Fat.SuccessfulCreates, 1);
735  }
736  else
737  {
738  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
739  }
740 
741  return Status;
742  }
743 
744  /*
745  * If the directory containing the file to open doesn't exist then
746  * fail immediately
747  */
753  {
754  if (ParentFcb)
755  {
756  vfatReleaseFCB(DeviceExt, ParentFcb);
757  }
758  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
759  return Status;
760  }
761 
762  if (!NT_SUCCESS(Status) && ParentFcb == NULL)
763  {
764  DPRINT1("VfatOpenFile failed for '%wZ', status %x\n", &PathNameU, Status);
765  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
766  return Status;
767  }
768 
769  Attributes = (Stack->Parameters.Create.FileAttributes & (FILE_ATTRIBUTE_ARCHIVE |
774 
775  /* If the file open failed then create the required file */
776  if (!NT_SUCCESS (Status))
777  {
778  if (RequestedDisposition == FILE_CREATE ||
779  RequestedDisposition == FILE_OPEN_IF ||
780  RequestedDisposition == FILE_OVERWRITE_IF ||
781  RequestedDisposition == FILE_SUPERSEDE)
782  {
783  if (!BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE))
784  {
785  if (TrailingBackslash)
786  {
787  vfatReleaseFCB(DeviceExt, ParentFcb);
788  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
790  }
792  }
793  vfatSplitPathName(&PathNameU, NULL, &FileNameU);
794  Status = VfatAddEntry(DeviceExt, &FileNameU, &pFcb, ParentFcb, RequestedOptions,
795  Attributes, NULL);
796  vfatReleaseFCB(DeviceExt, ParentFcb);
797  if (NT_SUCCESS(Status))
798  {
799  Status = vfatAttachFCBToFileObject(DeviceExt, pFcb, FileObject);
800  if (!NT_SUCCESS(Status))
801  {
802  vfatReleaseFCB(DeviceExt, pFcb);
803  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
804  return Status;
805  }
806 
807  Irp->IoStatus.Information = FILE_CREATED;
809  pFcb,
810  DeviceExt,
811  &Irp->Overlay.AllocationSize);
813  Irp->AssociatedIrp.SystemBuffer,
814  Stack->Parameters.Create.EaLength);
815 
816  if (PagingFileCreate)
817  {
818  pFcb->Flags |= FCB_IS_PAGE_FILE;
819  SetFlag(DeviceExt->Flags, VCB_IS_SYS_OR_HAS_PAGE);
820  }
821  }
822  else
823  {
824  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
825  return Status;
826  }
827  }
828  else
829  {
830  vfatReleaseFCB(DeviceExt, ParentFcb);
831  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
832  return Status;
833  }
834  }
835  else
836  {
837  if (ParentFcb)
838  {
839  vfatReleaseFCB(DeviceExt, ParentFcb);
840  }
841 
842  pFcb = FileObject->FsContext;
843 
844  /* Otherwise fail if the caller wanted to create a new file */
845  if (RequestedDisposition == FILE_CREATE)
846  {
847  VfatCloseFile(DeviceExt, FileObject);
848  if (TrailingBackslash && !vfatFCBIsDirectory(pFcb))
849  {
850  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
852  }
853  Irp->IoStatus.Information = FILE_EXISTS;
854  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
856  }
857 
858  if (pFcb->OpenHandleCount != 0)
859  {
860  Status = IoCheckShareAccess(Stack->Parameters.Create.SecurityContext->DesiredAccess,
861  Stack->Parameters.Create.ShareAccess,
862  FileObject,
863  &pFcb->FCBShareAccess,
864  FALSE);
865  if (!NT_SUCCESS(Status))
866  {
867  VfatCloseFile(DeviceExt, FileObject);
868  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
869  return Status;
870  }
871  }
872 
873  /*
874  * Check the file has the requested attributes
875  */
876  if (BooleanFlagOn(RequestedOptions, FILE_NON_DIRECTORY_FILE) &&
877  vfatFCBIsDirectory(pFcb))
878  {
879  VfatCloseFile (DeviceExt, FileObject);
880  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
882  }
883  if (BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE) &&
884  !vfatFCBIsDirectory(pFcb))
885  {
886  VfatCloseFile (DeviceExt, FileObject);
887  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
888  return STATUS_NOT_A_DIRECTORY;
889  }
890  if (TrailingBackslash && !vfatFCBIsDirectory(pFcb))
891  {
892  VfatCloseFile (DeviceExt, FileObject);
893  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
895  }
896 #ifndef USE_ROS_CC_AND_FS
897  if (!vfatFCBIsDirectory(pFcb))
898  {
899  if (BooleanFlagOn(Stack->Parameters.Create.SecurityContext->DesiredAccess, FILE_WRITE_DATA) ||
900  RequestedDisposition == FILE_OVERWRITE ||
901  RequestedDisposition == FILE_OVERWRITE_IF ||
902  (RequestedOptions & FILE_DELETE_ON_CLOSE))
903  {
904  if (!MmFlushImageSection(&pFcb->SectionObjectPointers, MmFlushForWrite))
905  {
906  DPRINT1("%wZ\n", &pFcb->PathNameU);
907  DPRINT1("%d %d %d\n", Stack->Parameters.Create.SecurityContext->DesiredAccess & FILE_WRITE_DATA,
908  RequestedDisposition == FILE_OVERWRITE, RequestedDisposition == FILE_OVERWRITE_IF);
909  VfatCloseFile (DeviceExt, FileObject);
910  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
911  return (BooleanFlagOn(RequestedOptions, FILE_DELETE_ON_CLOSE)) ? STATUS_CANNOT_DELETE
913  }
914  }
915  }
916 #endif
917  if (PagingFileCreate)
918  {
919  /* FIXME:
920  * Do more checking for page files. It is possible,
921  * that the file was opened and closed previously
922  * as a normal cached file. In this case, the cache
923  * manager has referenced the fileobject and the fcb
924  * is held in memory. Try to remove the fileobject
925  * from cache manager and use the fcb.
926  */
927  if (pFcb->RefCount > 1)
928  {
930  {
931  VfatCloseFile(DeviceExt, FileObject);
932  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
934  }
935  }
936  else
937  {
938  pFcb->Flags |= FCB_IS_PAGE_FILE;
939  SetFlag(DeviceExt->Flags, VCB_IS_SYS_OR_HAS_PAGE);
940  }
941  }
942  else
943  {
945  {
946  VfatCloseFile(DeviceExt, FileObject);
947  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
949  }
950  }
951 
952  if (RequestedDisposition == FILE_OVERWRITE ||
953  RequestedDisposition == FILE_OVERWRITE_IF ||
954  RequestedDisposition == FILE_SUPERSEDE)
955  {
958  {
959  VfatCloseFile(DeviceExt, FileObject);
960  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
961  return STATUS_ACCESS_DENIED;
962  }
963 
964  if (!vfatFCBIsDirectory(pFcb))
965  {
966  LARGE_INTEGER SystemTime;
967 
968  if (RequestedDisposition == FILE_SUPERSEDE)
969  {
970  *pFcb->Attributes = Attributes;
971  }
972  else
973  {
974  *pFcb->Attributes |= Attributes;
975  }
977 
978  KeQuerySystemTime(&SystemTime);
979  if (vfatVolumeIsFatX(DeviceExt))
980  {
981  FsdSystemTimeToDosDateTime(DeviceExt,
982  &SystemTime, &pFcb->entry.FatX.UpdateDate,
983  &pFcb->entry.FatX.UpdateTime);
984  }
985  else
986  {
987  FsdSystemTimeToDosDateTime(DeviceExt,
988  &SystemTime, &pFcb->entry.Fat.UpdateDate,
989  &pFcb->entry.Fat.UpdateTime);
990  }
991 
992  VfatUpdateEntry(DeviceExt, pFcb);
993  }
994 
997  pFcb,
998  DeviceExt,
999  &Irp->Overlay.AllocationSize);
1001  if (!NT_SUCCESS (Status))
1002  {
1003  VfatCloseFile(DeviceExt, FileObject);
1004  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
1005  return Status;
1006  }
1007  }
1008 
1009  if (RequestedDisposition == FILE_SUPERSEDE)
1010  {
1011  Irp->IoStatus.Information = FILE_SUPERSEDED;
1012  }
1013  else if (RequestedDisposition == FILE_OVERWRITE ||
1014  RequestedDisposition == FILE_OVERWRITE_IF)
1015  {
1016  Irp->IoStatus.Information = FILE_OVERWRITTEN;
1017  }
1018  else
1019  {
1020  Irp->IoStatus.Information = FILE_OPENED;
1021  }
1022  }
1023 
1024  if (pFcb->OpenHandleCount == 0)
1025  {
1026  IoSetShareAccess(Stack->Parameters.Create.SecurityContext->DesiredAccess,
1027  Stack->Parameters.Create.ShareAccess,
1028  FileObject,
1029  &pFcb->FCBShareAccess);
1030  }
1031  else
1032  {
1034  &pFcb->FCBShareAccess);
1035  }
1036 
1037  pCcb = FileObject->FsContext2;
1038  if (BooleanFlagOn(RequestedOptions, FILE_DELETE_ON_CLOSE))
1039  {
1040  pCcb->Flags |= CCB_DELETE_ON_CLOSE;
1041  }
1042 
1043  if (Irp->IoStatus.Information == FILE_CREATED)
1044  {
1045  vfatReportChange(DeviceExt,
1046  pFcb,
1047  (vfatFCBIsDirectory(pFcb) ?
1050  }
1051  else if (Irp->IoStatus.Information == FILE_OVERWRITTEN ||
1052  Irp->IoStatus.Information == FILE_SUPERSEDED)
1053  {
1054  vfatReportChange(DeviceExt,
1055  pFcb,
1058  }
1059 
1060  pFcb->OpenHandleCount++;
1061  DeviceExt->OpenHandleCount++;
1062 
1063  /* FIXME : test write access if requested */
1064 
1065  /* FIXME: That is broken, we cannot reach this code path with failure */
1067  if (NT_SUCCESS(Status))
1068  {
1069  vfatAddToStat(DeviceExt, Fat.SuccessfulCreates, 1);
1070  }
1071  else
1072  {
1073  vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);
1074  }
1075 
1076  return Status;
1077 }
1078 
1079 /*
1080  * FUNCTION: Create or open a file
1081  */
1082 NTSTATUS
1084  PVFAT_IRP_CONTEXT IrpContext)
1085 {
1086  NTSTATUS Status;
1087 
1088  ASSERT(IrpContext);
1089 
1090  if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
1091  {
1092  /* DeviceObject represents FileSystem instead of logical volume */
1093  DPRINT ("FsdCreate called with file system\n");
1094  IrpContext->Irp->IoStatus.Information = FILE_OPENED;
1095  IrpContext->PriorityBoost = IO_DISK_INCREMENT;
1096 
1097  return STATUS_SUCCESS;
1098  }
1099 
1100  IrpContext->Irp->IoStatus.Information = 0;
1101  ExAcquireResourceExclusiveLite(&IrpContext->DeviceExt->DirResource, TRUE);
1102  Status = VfatCreateFile(IrpContext->DeviceObject, IrpContext->Irp);
1103  ExReleaseResourceLite(&IrpContext->DeviceExt->DirResource);
1104 
1105  if (NT_SUCCESS(Status))
1106  IrpContext->PriorityBoost = IO_DISK_INCREMENT;
1107 
1108  return Status;
1109 }
1110 
1111 /* EOF */
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
unsigned short UpdateTime
Definition: vfat.h:126
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
LIST_ENTRY CloseListEntry
Definition: vfat.h:614
NTSTATUS VfatCreate(PVFAT_IRP_CONTEXT IrpContext)
Definition: create.c:1083
NTSTATUS VfatSetAllocationSizeInformation(PFILE_OBJECT FileObject, PVFATFCB Fcb, PDEVICE_EXTENSION DeviceExt, PLARGE_INTEGER AllocationSize)
Definition: finfo.c:1207
#define STATUS_DELETE_PENDING
Definition: ntstatus.h:308
#define FILE_EXISTS
Definition: nt_native.h:772
SECTION_OBJECT_POINTERS SectionObjectPointers
Definition: vfat.h:445
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_FILE_IS_A_DIRECTORY
Definition: udferr_usr.h:164
#define TAG_NAME
Definition: vfat.h:547
NTSTATUS VfatCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
Definition: close.c:160
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
Definition: string_lib.cpp:46
#define FILE_OPEN_IF
Definition: from_kernel.h:56
FAST_MUTEX CloseMutex
Definition: vfat.h:417
unsigned short UpdateDate
Definition: vfat.h:177
#define FILE_OVERWRITTEN
Definition: nt_native.h:771
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:193
UNICODE_STRING ShortNameU
Definition: vfat.h:460
#define CCB_DELETE_ON_CLOSE
Definition: ext2fs.h:1026
Definition: vfat.h:441
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
USHORT MaximumLength
Definition: env_spec_w32.h:370
ULONG dirIndex
Definition: vfat.h:496
Definition: vfat.h:530
PDEVICE_EXTENSION DeviceExt
Definition: vfat.h:579
Iosb Status
Definition: create.c:4311
POINT last
Definition: font.c:46
#define SL_OPEN_PAGING_FILE
Definition: iotypes.h:1774
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
if(OpenRequiringOplock &&(Iosb.Status==STATUS_SUCCESS))
Definition: create.c:4324
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
NTSTATUS vfatAttachFCBToFileObject(PDEVICE_EXTENSION vcb, PVFATFCB fcb, PFILE_OBJECT fileObject)
Definition: fcb.c:755
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_DISK_CHECK_VERIFY
Definition: cdrw_usr.h:175
#define FILE_CREATE
Definition: from_kernel.h:55
#define FILE_OPENED
Definition: nt_native.h:769
#define FILE_SUPERSEDED
Definition: nt_native.h:768
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pinsup.c:955
VOID vfat8Dot3ToString(PFAT_DIR_ENTRY pEntry, PUNICODE_STRING NameU)
Definition: create.c:37
ULONG DirIndex
Definition: ntfs.h:529
FORCEINLINE BOOLEAN vfatFCBIsDirectory(PVFATFCB FCB)
Definition: vfat.h:631
UNICODE_STRING LongNameU
Definition: vfat.h:457
BOOLEAN vfatFCBIsRoot(PVFATFCB FCB)
Definition: fcb.c:294
#define FILE_NOTIFY_CHANGE_SIZE
#define FILE_NOTIFY_CHANGE_LAST_WRITE
#define vfatAddToStat(Vcb, Stat, Inc)
Definition: vfat.h:665
#define FILE_OVERWRITE
Definition: from_kernel.h:57
#define FILE_NOTIFY_CHANGE_FILE_NAME
VOID NTAPI IoSetShareAccess(IN ACCESS_MASK DesiredAccess, IN ULONG DesiredShareAccess, IN PFILE_OBJECT FileObject, OUT PSHARE_ACCESS ShareAccess)
Definition: file.c:3516
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:722
uint16_t * PWCHAR
Definition: typedefs.h:54
STRING OEM_STRING
Definition: umtypes.h:203
NTSTATUS VfatSetExtendedAttributes(PFILE_OBJECT FileObject, PVOID Ea, ULONG EaLength)
Definition: ea.c:36
FAT_DIR_ENTRY Fat
Definition: vfat.h:226
#define FILE_NOTIFY_CHANGE_DIR_NAME
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
BOOLEAN NTAPI FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name)
Definition: name.c:464
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
BOOLEAN NTAPI FsRtlIsNameInExpression(IN PUNICODE_STRING Expression, IN PUNICODE_STRING Name, IN BOOLEAN IgnoreCase, IN PWCHAR UpcaseTable OPTIONAL)
Definition: name.c:514
#define FCB_DELETE_PENDING
Definition: ext2fs.h:879
#define FILE_VALID_OPTION_FLAGS
Definition: nt_native.h:759
#define ENTRY_VOLUME(IsFatX, DirEntry)
Definition: vfat.h:206
#define FILE_OPEN_BY_FILE_ID
Definition: from_kernel.h:41
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
LONG RefCount
Definition: vfat.h:475
unsigned char ShortName[11]
Definition: vfat.h:115
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
WCHAR First[]
Definition: FormatMessage.c:11
CCHAR PriorityBoost
Definition: vfat.h:588
#define STATUS_NOT_A_DIRECTORY
Definition: udferr_usr.h:169
FORCEINLINE BOOLEAN vfatFCBIsReadOnly(PVFATFCB FCB)
Definition: vfat.h:638
#define IO_DISK_INCREMENT
Definition: iotypes.h:568
BOOLEAN FsdSystemTimeToDosDateTime(PDEVICE_EXTENSION DeviceExt, PLARGE_INTEGER SystemTime, PUSHORT pDosDate, PUSHORT pDosTime)
Definition: dir.c:53
#define STATUS_SHARING_VIOLATION
Definition: udferr_usr.h:154
#define UNICODE_NULL
long LONG
Definition: pedump.c:60
ULONG Flags
Definition: vfat.h:533
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT FileObject
Definition: create.c:4157
#define FILE_ACTION_MODIFIED
unsigned int idx
Definition: utils.c:41
ULONG Flags
Definition: vfat.h:490
SHARE_ACCESS FCBShareAccess
Definition: vfat.h:502
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define FILE_OVERWRITE_IF
Definition: from_kernel.h:58
void DPRINT(...)
Definition: polytest.cpp:61
return Found
Definition: dirsup.c:1270
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
ULONG startIndex
Definition: vfat.h:499
FORCEINLINE BOOLEAN vfatVolumeIsFatX(PDEVICE_EXTENSION DeviceExt)
Definition: vfat.h:645
#define FILE_DELETE_ON_CLOSE
Definition: constants.h:494
BOOLEAN NTAPI FsRtlAreNamesEqual(IN PCUNICODE_STRING Name1, IN PCUNICODE_STRING Name2, IN BOOLEAN IgnoreCase, IN PCWCH UpcaseTable OPTIONAL)
Definition: name.c:296
PDEVICE_OBJECT DeviceObject
Definition: vfat.h:406
Dirent FileNameLen
Definition: dirsup.c:506
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOLEAN NTAPI MmFlushImageSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN MMFLUSH_TYPE FlushType)
Definition: section.c:4798
#define FCB_IS_PAGE_FILE
Definition: vfat.h:430
#define FAT_ENTRY_VOLUME(DirEntry)
Definition: vfat.h:212
FORCEINLINE NTSTATUS VfatAddEntry(PDEVICE_EXTENSION DeviceExt, PUNICODE_STRING NameU, struct _VFATFCB **Fcb, struct _VFATFCB *ParentFcb, ULONG RequestedOptions, UCHAR ReqAttr, struct _VFAT_MOVE_CONTEXT *MoveContext)
Definition: vfat.h:369
_In_ PFCB _In_ PDIRENT_ENUM_CONTEXT DirContext
Definition: cdprocs.h:429
const GLubyte * c
Definition: glext.h:8905
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define STATUS_OBJECT_PATH_NOT_FOUND
Definition: udferr_usr.h:151
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1955
_In_ PFCB ParentFcb
Definition: cdprocs.h:741
PVFATFCB vfatGrabFCBFromTable(PDEVICE_EXTENSION pVCB, PUNICODE_STRING PathNameU)
Definition: fcb.c:594
#define VFAT_CASE_LOWER_BASE
Definition: vfat.h:200
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
ULONG Flags
Definition: ntfs.h:532
FATX_DIR_ENTRY FatX
Definition: vfat.h:227
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
#define FILE_DOES_NOT_EXIST
Definition: nt_native.h:773
#define STATUS_CANNOT_DELETE
Definition: shellext.h:66
static const WCHAR L[]
Definition: oid.c:1250
PUNICODE_STRING FileName
Definition: iotypes.h:2793
FORCEINLINE NTSTATUS VfatGetNextDirEntry(PDEVICE_EXTENSION DeviceExt, PVOID *pContext, PVOID *pPage, struct _VFATFCB *pDirFcb, struct _VFAT_DIRENTRY_CONTEXT *DirContext, BOOLEAN First)
Definition: vfat.h:391
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define VFAT_CASE_LOWER_EXT
Definition: vfat.h:201
NTSYSAPI NTSTATUS NTAPI RtlOemStringToUnicodeString(PUNICODE_STRING DestinationString, PCOEM_STRING SourceString, BOOLEAN AllocateDestinationString)
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
Status
Definition: gdiplustypes.h:24
#define FILE_OPEN
Definition: from_kernel.h:54
#define FCB_DELAYED_CLOSE
Definition: vfat.h:433
#define VFAT_BREAK_ON_CORRUPTION
Definition: vfat.h:401
PVFAT_GLOBAL_DATA VfatGlobalData
Definition: iface.c:40
NTSTATUS NTAPI IoCheckShareAccess(IN ACCESS_MASK DesiredAccess, IN ULONG DesiredShareAccess, IN PFILE_OBJECT FileObject, IN PSHARE_ACCESS ShareAccess, IN BOOLEAN Update)
Definition: file.c:3389
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
DIR_ENTRY entry
Definition: vfat.h:451
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
PUCHAR Attributes
Definition: vfat.h:454
#define SL_OPEN_TARGET_DIRECTORY
Definition: iotypes.h:1775
FORCEINLINE VOID vfatReportChange(IN PDEVICE_EXTENSION DeviceExt, IN PVFATFCB Fcb, IN ULONG FilterMatch, IN ULONG Action)
Definition: vfat.h:652
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
unsigned short USHORT
Definition: pedump.c:61
NTSTATUS VfatBlockDeviceIoControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG CtlCode, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferSize, IN OUT PVOID OutputBuffer OPTIONAL, IN OUT PULONG OutputBufferSize, IN BOOLEAN Override)
Definition: blockdev.c:432
#define FILE_NOTIFY_CHANGE_ATTRIBUTES
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
unsigned char lCase
Definition: vfat.h:118
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
#define VCB_IS_SYS_OR_HAS_PAGE
Definition: vfat.h:243
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
PDEVICE_OBJECT DeviceObject
Definition: vfat.h:578
Definition: vfat.h:224
ULONG Flags
Definition: vfat.h:407
ERESOURCE MainResource
Definition: vfat.h:446
#define FILE_CREATED
Definition: nt_native.h:770
#define VCB_VOLUME_LOCKED
Definition: ext2fs.h:780
#define FILE_ACTION_ADDED
#define DPRINT1
Definition: precomp.h:8
BOOLEAN vfatIsLongIllegal(WCHAR c)
Definition: string.c:22
NTSTATUS FindFile(PDEVICE_EXTENSION DeviceExt, PVFATFCB Parent, PUNICODE_STRING FileToFindU, PVFAT_DIRENTRY_CONTEXT DirContext, BOOLEAN First)
Definition: create.c:101
UNICODE_STRING PathNameU
Definition: vfat.h:466
#define LONGNAME_MAX_LENGTH
Definition: vfat.h:203
NTSTATUS VfatUpdateEntry(IN PDEVICE_EXTENSION DeviceExt, IN PVFATFCB pFcb)
Definition: dirwr.c:117
#define c
Definition: ke_i.h:80
ULONG CloseCount
Definition: vfat.h:418
unsigned int ULONG
Definition: retypes.h:1
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
VOID vfatGrabFCB(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
Definition: fcb.c:302
static NTSTATUS VfatOpenFile(PDEVICE_EXTENSION DeviceExt, PUNICODE_STRING PathNameU, PFILE_OBJECT FileObject, ULONG RequestedDisposition, ULONG RequestedOptions, PVFATFCB *ParentFcb)
Definition: create.c:275
unsigned short UpdateDate
Definition: vfat.h:127
NTSYSAPI NTSTATUS WINAPI RtlDowncaseUnicodeString(UNICODE_STRING *, const UNICODE_STRING *, BOOLEAN)
VOID vfatReleaseFCB(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
Definition: fcb.c:336
NTSTATUS vfatGetFCBForFile(PDEVICE_EXTENSION pVCB, PVFATFCB *pParentFCB, PVFATFCB *pFCB, PUNICODE_STRING pFileNameU)
Definition: fcb.c:884
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
_In_ PFCB Fcb
Definition: cdprocs.h:151
ULONG OpenHandleCount
Definition: vfat.h:505
return STATUS_SUCCESS
Definition: btrfs.c:2966
unsigned short UpdateTime
Definition: vfat.h:176
VOID vfatSplitPathName(PUNICODE_STRING PathNameU, PUNICODE_STRING DirNameU, PUNICODE_STRING FileNameU)
Definition: fcb.c:55
HRESULT Create([out]ITransactionReceiver **ppReceiver)
VOID NTAPI IoUpdateShareAccess(IN PFILE_OBJECT FileObject, OUT PSHARE_ACCESS ShareAccess)
Definition: file.c:3350
PAGED_LOOKASIDE_LIST CloseContextLookasideList
Definition: vfat.h:414
static NTSTATUS VfatCreateFile(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: create.c:424