ReactOS 0.4.15-dev-7670-g69b08be
create.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYRIGHT.TXT
3 * PROJECT: Ext2 File System Driver for WinNT/2K/XP
4 * FILE: create.c
5 * PROGRAMMER: Matt Wu <mattwu@163.com>
6 * HOMEPAGE: http://www.ext2fsd.com
7 * UPDATE HISTORY:
8 */
9
10/* INCLUDES *****************************************************************/
11
12#include "ext2fs.h"
13#include <linux/ext4_xattr.h>
14
15/* GLOBALS *****************************************************************/
16
18
19/* DEFINITIONS *************************************************************/
20
21#ifdef ALLOC_PRAGMA
22#pragma alloc_text(PAGE, Ext2IsNameValid)
23#pragma alloc_text(PAGE, Ext2FollowLink)
24#pragma alloc_text(PAGE, Ext2IsSpecialSystemFile)
25#pragma alloc_text(PAGE, Ext2LookupFile)
26#pragma alloc_text(PAGE, Ext2ScanDir)
27#pragma alloc_text(PAGE, Ext2CreateFile)
28#pragma alloc_text(PAGE, Ext2CreateVolume)
29#pragma alloc_text(PAGE, Ext2Create)
30#pragma alloc_text(PAGE, Ext2CreateInode)
31#pragma alloc_text(PAGE, Ext2SupersedeOrOverWriteFile)
32#endif
33
34
37{
38 USHORT i = 0;
39 PUSHORT pName = (PUSHORT) FileName->Buffer;
40
41 if (FileName == NULL) {
42 return FALSE;
43 }
44
45 while (i < (FileName->Length / sizeof(WCHAR))) {
46
47 if (pName[i] == 0) {
48 break;
49 }
50
51 if (pName[i] == L'|' || pName[i] == L':' ||
52 pName[i] == L'/' || pName[i] == L'*' ||
53 pName[i] == L'?' || pName[i] == L'\"' ||
54 pName[i] == L'<' || pName[i] == L'>' ) {
55
56 return FALSE;
57 }
58
59 i++;
60 }
61
62 return TRUE;
63}
64
65
68 IN PEXT2_IRP_CONTEXT IrpContext,
72 IN ULONG Linkdep
73)
74{
76
77 UNICODE_STRING UniName;
79 BOOLEAN bOemBuffer = FALSE;
80
82
83 USHORT i;
84
85 _SEH2_TRY {
86
87 RtlZeroMemory(&UniName, sizeof(UNICODE_STRING));
89
90 /* exit if we jump into a possible symlink forever loop */
91 if ((Linkdep + 1) > EXT2_MAX_NESTED_LINKS ||
92 IoGetRemainingStackSize() < 1024) {
94 }
95
96 /* read the symlink target path */
97 if (!Mcb->Inode.i_blocks) {
98
99 OemName.Buffer = (PUCHAR) (&Mcb->Inode.i_block[0]);
100 OemName.Length = (USHORT)Mcb->Inode.i_size;
101 OemName.MaximumLength = OemName.Length + 1;
102
103 } else {
104
105 OemName.Length = (USHORT)Mcb->Inode.i_size;
106 OemName.MaximumLength = OemName.Length + 1;
108 OemName.MaximumLength,
109 'NL2E');
110 if (OemName.Buffer == NULL) {
113 }
114 bOemBuffer = TRUE;
115 RtlZeroMemory(OemName.Buffer, OemName.MaximumLength);
116
118 IrpContext,
119 Vcb,
120 Mcb,
121 OemName.Buffer,
122 (ULONG)(Mcb->Inode.i_size),
123 NULL);
124 if (!NT_SUCCESS(Status)) {
126 }
127 }
128
129 /* convert Linux slash to Windows backslash */
130 for (i=0; i < OemName.Length; i++) {
131 if (OemName.Buffer[i] == '/') {
132 OemName.Buffer[i] = '\\';
133 }
134 }
135
136 /* convert oem string to unicode string */
138 if (UniName.MaximumLength <= 0) {
141 }
142
143 UniName.MaximumLength += 2;
145 UniName.MaximumLength,
146 'NL2E');
147 if (UniName.Buffer == NULL) {
150 }
151 RtlZeroMemory(UniName.Buffer, UniName.MaximumLength);
152 Status = Ext2OEMToUnicode(Vcb, &UniName, &OemName);
153 if (!NT_SUCCESS(Status)) {
156 }
157
158 /* search the real target */
160 IrpContext,
161 Vcb,
162 &UniName,
163 Parent,
164 &Target,
165 Linkdep
166 );
167 if (Target == NULL) {
169 }
170
171 if (Target == NULL /* link target doesn't exist */ ||
172 Target == Mcb /* symlink points to itself */ ||
173 IsMcbSpecialFile(Target) /* target not resolved*/ ||
174 IsFileDeleted(Target) /* target deleted */ ) {
175
176 if (Target) {
177 ASSERT(Target->Refercount > 0);
179 }
182 Mcb->Target = NULL;
183
184 } else if (IsMcbSymLink(Target)) {
185
186 ASSERT(Target->Refercount > 0);
187 ASSERT(Target->Target != NULL);
188 Ext2ReferMcb(Target->Target);
189 Mcb->Target = Target->Target;
191 ASSERT(!IsMcbSymLink(Target->Target));
194 ASSERT(Mcb->Target->Refercount > 0);
195
196 } else {
197
198 Mcb->Target = Target;
201 ASSERT(Mcb->Target->Refercount > 0);
202 }
203
204 /* add directory flag to file attribute */
205 if (Mcb->Target && IsMcbDirectory(Mcb->Target)) {
206 Mcb->FileAttr |= FILE_ATTRIBUTE_DIRECTORY;
207 }
208
209 } _SEH2_FINALLY {
210
211 if (bOemBuffer) {
212 Ext2FreePool(OemName.Buffer, 'NL2E');
213 }
214
215 if (UniName.Buffer) {
216 Ext2FreePool(UniName.Buffer, 'NL2E');
217 }
218 } _SEH2_END;
219
220 return Status;
221}
222
226 IN BOOLEAN bDirectory
227)
228{
229 PWSTR SpecialFileList[] = {
230 L"pagefile.sys",
231 L"swapfile.sys",
232 L"hiberfil.sys",
233 NULL
234 };
235
236 PWSTR SpecialDirList[] = {
237 L"Recycled",
238 L"RECYCLER",
239 L"$RECYCLE.BIN",
240 NULL
241 };
242
243 PWSTR entryName;
245 int i;
246
247 for (i = 0; TRUE; i++) {
248
249 if (bDirectory) {
250 entryName = SpecialDirList[i];
251 } else {
252 entryName = SpecialFileList[i];
253 }
254
255 if (NULL == entryName) {
256 break;
257 }
258
259 length = wcslen(entryName) * sizeof(WCHAR);
260 if (FileName->Length == length) {
261 if ( 0 == _wcsnicmp( entryName,
262 FileName->Buffer,
263 length / sizeof(WCHAR) )) {
264 return TRUE;
265 }
266 }
267 }
268
269 return FALSE;
270}
271
274 IN PEXT2_IRP_CONTEXT IrpContext,
278 OUT PEXT2_MCB * Ext2Mcb,
279 IN ULONG Linkdep
280)
281{
285 struct dentry *de = NULL;
286
287 USHORT i = 0, End;
288 ULONG Inode;
289
290 BOOLEAN bParent = FALSE;
291 BOOLEAN bDirectory = FALSE;
292 BOOLEAN LockAcquired = FALSE;
293 BOOLEAN bNotFollow = FALSE;
294
295 _SEH2_TRY {
296
298 LockAcquired = TRUE;
299
300 bNotFollow = IsFlagOn(Linkdep, EXT2_LOOKUP_NOT_FOLLOW);
301#ifndef __REACTOS__
302 Linkdep = ClearFlag(Linkdep, EXT2_LOOKUP_FLAG_MASK);
303#else
305#endif
306
307 *Ext2Mcb = NULL;
308
309 DEBUG(DL_RES, ("Ext2LookupFile: %wZ\n", FullName));
310
311 /* check names and parameters */
312 if (FullName->Buffer[0] == L'\\') {
313 Parent = Vcb->McbTree;
314 } else if (Parent) {
315 bParent = TRUE;
316 } else {
317 Parent = Vcb->McbTree;
318 }
319
320 /* make sure the parent is NULL */
321 if (!IsMcbDirectory(Parent)) {
324 }
325
326 /* use symlink's target as parent directory */
327 if (IsMcbSymLink(Parent)) {
328 Parent = Parent->Target;
330 if (IsFileDeleted(Parent)) {
333 }
334 }
335
336 if (NULL == Parent) {
339 }
340
341 /* default is the parent Mcb*/
343 Mcb = Parent;
344
345 /* is empty file name or root node */
346 End = FullName->Length/sizeof(WCHAR);
347 if ( (End == 0) || (End == 1 &&
348 FullName->Buffer[0] == L'\\')) {
351 }
352
353 /* is a directory expected ? */
354 while (FullName->Buffer[End - 1] == L'\\') {
355 bDirectory = TRUE;
356 End -= 1;
357 }
358
359 /* loop with every sub name */
360 while (i < End) {
361
362 USHORT Start = 0;
363
364 /* zero the prefix '\' */
365 while (i < End && FullName->Buffer[i] == L'\\') i++;
366 Start = i;
367
368 /* zero the suffix '\' */
369 while (i < End && (FullName->Buffer[i] != L'\\')) i++;
370
371 if (i > Start) {
372
374 FileName.Buffer += Start;
375 FileName.Length = (USHORT)((i - Start) * 2);
376
377 /* make sure the parent is NULL */
378 if (!IsMcbDirectory(Parent)) {
381 break;
382 }
383
384 if (IsMcbSymLink(Parent)) {
385 if (IsFileDeleted(Parent->Target)) {
388 break;
389 } else {
390 Ext2ReferMcb(Parent->Target);
392 Parent = Parent->Target;
393 }
394 }
395
396 /* search cached Mcb nodes */
398
399 if (Mcb) {
400
401 /* derefer the parent Mcb */
404 Parent = Mcb;
405
406 if (IsMcbSymLink(Mcb) && IsFileDeleted(Mcb->Target) &&
407 Mcb->Refercount == 1) {
408
409 ASSERT(Mcb->Target);
410 ASSERT(Mcb->Target->Refercount > 0);
411 Ext2DerefMcb(Mcb->Target);
412 Mcb->Target = NULL;
415 Mcb->FileAttr = FILE_ATTRIBUTE_NORMAL;
416 }
417
418 } else {
419
420 /* need create new Mcb node */
421
422 /* is a valid ext2 name */
423 if (!Ext2IsNameValid(&FileName)) {
426 break;
427 }
428
429 /* seach the disk */
430 de = NULL;
432 IrpContext,
433 Vcb,
434 Parent,
435 &FileName,
436 &Inode,
437 &de);
438
439 if (NT_SUCCESS(Status)) {
440
441 /* check it's real parent */
443
444 /* allocate Mcb ... */
445 Mcb = Ext2AllocateMcb(Vcb, &FileName, &Parent->FullName, 0);
446 if (!Mcb) {
449 break;
450 }
451 Mcb->de = de;
452 Mcb->de->d_inode = &Mcb->Inode;
453 Mcb->Inode.i_ino = Inode;
454 Mcb->Inode.i_sb = &Vcb->sb;
455 de = NULL;
456
457 /* load inode information */
458 if (!Ext2LoadInode(Vcb, &Mcb->Inode)) {
462 break;
463 }
464
465 /* set inode attribute */
468 }
469
470 if (S_ISDIR(Mcb->Inode.i_mode)) {
472 } else {
473 if (S_ISREG(Mcb->Inode.i_mode)) {
475 } else if (S_ISLNK(Mcb->Inode.i_mode)) {
477 } else {
479 }
480 }
481
482 /* process special files under root directory */
483 if (IsMcbRoot(Parent)) {
484 /* set hidden and system attributes for
485 Recycled / RECYCLER / pagefile.sys */
487 if (Ext2IsSpecialSystemFile(&Mcb->ShortName, IsDirectory)) {
490 }
491 }
492
493 Mcb->CreationTime = Ext2NtTime(Mcb->Inode.i_ctime);
494 Mcb->LastAccessTime = Ext2NtTime(Mcb->Inode.i_atime);
495 Mcb->LastWriteTime = Ext2NtTime(Mcb->Inode.i_mtime);
496 Mcb->ChangeTime = Ext2NtTime(Mcb->Inode.i_mtime);
497
498 /* process symlink */
499 if (S_ISLNK(Mcb->Inode.i_mode) && !bNotFollow) {
500 Ext2FollowLink( IrpContext,
501 Vcb,
502 Parent,
503 Mcb,
504 Linkdep+1
505 );
506 }
507
508 /* add reference ... */
510
511 /* add Mcb to it's parent tree*/
513
514 /* it's safe to deref Parent Mcb */
516
517 /* linking this Mcb*/
519
520 /* set parent to preare re-scan */
521 Parent = Mcb;
522
523 } else {
524
525 /* derefernce it's parent */
527 break;
528 }
529 }
530
531 } else {
532
533 /* there seems too many \ or / */
534 /* Mcb should be already set to Parent */
535 ASSERT(Mcb == Parent);
537 break;
538 }
539 }
540
541 } _SEH2_FINALLY {
542
543 if (de) {
544 Ext2FreeEntry(de);
545 }
546
547 if (NT_SUCCESS(Status)) {
548 if (bDirectory) {
549 if (IsMcbDirectory(Mcb)) {
550 *Ext2Mcb = Mcb;
551 } else {
554 }
555 } else {
556 *Ext2Mcb = Mcb;
557 }
558 }
559
560 if (LockAcquired) {
561 ExReleaseResourceLite(&Vcb->McbLock);
562 }
563 } _SEH2_END;
564
565 return Status;
566}
567
568
571 IN PEXT2_IRP_CONTEXT IrpContext,
575 OUT PULONG Inode,
576 OUT struct dentry **dentry
577)
578{
580 struct buffer_head *bh = NULL;
581 struct dentry *de = NULL;
582
584
585 DEBUG(DL_RES, ("Ext2ScanDir: %wZ\\%wZ\n", &Parent->FullName, FileName));
586
587 _SEH2_TRY {
588
589 /* grab parent's reference first */
591
592 /* bad request ! Can a man be pregnant ? Maybe:) */
593 if (!IsMcbDirectory(Parent)) {
596 }
597
598 /* parent is a symlink ? */
599 if IsMcbSymLink(Parent) {
600 if (Parent->Target) {
601 Ext2ReferMcb(Parent->Target);
603 Parent = Parent->Target;
605 } else {
606 DbgBreak();
609 }
610 }
611
613 if (!de) {
614 DEBUG(DL_ERR, ( "Ex2ScanDir: failed to allocate dentry.\n"));
617 }
618
619 bh = ext3_find_entry(IrpContext, de, &dir_entry);
620 if (dir_entry) {
622 *Inode = dir_entry->inode;
623 *dentry = de;
624 }
625
626 } _SEH2_FINALLY {
627
629
630 if (bh)
631 __brelse(bh);
632
633 if (!NT_SUCCESS(Status)) {
634 if (de)
635 Ext2FreeEntry(de);
636 }
637 } _SEH2_END;
638
639 return Status;
640}
641
643 struct inode *inode)
644{
645 struct ext3_dir_entry_2 * de;
646 struct buffer_head * bh;
647 ext3_lblk_t block = 0;
648 int rc = 0;
649
650 bh = ext3_append(icb, inode, &block, &rc);
651 if (!bh) {
652 goto errorout;
653 }
654
655 de = (struct ext3_dir_entry_2 *) bh->b_data;
657 de->name_len = 1;
659 strcpy (de->name, ".");
661 de = (struct ext3_dir_entry_2 *)
662 ((char *) de + le16_to_cpu(de->rec_len));
663 de->inode = cpu_to_le32(dir->i_ino);
664 de->rec_len = cpu_to_le16(inode->i_sb->s_blocksize-EXT3_DIR_REC_LEN(1));
665 de->name_len = 2;
666 strcpy (de->name, "..");
668 inode->i_nlink = 2;
669 set_buffer_dirty(bh);
671
672errorout:
673 if (bh)
674 __brelse (bh);
675
676 return Ext2WinntError(rc);
677}
678
679//
680// Any call to this routine must have Fcb's MainResource and FcbLock acquired.
681//
682
685 PEXT2_IRP_CONTEXT IrpContext,
689)
690{
692 PIRP Irp;
694
695 struct ext4_xattr_ref xattr_ref;
696 BOOLEAN XattrRefAcquired = FALSE;
698
701 ULONG EaBufferLength;
702
703 _SEH2_TRY {
704
705 Irp = IrpContext->Irp;
707 Mcb = Fcb->Mcb;
708
709 EaBuffer = Irp->AssociatedIrp.SystemBuffer;
710 EaBufferLength = IrpSp->Parameters.Create.EaLength;
711
712 if (!Mcb)
714
715 //
716 // Return peacefully if there is no EaBuffer provided.
717 //
718 if (!EaBuffer) {
721 }
722
723 //
724 // If the caller specifies an EaBuffer, but has no knowledge about Ea,
725 // we reject the request.
726 //
727 if (EaBuffer != NULL &&
731 }
732
733 //
734 // Check Ea Buffer validity.
735 //
737 EaBufferLength, (PULONG)&Iosb->Information);
738 if (!NT_SUCCESS(Status))
740
742 if (!NT_SUCCESS(Status)) {
743 DbgPrint("ext4_fs_get_xattr_ref() failed!\n");
745 }
746
747 XattrRefAcquired = TRUE;
748
749 //
750 // Remove all existing EA entries.
751 //
752 ext4_xattr_purge_items(&xattr_ref);
753 xattr_ref.dirty = TRUE;
755
756 // Iterate the whole EA buffer to do inspection
757 for (FullEa = (PFILE_FULL_EA_INFORMATION)EaBuffer;
758 FullEa < (PFILE_FULL_EA_INFORMATION)&EaBuffer[EaBufferLength];
759 FullEa = (PFILE_FULL_EA_INFORMATION)(FullEa->NextEntryOffset == 0 ?
760 &EaBuffer[EaBufferLength] :
761 (PCHAR)FullEa + FullEa->NextEntryOffset)) {
762
763 OEM_STRING EaName;
764
765 EaName.MaximumLength = EaName.Length = FullEa->EaNameLength;
766 EaName.Buffer = &FullEa->EaName[0];
767
768 // Check if EA's name is valid
769 if (!Ext2IsEaNameValid(EaName)) {
772 }
773 }
774
775 // Now add EA entries to the inode
776 for (FullEa = (PFILE_FULL_EA_INFORMATION)EaBuffer;
777 FullEa < (PFILE_FULL_EA_INFORMATION)&EaBuffer[EaBufferLength];
778 FullEa = (PFILE_FULL_EA_INFORMATION)(FullEa->NextEntryOffset == 0 ?
779 &EaBuffer[EaBufferLength] :
780 (PCHAR)FullEa + FullEa->NextEntryOffset)) {
781
782 int ret;
783 OEM_STRING EaName;
784
785 EaName.MaximumLength = EaName.Length = FullEa->EaNameLength;
786 EaName.Buffer = &FullEa->EaName[0];
787
789 ext4_fs_set_xattr(&xattr_ref,
791 EaName.Buffer,
792 EaName.Length,
793 &FullEa->EaName[0] + FullEa->EaNameLength + 1,
794 FullEa->EaValueLength,
795 TRUE));
796 if (!NT_SUCCESS(Status) && ret != -ENODATA)
798
799 if (ret == -ENODATA) {
801 ext4_fs_set_xattr(&xattr_ref,
803 EaName.Buffer,
804 EaName.Length,
805 &FullEa->EaName[0] + FullEa->EaNameLength + 1,
806 FullEa->EaValueLength,
807 FALSE));
808 if (!NT_SUCCESS(Status))
810
811 }
812 }
813 }
815
816 if (XattrRefAcquired) {
817 if (!NT_SUCCESS(Status)) {
818 xattr_ref.dirty = FALSE;
819 ext4_fs_put_xattr_ref(&xattr_ref);
820 } else {
822 }
823 }
824 } _SEH2_END;
825 return Status;
826}
827
832 PBOOLEAN OpPostIrp
833)
834{
839 PEXT2_MCB SymLink = NULL;
841
843 PEXT2_MCB ParentMcb = NULL;
844
846 PIRP Irp;
847
850
851 BOOLEAN bParentFcbCreated = FALSE;
852#ifndef __REACTOS__
853 BOOLEAN bDir = FALSE;
854#endif
855 BOOLEAN bFcbAllocated = FALSE;
856 BOOLEAN bCreated = FALSE;
857
858 BOOLEAN bMainResourceAcquired = FALSE;
859 BOOLEAN bFcbLockAcquired = FALSE;
860
862 BOOLEAN OpenTargetDirectory;
864 BOOLEAN SequentialOnly;
865 BOOLEAN NoIntermediateBuffering;
866 BOOLEAN IsPagingFile;
868 BOOLEAN NonDirectoryFile;
871 BOOLEAN TemporaryFile;
872 BOOLEAN CaseSensitive;
873 BOOLEAN OpenReparsePoint;
874
877 ULONG CcbFlags = 0;
878
880
881 Irp = IrpContext->Irp;
883
884 Options = IrpSp->Parameters.Create.Options;
885
887 OpenTargetDirectory = IsFlagOn(IrpSp->Flags, SL_OPEN_TARGET_DIRECTORY);
888
889 NonDirectoryFile = IsFlagOn(Options, FILE_NON_DIRECTORY_FILE);
890 SequentialOnly = IsFlagOn(Options, FILE_SEQUENTIAL_ONLY);
891 NoIntermediateBuffering = IsFlagOn( Options, FILE_NO_INTERMEDIATE_BUFFERING );
894
895 /* Try to open reparse point (symlink) itself ? */
896 OpenReparsePoint = IsFlagOn(Options, FILE_OPEN_REPARSE_POINT);
897
898 CaseSensitive = IsFlagOn(IrpSp->Flags, SL_CASE_SENSITIVE);
899
900 TemporaryFile = IsFlagOn(IrpSp->Parameters.Create.FileAttributes,
902
903 CreateDisposition = (Options >> 24) & 0x000000ff;
904
905 IsPagingFile = IsFlagOn(IrpSp->Flags, SL_OPEN_PAGING_FILE);
906
910
914
915 DesiredAccess = IrpSp->Parameters.Create.SecurityContext->DesiredAccess;
916 ShareAccess = IrpSp->Parameters.Create.ShareAccess;
917
918 *OpPostIrp = FALSE;
919
920 _SEH2_TRY {
921
922 FileName.MaximumLength = IrpSp->FileObject->FileName.MaximumLength;
923 FileName.Length = IrpSp->FileObject->FileName.Length;
924
925 if (IrpSp->FileObject->RelatedFileObject) {
926 ParentFcb = (PEXT2_FCB)(IrpSp->FileObject->RelatedFileObject->FsContext);
927 }
928
929 if (ParentFcb) {
930 ParentMcb = ParentFcb->Mcb;
931 Ext2ReferMcb(ParentMcb);
932 ParentFcb = NULL;
933 }
934
935 if (FileName.Length == 0) {
936
937 if (ParentMcb) {
938 Mcb = ParentMcb;
941 goto McbExisting;
942 } else {
943 DbgBreak();
946 }
947 }
948
949 FileName.Buffer = Ext2AllocatePool(
950 PagedPool,
951 FileName.MaximumLength,
953 );
954
955 if (!FileName.Buffer) {
956 DEBUG(DL_ERR, ( "Ex2CreateFile: failed to allocate FileName.\n"));
959 }
960
961 INC_MEM_COUNT(PS_FILE_NAME, FileName.Buffer, FileName.MaximumLength);
962
963 RtlZeroMemory(FileName.Buffer, FileName.MaximumLength);
964 RtlCopyMemory(FileName.Buffer, IrpSp->FileObject->FileName.Buffer, FileName.Length);
965
966 if (IrpSp->FileObject->RelatedFileObject && FileName.Buffer[0] == L'\\') {
969 }
970
971 if ((FileName.Length > sizeof(WCHAR)) &&
972 (FileName.Buffer[1] == L'\\') &&
973 (FileName.Buffer[0] == L'\\')) {
974
975 FileName.Length -= sizeof(WCHAR);
976
977 RtlMoveMemory( &FileName.Buffer[0],
978 &FileName.Buffer[1],
979 FileName.Length );
980
981 //
982 // Bad Name if there are still beginning backslashes.
983 //
984
985 if ((FileName.Length > sizeof(WCHAR)) &&
986 (FileName.Buffer[1] == L'\\') &&
987 (FileName.Buffer[0] == L'\\')) {
988
991 }
992 }
993
997 }
998
999 DEBUG(DL_INF, ( "Ext2CreateFile: %wZ Paging=%d Option: %xh:"
1000 "Dir=%d NonDir=%d OpenTarget=%d NC=%d DeleteOnClose=%d\n",
1001 &FileName, IsPagingFile, IrpSp->Parameters.Create.Options,
1002 DirectoryFile, NonDirectoryFile, OpenTargetDirectory,
1003 NoIntermediateBuffering, DeleteOnClose ));
1004
1005 DEBUG(DL_RES, ("Ext2CreateFile: Lookup 1st: %wZ at %S\n",
1006 &FileName, ParentMcb ? ParentMcb->FullName.Buffer : L" "));
1008 IrpContext,
1009 Vcb,
1010 &FileName,
1011 ParentMcb,
1012 &Mcb,
1013 0 /* always follow link */
1014 );
1015McbExisting:
1016
1017 if (!NT_SUCCESS(Status)) {
1018
1019 UNICODE_STRING PathName;
1020 UNICODE_STRING RealName;
1021 UNICODE_STRING RemainName;
1022
1023#ifndef __REACTOS__
1024 LONG i = 0;
1025#endif
1026
1027 PathName = FileName;
1028 Mcb = NULL;
1029
1030 /* here we've found the target file, but it's not matched. */
1034 }
1035
1036 while (PathName.Length > 0 &&
1037 PathName.Buffer[PathName.Length/2 - 1] == L'\\') {
1039 PathName.Length -= 2;
1040 PathName.Buffer[PathName.Length / 2] = 0;
1041 }
1042
1043 if (!ParentMcb) {
1044 if (PathName.Buffer[0] != L'\\') {
1047 } else {
1048 ParentMcb = Vcb->McbTree;
1049 Ext2ReferMcb(ParentMcb);
1050 }
1051 }
1052
1053Dissecting:
1054
1055 FsRtlDissectName(PathName, &RealName, &RemainName);
1056
1057 if (((RemainName.Length != 0) && (RemainName.Buffer[0] == L'\\')) ||
1058 (RealName.Length >= 256 * sizeof(WCHAR))) {
1061 }
1062
1063 if (RemainName.Length != 0) {
1064
1065 PEXT2_MCB RetMcb = NULL;
1066
1067 DEBUG(DL_RES, ("Ext2CreateFile: Lookup 2nd: %wZ\\%wZ\n",
1068 &ParentMcb->FullName, &RealName));
1069
1071 IrpContext,
1072 Vcb,
1073 &RealName,
1074 ParentMcb,
1075 &RetMcb,
1076 0);
1077
1078 /* quit name resolving loop */
1079 if (!NT_SUCCESS(Status)) {
1080 if (Status == STATUS_NO_SUCH_FILE ||
1083 }
1085 }
1086
1087 /* deref ParentMcb */
1088 Ext2DerefMcb(ParentMcb);
1089
1090 /* RetMcb is already refered */
1091 ParentMcb = RetMcb;
1092 PathName = RemainName;
1093
1094 /* symlink must use it's target */
1095 if (IsMcbSymLink(ParentMcb)) {
1096 Ext2ReferMcb(ParentMcb->Target);
1097 Ext2DerefMcb(ParentMcb);
1098 ParentMcb = ParentMcb->Target;
1099 ASSERT(!IsMcbSymLink(ParentMcb));
1100 }
1101
1102 goto Dissecting;
1103 }
1104
1105 /* is name valid */
1106 if ( FsRtlDoesNameContainWildCards(&RealName) ||
1107 !Ext2IsNameValid(&RealName)) {
1110 }
1111
1112 if (!bFcbLockAcquired) {
1114 bFcbLockAcquired = TRUE;
1115 }
1116
1117 /* get the ParentFcb, allocate it if needed ... */
1118 ParentFcb = ParentMcb->Fcb;
1119 if (!ParentFcb) {
1120 ParentFcb = Ext2AllocateFcb(Vcb, ParentMcb);
1121 if (!ParentFcb) {
1124 }
1125 bParentFcbCreated = TRUE;
1126 }
1127 Ext2ReferXcb(&ParentFcb->ReferenceCount);
1128
1129 if (bFcbLockAcquired) {
1130 ExReleaseResourceLite(&Vcb->FcbLock);
1131 bFcbLockAcquired = FALSE;
1132 }
1133
1134 // We need to create a new one ?
1135 if ((CreateDisposition == FILE_CREATE ) ||
1139
1140 if (IsVcbReadOnly(Vcb)) {
1143 }
1144
1145 if (!Ext2CheckFileAccess(Vcb, ParentMcb, Ext2FileCanWrite)) {
1148 }
1149
1150 if (IsFlagOn(Vcb->Flags, VCB_WRITE_PROTECTED)) {
1152 Vcb->Vpb->RealDevice );
1153 SetFlag(Vcb->Vpb->RealDevice->Flags, DO_VERIFY_VOLUME);
1155 }
1156
1157 if (DirectoryFile) {
1158 if (TemporaryFile) {
1159 DbgBreak();
1162 }
1163 }
1164
1165 if (!ParentFcb) {
1168 }
1169
1170 /* allocate inode and construct entry for this file */
1172 IrpContext,
1173 Vcb,
1174 ParentFcb,
1176 IrpSp->Parameters.Create.FileAttributes,
1177 &RealName
1178 );
1179
1180 if (!NT_SUCCESS(Status)) {
1181 DbgBreak();
1183 }
1184
1185 bCreated = TRUE;
1186 DEBUG(DL_RES, ("Ext2CreateFile: Confirm creation: %wZ\\%wZ\n",
1187 &ParentMcb->FullName, &RealName));
1188
1189 Irp->IoStatus.Information = FILE_CREATED;
1191 IrpContext,
1192 Vcb,
1193 &RealName,
1194 ParentMcb,
1195 &Mcb,
1196 0);
1197 if (!NT_SUCCESS(Status)) {
1198 DbgBreak();
1199 }
1200
1201 } else if (OpenTargetDirectory) {
1202
1203 if (IsVcbReadOnly(Vcb)) {
1206 }
1207
1208 if (!ParentFcb) {
1211 }
1212
1213 RtlZeroMemory( IrpSp->FileObject->FileName.Buffer,
1214 IrpSp->FileObject->FileName.MaximumLength);
1215 IrpSp->FileObject->FileName.Length = RealName.Length;
1216
1217 RtlCopyMemory( IrpSp->FileObject->FileName.Buffer,
1218 RealName.Buffer,
1219 RealName.Length );
1220
1221 Fcb = ParentFcb;
1222 Mcb = Fcb->Mcb;
1224
1225 Irp->IoStatus.Information = FILE_DOES_NOT_EXIST;
1227
1228 } else {
1229
1232 }
1233
1234 } else { // File / Dir already exists.
1235
1236 /* here already get Mcb referred */
1237 if (OpenTargetDirectory) {
1238
1239 UNICODE_STRING RealName = FileName;
1240 USHORT i = 0;
1241
1242 while (RealName.Buffer[RealName.Length/2 - 1] == L'\\') {
1243 RealName.Length -= sizeof(WCHAR);
1244 RealName.Buffer[RealName.Length/2] = 0;
1245 }
1246 i = RealName.Length/2;
1247 while (i > 0 && RealName.Buffer[i - 1] != L'\\')
1248 i--;
1249
1250 if (IsVcbReadOnly(Vcb)) {
1254 }
1255
1256 Irp->IoStatus.Information = FILE_EXISTS;
1258
1259 RtlZeroMemory( IrpSp->FileObject->FileName.Buffer,
1260 IrpSp->FileObject->FileName.MaximumLength);
1261 IrpSp->FileObject->FileName.Length = RealName.Length - i * sizeof(WCHAR);
1262 RtlCopyMemory( IrpSp->FileObject->FileName.Buffer, &RealName.Buffer[i],
1263 IrpSp->FileObject->FileName.Length );
1264
1265 // use's it's parent since it's open-target operation
1266 Ext2ReferMcb(Mcb->Parent);
1268 Mcb = Mcb->Parent;
1269
1270 goto Openit;
1271 }
1272
1273 // We can not create if one exists
1275 Irp->IoStatus.Information = FILE_EXISTS;
1279 }
1280
1281 /* directory forbits us to do the followings ... */
1282 if (IsMcbDirectory(Mcb)) {
1283
1284 if ((CreateDisposition != FILE_OPEN) &&
1286
1290 }
1291
1292 if (NonDirectoryFile) {
1296 }
1297
1298 if (Mcb->Inode.i_ino == EXT2_ROOT_INO) {
1299
1300 if (OpenTargetDirectory) {
1301 DbgBreak();
1305 }
1306 }
1307
1308 } else {
1309
1310 if (DirectoryFile) {
1314 }
1315 }
1316
1317 Irp->IoStatus.Information = FILE_OPENED;
1318 }
1319
1320Openit:
1321
1322 if (!bFcbLockAcquired) {
1324 bFcbLockAcquired = TRUE;
1325 }
1326
1327 /* Mcb should already be referred and symlink is too */
1328 if (Mcb) {
1329
1330 ASSERT(Mcb->Refercount > 0);
1331
1332 /* refer it's target if it's a symlink, so both refered */
1333 if (IsMcbSymLink(Mcb)) {
1334
1335 if (OpenReparsePoint) {
1336 /* set Ccb flag */
1337 CcbFlags = CCB_OPEN_REPARSE_POINT;
1338 } else if (IsFileDeleted(Mcb->Target)) {
1339 DbgBreak();
1342 Ext2DerefMcb(Mcb->Target);
1343 Mcb->Target = NULL;
1344 } else {
1345 SymLink = Mcb;
1346 Mcb = Mcb->Target;
1349 }
1350 }
1351
1352 // Check readonly flag
1357 }
1363 } else if (IsFlagOn(Options, FILE_DELETE_ON_CLOSE )) {
1366 }
1367 }
1368
1369 Fcb = Mcb->Fcb;
1370 if (Fcb == NULL) {
1371
1372 /* allocate Fcb for this file */
1374 if (Fcb) {
1375 bFcbAllocated = TRUE;
1376 } else {
1378 }
1379 } else {
1380 if (IsPagingFile) {
1382 Fcb = NULL;
1383 }
1384 }
1385
1386 /* Now it's safe to defer Mcb */
1388 }
1389
1390 if (Fcb) {
1391 /* grab Fcb's reference first to avoid the race between
1392 Ext2Close (it could free the Fcb we are accessing) */
1393 Ext2ReferXcb(&Fcb->ReferenceCount);
1394 }
1395
1396 ExReleaseResourceLite(&Vcb->FcbLock);
1397 bFcbLockAcquired = FALSE;
1398
1399 if (Fcb) {
1400
1402 bMainResourceAcquired = TRUE;
1403
1404 /* Open target directory ? */
1405 if (NULL == Mcb) {
1406 DbgBreak();
1407 Mcb = Fcb->Mcb;
1408 }
1409
1410 /* check Mcb reference */
1411 ASSERT(Fcb->Mcb->Refercount > 0);
1412
1413 /* file delted ? */
1414 if (IsFlagOn(Fcb->Mcb->Flags, MCB_FILE_DELETED)) {
1417 }
1418
1419 if (DeleteOnClose && NULL == SymLink) {
1421 if (!NT_SUCCESS(Status)) {
1423 }
1424 }
1425
1426 /* check access and oplock access for opened files */
1427 if (!bFcbAllocated && !IsDirectory(Fcb)) {
1428
1429 /* whether there's batch oplock grabed on the file */
1430 if (FsRtlCurrentBatchOplock(&Fcb->Oplock)) {
1431
1432 Irp->IoStatus.Information = FILE_OPBATCH_BREAK_UNDERWAY;
1433
1434 /* break the batch lock if the sharing check fails */
1435 Status = FsRtlCheckOplock( &Fcb->Oplock,
1436 IrpContext->Irp,
1437 IrpContext,
1439 Ext2LockIrp );
1440
1441 if ( Status != STATUS_SUCCESS &&
1443 *OpPostIrp = TRUE;
1445 }
1446 }
1447 }
1448
1449 if (bCreated) {
1450
1451 //
1452 // This file is just created.
1453 //
1454
1455 Status = Ext2OverwriteEa(IrpContext, Vcb, Fcb, &Irp->IoStatus);
1456 if (!NT_SUCCESS(Status)) {
1459 }
1460
1461 if (DirectoryFile) {
1462
1463 Status = Ext2AddDotEntries(IrpContext, &ParentMcb->Inode, &Mcb->Inode);
1464 if (!NT_SUCCESS(Status)) {
1467 }
1468
1469 } else {
1470
1472 Ext2TotalBlocks(Vcb, &Irp->Overlay.AllocationSize, NULL)) {
1473 DbgBreak();
1476 }
1477
1478 /* disable data blocks allocation */
1479#if 0
1480 Fcb->Header.AllocationSize.QuadPart =
1481 Irp->Overlay.AllocationSize.QuadPart;
1482
1483 if (Fcb->Header.AllocationSize.QuadPart > 0) {
1485 Vcb,
1486 Fcb->Mcb,
1487 &(Fcb->Header.AllocationSize)
1488 );
1490 if (!NT_SUCCESS(Status)) {
1491 Fcb->Header.AllocationSize.QuadPart = 0;
1493 &Fcb->Header.AllocationSize);
1495 }
1496 }
1497#endif
1498 }
1499
1500 } else {
1501
1502 //
1503 // This file alreayd exists.
1504 //
1505
1506 if (DeleteOnClose) {
1507
1508 if (IsVcbReadOnly(Vcb)) {
1511 }
1512
1513 if (IsFlagOn(Vcb->Flags, VCB_WRITE_PROTECTED)) {
1515
1517 Vcb->Vpb->RealDevice );
1518
1519 SetFlag(Vcb->Vpb->RealDevice->Flags, DO_VERIFY_VOLUME);
1520
1522 }
1523
1524 } else {
1525
1526 //
1527 // Just to Open file (Open/OverWrite ...)
1528 //
1529
1530 if ((!IsDirectory(Fcb)) && (IsFlagOn(IrpSp->FileObject->Flags,
1532 Fcb->Header.IsFastIoPossible = FastIoIsPossible;
1533
1534 if (Fcb->SectionObject.DataSectionObject != NULL) {
1535
1536 if (Fcb->NonCachedOpenCount == Fcb->OpenHandleCount) {
1537
1538 if (!IsVcbReadOnly(Vcb)) {
1539 CcFlushCache(&Fcb->SectionObject, NULL, 0, NULL);
1541 }
1542
1543 CcPurgeCacheSection(&Fcb->SectionObject,
1544 NULL,
1545 0,
1546 FALSE );
1547 }
1548 }
1549 }
1550 }
1551 }
1552
1553 if (!IsDirectory(Fcb)) {
1554
1555 if (!IsVcbReadOnly(Vcb)) {
1556 if ((CreateDisposition == FILE_SUPERSEDE) && !IsPagingFile) {
1558 } else if (((CreateDisposition == FILE_OVERWRITE) ||
1559 (CreateDisposition == FILE_OVERWRITE_IF)) && !IsPagingFile) {
1562 }
1563 }
1564
1565 if (!bFcbAllocated) {
1566
1567 //
1568 // check the oplock state of the file
1569 //
1570
1571 Status = FsRtlCheckOplock( &Fcb->Oplock,
1572 IrpContext->Irp,
1573 IrpContext,
1575 Ext2LockIrp );
1576
1577 if ( Status != STATUS_SUCCESS &&
1579 *OpPostIrp = TRUE;
1581 }
1582 }
1583 }
1584
1585 if (Fcb->OpenHandleCount > 0) {
1586
1587 /* check the shrae access conflicts */
1591 &(Fcb->ShareAccess),
1592 TRUE );
1593 if (!NT_SUCCESS(Status)) {
1595 }
1596
1597 } else {
1598
1599 /* set share access rights */
1603 &(Fcb->ShareAccess) );
1604 }
1605
1606 Ccb = Ext2AllocateCcb(CcbFlags, SymLink);
1607 if (!Ccb) {
1609 DbgBreak();
1611 }
1612
1613 if (DeleteOnClose)
1615
1616 if (SymLink)
1617 Ccb->filp.f_dentry = SymLink->de;
1618 else
1619 Ccb->filp.f_dentry = Fcb->Mcb->de;
1620
1621 Ccb->filp.f_version = Fcb->Mcb->Inode.i_version;
1623 Ext2ReferXcb(&Fcb->ReferenceCount);
1624
1625 if (!IsDirectory(Fcb)) {
1626 if (NoIntermediateBuffering) {
1627 Fcb->NonCachedOpenCount++;
1629 } else {
1631 }
1632 }
1633
1634 Ext2ReferXcb(&Vcb->OpenHandleCount);
1635 Ext2ReferXcb(&Vcb->ReferenceCount);
1636
1637 IrpSp->FileObject->FsContext = (void*) Fcb;
1638 IrpSp->FileObject->FsContext2 = (void*) Ccb;
1639 IrpSp->FileObject->PrivateCacheMap = NULL;
1640 IrpSp->FileObject->SectionObjectPointer = &(Fcb->SectionObject);
1641
1642 DEBUG(DL_INF, ( "Ext2CreateFile: %wZ OpenCount=%u ReferCount=%u NonCachedCount=%u\n",
1643 &Fcb->Mcb->FullName, Fcb->OpenHandleCount, Fcb->ReferenceCount, Fcb->NonCachedOpenCount));
1644
1646
1647 if (bCreated) {
1648
1649 if (IsDirectory(Fcb)) {
1651 IrpContext,
1652 Vcb,
1653 Fcb->Mcb,
1656 } else {
1658 IrpContext,
1659 Vcb,
1660 Fcb->Mcb,
1663 }
1664
1665 } else if (!IsDirectory(Fcb)) {
1666
1667 if ( DeleteOnClose ||
1671 if (!MmFlushImageSection( &Fcb->SectionObject,
1672 MmFlushForWrite )) {
1673
1677 }
1678 }
1679
1683
1684 if (IsDirectory(Fcb)) {
1687 }
1688
1689 if (SymLink != NULL) {
1690 DbgBreak();
1693 }
1694
1695 if (IsVcbReadOnly(Vcb)) {
1698 }
1699
1700 if (IsFlagOn(Vcb->Flags, VCB_WRITE_PROTECTED)) {
1701
1703 Vcb->Vpb->RealDevice );
1704 SetFlag(Vcb->Vpb->RealDevice->Flags, DO_VERIFY_VOLUME);
1706 }
1707
1709 IrpContext,
1711 Vcb,
1712 Fcb,
1713 &Irp->Overlay.AllocationSize,
1715
1716 if (!NT_SUCCESS(Status)) {
1717 DbgBreak();
1719 }
1720
1722 IrpContext,
1723 Vcb,
1724 Fcb->Mcb,
1729
1730
1732 Irp->IoStatus.Information = FILE_SUPERSEDED;
1733 } else {
1734 Irp->IoStatus.Information = FILE_OVERWRITTEN;
1735 }
1736 }
1737 }
1738
1739 } else {
1740 DbgBreak();
1742 }
1743
1744 } _SEH2_FINALLY {
1745
1746 if (bFcbLockAcquired) {
1747 ExReleaseResourceLite(&Vcb->FcbLock);
1748 }
1749
1750 if (ParentMcb) {
1751 Ext2DerefMcb(ParentMcb);
1752 }
1753
1754 /* cleanup Fcb and Ccb, Mcb if necessary */
1755 if (!NT_SUCCESS(Status)) {
1756
1757 if (Ccb != NULL) {
1758
1759 DbgBreak();
1760
1761 ASSERT(Fcb != NULL);
1762 ASSERT(Fcb->Mcb != NULL);
1763
1764 DEBUG(DL_ERR, ("Ext2CreateFile: failed to create %wZ status = %xh\n",
1765 &Fcb->Mcb->FullName, Status));
1766
1768 Ext2DerefXcb(&Fcb->ReferenceCount);
1769
1770 if (!IsDirectory(Fcb)) {
1771 if (NoIntermediateBuffering) {
1772 Fcb->NonCachedOpenCount--;
1773 } else {
1775 }
1776 }
1777
1778 Ext2DerefXcb(&Vcb->OpenHandleCount);
1779 Ext2DerefXcb(&Vcb->ReferenceCount);
1780
1782
1783 IrpSp->FileObject->FsContext = NULL;
1784 IrpSp->FileObject->FsContext2 = NULL;
1785 IrpSp->FileObject->PrivateCacheMap = NULL;
1786 IrpSp->FileObject->SectionObjectPointer = NULL;
1787
1789 }
1790
1791 if (Fcb != NULL) {
1792
1796 _SEH2_TRY {
1797 Size.QuadPart = 0;
1799 } _SEH2_FINALLY {
1801 } _SEH2_END;
1802 }
1803
1804 if (bCreated) {
1806 }
1807 }
1808 }
1809
1810 if (bMainResourceAcquired) {
1812 }
1813
1814 /* free file name buffer */
1815 if (FileName.Buffer) {
1816 DEC_MEM_COUNT(PS_FILE_NAME, FileName.Buffer, FileName.MaximumLength);
1818 }
1819
1820 /* dereference Fcb and parent */
1821 if (Fcb) {
1823 }
1824 if (ParentFcb) {
1826 }
1827
1828 /* drop SymLink's refer: If succeeds, Ext2AllocateCcb should refer
1829 it already. It fails, we need release the refer to let it freed */
1830 if (SymLink) {
1831 Ext2DerefMcb(SymLink);
1832 }
1833 } _SEH2_END;
1834
1835 return Status;
1836}
1837
1840{
1842 PIRP Irp;
1843 PEXT2_CCB Ccb;
1844
1846
1849
1850 ULONG Options;
1852 BOOLEAN OpenTargetDirectory;
1853
1855
1856 Irp = IrpContext->Irp;
1858
1859 Options = IrpSp->Parameters.Create.Options;
1860
1862 OpenTargetDirectory = IsFlagOn(IrpSp->Flags, SL_OPEN_TARGET_DIRECTORY);
1863
1864 CreateDisposition = (Options >> 24) & 0x000000ff;
1865
1866 DesiredAccess = IrpSp->Parameters.Create.SecurityContext->DesiredAccess;
1867 ShareAccess = IrpSp->Parameters.Create.ShareAccess;
1868
1869 if (DirectoryFile) {
1871 }
1872
1873 if (OpenTargetDirectory) {
1874 DbgBreak();
1876 }
1877
1878 if ( (CreateDisposition != FILE_OPEN) &&
1880 return STATUS_ACCESS_DENIED;
1881 }
1882
1884 Vcb->OpenVolumeCount != 0 ) {
1886 }
1887
1888 Ccb = Ext2AllocateCcb(0, NULL);
1889 if (Ccb == NULL) {
1891 goto errorout;
1892 }
1893
1895
1896 if (Vcb->OpenVolumeCount > 0) {
1899 &(Vcb->ShareAccess), TRUE);
1900
1901 if (!NT_SUCCESS(Status)) {
1902 goto errorout;
1903 }
1904 } else {
1907 &(Vcb->ShareAccess) );
1908 }
1909
1910
1911 if (Vcb->OpenVolumeCount == 0 &&
1914
1915 if (!IsVcbReadOnly(Vcb)) {
1918 }
1919
1921 Vcb->LockFile = IrpSp->FileObject;
1922 } else {
1923
1926 if (!IsVcbReadOnly(Vcb)) {
1929 }
1930 }
1931 }
1932
1934 IrpSp->FileObject->FsContext = Vcb;
1935 IrpSp->FileObject->FsContext2 = Ccb;
1936 IrpSp->FileObject->Vpb = Vcb->Vpb;
1937
1938 Ext2ReferXcb(&Vcb->ReferenceCount);
1939 Ext2ReferXcb(&Vcb->OpenHandleCount);
1940 Ext2ReferXcb(&Vcb->OpenVolumeCount);
1941
1942 Irp->IoStatus.Information = FILE_OPENED;
1943
1944errorout:
1945
1946 return Status;
1947}
1948
1949
1952{
1954 PIRP Irp;
1956 PEXT2_VCB Vcb = 0;
1958 PEXT2_FCBVCB Xcb = NULL;
1959 BOOLEAN PostIrp = FALSE;
1960 BOOLEAN VcbResourceAcquired = FALSE;
1961
1963 Irp = IrpContext->Irp;
1965
1966 Xcb = (PEXT2_FCBVCB) (IrpSp->FileObject->FsContext);
1967
1969
1970 DEBUG(DL_INF, ( "Ext2Create: Create on main device object.\n"));
1971
1973 Irp->IoStatus.Information = FILE_OPENED;
1974
1976
1977 return Status;
1978 }
1979
1980 _SEH2_TRY {
1981
1982 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
1983 ASSERT(Vcb->Identifier.Type == EXT2VCB);
1984 IrpSp->FileObject->Vpb = Vcb->Vpb;
1985
1986 if (!IsMounted(Vcb)) {
1987 DbgBreak();
1988 if (IsFlagOn(Vcb->Flags, VCB_DEVICE_REMOVED)) {
1990 } else {
1992 }
1994 }
1995
1997 &Vcb->MainResource, TRUE)) {
2000 }
2001 VcbResourceAcquired = TRUE;
2002
2004
2005 if (FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED)) {
2007 if (IsFlagOn(Vcb->Flags, VCB_DISMOUNT_PENDING)) {
2009 }
2011 }
2012
2013 if ( ((IrpSp->FileObject->FileName.Length == 0) &&
2014 (IrpSp->FileObject->RelatedFileObject == NULL)) ||
2015 (Xcb && Xcb->Identifier.Type == EXT2VCB) ) {
2017 } else {
2018
2019 Status = Ext2CreateFile(IrpContext, Vcb, &PostIrp);
2020 }
2021
2022 } _SEH2_FINALLY {
2023
2024 if (VcbResourceAcquired) {
2025 ExReleaseResourceLite(&Vcb->MainResource);
2026 }
2027
2028 if (!IrpContext->ExceptionInProgress && !PostIrp) {
2029 if ( Status == STATUS_PENDING ||
2032 } else {
2034 }
2035 }
2036 } _SEH2_END;
2037
2038 return Status;
2039}
2040
2044 PEXT2_VCB Vcb,
2046 ULONG Type,
2049{
2051 ULONG iGrp;
2052 ULONG iNo;
2053 struct inode Inode = { 0 };
2054 struct dentry *Dentry = NULL;
2055 struct ext3_super_block *es = EXT3_SB(&Vcb->sb)->s_es;
2056
2057 LARGE_INTEGER SysTime;
2058
2059 iGrp = (Parent->Inode->i_ino - 1) / BLOCKS_PER_GROUP;
2060
2061 DEBUG(DL_INF, ("Ext2CreateInode: %S in %S(Inode=%xh)\n",
2062 FileName->Buffer,
2063 Parent->Mcb->ShortName.Buffer,
2064 Parent->Inode->i_ino));
2065
2066 Status = Ext2NewInode(IrpContext, Vcb, iGrp, Type, &iNo);
2067 if (!NT_SUCCESS(Status)) {
2068 goto errorout;
2069 }
2070
2071 KeQuerySystemTime(&SysTime);
2072 Ext2ClearInode(IrpContext, Vcb, iNo);
2073 Inode.i_sb = &Vcb->sb;
2074 Inode.i_ino = iNo;
2075 Inode.i_ctime = Inode.i_mtime =
2076 Inode.i_atime = Ext2LinuxTime(SysTime);
2077 if (IsFlagOn(Vcb->Flags, VCB_USER_IDS)) {
2078 Inode.i_uid = Vcb->uid;
2079 Inode.i_gid = Vcb->gid;
2080 } else {
2081 Inode.i_uid = Parent->Mcb->Inode.i_uid;
2082 Inode.i_gid = Parent->Mcb->Inode.i_gid;
2083 }
2084 Inode.i_generation = Parent->Inode->i_generation;
2085 Inode.i_mode = S_IPERMISSION_MASK &
2086 Parent->Inode->i_mode;
2087 if (Type == EXT2_FT_DIR) {
2088 Inode.i_mode |= S_IFDIR;
2089 } else if (Type == EXT2_FT_REG_FILE) {
2090 Inode.i_mode &= S_IFATTR;
2091 Inode.i_mode |= S_IFREG;
2092 } else {
2093 DbgBreak();
2094 }
2095 if (le16_to_cpu(es->s_want_extra_isize))
2096 Inode.i_extra_isize = le16_to_cpu(es->s_want_extra_isize);
2097
2098 /* Force using extent */
2099 if (IsFlagOn(SUPER_BLOCK->s_feature_incompat, EXT4_FEATURE_INCOMPAT_EXTENTS)) {
2100 Inode.i_flags |= EXT2_EXTENTS_FL;
2101 ext4_ext_tree_init(IrpContext, NULL, &Inode);
2102 /* ext4_ext_tree_init will save inode body */
2103 } else {
2104 /* save inode body to cache */
2105 Ext2SaveInode(IrpContext, Vcb, &Inode);
2106 }
2107
2108 /* add new entry to its parent */
2110 IrpContext,
2111 Vcb,
2112 Parent,
2113 &Inode,
2114 FileName,
2115 &Dentry
2116 );
2117
2118 if (!NT_SUCCESS(Status)) {
2119 DbgBreak();
2120 Ext2FreeInode(IrpContext, Vcb, iNo, Type);
2121 goto errorout;
2122 }
2123
2124 DEBUG(DL_INF, ("Ext2CreateInode: New Inode = %xh (Type=%xh)\n",
2125 Inode.i_ino, Type));
2126
2127errorout:
2128
2129 if (Dentry)
2130 Ext2FreeEntry(Dentry);
2131
2132 return Status;
2133}
2134
2135
2138 IN PEXT2_IRP_CONTEXT IrpContext,
2144)
2145{
2146 LARGE_INTEGER CurrentTime;
2148
2149 KeQuerySystemTime(&CurrentTime);
2150
2151 Size.QuadPart = 0;
2152 if (!MmCanFileBeTruncated(&(Fcb->SectionObject), &(Size))) {
2154 }
2155
2156 /* purge all file cache and shrink cache windows size */
2157 CcPurgeCacheSection(&Fcb->SectionObject, NULL, 0, FALSE);
2158 Fcb->Header.AllocationSize.QuadPart =
2159 Fcb->Header.FileSize.QuadPart =
2160 Fcb->Header.ValidDataLength.QuadPart = 0;
2162 (PCC_FILE_SIZES)&Fcb->Header.AllocationSize);
2163
2164 Size.QuadPart = CEILING_ALIGNED(ULONGLONG,
2165 (ULONGLONG)AllocationSize->QuadPart,
2167
2168 if ((loff_t)Size.QuadPart > Fcb->Inode->i_size) {
2169 Ext2ExpandFile(IrpContext, Vcb, Fcb->Mcb, &Size);
2170 } else {
2171 Ext2TruncateFile(IrpContext, Vcb, Fcb->Mcb, &Size);
2172 }
2173
2174 Fcb->Header.AllocationSize = Size;
2175 if (Fcb->Header.AllocationSize.QuadPart > 0) {
2178 (PCC_FILE_SIZES)&Fcb->Header.AllocationSize );
2179 }
2180
2181 /* remove all extent mappings */
2182 DEBUG(DL_EXT, ("Ext2SuperSede ...: %wZ\n", &Fcb->Mcb->FullName));
2183 Fcb->Inode->i_size = 0;
2184
2185 if (Disposition == FILE_SUPERSEDE) {
2186 Fcb->Inode->i_ctime = Ext2LinuxTime(CurrentTime);
2187 }
2188 Fcb->Inode->i_atime =
2189 Fcb->Inode->i_mtime = Ext2LinuxTime(CurrentTime);
2190 Ext2SaveInode(IrpContext, Vcb, Fcb->Inode);
2191
2192 // See if we need to overwrite EA of the file
2193 return Ext2OverwriteEa(IrpContext, Vcb, Fcb, &IrpContext->Irp->IoStatus);
2194}
unsigned char BOOLEAN
Type
Definition: Type.h:7
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx 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:732
#define S_IFDIR
Definition: acwin.h:115
unsigned int dir
Definition: maze.c:112
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define FILE_DELETE_ON_CLOSE
Definition: constants.h:494
#define DEBUG(args)
Definition: rdesktop.h:129
#define S_ISDIR(mode)
Definition: various.h:18
#define S_ISREG(mode)
Definition: various.h:17
#define EXT2_ROOT_INO
Definition: ext2.h:177
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
Definition: cachesub.c:222
_In_ PFCB ParentFcb
Definition: cdprocs.h:736
_In_ PFCB Fcb
Definition: cdprocs.h:159
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
Definition: bufpool.h:45
_In_ PIRP Irp
Definition: csq.h:116
#define BLOCK_SIZE
Definition: dlist.c:220
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
#define PS_FILE_NAME
Definition: common.h:24
#define ENODATA
Definition: errno.h:65
#define EXT2_EXTENTS_FL
Definition: ext2_fs.h:207
unsigned __int64 loff_t
Definition: types.h:84
NTSTATUS Ext2CreateInode(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Parent, ULONG Type, ULONG FileAttr, PUNICODE_STRING FileName)
Definition: create.c:2042
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
NTSTATUS Ext2OverwriteEa(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PIO_STATUS_BLOCK Iosb)
Definition: create.c:684
NTSTATUS Ext2Create(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: create.c:1951
NTSTATUS Ext2SupersedeOrOverWriteFile(IN PEXT2_IRP_CONTEXT IrpContext, IN PFILE_OBJECT FileObject, IN PEXT2_VCB Vcb, IN PEXT2_FCB Fcb, IN PLARGE_INTEGER AllocationSize, IN ULONG Disposition)
Definition: create.c:2137
BOOLEAN Ext2IsSpecialSystemFile(IN PUNICODE_STRING FileName, IN BOOLEAN bDirectory)
Definition: create.c:224
NTSTATUS Ext2ScanDir(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Parent, IN PUNICODE_STRING FileName, OUT PULONG Inode, OUT struct dentry **dentry)
Definition: create.c:570
NTSTATUS Ext2CreateFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PBOOLEAN OpPostIrp)
Definition: create.c:829
BOOLEAN Ext2IsNameValid(PUNICODE_STRING FileName)
Definition: create.c:36
NTSTATUS Ext2AddDotEntries(struct ext2_icb *icb, struct inode *dir, struct inode *inode)
Definition: create.c:642
NTSTATUS Ext2CreateVolume(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb)
Definition: create.c:1839
NTSTATUS Ext2LookupFile(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PUNICODE_STRING FullName, IN PEXT2_MCB Parent, OUT PEXT2_MCB *Ext2Mcb, IN ULONG Linkdep)
Definition: create.c:273
NTSTATUS Ext2FollowLink(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Parent, IN PEXT2_MCB Mcb, IN ULONG Linkdep)
Definition: create.c:67
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT _In_ ULONG _In_ BOOLEAN _In_ BOOLEAN DeleteOnClose
Definition: create.c:4150
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT _In_ ULONG _In_ BOOLEAN NoEaKnowledge
Definition: create.c:4149
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT ShareAccess
Definition: create.c:4147
return Iosb
Definition: create.c:4402
#define DO_VERIFY_VOLUME
Definition: env_spec_w32.h:393
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
#define PagedPool
Definition: env_spec_w32.h:308
VOID Ext2FreeMcb(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
Definition: memory.c:1538
VOID Ext2FreePool(IN PVOID P, IN ULONG Tag)
Definition: debug.c:2697
#define ClearFlag(_F, _SF)
Definition: ext2fs.h:191
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define VCB_VOLUME_LOCKED
Definition: ext2fs.h:789
#define IsMcbSymLink(Mcb)
Definition: ext2fs.h:962
NTSTATUS Ext2IsFileRemovable(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Fcb, IN PEXT2_CCB Ccb)
Definition: fileinfo.c:1239
#define VCB_WRITE_PROTECTED
Definition: ext2fs.h:805
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
VOID Ext2OplockComplete(IN PVOID Context, IN PIRP Irp)
Definition: dispatch.c:45
#define Ext2FileCanWrite
Definition: ext2fs.h:432
VOID Ext2ReleaseFcb(IN PEXT2_FCB Fcb)
Definition: memory.c:276
#define S_IFREG
Definition: ext2fs.h:361
#define Ext2RaiseStatus(IRPCONTEXT, STATUS)
Definition: ext2fs.h:263
NTSTATUS Ext2WinntError(int rc)
Definition: misc.c:410
#define Ext2FileCanRead
Definition: ext2fs.h:431
#define IsMcbSpecialFile(Mcb)
Definition: ext2fs.h:964
#define EXT2_LOOKUP_NOT_FOLLOW
Definition: ext2fs.h:1380
static ext3_fsblk_t ext3_free_blocks_count(struct ext3_super_block *es)
Definition: ext2fs.h:1757
PVOID Ext2AllocatePool(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: debug.c:2684
int ext3_mark_inode_dirty(struct ext2_icb *icb, struct inode *in)
Definition: htree.c:360
@ EXT2VCB
Definition: ext2fs.h:462
struct buffer_head * ext3_find_entry(struct ext2_icb *icb, struct dentry *dentry, struct ext3_dir_entry_2 **res_dir)
Definition: htree.c:2166
#define IsDirectory(Fcb)
Definition: ext2fs.h:283
#define IsVcbReadOnly(Vcb)
Definition: ext2fs.h:814
#define IsFileDeleted(Mcb)
Definition: ext2fs.h:968
#define IsMounted(Vcb)
Definition: ext2fs.h:812
NTSTATUS Ext2TruncateFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER AllocationSize)
Definition: fileinfo.c:1204
#define DL_EXT
Definition: ext2fs.h:1443
NTSTATUS Ext2FreeInode(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Inode, IN ULONG Type)
Definition: generic.c:1766
#define EXT2_MAX_NESTED_LINKS
Definition: ext2fs.h:75
LARGE_INTEGER Ext2NtTime(IN ULONG i_time)
Definition: misc.c:40
#define EXT2_FNAME_MAGIC
Definition: ext2fs.h:298
#define EXT2_LOOKUP_FLAG_MASK
Definition: ext2fs.h:1379
BOOLEAN Ext2SaveInode(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN struct inode *Inode)
Definition: generic.c:552
PEXT2_MCB Ext2SearchMcbWithoutLock(PEXT2_MCB Parent, PUNICODE_STRING FileName)
Definition: memory.c:1622
NTSTATUS Ext2DeleteFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_MCB Mcb)
Definition: fileinfo.c:1920
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:616
NTSTATUS Ext2QueueRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:158
#define S_IPERMISSION_MASK
Definition: ext2fs.h:380
#define Ext2ReferXcb(_C)
Definition: ext2fs.h:976
#define CCB_OPEN_REPARSE_POINT
Definition: ext2fs.h:1034
#define DEC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:608
#define IsMcbRoot(Mcb)
Definition: ext2fs.h:965
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:258
#define DL_INF
Definition: ext2fs.h:1436
NTSTATUS Ext2OEMToUnicode(IN PEXT2_VCB Vcb, IN OUT PUNICODE_STRING Oem, IN POEM_STRING Unicode)
Definition: misc.c:206
#define VCB_DISMOUNT_PENDING
Definition: ext2fs.h:791
VOID Ext2LinkTailMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb)
Definition: memory.c:2912
#define FCB_FILE_MODIFIED
Definition: ext2fs.h:882
struct dentry * Ext2BuildEntry(PEXT2_VCB Vcb, PEXT2_MCB Dcb, PUNICODE_STRING FileName)
Definition: memory.c:444
NTSTATUS Ext2ReadSymlink(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN PVOID Buffer, IN ULONG Size, OUT PULONG BytesRead)
Definition: fsctl.c:1364
#define BLOCKS_PER_GROUP
Definition: ext2fs.h:100
ULONG Ext2LinuxTime(IN LARGE_INTEGER SysTime)
Definition: misc.c:51
#define SUPER_BLOCK
Definition: ext2fs.h:90
#define ClearLongFlag(_F, _SF)
Definition: ext2fs.h:259
#define S_ISLNK(m)
Definition: ext2fs.h:373
#define Ext2DerefMcb(Mcb)
Definition: ext2fs.h:996
struct _EXT2_FCBVCB * PEXT2_FCBVCB
VOID Ext2VerifyVcb(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: fsctl.c:2277
VOID Ext2NotifyReportChange(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Filter, IN ULONG Action)
Definition: dirctl.c:1209
#define MCB_TYPE_SYMLINK
Definition: ext2fs.h:959
#define IsMcbDirectory(Mcb)
Definition: ext2fs.h:967
struct buffer_head * ext3_append(struct ext2_icb *icb, struct inode *inode, ext3_lblk_t *block, int *err)
Definition: htree.c:279
#define MCB_TYPE_SPECIAL
Definition: ext2fs.h:958
#define DbgBreak()
Definition: ext2fs.h:46
#define FCB_ALLOC_IN_CREATE
Definition: ext2fs.h:884
void ext3_set_de_type(struct super_block *sb, struct ext3_dir_entry_2 *de, umode_t mode)
Definition: htree.c:347
#define VCB_DEVICE_REMOVED
Definition: ext2fs.h:800
struct _EXT2_VCB * PEXT2_VCB
BOOLEAN Ext2IsEaNameValid(IN OEM_STRING Name)
Definition: ea.c:389
PEXT2_CCB Ext2AllocateCcb(ULONG Flags, PEXT2_MCB SymLink)
Definition: memory.c:320
VOID Ext2LockIrp(IN PVOID Context, IN PIRP Irp)
Definition: dispatch.c:94
BOOLEAN Ext2LoadInode(IN PEXT2_VCB Vcb, IN struct inode *Inode)
Definition: generic.c:508
#define CCB_DELETE_ON_CLOSE
Definition: ext2fs.h:1035
PEXT2_MCB Ext2AllocateMcb(IN PEXT2_VCB Vcb, IN PUNICODE_STRING FileName, IN PUNICODE_STRING Parent, IN ULONG FileAttr)
Definition: memory.c:1430
#define VCB_USER_IDS
Definition: ext2fs.h:794
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
#define DL_ERR
Definition: ext2fs.h:1434
NTSTATUS Ext2ExpandFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
Definition: fileinfo.c:1152
VOID Ext2FreeCcb(IN PEXT2_VCB Vcb, IN PEXT2_CCB Ccb)
Definition: memory.c:356
struct _EXT2_FCB * PEXT2_FCB
#define CEILING_ALIGNED(T, A, B)
Definition: ext2fs.h:111
NTSTATUS Ext2AddEntry(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Dcb, IN struct inode *Inode, IN PUNICODE_STRING FileName, OUT struct dentry **dentry)
BOOLEAN Ext2ClearInode(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG inode)
Definition: generic.c:530
VOID Ext2FreeEntry(IN struct dentry *de)
Definition: memory.c:432
NTSTATUS Ext2NewInode(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG GroupHint, IN ULONG Type, OUT PULONG Inode)
Definition: generic.c:1366
ULONG Ext2OEMToUnicodeSize(IN PEXT2_VCB Vcb, IN PANSI_STRING Oem)
Definition: misc.c:183
#define Ext2ReferMcb(Mcb)
Definition: ext2fs.h:995
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
#define MCB_FILE_DELETED
Definition: ext2fs.h:955
NTSTATUS Ext2FlushFiles(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:112
#define INC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:607
#define S_IFATTR
Definition: ext2fs.h:405
PEXT2_FCB Ext2AllocateFcb(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
Definition: memory.c:131
VOID Ext2InsertMcb(PEXT2_VCB Vcb, PEXT2_MCB Parent, PEXT2_MCB Child)
Definition: memory.c:1686
#define DL_RES
Definition: ext2fs.h:1440
NTSTATUS Ext2FlushVolume(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:43
ULONG Ext2TotalBlocks(PEXT2_VCB Vcb, PLARGE_INTEGER Size, PULONG pMeta)
Definition: fileinfo.c:1077
int Ext2CheckFileAccess(PEXT2_VCB Vcb, PEXT2_MCB Mcb, int attempt)
Definition: access.c:51
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define Ext2DerefXcb(_C)
Definition: ext2fs.h:977
#define EXT4_FEATURE_INCOMPAT_EXTENTS
Definition: ext3_fs.h:709
#define EXT3_SB(sb)
Definition: ext3_fs.h:615
#define EXT3_DIR_REC_LEN(len)
Definition: ext3_fs.h:867
__u32 ext3_lblk_t
Definition: ext3_fs_i.h:30
int ext4_ext_tree_init(void *icb, handle_t *handle, struct inode *inode)
Extended Attribute manipulation.
@ DirectoryFile
Definition: fatprocs.h:1046
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:322
IN PDCB IN POEM_STRING OemName
Definition: fatprocs.h:1304
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:348
struct _FileName FileName
Definition: fatprocs.h:896
#define _SEH2_FINALLY
Definition: filesup.c:21
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _FILE_FULL_EA_INFORMATION * PFILE_FULL_EA_INFORMATION
#define FILE_OPEN_BY_FILE_ID
Definition: from_kernel.h:41
#define FILE_OPEN
Definition: from_kernel.h:54
#define FILE_CREATE
Definition: from_kernel.h:55
#define FILE_OVERWRITE_IF
Definition: from_kernel.h:58
#define FILE_OPEN_REPARSE_POINT
Definition: from_kernel.h:46
#define FILE_NO_EA_KNOWLEDGE
Definition: from_kernel.h:36
#define FILE_NO_INTERMEDIATE_BUFFERING
Definition: from_kernel.h:28
#define FILE_OVERWRITE
Definition: from_kernel.h:57
#define FILE_OPEN_IF
Definition: from_kernel.h:56
#define FILE_SEQUENTIAL_ONLY
Definition: from_kernel.h:27
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
@ FastIoIsPossible
Definition: fsrtltypes.h:241
VOID NTAPI CcSetFileSizes(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
Definition: fssup.c:356
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
Definition: fssup.c:386
Status
Definition: gdiplustypes.h:25
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int ext4_fs_set_xattr(struct ext4_xattr_ref *ref, __u8 name_index, const char *name, size_t name_len, const void *data, size_t data_size, BOOL replace)
Definition: ext4_xattr.c:1024
void ext4_xattr_purge_items(struct ext4_xattr_ref *xattr_ref)
Definition: ext4_xattr.c:736
#define EXT4_XATTR_INDEX_USER
Definition: ext4_xattr.h:52
int ext4_fs_put_xattr_ref(struct ext4_xattr_ref *ref)
Definition: ext4_xattr.c:1176
int ext4_fs_get_xattr_ref(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB fs, PEXT2_MCB inode_ref, struct ext4_xattr_ref *ref)
Definition: ext4_xattr.c:1105
#define DbgPrint
Definition: hal.h:12
#define es
Definition: i386-dis.c:440
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
HRESULT Create([out]ITransactionReceiver **ppReceiver)
if(dx< 0)
Definition: linetemp.h:194
#define ASSERT(a)
Definition: mode.c:44
#define le16_to_cpu
Definition: module.h:151
#define cpu_to_le32
Definition: module.h:148
void __brelse(struct buffer_head *)
Definition: linux.c:808
#define cpu_to_le16
Definition: module.h:150
static LPSTR pName
Definition: security.c:75
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_DOES_NOT_EXIST
Definition: nt_native.h:773
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define FILE_READ_DATA
Definition: nt_native.h:628
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define FILE_DELETE_CHILD
Definition: nt_native.h:645
#define FILE_CREATED
Definition: nt_native.h:770
#define FILE_OVERWRITTEN
Definition: nt_native.h:771
#define FILE_SUPERSEDED
Definition: nt_native.h:768
#define FILE_EXISTS
Definition: nt_native.h:772
#define FILE_WRITE_ATTRIBUTES
Definition: nt_native.h:649
#define FILE_APPEND_DATA
Definition: nt_native.h:634
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define DELETE
Definition: nt_native.h:57
#define FILE_OPENED
Definition: nt_native.h:769
#define FILE_ADD_SUBDIRECTORY
Definition: nt_native.h:635
#define FILE_GENERIC_READ
Definition: nt_native.h:653
#define FILE_WRITE_EA
Definition: nt_native.h:640
#define FILE_ATTRIBUTE_TEMPORARY
Definition: nt_native.h:708
#define FILE_ATTRIBUTE_REPARSE_POINT
Definition: ntifs_ex.h:381
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
BOOLEAN NTAPI FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name)
Definition: name.c:464
VOID NTAPI FsRtlDissectName(IN UNICODE_STRING Name, OUT PUNICODE_STRING FirstPart, OUT PUNICODE_STRING RemainingPart)
Definition: name.c:398
VOID NTAPI IoSetShareAccess(IN ACCESS_MASK DesiredAccess, IN ULONG DesiredShareAccess, IN PFILE_OBJECT FileObject, OUT PSHARE_ACCESS ShareAccess)
Definition: file.c:3517
NTSTATUS NTAPI IoCheckShareAccess(IN ACCESS_MASK DesiredAccess, IN ULONG DesiredShareAccess, IN PFILE_OBJECT FileObject, IN PSHARE_ACCESS ShareAccess, IN BOOLEAN Update)
Definition: file.c:3390
VOID NTAPI IoRemoveShareAccess(IN PFILE_OBJECT FileObject, IN PSHARE_ACCESS ShareAccess)
Definition: file.c:3478
VOID NTAPI IoSetHardErrorOrVerifyDevice(IN PIRP Irp, IN PDEVICE_OBJECT DeviceObject)
Definition: util.c:316
NTSTATUS NTAPI IoCheckEaBufferValidity(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: util.c:191
#define STATUS_CANT_WAIT
Definition: ntstatus.h:452
#define STATUS_INVALID_EA_NAME
Definition: ntstatus.h:199
#define STATUS_VOLUME_DISMOUNTED
Definition: ntstatus.h:747
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_USER_MAPPED_FILE
Definition: ntstatus.h:711
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define STATUS_OPLOCK_BREAK_IN_PROGRESS
Definition: ntstatus.h:87
#define STATUS_LINK_FAILED
Definition: ntstatus.h:554
#define L(x)
Definition: ntvdm.h:50
BOOLEAN NTAPI FsRtlCurrentBatchOplock(IN POPLOCK Oplock)
Definition: oplock.c:1364
NTSTATUS NTAPI FsRtlCheckOplock(IN POPLOCK Oplock, IN PIRP Irp, IN PVOID Context, IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL)
Definition: oplock.c:1170
#define BOOLEAN
Definition: pedump.c:73
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
#define Vcb
Definition: cdprocs.h:1415
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
@ OpenDirectory
Definition: arc.h:73
#define EXT2_FT_DIR
Definition: ext2_fs.h:531
#define EXT2_FT_REG_FILE
Definition: ext2_fs.h:530
BOOLEAN NTAPI MmCanFileBeTruncated(_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer, _In_opt_ PLARGE_INTEGER NewFileSize)
Definition: section.c:4255
BOOLEAN NTAPI MmFlushImageSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN MMFLUSH_TYPE FlushType)
Definition: section.c:4356
#define STATUS_CANNOT_DELETE
Definition: shellext.h:71
#define STATUS_SUCCESS
Definition: shellext.h:65
EXT2_IDENTIFIER Identifier
Definition: ext2fs.h:633
EXT2_IDENTIFIER_TYPE Type
Definition: ext2fs.h:477
struct dentry * de
Definition: ext2fs.h:946
PEXT2_FCB Fcb
Definition: ext2fs.h:914
PEXT2_MCB Target
Definition: ext2fs.h:908
struct inode Inode
Definition: ext2fs.h:945
UNICODE_STRING FullName
Definition: ext2fs.h:920
ULONG Flags
Definition: ntfs.h:536
SHARE_ACCESS ShareAccess
Definition: cdstruc.h:1009
CD_MCB Mcb
Definition: cdstruc.h:1016
ERESOURCE PagingIoResource
Definition: ntfs.h:527
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:925
ULONG OpenHandleCount
Definition: ntfs.h:537
ERESOURCE MainResource
Definition: ntfs.h:528
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
USHORT MaximumLength
Definition: env_spec_w32.h:370
char * b_data
Definition: module.h:735
Definition: fs.h:117
Definition: dirctrl.c:75
PDEVICE_OBJECT DeviceObject
Definition: ext2fs.h:1060
PIRP Irp
Definition: ext2fs.h:1050
BOOLEAN ExceptionInProgress
Definition: ext2fs.h:1078
Definition: ext3_fs.h:774
char name[EXT3_NAME_LEN]
Definition: ext3_fs.h:779
__le32 inode
Definition: ext3_fs.h:775
__u8 name_len
Definition: ext3_fs.h:777
__le16 rec_len
Definition: ext3_fs.h:776
PEXT2_IRP_CONTEXT IrpContext
Definition: ext4_xattr.h:141
Definition: fs.h:78
gid_t i_gid
Definition: fs.h:89
__u32 i_ino
Definition: fs.h:79
__u32 i_mtime
Definition: fs.h:83
__u16 i_extra_isize
Definition: fs.h:99
__u32 i_flags
Definition: fs.h:94
umode_t i_mode
Definition: fs.h:87
struct super_block * i_sb
Definition: fs.h:96
__u16 i_nlink
Definition: fs.h:91
uid_t i_uid
Definition: fs.h:88
__u32 i_atime
Definition: fs.h:81
__u32 i_ctime
Definition: fs.h:82
__u32 i_generation
Definition: fs.h:92
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
unsigned char * PBOOLEAN
Definition: typedefs.h:53
int64_t LONGLONG
Definition: typedefs.h:68
uint16_t * PUSHORT
Definition: typedefs.h:56
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
#define OUT
Definition: typedefs.h:40
char * PCHAR
Definition: typedefs.h:51
#define STATUS_FILE_IS_A_DIRECTORY
Definition: udferr_usr.h:164
#define STATUS_NOT_A_DIRECTORY
Definition: udferr_usr.h:169
#define STATUS_MEDIA_WRITE_PROTECTED
Definition: udferr_usr.h:161
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_OBJECT_PATH_NOT_FOUND
Definition: udferr_usr.h:151
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_NO_SUCH_FILE
Definition: udferr_usr.h:137
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define STATUS_FILE_DELETED
Definition: udferr_usr.h:172
#define STATUS_SHARING_VIOLATION
Definition: udferr_usr.h:154
#define STATUS_DISK_FULL
Definition: udferr_usr.h:155
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
STRING OEM_STRING
Definition: umtypes.h:203
@ Start
Definition: partlist.h:33
int ret
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3534
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_opt_ WDFKEY _In_ PCUNICODE_STRING _In_ ACCESS_MASK _In_ ULONG _Out_opt_ PULONG CreateDisposition
Definition: wdfregistry.h:120
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
#define CreateDirectory
Definition: winbase.h:3681
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG _In_opt_ PVOID EaBuffer
Definition: iofuncs.h:845
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define FILE_OPBATCH_BREAK_UNDERWAY
#define SL_OPEN_PAGING_FILE
Definition: iotypes.h:1817
#define FILE_NOTIFY_CHANGE_SIZE
#define FILE_ACTION_MODIFIED
#define FILE_NOTIFY_CHANGE_ATTRIBUTES
#define FILE_NOTIFY_CHANGE_FILE_NAME
* PFILE_OBJECT
Definition: iotypes.h:1998
#define FO_NO_INTERMEDIATE_BUFFERING
Definition: iotypes.h:1778
#define FO_CACHE_SUPPORTED
Definition: iotypes.h:1781
#define FILE_NOTIFY_CHANGE_LAST_WRITE
#define SL_OPEN_TARGET_DIRECTORY
Definition: iotypes.h:1818
#define FILE_ACTION_ADDED
#define FILE_NOTIFY_CHANGE_DIR_NAME
#define SL_CASE_SENSITIVE
Definition: iotypes.h:1820
_In_ PSTRING FullName
Definition: rtlfuncs.h:1648
static unsigned int block
Definition: xmlmemory.c:101
__wchar_t WCHAR
Definition: xmlstorage.h:180