ReactOS 0.4.15-dev-6680-g8c76870
fileinfo.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: fileinfo.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#ifdef __REACTOS__
14#include "linux/ext4.h"
15#include "linux/ext4_xattr.h"
16#else
17#include "linux\ext4.h"
18#include "linux\ext4_xattr.h"
19#endif
20
21/* GLOBALS ***************************************************************/
22
24
25/* DEFINITIONS *************************************************************/
26
27#ifdef ALLOC_PRAGMA
28#pragma alloc_text(PAGE, Ext2QueryFileInformation)
29#pragma alloc_text(PAGE, Ext2SetFileInformation)
30#pragma alloc_text(PAGE, Ext2ExpandFile)
31#pragma alloc_text(PAGE, Ext2TruncateFile)
32#pragma alloc_text(PAGE, Ext2SetDispositionInfo)
33#pragma alloc_text(PAGE, Ext2SetRenameInfo)
34#pragma alloc_text(PAGE, Ext2SetLinkInfo)
35#pragma alloc_text(PAGE, Ext2DeleteFile)
36#endif
37
38static int Ext2IterateAllEa(struct ext4_xattr_ref *xattr_ref, struct ext4_xattr_item *item, BOOL is_last)
39{
40 PULONG EaSize = xattr_ref->iter_arg;
41 ULONG EaEntrySize = 4 + 1 + 1 + 2 + item->name_len + 1 + item->data_size;
42
43 *EaSize += EaEntrySize - 4;
45}
46
49{
57 PIRP Irp = NULL;
58 PIO_STACK_LOCATION IoStackLocation;
62 BOOLEAN FcbResourceAcquired = FALSE;
63
64 _SEH2_TRY {
65
66 ASSERT(IrpContext != NULL);
67 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
68 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
69
70 DeviceObject = IrpContext->DeviceObject;
71
72 //
73 // This request is not allowed on the main device object
74 //
78 }
79
80 FileObject = IrpContext->FileObject;
81 Fcb = (PEXT2_FCB) FileObject->FsContext;
82 if (Fcb == NULL) {
85 }
86
87 //
88 // This request is not allowed on volumes
89 //
90 if (Fcb->Identifier.Type == EXT2VCB) {
93 }
94
95 if (!((Fcb->Identifier.Type == EXT2FCB) &&
96 (Fcb->Identifier.Size == sizeof(EXT2_FCB)))) {
99 }
100
101 Vcb = Fcb->Vcb;
102
103 {
106 IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT)
107 )) {
108
111 }
112
113 FcbResourceAcquired = TRUE;
114 }
115
116 Ccb = (PEXT2_CCB) FileObject->FsContext2;
117 ASSERT(Ccb != NULL);
119 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
120 Mcb = Ccb->SymLink;
121 if (!Mcb)
122 Mcb = Fcb->Mcb;
123
124 Irp = IrpContext->Irp;
125 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
127 IoStackLocation->Parameters.QueryFile.FileInformationClass;
128
129 Length = IoStackLocation->Parameters.QueryFile.Length;
130 Buffer = Irp->AssociatedIrp.SystemBuffer;
132
133 switch (FileInformationClass) {
134
136 {
138
139 if (Length < sizeof(FILE_BASIC_INFORMATION)) {
142 }
143
145
146 FileBasicInformation->CreationTime = Mcb->CreationTime;
147 FileBasicInformation->LastAccessTime = Mcb->LastAccessTime;
148 FileBasicInformation->LastWriteTime = Mcb->LastWriteTime;
149 FileBasicInformation->ChangeTime = Mcb->ChangeTime;
150
151 FileBasicInformation->FileAttributes = Mcb->FileAttr;
152 if (IsLinkInvalid(Mcb)) {
154 }
155 if (FileBasicInformation->FileAttributes == 0) {
157 }
158
159 Irp->IoStatus.Information = sizeof(FILE_BASIC_INFORMATION);
161 }
162 break;
163
165 {
167
168 if (Length < sizeof(FILE_STANDARD_INFORMATION)) {
171 }
172
174
175 FSI->NumberOfLinks = Mcb->Inode.i_nlink;
176
177 if (IsVcbReadOnly(Fcb->Vcb))
178 FSI->DeletePending = FALSE;
179 else
180 FSI->DeletePending = IsFlagOn(Fcb->Flags, FCB_DELETE_PENDING);
181
182 if (IsLinkInvalid(Mcb)) {
183 FSI->Directory = FALSE;
184 FSI->AllocationSize.QuadPart = 0;
185 FSI->EndOfFile.QuadPart = 0;
186 } else if (IsMcbDirectory(Mcb)) {
187 FSI->Directory = TRUE;
188 FSI->AllocationSize.QuadPart = 0;
189 FSI->EndOfFile.QuadPart = 0;
190 } else {
191 FSI->Directory = FALSE;
192 FSI->AllocationSize = Fcb->Header.AllocationSize;
193 FSI->EndOfFile = Fcb->Header.FileSize;
194 }
195
196 Irp->IoStatus.Information = sizeof(FILE_STANDARD_INFORMATION);
198 }
199 break;
200
202 {
204
205 if (Length < sizeof(FILE_INTERNAL_INFORMATION)) {
208 }
209
211
212 /* we use the inode number as the internal index */
213 FileInternalInformation->IndexNumber.QuadPart = (LONGLONG)Mcb->Inode.i_ino;
214
215 Irp->IoStatus.Information = sizeof(FILE_INTERNAL_INFORMATION);
217 }
218 break;
219
220
222 {
223 struct ext4_xattr_ref xattr_ref;
225
226 if (Length < sizeof(FILE_EA_INFORMATION)) {
229 }
230
232 FileEaInformation->EaSize = 0;
233
235 if (!NT_SUCCESS(Status))
237
238 xattr_ref.iter_arg = &FileEaInformation->EaSize;
240 ext4_fs_put_xattr_ref(&xattr_ref);
241
242 if (FileEaInformation->EaSize)
243 FileEaInformation->EaSize += 4;
244
245 Irp->IoStatus.Information = sizeof(FILE_EA_INFORMATION);
247 }
248 break;
249
251 {
253 ULONG BytesToCopy = 0;
254
256 Mcb->FullName.Length) {
259 } else {
260 BytesToCopy = Mcb->FullName.Length;
262 }
263
265 FileNameInformation->FileNameLength = Mcb->FullName.Length;
266
268 FileNameInformation->FileName,
269 Mcb->FullName.Buffer,
270 BytesToCopy );
271
272 Irp->IoStatus.Information = BytesToCopy +
274 }
275 break;
276
278 {
280
281 if (Length < sizeof(FILE_POSITION_INFORMATION)) {
284 }
285
287 FilePositionInformation->CurrentByteOffset =
288 FileObject->CurrentByteOffset;
289
290 Irp->IoStatus.Information = sizeof(FILE_POSITION_INFORMATION);
292 }
293 break;
294
296 {
304
305 if (Length < sizeof(FILE_ALL_INFORMATION)) {
308 }
309
311
313 &FileAllInformation->BasicInformation;
314
315 FSI =
316 &FileAllInformation->StandardInformation;
317
319 &FileAllInformation->InternalInformation;
320
322 &FileAllInformation->EaInformation;
323
325 &FileAllInformation->PositionInformation;
326
328 &FileAllInformation->NameInformation;
329
330 FileBasicInformation->CreationTime = Mcb->CreationTime;
331 FileBasicInformation->LastAccessTime = Mcb->LastAccessTime;
332 FileBasicInformation->LastWriteTime = Mcb->LastWriteTime;
333 FileBasicInformation->ChangeTime = Mcb->ChangeTime;
334
335 FileBasicInformation->FileAttributes = Mcb->FileAttr;
336 if (IsMcbSymLink(Mcb) && IsFileDeleted(Mcb->Target)) {
338 }
339 if (FileBasicInformation->FileAttributes == 0) {
341 }
342
343 FSI->NumberOfLinks = Mcb->Inode.i_nlink;
344
345 if (IsVcbReadOnly(Fcb->Vcb))
346 FSI->DeletePending = FALSE;
347 else
348 FSI->DeletePending = IsFlagOn(Fcb->Flags, FCB_DELETE_PENDING);
349
350 if (IsLinkInvalid(Mcb)) {
351 FSI->Directory = FALSE;
352 FSI->AllocationSize.QuadPart = 0;
353 FSI->EndOfFile.QuadPart = 0;
354 } else if (IsDirectory(Fcb)) {
355 FSI->Directory = TRUE;
356 FSI->AllocationSize.QuadPart = 0;
357 FSI->EndOfFile.QuadPart = 0;
358 } else {
359 FSI->Directory = FALSE;
360 FSI->AllocationSize = Fcb->Header.AllocationSize;
361 FSI->EndOfFile = Fcb->Header.FileSize;
362 }
363
364 // The "inode number"
365 FileInternalInformation->IndexNumber.QuadPart = (LONGLONG)Mcb->Inode.i_ino;
366
367 // Romfs doesn't have any extended attributes
368 FileEaInformation->EaSize = 0;
369
370 FilePositionInformation->CurrentByteOffset =
371 FileObject->CurrentByteOffset;
372
373 FileNameInformation->FileNameLength = Mcb->ShortName.Length;
374
375 if (Length < sizeof(FILE_ALL_INFORMATION) +
376 Mcb->ShortName.Length - sizeof(WCHAR)) {
377 Irp->IoStatus.Information = sizeof(FILE_ALL_INFORMATION);
380 FileNameInformation->FileName,
381 Mcb->ShortName.Buffer,
383 NameInformation.FileName)
384 );
386 }
387
389 FileNameInformation->FileName,
390 Mcb->ShortName.Buffer,
391 Mcb->ShortName.Length
392 );
393
394 Irp->IoStatus.Information = sizeof(FILE_ALL_INFORMATION) +
395 Mcb->ShortName.Length - sizeof(WCHAR);
396#if 0
398 sizeof(FILE_MODE_INFORMATION) -
400#endif
401
403 }
404 break;
405
406 /*
407 case FileAlternateNameInformation:
408 {
409 // TODO: Handle FileAlternateNameInformation
410
411 // Here we would like to use RtlGenerate8dot3Name but I don't
412 // know how to use the argument PGENERATE_NAME_CONTEXT
413 }
414 */
415
417 {
419
423 }
424
426
427 PFNOI->FileAttributes = Mcb->FileAttr;
428 if (IsLinkInvalid(Mcb)) {
430 PFNOI->AllocationSize.QuadPart = 0;
431 PFNOI->EndOfFile.QuadPart = 0;
432 } else if (IsDirectory(Fcb)) {
433 PFNOI->AllocationSize.QuadPart = 0;
434 PFNOI->EndOfFile.QuadPart = 0;
435 } else {
436 PFNOI->AllocationSize = Fcb->Header.AllocationSize;
437 PFNOI->EndOfFile = Fcb->Header.FileSize;
438 }
439
440 if (PFNOI->FileAttributes == 0) {
442 }
443
444 PFNOI->CreationTime = Mcb->CreationTime;
445 PFNOI->LastAccessTime = Mcb->LastAccessTime;
446 PFNOI->LastWriteTime = Mcb->LastWriteTime;
447 PFNOI->ChangeTime = Mcb->ChangeTime;
448
449
450 Irp->IoStatus.Information =
453 }
454 break;
455
456#if (_WIN32_WINNT >= 0x0500)
457
459 {
461
465 }
466
468 FATI->FileAttributes = Mcb->FileAttr;
469 if (IsLinkInvalid(Mcb)) {
471 }
472 if (FATI->FileAttributes == 0) {
474 }
476 Irp->IoStatus.Information = sizeof(FILE_ATTRIBUTE_TAG_INFORMATION);
478 }
479 break;
480#endif // (_WIN32_WINNT >= 0x0500)
481
484 break;
485
486 default:
487 DEBUG(DL_WRN, ( "Ext2QueryInformation: invalid class: %d\n",
489 Status = STATUS_INVALID_PARAMETER; /* STATUS_INVALID_INFO_CLASS; */
490 break;
491 }
492
493 } _SEH2_FINALLY {
494
495 if (FcbResourceAcquired) {
497 }
498
500 if (Status == STATUS_PENDING ||
503 } else {
505 }
506 }
507 } _SEH2_END;
508
509 return Status;
510}
511
512
515{
523 PIRP Irp = NULL;
524 PIO_STACK_LOCATION IoStackLocation = NULL;
526
528
531
532 BOOLEAN FcbMainResourceAcquired = FALSE;
533 BOOLEAN FcbPagingIoResourceAcquired = FALSE;
534
535 _SEH2_TRY {
536
538
542
543 //
544 // This request is not allowed on the main device object
545 //
549 }
550
551 /* check io stack location of irp stack */
552 Irp = IrpContext->Irp;
553 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
555 IoStackLocation->Parameters.SetFile.FileInformationClass;
556 Length = IoStackLocation->Parameters.SetFile.Length;
557 Buffer = Irp->AssociatedIrp.SystemBuffer;
558
559 /* check Vcb */
560 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
561 ASSERT(Vcb != NULL);
562 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
563 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
564 if (!IsMounted(Vcb)) {
567 }
568
569 if (FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED)) {
572 }
573
575 Fcb = (PEXT2_FCB) FileObject->FsContext;
576
577 // This request is issued to volumes, just return success
578 if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
581 }
583 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
584
585 if (IsFlagOn(Fcb->Mcb->Flags, MCB_FILE_DELETED)) {
588 }
589
590 Ccb = (PEXT2_CCB) FileObject->FsContext2;
591 ASSERT(Ccb != NULL);
593 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
594 Mcb = Ccb->SymLink;
595 if (Mcb) {
596 if (IsFlagOn(Mcb->Flags, MCB_FILE_DELETED)) {
599 }
600 } else {
601 Mcb = Fcb->Mcb;
602 }
603
605 if (IsVcbReadOnly(Vcb)) {
608 }
612 }
613 }
614
619
620 Status = FsRtlCheckOplock( &Fcb->Oplock,
621 Irp,
623 NULL,
624 NULL );
625
626 if (Status != STATUS_SUCCESS) {
628 }
629
630 //
631 // Set the flag indicating if Fast I/O is possible
632 //
633
634 Fcb->Header.IsFastIoPossible = Ext2IsFastIoPossible(Fcb);
635 }
636
637 /* for renaming or set link, we must not grab any Fcb locks,
638 and later we will get Dcb or Fcb resources exclusively. */
642
648 }
649
650 FcbMainResourceAcquired = TRUE;
651
655
660 DbgBreak();
662 }
663 FcbPagingIoResourceAcquired = TRUE;
664 }
665 }
666
667 switch (FileInformationClass) {
668
670 {
672 struct inode *Inode = &Mcb->Inode;
673
674 if (FBI->CreationTime.QuadPart != 0 && FBI->CreationTime.QuadPart != -1) {
675 Inode->i_ctime = Ext2LinuxTime(FBI->CreationTime);
676 Mcb->CreationTime = Ext2NtTime(Inode->i_ctime);
678 }
679
680 if (FBI->LastAccessTime.QuadPart != 0 && FBI->LastAccessTime.QuadPart != -1) {
681 Inode->i_atime = Ext2LinuxTime(FBI->LastAccessTime);
682 Mcb->LastAccessTime = Ext2NtTime(Inode->i_atime);
684 }
685
686 if (FBI->LastWriteTime.QuadPart != 0 && FBI->LastWriteTime.QuadPart != -1) {
687 Inode->i_mtime = Ext2LinuxTime(FBI->LastWriteTime);
688 Mcb->LastWriteTime = Ext2NtTime(Inode->i_mtime);
691 }
692
693 if (FBI->ChangeTime.QuadPart !=0 && FBI->ChangeTime.QuadPart != -1) {
694 Mcb->ChangeTime = FBI->ChangeTime;
695 }
696
697 if (FBI->FileAttributes != 0) {
698
699 BOOLEAN bIsDirectory = IsDirectory(Fcb);
701
704 } else {
706 }
707
710 } else {
712 }
713
714 Mcb->FileAttr = FBI->FileAttributes;
715 if (bIsDirectory) {
718 }
719 }
720
721 if (NotifyFilter != 0) {
722 if (Ext2SaveInode(IrpContext, Vcb, Inode)) {
724 }
725 }
726
729 }
730
731 break;
732
734 {
737
741 } else {
743 }
744
745 /* set Mcb to it's target */
746 if (IsMcbSymLink(Mcb)) {
747 ASSERT(Fcb->Mcb == Mcb->Target);
748 }
749 Mcb = Fcb->Mcb;
750
751 /* get user specified allocationsize aligned with BLOCK_SIZE */
755
756 if (AllocationSize.QuadPart > Fcb->Header.AllocationSize.QuadPart) {
757
758 Status = Ext2ExpandFile(IrpContext, Vcb, Mcb, &AllocationSize);
759 Fcb->Header.AllocationSize = AllocationSize;
762
763 } else if (AllocationSize.QuadPart < Fcb->Header.AllocationSize.QuadPart) {
764
765 if (MmCanFileBeTruncated(&(Fcb->SectionObject), &AllocationSize)) {
766
767 /* truncate file blocks */
768 Status = Ext2TruncateFile(IrpContext, Vcb, Mcb, &AllocationSize);
769
770 if (NT_SUCCESS(Status)) {
772 }
773
775 Fcb->Header.AllocationSize.QuadPart = AllocationSize.QuadPart;
776 if (Mcb->Inode.i_size > (loff_t)AllocationSize.QuadPart) {
777 Mcb->Inode.i_size = AllocationSize.QuadPart;
778 }
779 Fcb->Header.FileSize.QuadPart = Mcb->Inode.i_size;
780 if (Fcb->Header.ValidDataLength.QuadPart > Fcb->Header.FileSize.QuadPart) {
781 Fcb->Header.ValidDataLength.QuadPart = Fcb->Header.FileSize.QuadPart;
782 }
783
784 } else {
785
787 DbgBreak();
789 }
790 }
791
792 if (NotifyFilter) {
793
796 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
798 CcSetFileSizes(FileObject, (PCC_FILE_SIZES)(&(Fcb->Header.AllocationSize)));
799 }
800 }
801
802 DEBUG(DL_IO, ("Ext2SetInformation: %wZ NewSize=%I64xh AllocationSize=%I64xh "
803 "FileSize=%I64xh VDL=%I64xh i_size=%I64xh status = %xh\n",
804 &Fcb->Mcb->ShortName, AllocationSize.QuadPart,
805 Fcb->Header.AllocationSize.QuadPart,
806 Fcb->Header.FileSize.QuadPart, Fcb->Header.ValidDataLength.QuadPart,
807 Mcb->Inode.i_size, Status));
808 }
809
810 break;
811
813 {
815 LARGE_INTEGER NewSize, OldSize, EndOfFile;
816
820 } else {
822 }
823
824 /* set Mcb to it's target */
825 if (IsMcbSymLink(Mcb)) {
826 ASSERT(Fcb->Mcb == Mcb->Target);
827 }
828 Mcb = Fcb->Mcb;
829
830 OldSize = Fcb->Header.AllocationSize;
831 EndOfFile = FEOFI->EndOfFile;
832
833 if (IoStackLocation->Parameters.SetFile.AdvanceOnly) {
834
837 }
838
839 if (EndOfFile.QuadPart > Fcb->Header.FileSize.QuadPart) {
840 EndOfFile.QuadPart = Fcb->Header.FileSize.QuadPart;
841 }
842
843 if (EndOfFile.QuadPart > Fcb->Header.ValidDataLength.QuadPart) {
844 Fcb->Header.ValidDataLength.QuadPart = EndOfFile.QuadPart;
846 }
847
849 }
850
852 EndOfFile.QuadPart, BLOCK_SIZE);
853
854 if (NewSize.QuadPart > OldSize.QuadPart) {
855
856 Fcb->Header.AllocationSize = NewSize;
858 IrpContext,
859 Vcb,
860 Mcb,
861 &(Fcb->Header.AllocationSize)
862 );
865
866
867 } else if (NewSize.QuadPart == OldSize.QuadPart) {
868
869 /* we are luck ;) */
871
872 } else {
873
874 /* don't truncate file data since it's still being written */
876
878
879 } else {
880
881 if (!MmCanFileBeTruncated(&(Fcb->SectionObject), &NewSize)) {
883 DbgBreak();
885 }
886
887 /* truncate file blocks */
888 Status = Ext2TruncateFile(IrpContext, Vcb, Mcb, &NewSize);
889
890 /* restore original file size */
891 if (NT_SUCCESS(Status)) {
893 }
894
895 /* update file allocateion size */
896 Fcb->Header.AllocationSize.QuadPart = NewSize.QuadPart;
897
898 ASSERT((loff_t)NewSize.QuadPart >= Mcb->Inode.i_size);
899 if ((loff_t)Fcb->Header.FileSize.QuadPart < Mcb->Inode.i_size) {
900 Fcb->Header.FileSize.QuadPart = Mcb->Inode.i_size;
901 }
902 if (Fcb->Header.ValidDataLength.QuadPart > Fcb->Header.FileSize.QuadPart) {
903 Fcb->Header.ValidDataLength.QuadPart = Fcb->Header.FileSize.QuadPart;
904 }
905
908 }
909
911 }
912
913 if (NT_SUCCESS(Status)) {
914
915 Fcb->Header.FileSize.QuadPart = Mcb->Inode.i_size = EndOfFile.QuadPart;
917 CcSetFileSizes(FileObject, (PCC_FILE_SIZES)(&(Fcb->Header.AllocationSize)));
918 }
919
920 if (Fcb->Header.FileSize.QuadPart >= 0x80000000 &&
923 Ext2SaveSuper(IrpContext, Vcb);
924 }
925
929 }
930
931
932 Ext2SaveInode( IrpContext, Vcb, &Mcb->Inode);
933
934 DEBUG(DL_IO, ("Ext2SetInformation: FileEndOfFileInformation %wZ EndofFile=%I64xh "
935 "AllocatieonSize=%I64xh FileSize=%I64xh VDL=%I64xh i_size=%I64xh status = %xh\n",
936 &Fcb->Mcb->ShortName, EndOfFile.QuadPart, Fcb->Header.AllocationSize.QuadPart,
937 Fcb->Header.FileSize.QuadPart, Fcb->Header.ValidDataLength.QuadPart,
938 Mcb->Inode.i_size, Status));
939 }
940
941 break;
942
944 {
946 LARGE_INTEGER NewVDL;
947
951 } else {
953 }
954
955 NewVDL = FVDL->ValidDataLength;
956 if ((NewVDL.QuadPart < Fcb->Header.ValidDataLength.QuadPart)) {
959 }
960 if (NewVDL.QuadPart > Fcb->Header.FileSize.QuadPart)
961 NewVDL = Fcb->Header.FileSize;
962
963 if (!MmCanFileBeTruncated(FileObject->SectionObjectPointer,
964 &NewVDL)) {
967 }
968
969 Fcb->Header.ValidDataLength = NewVDL;
972 CcSetFileSizes(FileObject, (PCC_FILE_SIZES)(&(Fcb->Header.AllocationSize)));
973 }
974 }
975
976 break;
977
979 {
981
982 Status = Ext2SetDispositionInfo(IrpContext, Vcb, Fcb, Ccb, FDI->DeleteFile);
983
984 DEBUG(DL_INF, ( "Ext2SetInformation: SetDispositionInformation: DeleteFile=%d %wZ status = %xh\n",
985 FDI->DeleteFile, &Mcb->ShortName, Status));
986 }
987
988 break;
989
991 {
992 Status = Ext2SetRenameInfo(IrpContext, Vcb, Fcb, Ccb);
993 }
994
995 break;
996
997
999 {
1000 Status = Ext2SetLinkInfo(IrpContext, Vcb, Fcb, Ccb);
1001 }
1002
1003 break;
1004
1005 //
1006 // This is the only set file information request supported on read
1007 // only file systems
1008 //
1010 {
1012
1013 if (Length < sizeof(FILE_POSITION_INFORMATION)) {
1016 }
1017
1019
1021 (FilePositionInformation->CurrentByteOffset.LowPart &
1022 DeviceObject->AlignmentRequirement) ) {
1025 }
1026
1027 FileObject->CurrentByteOffset =
1028 FilePositionInformation->CurrentByteOffset;
1029
1032 }
1033
1034 break;
1035
1036 default:
1037 DEBUG(DL_WRN, ( "Ext2SetInformation: invalid class: %d\n",
1039 Status = STATUS_INVALID_PARAMETER;/* STATUS_INVALID_INFO_CLASS; */
1040 }
1041
1042 } _SEH2_FINALLY {
1043
1044 if (FcbPagingIoResourceAcquired) {
1046 }
1047
1048 if (NT_SUCCESS(Status) && (NotifyFilter != 0)) {
1050 IrpContext,
1051 Vcb,
1052 Mcb,
1055
1056 }
1057
1058 if (FcbMainResourceAcquired) {
1060 }
1061
1062 if (!IrpContext->ExceptionInProgress) {
1063 if (Status == STATUS_PENDING ||
1065 DbgBreak();
1066 Status = Ext2QueueRequest(IrpContext);
1067 } else {
1068 Ext2CompleteIrpContext(IrpContext, Status);
1069 }
1070 }
1071 } _SEH2_END;
1072
1073 return Status;
1074}
1075
1076ULONG
1078 PEXT2_VCB Vcb,
1080 PULONG pMeta
1081)
1082{
1083 ULONG Blocks, Meta =0, Remain;
1084
1085 Blocks = (ULONG)((Size->QuadPart + BLOCK_SIZE - 1) >> BLOCK_BITS);
1086 if (Blocks <= EXT2_NDIR_BLOCKS)
1087 goto errorout;
1088 Blocks -= EXT2_NDIR_BLOCKS;
1089
1090 Meta += 1;
1091 if (Blocks <= Vcb->max_blocks_per_layer[1]) {
1092 goto errorout;
1093 }
1094 Blocks -= Vcb->max_blocks_per_layer[1];
1095
1096level2:
1097
1098 if (Blocks <= Vcb->max_blocks_per_layer[2]) {
1099 Meta += 1 + ((Blocks + BLOCK_SIZE/4 - 1) >> (BLOCK_BITS - 2));
1100 goto errorout;
1101 }
1102 Meta += 1 + BLOCK_SIZE/4;
1103 Blocks -= Vcb->max_blocks_per_layer[2];
1104
1105 if (Blocks > Vcb->max_blocks_per_layer[3]) {
1106 Blocks = Vcb->max_blocks_per_layer[3];
1107 }
1108
1109 ASSERT(Vcb->max_blocks_per_layer[2]);
1110 Remain = Blocks % Vcb->max_blocks_per_layer[2];
1111 Blocks = Blocks / Vcb->max_blocks_per_layer[2];
1112 Meta += 1 + Blocks * (1 + BLOCK_SIZE/4);
1113 if (Remain) {
1114 Blocks = Remain;
1115 goto level2;
1116 }
1117
1118errorout:
1119
1120 if (pMeta)
1121 *pMeta = Meta;
1122 Blocks = (ULONG)((Size->QuadPart + BLOCK_SIZE - 1) >> BLOCK_BITS);
1123 return (Blocks + Meta);
1124}
1125
1128 IN PEXT2_IRP_CONTEXT IrpContext,
1131 IN ULONG Index,
1132 IN BOOLEAN bAlloc,
1133 OUT PULONG pBlock,
1135)
1136{
1138
1139 if (INODE_HAS_EXTENT(&Mcb->Inode)) {
1140 status = Ext2MapExtent(IrpContext, Vcb, Mcb, Index,
1141 bAlloc, pBlock, Number );
1142 } else {
1143 status = Ext2MapIndirect(IrpContext, Vcb, Mcb, Index,
1144 bAlloc, pBlock, Number );
1145 }
1146
1147 return status;
1148}
1149
1150
1153 PEXT2_IRP_CONTEXT IrpContext,
1154 PEXT2_VCB Vcb,
1155 PEXT2_MCB Mcb,
1157)
1158{
1160 ULONG Start = 0;
1161 ULONG End = 0;
1162
1163 Start = (ULONG)((Mcb->Inode.i_size + BLOCK_SIZE - 1) >> BLOCK_BITS);
1164 End = (ULONG)((Size->QuadPart + BLOCK_SIZE - 1) >> BLOCK_BITS);
1165
1166 /* it's a truncate operation, not expanding */
1167 if (Start >= End) {
1168 Size->QuadPart = ((LONGLONG) Start) << BLOCK_BITS;
1169 return STATUS_SUCCESS;
1170 }
1171
1172 /* ignore special files */
1173 if (IsMcbSpecialFile(Mcb)) {
1175 }
1176
1177 /* expandind file extents */
1178 if (INODE_HAS_EXTENT(&Mcb->Inode)) {
1179
1180 status = Ext2ExpandExtent(IrpContext, Vcb, Mcb, Start, End, Size);
1181
1182 } else {
1183
1184 BOOLEAN do_expand;
1185
1186#if EXT2_PRE_ALLOCATION_SUPPORT
1187 do_expand = TRUE;
1188#else
1189 do_expand = (IrpContext->MajorFunction == IRP_MJ_WRITE) ||
1191#endif
1192 if (!do_expand)
1193 goto errorout;
1194
1195 status = Ext2ExpandIndirect(IrpContext, Vcb, Mcb, Start, End, Size);
1196 }
1197
1198errorout:
1199 return status;
1200}
1201
1202
1205 PEXT2_IRP_CONTEXT IrpContext,
1206 PEXT2_VCB Vcb,
1207 PEXT2_MCB Mcb,
1209)
1210{
1212
1213 if (INODE_HAS_EXTENT(&Mcb->Inode)) {
1214 status = Ext2TruncateExtent(IrpContext, Vcb, Mcb, Size);
1215 } else {
1216 status = Ext2TruncateIndirect(IrpContext, Vcb, Mcb, Size);
1217 }
1218
1219 /* check and clear data/meta mcb extents */
1220 if (Size->QuadPart == 0) {
1221
1222 /* check and remove all data extents */
1223 if (Ext2ListExtents(&Mcb->Extents)) {
1224 DbgBreak();
1225 }
1226 Ext2ClearAllExtents(&Mcb->Extents);
1227 /* check and remove all meta extents */
1228 if (Ext2ListExtents(&Mcb->MetaExts)) {
1229 DbgBreak();
1230 }
1231 Ext2ClearAllExtents(&Mcb->MetaExts);
1233 }
1234
1235 return status;
1236}
1237
1240 IN PEXT2_IRP_CONTEXT IrpContext,
1244)
1245{
1246 PEXT2_MCB Mcb = Fcb->Mcb;
1247
1248 if (Mcb->Inode.i_ino == EXT2_ROOT_INO) {
1249 return STATUS_CANNOT_DELETE;
1250 }
1251
1252 if (IsMcbDirectory(Mcb)) {
1253 if (!Ext2IsDirectoryEmpty(IrpContext, Vcb, Mcb)) {
1255 }
1256 }
1257
1258 if (!MmFlushImageSection(&Fcb->SectionObject,
1259 MmFlushForDelete )) {
1260 return STATUS_CANNOT_DELETE;
1261 }
1262
1263 if (IsMcbDirectory(Mcb)) {
1265 Vcb->NotifySync,
1266 &Vcb->NotifyList,
1267 Ccb,
1268 NULL,
1269 FALSE,
1270 FALSE,
1271 0,
1272 NULL,
1273 NULL,
1274 NULL
1275 );
1276 }
1277
1278 return STATUS_SUCCESS;
1279}
1280
1283 PEXT2_IRP_CONTEXT IrpContext,
1284 PEXT2_VCB Vcb,
1285 PEXT2_FCB Fcb,
1286 PEXT2_CCB Ccb,
1287 BOOLEAN bDelete
1288)
1289{
1290 PIRP Irp = IrpContext->Irp;
1293 PEXT2_MCB Mcb = Fcb->Mcb;
1294
1296
1297 DEBUG(DL_INF, ( "Ext2SetDispositionInfo: bDelete=%x\n", bDelete));
1298
1299 if (bDelete) {
1300
1301 DEBUG(DL_INF, ( "Ext2SetDispositionInformation: Removing %wZ.\n",
1302 &Mcb->FullName));
1303
1304 if (Ccb->SymLink || IsInodeSymLink(&Mcb->Inode)) {
1305 /* always allow deleting on symlinks */
1306 } else {
1307 status = Ext2IsFileRemovable(IrpContext, Vcb, Fcb, Ccb);
1308 }
1309
1310 if (NT_SUCCESS(status)) {
1312 IrpSp->FileObject->DeletePending = TRUE;
1313 }
1314
1315 } else {
1316
1318 IrpSp->FileObject->DeletePending = FALSE;
1319 }
1320
1321 return status;
1322}
1323
1326 PEXT2_IRP_CONTEXT IrpContext,
1327 PEXT2_VCB Vcb,
1328 PEXT2_FCB Fcb,
1330)
1331{
1332 PEXT2_MCB Mcb = Fcb->Mcb;
1333
1334 PEXT2_FCB TargetDcb = NULL; /* Dcb of target directory */
1335 PEXT2_MCB TargetMcb = NULL;
1336 PEXT2_FCB ParentDcb = NULL; /* Dcb of it's current parent */
1337 PEXT2_MCB ParentMcb = NULL;
1338
1339 PEXT2_FCB ExistingFcb = NULL; /* Target file Fcb if it exists*/
1340 PEXT2_MCB ExistingMcb = NULL;
1341
1343
1345
1346 PIRP Irp;
1348
1350 PFILE_OBJECT TargetObject;
1351
1352 struct dentry *NewEntry = NULL;
1353
1354 BOOLEAN ReplaceIfExists;
1355 BOOLEAN bMove = FALSE;
1356 BOOLEAN bTargetRemoved = FALSE;
1357
1358 BOOLEAN bFcbLockAcquired = FALSE;
1359
1361
1362 if (Ccb->SymLink) {
1363 Mcb = Ccb->SymLink;
1364 }
1365
1366 if (Mcb->Inode.i_ino == EXT2_ROOT_INO) {
1368 goto errorout;
1369 }
1370
1371 Irp = IrpContext->Irp;
1373
1375 TargetObject = IrpSp->Parameters.SetFile.FileObject;
1376 ReplaceIfExists = IrpSp->Parameters.SetFile.ReplaceIfExists;
1377
1378 FRI = (PFILE_RENAME_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
1379
1380 if (TargetObject == NULL) {
1381
1383
1384 NewName.Buffer = FRI->FileName;
1386
1387 while (NewName.Length > 0 && NewName.Buffer[NewName.Length/2 - 1] == L'\\') {
1388 NewName.Buffer[NewName.Length/2 - 1] = 0;
1389 NewName.Length -= 2;
1390 }
1391
1392 while (NewName.Length > 0 && NewName.Buffer[NewName.Length/2 - 1] != L'\\') {
1393 NewName.Length -= 2;
1394 }
1395
1398
1399 FileName = NewName;
1400
1401 TargetMcb = Mcb->Parent;
1402 if (IsMcbSymLink(TargetMcb)) {
1403 TargetMcb = TargetMcb->Target;
1404 ASSERT(!IsMcbSymLink(TargetMcb));
1405 }
1406
1407 if (TargetMcb == NULL || FileName.Length >= EXT2_NAME_LEN*2) {
1409 goto errorout;
1410 }
1411
1412 } else {
1413
1414 TargetDcb = (PEXT2_FCB)(TargetObject->FsContext);
1415
1416 if (!TargetDcb || TargetDcb->Vcb != Vcb) {
1417
1418 DbgBreak();
1419
1421 goto errorout;
1422 }
1423
1424 TargetMcb = TargetDcb->Mcb;
1425 FileName = TargetObject->FileName;
1426 }
1427
1430 goto errorout;
1431 }
1432
1433 if (TargetMcb->Inode.i_ino == Mcb->Parent->Inode.i_ino) {
1435 &(Mcb->ShortName),
1436 FALSE,
1437 NULL )) {
1439 goto errorout;
1440 }
1441 } else {
1442 bMove = TRUE;
1443 }
1444
1445 if (!bFcbLockAcquired) {
1447 bFcbLockAcquired = TRUE;
1448 }
1449
1450 TargetDcb = TargetMcb->Fcb;
1451 if (TargetDcb == NULL) {
1452 TargetDcb = Ext2AllocateFcb(Vcb, TargetMcb);
1453 }
1454 if (TargetDcb) {
1455 Ext2ReferXcb(&TargetDcb->ReferenceCount);
1456 }
1457
1458 ParentMcb = Mcb->Parent;
1459 ParentDcb = ParentMcb->Fcb;
1460
1461 if ((TargetMcb->Inode.i_ino != ParentMcb->Inode.i_ino)) {
1462
1463 if (ParentDcb == NULL) {
1464 ParentDcb = Ext2AllocateFcb(Vcb, ParentMcb);
1465 }
1466 }
1467 if (ParentDcb) {
1468 Ext2ReferXcb(&ParentDcb->ReferenceCount);
1469 }
1470
1471 if (bFcbLockAcquired) {
1472 ExReleaseResourceLite(&Vcb->FcbLock);
1473 bFcbLockAcquired = FALSE;
1474 }
1475
1476 if (!TargetDcb || !ParentDcb) {
1478 goto errorout;
1479 }
1480
1481 DEBUG(DL_RES, ("Ext2SetRenameInfo: rename %wZ to %wZ\\%wZ\n",
1482 &Mcb->FullName, &TargetMcb->FullName, &FileName));
1483
1485 IrpContext,
1486 Vcb,
1487 &FileName,
1488 TargetMcb,
1489 &ExistingMcb,
1490 0
1491 );
1492
1493 if (NT_SUCCESS(Status) && ExistingMcb != Mcb) {
1494
1495 if (!ReplaceIfExists) {
1496
1498 DEBUG(DL_RES, ("Ext2SetRenameInfo: Target file %wZ exists\n",
1499 &ExistingMcb->FullName));
1500 goto errorout;
1501
1502 } else {
1503
1504 if ( (ExistingFcb = ExistingMcb->Fcb) && !IsMcbSymLink(ExistingMcb) ) {
1505
1506 Status = Ext2IsFileRemovable(IrpContext, Vcb, ExistingFcb, Ccb);
1507 if (!NT_SUCCESS(Status)) {
1508 DEBUG(DL_REN, ("Ext2SetRenameInfo: Target file %wZ cannot be removed.\n",
1509 &ExistingMcb->FullName));
1510 goto errorout;
1511 }
1512 }
1513
1514 Status = Ext2DeleteFile(IrpContext, Vcb, ExistingFcb, ExistingMcb);
1515 if (!NT_SUCCESS(Status)) {
1516 DEBUG(DL_REN, ("Ext2SetRenameInfo: Failed to delete %wZ with status: %xh.\n",
1517 &FileName, Status));
1518
1519 goto errorout;
1520 }
1521
1522 bTargetRemoved = TRUE;
1523 }
1524 }
1525
1526 /* remove directory entry of old name */
1527 Status = Ext2RemoveEntry(IrpContext, Vcb, ParentDcb, Mcb);
1528 if (!NT_SUCCESS(Status)) {
1529 DEBUG(DL_REN, ("Ext2SetRenameInfo: Failed to remove entry %wZ with status %xh.\n",
1530 &Mcb->FullName, Status));
1531 DbgBreak();
1532 goto errorout;
1533 }
1534
1535 /* add new entry for new target name */
1536 Status = Ext2AddEntry(IrpContext, Vcb, TargetDcb, &Mcb->Inode, &FileName, &NewEntry);
1537 if (!NT_SUCCESS(Status)) {
1538 DEBUG(DL_REN, ("Ext2SetRenameInfo: Failed to add entry for %wZ with status: %xh.\n",
1539 &FileName, Status));
1540 Ext2AddEntry(IrpContext, Vcb, ParentDcb, &Mcb->Inode, &Mcb->ShortName, &NewEntry);
1541 goto errorout;
1542 }
1543
1544 /* correct the inode number in .. entry */
1545 if (IsMcbDirectory(Mcb)) {
1547 IrpContext, Vcb, Fcb,
1548 ParentMcb->Inode.i_ino,
1549 TargetMcb->Inode.i_ino );
1550 if (!NT_SUCCESS(Status)) {
1551 DEBUG(DL_REN, ("Ext2SetRenameInfo: Failed to set parent refer of %wZ with %xh.\n",
1552 &Mcb->FullName, Status));
1553 DbgBreak();
1554 goto errorout;
1555 }
1556 }
1557
1558 /* Update current dentry from the newly created one. We need keep the original
1559 dentry to assure children's links are valid if current entry is a directory */
1560 if (Mcb->de) {
1561 char *np = Mcb->de->d_name.name;
1562 *(Mcb->de) = *NewEntry;
1563 NewEntry->d_name.name = np;
1564 }
1565
1566 if (bTargetRemoved) {
1568 IrpContext,
1569 Vcb,
1570 ExistingMcb,
1571 (IsMcbDirectory(ExistingMcb) ?
1575 }
1576
1577 if (NT_SUCCESS(Status)) {
1578
1579 if (bMove) {
1581 IrpContext,
1582 Vcb,
1583 Mcb,
1584 (IsDirectory(Fcb) ?
1588
1589 } else {
1591 IrpContext,
1592 Vcb,
1593 Mcb,
1594 (IsDirectory(Fcb) ?
1598
1599 }
1600
1601 if (TargetMcb->Inode.i_ino != ParentMcb->Inode.i_ino) {
1603 Ext2InsertMcb(Vcb, TargetMcb, Mcb);
1604 }
1605
1606 if (!Ext2BuildName( &Mcb->ShortName,
1607 &FileName, NULL )) {
1609 goto errorout;
1610 }
1611
1612 if (!Ext2BuildName( &Mcb->FullName,
1613 &FileName,
1614 &TargetMcb->FullName)) {
1616 goto errorout;
1617 }
1618
1619 if (bMove) {
1621 IrpContext,
1622 Vcb,
1623 Mcb,
1624 (IsDirectory(Fcb) ?
1628 } else {
1630 IrpContext,
1631 Vcb,
1632 Mcb,
1633 (IsDirectory(Fcb) ?
1637 }
1638 }
1639
1640errorout:
1641
1642 if (bFcbLockAcquired) {
1643 ExReleaseResourceLite(&Vcb->FcbLock);
1644 bFcbLockAcquired = FALSE;
1645 }
1646
1647 if (NewEntry)
1648 Ext2FreeEntry(NewEntry);
1649
1650 if (TargetDcb) {
1652 }
1653
1654 if (ParentDcb) {
1656 }
1657
1658 if (ExistingMcb)
1659 Ext2DerefMcb(ExistingMcb);
1660
1661 return Status;
1662}
1663
1666 PEXT2_IRP_CONTEXT IrpContext,
1667 PEXT2_VCB Vcb,
1668 PEXT2_FCB Fcb,
1670)
1671{
1672 PEXT2_MCB Mcb = Fcb->Mcb;
1673
1674 PEXT2_FCB TargetDcb = NULL; /* Dcb of target directory */
1675 PEXT2_MCB TargetMcb = NULL;
1676 PEXT2_FCB ParentDcb = NULL; /* Dcb of it's current parent */
1677 PEXT2_MCB ParentMcb = NULL;
1678
1679 PEXT2_FCB ExistingFcb = NULL; /* Target file Fcb if it exists*/
1680 PEXT2_MCB ExistingMcb = NULL;
1681 PEXT2_MCB LinkMcb = NULL; /* Mcb for new hardlink */
1682
1684
1686
1687 PIRP Irp;
1689
1691 PFILE_OBJECT TargetObject;
1692
1693 BOOLEAN ReplaceIfExists;
1694 BOOLEAN bTargetRemoved = FALSE;
1695
1696 BOOLEAN bFcbLockAcquired = FALSE;
1697
1699
1700 if (Ccb->SymLink) {
1701 Mcb = Ccb->SymLink;
1702 }
1703
1704 if (IsMcbDirectory(Mcb)) {
1706 goto errorout;
1707 }
1708
1709 Irp = IrpContext->Irp;
1711
1713 TargetObject = IrpSp->Parameters.SetFile.FileObject;
1714 ReplaceIfExists = IrpSp->Parameters.SetFile.ReplaceIfExists;
1715
1716 FLI = (PFILE_LINK_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
1717
1718 if (TargetObject == NULL) {
1719
1721
1722 NewName.Buffer = FLI->FileName;
1724
1725 while (NewName.Length > 0 && NewName.Buffer[NewName.Length/2 - 1] == L'\\') {
1726 NewName.Buffer[NewName.Length/2 - 1] = 0;
1727 NewName.Length -= 2;
1728 }
1729
1730 while (NewName.Length > 0 && NewName.Buffer[NewName.Length/2 - 1] != L'\\') {
1731 NewName.Length -= 2;
1732 }
1733
1736
1737 FileName = NewName;
1738
1739 TargetMcb = Mcb->Parent;
1740 if (IsMcbSymLink(TargetMcb)) {
1741 TargetMcb = TargetMcb->Target;
1742 ASSERT(!IsMcbSymLink(TargetMcb));
1743 }
1744
1745 if (TargetMcb == NULL || FileName.Length >= EXT2_NAME_LEN*2) {
1747 goto errorout;
1748 }
1749
1750 } else {
1751
1752 TargetDcb = (PEXT2_FCB)(TargetObject->FsContext);
1753 if (!TargetDcb || TargetDcb->Vcb != Vcb) {
1754 DbgBreak();
1756 goto errorout;
1757 }
1758
1759 TargetMcb = TargetDcb->Mcb;
1760 FileName = TargetObject->FileName;
1761 }
1762
1765 goto errorout;
1766 }
1767
1768 if (TargetMcb->Inode.i_ino == Mcb->Parent->Inode.i_ino) {
1770 &(Mcb->ShortName),
1771 FALSE,
1772 NULL )) {
1774 goto errorout;
1775 }
1776 }
1777
1779 bFcbLockAcquired = TRUE;
1780
1781 TargetDcb = TargetMcb->Fcb;
1782 if (TargetDcb == NULL) {
1783 TargetDcb = Ext2AllocateFcb(Vcb, TargetMcb);
1784 }
1785 if (TargetDcb) {
1786 Ext2ReferXcb(&TargetDcb->ReferenceCount);
1787 }
1788
1789 ParentMcb = Mcb->Parent;
1790 ParentDcb = ParentMcb->Fcb;
1791
1792 if ((TargetMcb->Inode.i_ino != ParentMcb->Inode.i_ino)) {
1793
1794 if (ParentDcb == NULL) {
1795 ParentDcb = Ext2AllocateFcb(Vcb, ParentMcb);
1796 }
1797 }
1798 if (ParentDcb) {
1799 Ext2ReferXcb(&ParentDcb->ReferenceCount);
1800 }
1801
1802 if (bFcbLockAcquired) {
1803 ExReleaseResourceLite(&Vcb->FcbLock);
1804 bFcbLockAcquired = FALSE;
1805 }
1806
1807 if (!TargetDcb || !ParentDcb) {
1809 goto errorout;
1810 }
1811
1812 DEBUG(DL_RES, ("Ext2SetLinkInfo: %wZ\\%wZ -> %wZ\n",
1813 &TargetMcb->FullName, &FileName, &Mcb->FullName));
1814
1815 Status = Ext2LookupFile(IrpContext, Vcb, &FileName,
1816 TargetMcb, &ExistingMcb, 0);
1817 if (NT_SUCCESS(Status) && ExistingMcb != Mcb) {
1818
1819 if (!ReplaceIfExists) {
1820
1822 DEBUG(DL_RES, ("Ext2SetRenameInfo: Target file %wZ exists\n",
1823 &ExistingMcb->FullName));
1824 goto errorout;
1825
1826 } else {
1827
1828 if ( (ExistingFcb = ExistingMcb->Fcb) && !IsMcbSymLink(ExistingMcb) ) {
1829 Status = Ext2IsFileRemovable(IrpContext, Vcb, ExistingFcb, Ccb);
1830 if (!NT_SUCCESS(Status)) {
1831 DEBUG(DL_REN, ("Ext2SetRenameInfo: Target file %wZ cannot be removed.\n",
1832 &ExistingMcb->FullName));
1833 goto errorout;
1834 }
1835 }
1836
1837 Status = Ext2DeleteFile(IrpContext, Vcb, ExistingFcb, ExistingMcb);
1838 if (!NT_SUCCESS(Status)) {
1839 DEBUG(DL_REN, ("Ext2SetRenameInfo: Failed to delete %wZ with status: %xh.\n",
1840 &FileName, Status));
1841
1842 goto errorout;
1843 }
1844 bTargetRemoved = TRUE;
1845 }
1846 }
1847
1848 /* add new entry for new target name */
1849 Status = Ext2AddEntry(IrpContext, Vcb, TargetDcb, &Mcb->Inode, &FileName, NULL);
1850 if (!NT_SUCCESS(Status)) {
1851 DEBUG(DL_REN, ("Ext2SetLinkInfo: Failed to add entry for %wZ with status: %xh.\n",
1852 &FileName, Status));
1853 goto errorout;
1854 }
1855
1856 if (bTargetRemoved) {
1858 IrpContext,
1859 Vcb,
1860 ExistingMcb,
1861 (IsMcbDirectory(ExistingMcb) ?
1865 }
1866
1867 if (NT_SUCCESS(Status)) {
1868
1869 Ext2LookupFile(IrpContext, Vcb, &FileName, TargetMcb, &LinkMcb, 0);
1870 if (!LinkMcb)
1871 goto errorout;
1872
1874 IrpContext,
1875 Vcb,
1876 LinkMcb,
1879 }
1880
1881errorout:
1882
1883 if (bFcbLockAcquired) {
1884 ExReleaseResourceLite(&Vcb->FcbLock);
1885 bFcbLockAcquired = FALSE;
1886 }
1887
1888 if (TargetDcb) {
1890 }
1891
1892 if (ParentDcb) {
1894 }
1895
1896 if (ExistingMcb)
1897 Ext2DerefMcb(ExistingMcb);
1898
1899 if (LinkMcb)
1900 Ext2DerefMcb(LinkMcb);
1901
1902 return Status;
1903}
1904
1905ULONG
1907{
1908 if (IsMcbSymLink(Mcb)) {
1909 return EXT2_FT_SYMLINK;
1910 }
1911
1912 if (IsMcbDirectory(Mcb)) {
1913 return EXT2_FT_DIR;
1914 }
1915
1916 return EXT2_FT_REG_FILE;
1917}
1918
1921 PEXT2_IRP_CONTEXT IrpContext,
1922 PEXT2_VCB Vcb,
1923 PEXT2_FCB Fcb,
1925)
1926{
1927 PEXT2_FCB Dcb = NULL;
1928
1930
1931 BOOLEAN VcbResourceAcquired = FALSE;
1932 BOOLEAN FcbPagingIoAcquired = FALSE;
1933 BOOLEAN FcbResourceAcquired = FALSE;
1934 BOOLEAN DcbResourceAcquired = FALSE;
1935
1937 LARGE_INTEGER SysTime;
1938
1939 BOOLEAN bFcbLockAcquired = FALSE;
1940
1941 DEBUG(DL_INF, ( "Ext2DeleteFile: File %wZ (%xh) will be deleted!\n",
1942 &Mcb->FullName, Mcb->Inode.i_ino));
1943
1944 if (IsFlagOn(Mcb->Flags, MCB_FILE_DELETED)) {
1945 return STATUS_SUCCESS;
1946 }
1947
1948 if (!IsMcbSymLink(Mcb) && IsMcbDirectory(Mcb)) {
1949 if (!Ext2IsDirectoryEmpty(IrpContext, Vcb, Mcb)) {
1951 }
1952 }
1953
1954 _SEH2_TRY {
1955
1957
1958 ExAcquireResourceExclusiveLite(&Vcb->MainResource, TRUE);
1959 VcbResourceAcquired = TRUE;
1960
1962 bFcbLockAcquired = TRUE;
1963
1964 /* Mcb->Parent could be NULL when working with layered file systems */
1965 if (Mcb->Parent) {
1966 Dcb = Mcb->Parent->Fcb;
1967 if (!Dcb)
1968 Dcb = Ext2AllocateFcb(Vcb, Mcb->Parent);
1969 }
1970 if (Dcb)
1971 Ext2ReferXcb(&Dcb->ReferenceCount);
1972
1973 if (bFcbLockAcquired) {
1974 ExReleaseResourceLite(&Vcb->FcbLock);
1975 bFcbLockAcquired = FALSE;
1976 }
1977
1978 if (Dcb) {
1979 DcbResourceAcquired =
1980 ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
1981
1982 /* remove it's entry form it's parent */
1983 Status = Ext2RemoveEntry(IrpContext, Vcb, Dcb, Mcb);
1984 }
1985
1986 if (NT_SUCCESS(Status)) {
1987
1988 SetFlag(Mcb->Flags, MCB_FILE_DELETED);
1990
1991 if (Fcb) {
1992 FcbResourceAcquired =
1994
1995 FcbPagingIoAcquired =
1997 }
1998
1999 if (DcbResourceAcquired) {
2000 ExReleaseResourceLite(&Dcb->MainResource);
2001 DcbResourceAcquired = FALSE;
2002 }
2003
2004 if (VcbResourceAcquired) {
2005 ExReleaseResourceLite(&Vcb->MainResource);
2006 VcbResourceAcquired = FALSE;
2007 }
2008
2009 if (IsMcbSymLink(Mcb)) {
2010 if (Mcb->Inode.i_nlink > 0) {
2013 }
2014 } else if (!IsMcbDirectory(Mcb)) {
2015 if (Mcb->Inode.i_nlink > 0) {
2017 }
2018 } else {
2019 if (Mcb->Inode.i_nlink >= 2) {
2021 }
2022 }
2023
2024 if (S_ISLNK(Mcb->Inode.i_mode)) {
2025
2026 /* for symlink, we should do differenctly */
2027 if (Mcb->Inode.i_size > EXT2_LINKLEN_IN_INODE) {
2028 Size.QuadPart = (LONGLONG)0;
2029 Status = Ext2TruncateFile(IrpContext, Vcb, Mcb, &Size);
2030 }
2031
2032 } else {
2033
2034 /* truncate file size */
2035 Size.QuadPart = (LONGLONG)0;
2036 Status = Ext2TruncateFile(IrpContext, Vcb, Mcb, &Size);
2037
2038 /* check file offset mappings */
2039 DEBUG(DL_EXT, ("Ext2DeleteFile ...: %wZ\n", &Mcb->FullName));
2040
2041 if (Fcb) {
2042 Fcb->Header.AllocationSize.QuadPart = Size.QuadPart;
2043 if (Fcb->Header.FileSize.QuadPart > Size.QuadPart) {
2044 Fcb->Header.FileSize.QuadPart = Size.QuadPart;
2045 Fcb->Mcb->Inode.i_size = Size.QuadPart;
2046 }
2047 if (Fcb->Header.ValidDataLength.QuadPart > Fcb->Header.FileSize.QuadPart) {
2048 Fcb->Header.ValidDataLength.QuadPart = Fcb->Header.FileSize.QuadPart;
2049 }
2050 } else if (Mcb) {
2051 /* Update the inode's data length . It should be ZERO if succeeds. */
2052 if (Mcb->Inode.i_size > (loff_t)Size.QuadPart) {
2053 Mcb->Inode.i_size = Size.QuadPart;
2054 }
2055 }
2056 }
2057
2058 /* set delete time and free the inode */
2059 KeQuerySystemTime(&SysTime);
2060 Mcb->Inode.i_nlink = 0;
2061 Mcb->Inode.i_dtime = Ext2LinuxTime(SysTime);
2062 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
2063 Ext2FreeInode(IrpContext, Vcb, Mcb->Inode.i_ino, Ext2InodeType(Mcb));
2064 }
2065
2066 } _SEH2_FINALLY {
2067
2068 if (FcbPagingIoAcquired) {
2070 }
2071
2072 if (FcbResourceAcquired) {
2074 }
2075
2076 if (DcbResourceAcquired) {
2077 ExReleaseResourceLite(&Dcb->MainResource);
2078 }
2079
2080 if (bFcbLockAcquired) {
2081 ExReleaseResourceLite(&Vcb->FcbLock);
2082 }
2083
2084 if (VcbResourceAcquired) {
2085 ExReleaseResourceLite(&Vcb->MainResource);
2086 }
2087
2088 if (Dcb) {
2090 }
2091
2093 } _SEH2_END;
2094
2095 DEBUG(DL_INF, ( "Ext2DeleteFile: %wZ Succeed... EXT2SB->S_FREE_BLOCKS = %I64xh .\n",
2096 &Mcb->FullName, ext3_free_blocks_count(SUPER_BLOCK)));
2097
2098 return Status;
2099}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define DEBUG(args)
Definition: rdesktop.h:129
#define EXT2_NAME_LEN
Definition: ext2.h:156
#define EXT2_ROOT_INO
Definition: ext2.h:177
BOOLEAN Ext2LookupFile(PEXT2_VOLUME_INFO Volume, PCSTR FileName, PEXT2_FILE_INFO Ext2FileInfo)
Definition: ext2.c:205
#define CcIsFileCached(FO)
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
_In_ PFCB Fcb
Definition: cdprocs.h:159
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1215
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 BLOCK_BITS
Definition: stream.h:22
#define EXT2_NDIR_BLOCKS
Definition: ext2_fs.h:177
#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE
Definition: ext2_fs.h:466
unsigned __int64 loff_t
Definition: types.h:84
NTSTATUS Ext2BlockMap(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Index, IN BOOLEAN bAlloc, OUT PULONG pBlock, OUT PULONG Number)
Definition: fileinfo.c:1127
NTSTATUS Ext2IsFileRemovable(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Fcb, IN PEXT2_CCB Ccb)
Definition: fileinfo.c:1239
NTSTATUS Ext2TruncateFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
Definition: fileinfo.c:1204
NTSTATUS Ext2SetLinkInfo(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_CCB Ccb)
Definition: fileinfo.c:1665
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
NTSTATUS Ext2DeleteFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_MCB Mcb)
Definition: fileinfo.c:1920
NTSTATUS Ext2SetRenameInfo(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_CCB Ccb)
Definition: fileinfo.c:1325
NTSTATUS Ext2SetFileInformation(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fileinfo.c:514
ULONG Ext2InodeType(PEXT2_MCB Mcb)
Definition: fileinfo.c:1906
NTSTATUS Ext2SetDispositionInfo(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_CCB Ccb, BOOLEAN bDelete)
Definition: fileinfo.c:1282
static int Ext2IterateAllEa(struct ext4_xattr_ref *xattr_ref, struct ext4_xattr_item *item, BOOL is_last)
Definition: fileinfo.c:38
NTSTATUS Ext2QueryFileInformation(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fileinfo.c:48
NTSTATUS Ext2ExpandFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
Definition: fileinfo.c:1152
ULONG Ext2TotalBlocks(PEXT2_VCB Vcb, PLARGE_INTEGER Size, PULONG pMeta)
Definition: fileinfo.c:1077
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB ParentDcb
Definition: create.c:4141
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition: create.c:4140
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
#define ExAcquireResourceSharedLite(res, wait)
Definition: env_spec_w32.h:621
#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
#define DL_WRN
Definition: ext2fs.h:1447
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
NTSTATUS Ext2ExpandIndirect(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, ULONG Start, ULONG End, PLARGE_INTEGER Size)
Definition: indirect.c:948
#define Ext2FileCanWrite
Definition: ext2fs.h:432
VOID Ext2ReleaseFcb(IN PEXT2_FCB Fcb)
Definition: memory.c:276
NTSTATUS Ext2WinntError(int rc)
Definition: misc.c:410
NTSTATUS Ext2TruncateExtent(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
Definition: extents.c:200
#define IsMcbSpecialFile(Mcb)
Definition: ext2fs.h:964
static ext3_fsblk_t ext3_free_blocks_count(struct ext3_super_block *es)
Definition: ext2fs.h:1757
#define Ext2SetOwnerWritable(m)
Definition: ext2fs.h:413
@ EXT2FCB
Definition: ext2fs.h:463
@ EXT2ICX
Definition: ext2fs.h:465
@ EXT2VCB
Definition: ext2fs.h:462
@ EXT2CCB
Definition: ext2fs.h:464
#define IsDirectory(Fcb)
Definition: ext2fs.h:283
#define IsVcbReadOnly(Vcb)
Definition: ext2fs.h:814
NTSTATUS Ext2ExpandExtent(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, ULONG Start, ULONG End, PLARGE_INTEGER Size)
Definition: extents.c:151
#define IsFileDeleted(Mcb)
Definition: ext2fs.h:968
#define IsMounted(Vcb)
Definition: ext2fs.h:812
#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
LARGE_INTEGER Ext2NtTime(IN ULONG i_time)
Definition: misc.c:40
BOOLEAN Ext2SaveInode(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN struct inode *Inode)
Definition: generic.c:552
#define EXT2_LINKLEN_IN_INODE
Definition: ext2fs.h:76
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:616
NTSTATUS Ext2QueueRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:158
#define Ext2ReferXcb(_C)
Definition: ext2fs.h:976
#define FCB_ALLOC_IN_WRITE
Definition: ext2fs.h:885
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:258
#define DL_INF
Definition: ext2fs.h:1436
#define FCB_PAGE_FILE
Definition: ext2fs.h:881
NTSTATUS Ext2MapExtent(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Index, IN BOOLEAN Alloc, OUT PULONG Block, OUT PULONG Number)
Definition: extents.c:25
#define FCB_FILE_MODIFIED
Definition: ext2fs.h:882
#define FCB_ALLOC_IN_SETINFO
Definition: ext2fs.h:886
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
NTSTATUS Ext2SetParentEntry(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Dcb, IN ULONG OldParent, IN ULONG NewParent)
Definition: generic.c:2098
#define DL_REN
Definition: ext2fs.h:1439
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 IsMcbDirectory(Mcb)
Definition: ext2fs.h:967
#define IsInodeSymLink(I)
Definition: ext2fs.h:286
#define FCB_DELETE_PENDING
Definition: ext2fs.h:888
BOOLEAN Ext2SaveSuper(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:67
#define DbgBreak()
Definition: ext2fs.h:46
#define FCB_ALLOC_IN_CREATE
Definition: ext2fs.h:884
#define Ext2SetOwnerReadOnly(m)
Definition: ext2fs.h:414
struct _EXT2_VCB * PEXT2_VCB
BOOLEAN Ext2BuildName(IN OUT PUNICODE_STRING Target, IN PUNICODE_STRING File, IN PUNICODE_STRING Parent)
Definition: memory.c:1361
BOOLEAN Ext2RemoveMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb)
Definition: memory.c:1746
#define MCB_ZONE_INITED
Definition: ext2fs.h:957
struct _EXT2_CCB * PEXT2_CCB
#define CCB_LAST_WRITE_UPDATED
Definition: ext2fs.h:1033
NTSTATUS Ext2TruncateIndirect(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
Definition: indirect.c:1099
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)
NTSTATUS Ext2MapIndirect(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Index, IN BOOLEAN bAlloc, OUT PULONG pBlock, OUT PULONG Number)
Definition: indirect.c:835
VOID Ext2FreeEntry(IN struct dentry *de)
Definition: memory.c:432
NTSTATUS Ext2RemoveEntry(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Dcb, IN PEXT2_MCB Mcb)
Definition: generic.c:2021
BOOLEAN Ext2ListExtents(PLARGE_MCB Extents)
Definition: memory.c:558
#define Ext2ReferMcb(Mcb)
Definition: ext2fs.h:995
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
BOOLEAN Ext2IsDirectoryEmpty(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
#define MCB_FILE_DELETED
Definition: ext2fs.h:955
#define IsLinkInvalid(Mcb)
Definition: ext2fs.h:970
VOID Ext2ClearAllExtents(PLARGE_MCB Zone)
Definition: memory.c:637
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_IO
Definition: ext2fs.h:1450
#define DL_RES
Definition: ext2fs.h:1440
int Ext2CheckFileAccess(PEXT2_VCB Vcb, PEXT2_MCB Mcb, int attempt)
Definition: access.c:51
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
FAST_IO_POSSIBLE Ext2IsFastIoPossible(IN PEXT2_FCB Fcb)
Definition: fastio.c:38
#define INODE_HAS_EXTENT(i)
Definition: ext4_ext.h:228
Extended Attribute manipulation.
IN PDCB TargetDcb
Definition: fatprocs.h:788
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:322
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
unsigned int BOOL
Definition: ntddk_ex.h:94
_Must_inspect_result_ _In_ USHORT NewSize
Definition: fltkernel.h:975
@ FilePositionInformation
Definition: from_kernel.h:75
@ FileEndOfFileInformation
Definition: from_kernel.h:81
@ FileRenameInformation
Definition: from_kernel.h:71
@ FileAllInformation
Definition: from_kernel.h:79
@ FileLinkInformation
Definition: from_kernel.h:72
@ FileInternalInformation
Definition: from_kernel.h:67
@ FileAttributeTagInformation
Definition: from_kernel.h:96
@ FileEaInformation
Definition: from_kernel.h:68
@ FileValidDataLengthInformation
Definition: from_kernel.h:100
@ FileNameInformation
Definition: from_kernel.h:70
@ FileAllocationInformation
Definition: from_kernel.h:80
@ FileNetworkOpenInformation
Definition: from_kernel.h:95
@ FileStreamInformation
Definition: from_kernel.h:83
@ FileBasicInformation
Definition: from_kernel.h:65
@ FileDispositionInformation
Definition: from_kernel.h:74
struct _FILE_NETWORK_OPEN_INFORMATION FILE_NETWORK_OPEN_INFORMATION
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: directory.c:44
struct _FILE_NETWORK_OPEN_INFORMATION * PFILE_NETWORK_OPEN_INFORMATION
struct _FILE_LINK_INFORMATION * PFILE_LINK_INFORMATION
struct _FILE_INTERNAL_INFORMATION * PFILE_INTERNAL_INFORMATION
VOID NTAPI CcSetFileSizes(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
Definition: fssup.c:356
Status
Definition: gdiplustypes.h:25
#define EXT4_XATTR_ITERATE_CONT
Definition: ext4_xattr.h:162
void ext4_fs_xattr_iterate(struct ext4_xattr_ref *ref, int(*iter)(struct ext4_xattr_ref *ref, struct ext4_xattr_item *item, BOOL is_last))
Definition: ext4_xattr.c:978
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
struct _FILE_ATTRIBUTE_TAG_INFORMATION FILE_ATTRIBUTE_TAG_INFORMATION
struct _FILE_ALLOCATION_INFORMATION * PFILE_ALLOCATION_INFORMATION
struct _FILE_RENAME_INFORMATION * PFILE_RENAME_INFORMATION
struct _FILE_ALL_INFORMATION * PFILE_ALL_INFORMATION
struct _FILE_NAME_INFORMATION * PFILE_NAME_INFORMATION
struct _FILE_EA_INFORMATION * PFILE_EA_INFORMATION
struct _FILE_ATTRIBUTE_TAG_INFORMATION * PFILE_ATTRIBUTE_TAG_INFORMATION
struct _FILE_EA_INFORMATION FILE_EA_INFORMATION
struct _FILE_ALL_INFORMATION FILE_ALL_INFORMATION
if(dx< 0)
Definition: linetemp.h:194
@ FSI
Definition: bidi.c:98
#define ASSERT(a)
Definition: mode.c:44
#define FILE_STANDARD_INFORMATION
Definition: disk.h:54
#define FILE_BASIC_INFORMATION
Definition: disk.h:53
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:75
static ATOM item
Definition: dde.c:856
_In_ UINT _In_ UINT BytesToCopy
Definition: ndis.h:3168
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
struct _FILE_POSITION_INFORMATION FILE_POSITION_INFORMATION
struct _FILE_END_OF_FILE_INFORMATION * PFILE_END_OF_FILE_INFORMATION
struct _FILE_BASIC_INFORMATION * PFILE_BASIC_INFORMATION
struct _FILE_ALIGNMENT_INFORMATION FILE_ALIGNMENT_INFORMATION
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
struct _FILE_DISPOSITION_INFORMATION * PFILE_DISPOSITION_INFORMATION
struct _FILE_POSITION_INFORMATION * PFILE_POSITION_INFORMATION
#define FILE_ATTRIBUTE_TEMPORARY
Definition: nt_native.h:708
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
BOOLEAN NTAPI FsRtlAreNamesEqual(IN PCUNICODE_STRING Name1, IN PCUNICODE_STRING Name2, IN BOOLEAN IgnoreCase, IN PCWCH UpcaseTable OPTIONAL)
Definition: name.c:296
BOOLEAN NTAPI FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name)
Definition: name.c:464
VOID NTAPI FsRtlNotifyFullChangeDirectory(IN PNOTIFY_SYNC NotifySync, IN PLIST_ENTRY NotifyList, IN PVOID FsContext, IN PSTRING FullDirectoryName, IN BOOLEAN WatchTree, IN BOOLEAN IgnoreBuffer, IN ULONG CompletionFilter, IN PIRP NotifyIrp, IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL)
Definition: notify.c:1487
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:207
#define STATUS_CANT_WAIT
Definition: ntstatus.h:452
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_USER_MAPPED_FILE
Definition: ntstatus.h:711
#define L(x)
Definition: ntvdm.h:50
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
unsigned short USHORT
Definition: pedump.c:61
#define Vcb
Definition: cdprocs.h:1415
struct _FILE_STANDARD_INFORMATION * PFILE_STANDARD_INFORMATION
struct _FILE_ACCESS_INFORMATION FILE_ACCESS_INFORMATION
#define FileStandardInformation
Definition: propsheet.cpp:61
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define EXT2_FT_DIR
Definition: ext2_fs.h:531
#define EXT2_FT_SYMLINK
Definition: ext2_fs.h:536
#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:4242
BOOLEAN NTAPI MmFlushImageSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN MMFLUSH_TYPE FlushType)
Definition: section.c:4343
#define STATUS_CANNOT_DELETE
Definition: shellext.h:71
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
ULONG Type
Definition: ntfs.h:95
ULONG Size
Definition: ntfs.h:96
EXT2_IDENTIFIER_TYPE Type
Definition: ext2fs.h:477
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
PVCB Vcb
Definition: cdstruc.h:933
CD_MCB Mcb
Definition: cdstruc.h:1016
ERESOURCE PagingIoResource
Definition: ntfs.h:527
NTFSIDENTIFIER Identifier
Definition: ntfs.h:515
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:925
ERESOURCE MainResource
Definition: ntfs.h:528
LARGE_INTEGER AllocationSize
Definition: winternl.h:688
LARGE_INTEGER LastWriteTime
Definition: nt_native.h:941
LARGE_INTEGER CreationTime
Definition: nt_native.h:939
LARGE_INTEGER ChangeTime
Definition: nt_native.h:942
LARGE_INTEGER LastAccessTime
Definition: nt_native.h:940
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: fs.h:117
struct dentry::@696 d_name
UCHAR MajorFunction
Definition: ext2fs.h:1056
PDEVICE_OBJECT DeviceObject
Definition: ext2fs.h:1060
EXT2_IDENTIFIER Identifier
Definition: ext2fs.h:1047
ULONG Flags
Definition: ext2fs.h:1053
PIRP Irp
Definition: ext2fs.h:1050
PFILE_OBJECT FileObject
Definition: ext2fs.h:1066
BOOLEAN ExceptionInProgress
Definition: ext2fs.h:1078
void * iter_arg
Definition: ext4_xattr.h:155
PEXT2_IRP_CONTEXT IrpContext
Definition: ext4_xattr.h:141
Definition: fs.h:78
__u32 i_mtime
Definition: fs.h:83
umode_t i_mode
Definition: fs.h:87
__u32 i_atime
Definition: fs.h:81
__u32 i_ctime
Definition: fs.h:82
Definition: ps.c:97
uint32_t * PULONG
Definition: typedefs.h:59
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
int64_t LONGLONG
Definition: typedefs.h:68
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
#define OUT
Definition: typedefs.h:40
#define STATUS_DIRECTORY_NOT_EMPTY
Definition: udferr_usr.h:167
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_MEDIA_WRITE_PROTECTED
Definition: udferr_usr.h:161
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define STATUS_FILE_DELETED
Definition: udferr_usr.h:172
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONGLONG QuadPart
Definition: typedefs.h:114
@ Start
Definition: partlist.h:33
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define FILE_NOTIFY_CHANGE_SIZE
#define FILE_ACTION_MODIFIED
#define FO_TEMPORARY_FILE
Definition: iotypes.h:1791
#define FILE_ACTION_RENAMED_OLD_NAME
#define FILE_NOTIFY_CHANGE_LAST_ACCESS
#define FILE_NOTIFY_CHANGE_ATTRIBUTES
#define FILE_ACTION_REMOVED
#define FO_FILE_MODIFIED
Definition: iotypes.h:1788
#define FILE_NOTIFY_CHANGE_FILE_NAME
* PFILE_OBJECT
Definition: iotypes.h:1998
#define FILE_ACTION_RENAMED_NEW_NAME
struct _FILE_VALID_DATA_LENGTH_INFORMATION * PFILE_VALID_DATA_LENGTH_INFORMATION
#define FO_NO_INTERMEDIATE_BUFFERING
Definition: iotypes.h:1778
#define FILE_NOTIFY_CHANGE_CREATION
#define IO_REPARSE_TAG_RESERVED_ZERO
Definition: iotypes.h:7216
#define FILE_NOTIFY_CHANGE_LAST_WRITE
#define FILE_ACTION_ADDED
#define FILE_NOTIFY_CHANGE_DIR_NAME
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE _In_opt_ PVOID _Out_ PIO_STATUS_BLOCK _In_ ULONG NotifyFilter
Definition: zwfuncs.h:504
_In_ PUNICODE_STRING NewName
Definition: zwfuncs.h:1203