ReactOS 0.4.15-dev-5884-gab5aff5
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#include <linux/ext4.h>
14#include "linux/ext4_xattr.h"
15
16/* GLOBALS ***************************************************************/
17
19
20/* DEFINITIONS *************************************************************/
21
22#ifdef ALLOC_PRAGMA
23#pragma alloc_text(PAGE, Ext2QueryFileInformation)
24#pragma alloc_text(PAGE, Ext2SetFileInformation)
25#pragma alloc_text(PAGE, Ext2ExpandFile)
26#pragma alloc_text(PAGE, Ext2TruncateFile)
27#pragma alloc_text(PAGE, Ext2SetDispositionInfo)
28#pragma alloc_text(PAGE, Ext2SetRenameInfo)
29#pragma alloc_text(PAGE, Ext2SetLinkInfo)
30#pragma alloc_text(PAGE, Ext2DeleteFile)
31#endif
32
33static int Ext2IterateAllEa(struct ext4_xattr_ref *xattr_ref, struct ext4_xattr_item *item, BOOL is_last)
34{
35 PULONG EaSize = xattr_ref->iter_arg;
36 ULONG EaEntrySize = 4 + 1 + 1 + 2 + item->name_len + 1 + item->data_size;
37
38 *EaSize += EaEntrySize - 4;
40}
41
44{
52 PIRP Irp = NULL;
53 PIO_STACK_LOCATION IoStackLocation;
57 BOOLEAN FcbResourceAcquired = FALSE;
58
59 _SEH2_TRY {
60
61 ASSERT(IrpContext != NULL);
62 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
63 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
64
65 DeviceObject = IrpContext->DeviceObject;
66
67 //
68 // This request is not allowed on the main device object
69 //
73 }
74
75 FileObject = IrpContext->FileObject;
76 Fcb = (PEXT2_FCB) FileObject->FsContext;
77 if (Fcb == NULL) {
80 }
81
82 //
83 // This request is not allowed on volumes
84 //
85 if (Fcb->Identifier.Type == EXT2VCB) {
88 }
89
90 if (!((Fcb->Identifier.Type == EXT2FCB) &&
91 (Fcb->Identifier.Size == sizeof(EXT2_FCB)))) {
94 }
95
96 Vcb = Fcb->Vcb;
97
98 {
101 IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT)
102 )) {
103
106 }
107
108 FcbResourceAcquired = TRUE;
109 }
110
111 Ccb = (PEXT2_CCB) FileObject->FsContext2;
112 ASSERT(Ccb != NULL);
114 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
115 Mcb = Ccb->SymLink;
116 if (!Mcb)
117 Mcb = Fcb->Mcb;
118
119 Irp = IrpContext->Irp;
120 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
122 IoStackLocation->Parameters.QueryFile.FileInformationClass;
123
124 Length = IoStackLocation->Parameters.QueryFile.Length;
125 Buffer = Irp->AssociatedIrp.SystemBuffer;
127
128 switch (FileInformationClass) {
129
131 {
133
134 if (Length < sizeof(FILE_BASIC_INFORMATION)) {
137 }
138
140
141 FileBasicInformation->CreationTime = Mcb->CreationTime;
142 FileBasicInformation->LastAccessTime = Mcb->LastAccessTime;
143 FileBasicInformation->LastWriteTime = Mcb->LastWriteTime;
144 FileBasicInformation->ChangeTime = Mcb->ChangeTime;
145
146 FileBasicInformation->FileAttributes = Mcb->FileAttr;
147 if (IsLinkInvalid(Mcb)) {
149 }
150 if (FileBasicInformation->FileAttributes == 0) {
152 }
153
154 Irp->IoStatus.Information = sizeof(FILE_BASIC_INFORMATION);
156 }
157 break;
158
160 {
162
163 if (Length < sizeof(FILE_STANDARD_INFORMATION)) {
166 }
167
169
170 FSI->NumberOfLinks = Mcb->Inode.i_nlink;
171
172 if (IsVcbReadOnly(Fcb->Vcb))
173 FSI->DeletePending = FALSE;
174 else
175 FSI->DeletePending = IsFlagOn(Fcb->Flags, FCB_DELETE_PENDING);
176
177 if (IsLinkInvalid(Mcb)) {
178 FSI->Directory = FALSE;
179 FSI->AllocationSize.QuadPart = 0;
180 FSI->EndOfFile.QuadPart = 0;
181 } else if (IsMcbDirectory(Mcb)) {
182 FSI->Directory = TRUE;
183 FSI->AllocationSize.QuadPart = 0;
184 FSI->EndOfFile.QuadPart = 0;
185 } else {
186 FSI->Directory = FALSE;
187 FSI->AllocationSize = Fcb->Header.AllocationSize;
188 FSI->EndOfFile = Fcb->Header.FileSize;
189 }
190
191 Irp->IoStatus.Information = sizeof(FILE_STANDARD_INFORMATION);
193 }
194 break;
195
197 {
199
200 if (Length < sizeof(FILE_INTERNAL_INFORMATION)) {
203 }
204
206
207 /* we use the inode number as the internal index */
208 FileInternalInformation->IndexNumber.QuadPart = (LONGLONG)Mcb->Inode.i_ino;
209
210 Irp->IoStatus.Information = sizeof(FILE_INTERNAL_INFORMATION);
212 }
213 break;
214
215
217 {
218 struct ext4_xattr_ref xattr_ref;
220
221 if (Length < sizeof(FILE_EA_INFORMATION)) {
224 }
225
227 FileEaInformation->EaSize = 0;
228
230 if (!NT_SUCCESS(Status))
232
233 xattr_ref.iter_arg = &FileEaInformation->EaSize;
235 ext4_fs_put_xattr_ref(&xattr_ref);
236
237 if (FileEaInformation->EaSize)
238 FileEaInformation->EaSize += 4;
239
240 Irp->IoStatus.Information = sizeof(FILE_EA_INFORMATION);
242 }
243 break;
244
246 {
248 ULONG BytesToCopy = 0;
249
251 Mcb->FullName.Length) {
254 } else {
255 BytesToCopy = Mcb->FullName.Length;
257 }
258
260 FileNameInformation->FileNameLength = Mcb->FullName.Length;
261
263 FileNameInformation->FileName,
264 Mcb->FullName.Buffer,
265 BytesToCopy );
266
267 Irp->IoStatus.Information = BytesToCopy +
269 }
270 break;
271
273 {
275
276 if (Length < sizeof(FILE_POSITION_INFORMATION)) {
279 }
280
282 FilePositionInformation->CurrentByteOffset =
283 FileObject->CurrentByteOffset;
284
285 Irp->IoStatus.Information = sizeof(FILE_POSITION_INFORMATION);
287 }
288 break;
289
291 {
299
300 if (Length < sizeof(FILE_ALL_INFORMATION)) {
303 }
304
306
308 &FileAllInformation->BasicInformation;
309
310 FSI =
311 &FileAllInformation->StandardInformation;
312
314 &FileAllInformation->InternalInformation;
315
317 &FileAllInformation->EaInformation;
318
320 &FileAllInformation->PositionInformation;
321
323 &FileAllInformation->NameInformation;
324
325 FileBasicInformation->CreationTime = Mcb->CreationTime;
326 FileBasicInformation->LastAccessTime = Mcb->LastAccessTime;
327 FileBasicInformation->LastWriteTime = Mcb->LastWriteTime;
328 FileBasicInformation->ChangeTime = Mcb->ChangeTime;
329
330 FileBasicInformation->FileAttributes = Mcb->FileAttr;
331 if (IsMcbSymLink(Mcb) && IsFileDeleted(Mcb->Target)) {
333 }
334 if (FileBasicInformation->FileAttributes == 0) {
336 }
337
338 FSI->NumberOfLinks = Mcb->Inode.i_nlink;
339
340 if (IsVcbReadOnly(Fcb->Vcb))
341 FSI->DeletePending = FALSE;
342 else
343 FSI->DeletePending = IsFlagOn(Fcb->Flags, FCB_DELETE_PENDING);
344
345 if (IsLinkInvalid(Mcb)) {
346 FSI->Directory = FALSE;
347 FSI->AllocationSize.QuadPart = 0;
348 FSI->EndOfFile.QuadPart = 0;
349 } else if (IsDirectory(Fcb)) {
350 FSI->Directory = TRUE;
351 FSI->AllocationSize.QuadPart = 0;
352 FSI->EndOfFile.QuadPart = 0;
353 } else {
354 FSI->Directory = FALSE;
355 FSI->AllocationSize = Fcb->Header.AllocationSize;
356 FSI->EndOfFile = Fcb->Header.FileSize;
357 }
358
359 // The "inode number"
360 FileInternalInformation->IndexNumber.QuadPart = (LONGLONG)Mcb->Inode.i_ino;
361
362 // Romfs doesn't have any extended attributes
363 FileEaInformation->EaSize = 0;
364
365 FilePositionInformation->CurrentByteOffset =
366 FileObject->CurrentByteOffset;
367
368 FileNameInformation->FileNameLength = Mcb->ShortName.Length;
369
370 if (Length < sizeof(FILE_ALL_INFORMATION) +
371 Mcb->ShortName.Length - sizeof(WCHAR)) {
372 Irp->IoStatus.Information = sizeof(FILE_ALL_INFORMATION);
375 FileNameInformation->FileName,
376 Mcb->ShortName.Buffer,
378 NameInformation.FileName)
379 );
381 }
382
384 FileNameInformation->FileName,
385 Mcb->ShortName.Buffer,
386 Mcb->ShortName.Length
387 );
388
389 Irp->IoStatus.Information = sizeof(FILE_ALL_INFORMATION) +
390 Mcb->ShortName.Length - sizeof(WCHAR);
391#if 0
393 sizeof(FILE_MODE_INFORMATION) -
395#endif
396
398 }
399 break;
400
401 /*
402 case FileAlternateNameInformation:
403 {
404 // TODO: Handle FileAlternateNameInformation
405
406 // Here we would like to use RtlGenerate8dot3Name but I don't
407 // know how to use the argument PGENERATE_NAME_CONTEXT
408 }
409 */
410
412 {
414
418 }
419
421
422 PFNOI->FileAttributes = Mcb->FileAttr;
423 if (IsLinkInvalid(Mcb)) {
425 PFNOI->AllocationSize.QuadPart = 0;
426 PFNOI->EndOfFile.QuadPart = 0;
427 } else if (IsDirectory(Fcb)) {
428 PFNOI->AllocationSize.QuadPart = 0;
429 PFNOI->EndOfFile.QuadPart = 0;
430 } else {
431 PFNOI->AllocationSize = Fcb->Header.AllocationSize;
432 PFNOI->EndOfFile = Fcb->Header.FileSize;
433 }
434
435 if (PFNOI->FileAttributes == 0) {
437 }
438
439 PFNOI->CreationTime = Mcb->CreationTime;
440 PFNOI->LastAccessTime = Mcb->LastAccessTime;
441 PFNOI->LastWriteTime = Mcb->LastWriteTime;
442 PFNOI->ChangeTime = Mcb->ChangeTime;
443
444
445 Irp->IoStatus.Information =
448 }
449 break;
450
451#if (_WIN32_WINNT >= 0x0500)
452
454 {
456
460 }
461
463 FATI->FileAttributes = Mcb->FileAttr;
464 if (IsLinkInvalid(Mcb)) {
466 }
467 if (FATI->FileAttributes == 0) {
469 }
471 Irp->IoStatus.Information = sizeof(FILE_ATTRIBUTE_TAG_INFORMATION);
473 }
474 break;
475#endif // (_WIN32_WINNT >= 0x0500)
476
479 break;
480
481 default:
482 DEBUG(DL_WRN, ( "Ext2QueryInformation: invalid class: %d\n",
484 Status = STATUS_INVALID_PARAMETER; /* STATUS_INVALID_INFO_CLASS; */
485 break;
486 }
487
488 } _SEH2_FINALLY {
489
490 if (FcbResourceAcquired) {
492 }
493
495 if (Status == STATUS_PENDING ||
498 } else {
500 }
501 }
502 } _SEH2_END;
503
504 return Status;
505}
506
507
510{
518 PIRP Irp = NULL;
519 PIO_STACK_LOCATION IoStackLocation = NULL;
521
523
526
527 BOOLEAN FcbMainResourceAcquired = FALSE;
528 BOOLEAN FcbPagingIoResourceAcquired = FALSE;
529
530 _SEH2_TRY {
531
533
537
538 //
539 // This request is not allowed on the main device object
540 //
544 }
545
546 /* check io stack location of irp stack */
547 Irp = IrpContext->Irp;
548 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
550 IoStackLocation->Parameters.SetFile.FileInformationClass;
551 Length = IoStackLocation->Parameters.SetFile.Length;
552 Buffer = Irp->AssociatedIrp.SystemBuffer;
553
554 /* check Vcb */
555 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
556 ASSERT(Vcb != NULL);
557 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
558 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
559 if (!IsMounted(Vcb)) {
562 }
563
564 if (FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED)) {
567 }
568
570 Fcb = (PEXT2_FCB) FileObject->FsContext;
571
572 // This request is issued to volumes, just return success
573 if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
576 }
578 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
579
580 if (IsFlagOn(Fcb->Mcb->Flags, MCB_FILE_DELETED)) {
583 }
584
585 Ccb = (PEXT2_CCB) FileObject->FsContext2;
586 ASSERT(Ccb != NULL);
588 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
589 Mcb = Ccb->SymLink;
590 if (Mcb) {
591 if (IsFlagOn(Mcb->Flags, MCB_FILE_DELETED)) {
594 }
595 } else {
596 Mcb = Fcb->Mcb;
597 }
598
600 if (IsVcbReadOnly(Vcb)) {
603 }
607 }
608 }
609
614
615 Status = FsRtlCheckOplock( &Fcb->Oplock,
616 Irp,
618 NULL,
619 NULL );
620
621 if (Status != STATUS_SUCCESS) {
623 }
624
625 //
626 // Set the flag indicating if Fast I/O is possible
627 //
628
629 Fcb->Header.IsFastIoPossible = Ext2IsFastIoPossible(Fcb);
630 }
631
632 /* for renaming or set link, we must not grab any Fcb locks,
633 and later we will get Dcb or Fcb resources exclusively. */
637
643 }
644
645 FcbMainResourceAcquired = TRUE;
646
650
655 DbgBreak();
657 }
658 FcbPagingIoResourceAcquired = TRUE;
659 }
660 }
661
662 switch (FileInformationClass) {
663
665 {
667 struct inode *Inode = &Mcb->Inode;
668
669 if (FBI->CreationTime.QuadPart != 0 && FBI->CreationTime.QuadPart != -1) {
670 Inode->i_ctime = Ext2LinuxTime(FBI->CreationTime);
671 Mcb->CreationTime = Ext2NtTime(Inode->i_ctime);
673 }
674
675 if (FBI->LastAccessTime.QuadPart != 0 && FBI->LastAccessTime.QuadPart != -1) {
676 Inode->i_atime = Ext2LinuxTime(FBI->LastAccessTime);
677 Mcb->LastAccessTime = Ext2NtTime(Inode->i_atime);
679 }
680
681 if (FBI->LastWriteTime.QuadPart != 0 && FBI->LastWriteTime.QuadPart != -1) {
682 Inode->i_mtime = Ext2LinuxTime(FBI->LastWriteTime);
683 Mcb->LastWriteTime = Ext2NtTime(Inode->i_mtime);
686 }
687
688 if (FBI->ChangeTime.QuadPart !=0 && FBI->ChangeTime.QuadPart != -1) {
689 Mcb->ChangeTime = FBI->ChangeTime;
690 }
691
692 if (FBI->FileAttributes != 0) {
693
694 BOOLEAN bIsDirectory = IsDirectory(Fcb);
696
699 } else {
701 }
702
705 } else {
707 }
708
709 Mcb->FileAttr = FBI->FileAttributes;
710 if (bIsDirectory) {
713 }
714 }
715
716 if (NotifyFilter != 0) {
717 if (Ext2SaveInode(IrpContext, Vcb, Inode)) {
719 }
720 }
721
724 }
725
726 break;
727
729 {
732
736 } else {
738 }
739
740 /* set Mcb to it's target */
741 if (IsMcbSymLink(Mcb)) {
742 ASSERT(Fcb->Mcb == Mcb->Target);
743 }
744 Mcb = Fcb->Mcb;
745
746 /* get user specified allocationsize aligned with BLOCK_SIZE */
750
751 if (AllocationSize.QuadPart > Fcb->Header.AllocationSize.QuadPart) {
752
753 Status = Ext2ExpandFile(IrpContext, Vcb, Mcb, &AllocationSize);
754 Fcb->Header.AllocationSize = AllocationSize;
757
758 } else if (AllocationSize.QuadPart < Fcb->Header.AllocationSize.QuadPart) {
759
760 if (MmCanFileBeTruncated(&(Fcb->SectionObject), &AllocationSize)) {
761
762 /* truncate file blocks */
763 Status = Ext2TruncateFile(IrpContext, Vcb, Mcb, &AllocationSize);
764
765 if (NT_SUCCESS(Status)) {
767 }
768
770 Fcb->Header.AllocationSize.QuadPart = AllocationSize.QuadPart;
771 if (Mcb->Inode.i_size > (loff_t)AllocationSize.QuadPart) {
772 Mcb->Inode.i_size = AllocationSize.QuadPart;
773 }
774 Fcb->Header.FileSize.QuadPart = Mcb->Inode.i_size;
775 if (Fcb->Header.ValidDataLength.QuadPart > Fcb->Header.FileSize.QuadPart) {
776 Fcb->Header.ValidDataLength.QuadPart = Fcb->Header.FileSize.QuadPart;
777 }
778
779 } else {
780
782 DbgBreak();
784 }
785 }
786
787 if (NotifyFilter) {
788
791 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
793 CcSetFileSizes(FileObject, (PCC_FILE_SIZES)(&(Fcb->Header.AllocationSize)));
794 }
795 }
796
797 DEBUG(DL_IO, ("Ext2SetInformation: %wZ NewSize=%I64xh AllocationSize=%I64xh "
798 "FileSize=%I64xh VDL=%I64xh i_size=%I64xh status = %xh\n",
799 &Fcb->Mcb->ShortName, AllocationSize.QuadPart,
800 Fcb->Header.AllocationSize.QuadPart,
801 Fcb->Header.FileSize.QuadPart, Fcb->Header.ValidDataLength.QuadPart,
802 Mcb->Inode.i_size, Status));
803 }
804
805 break;
806
808 {
810 LARGE_INTEGER NewSize, OldSize, EndOfFile;
811
815 } else {
817 }
818
819 /* set Mcb to it's target */
820 if (IsMcbSymLink(Mcb)) {
821 ASSERT(Fcb->Mcb == Mcb->Target);
822 }
823 Mcb = Fcb->Mcb;
824
825 OldSize = Fcb->Header.AllocationSize;
826 EndOfFile = FEOFI->EndOfFile;
827
828 if (IoStackLocation->Parameters.SetFile.AdvanceOnly) {
829
832 }
833
834 if (EndOfFile.QuadPart > Fcb->Header.FileSize.QuadPart) {
835 EndOfFile.QuadPart = Fcb->Header.FileSize.QuadPart;
836 }
837
838 if (EndOfFile.QuadPart > Fcb->Header.ValidDataLength.QuadPart) {
839 Fcb->Header.ValidDataLength.QuadPart = EndOfFile.QuadPart;
841 }
842
844 }
845
847 EndOfFile.QuadPart, BLOCK_SIZE);
848
849 if (NewSize.QuadPart > OldSize.QuadPart) {
850
851 Fcb->Header.AllocationSize = NewSize;
853 IrpContext,
854 Vcb,
855 Mcb,
856 &(Fcb->Header.AllocationSize)
857 );
860
861
862 } else if (NewSize.QuadPart == OldSize.QuadPart) {
863
864 /* we are luck ;) */
866
867 } else {
868
869 /* don't truncate file data since it's still being written */
871
873
874 } else {
875
876 if (!MmCanFileBeTruncated(&(Fcb->SectionObject), &NewSize)) {
878 DbgBreak();
880 }
881
882 /* truncate file blocks */
883 Status = Ext2TruncateFile(IrpContext, Vcb, Mcb, &NewSize);
884
885 /* restore original file size */
886 if (NT_SUCCESS(Status)) {
888 }
889
890 /* update file allocateion size */
891 Fcb->Header.AllocationSize.QuadPart = NewSize.QuadPart;
892
893 ASSERT((loff_t)NewSize.QuadPart >= Mcb->Inode.i_size);
894 if ((loff_t)Fcb->Header.FileSize.QuadPart < Mcb->Inode.i_size) {
895 Fcb->Header.FileSize.QuadPart = Mcb->Inode.i_size;
896 }
897 if (Fcb->Header.ValidDataLength.QuadPart > Fcb->Header.FileSize.QuadPart) {
898 Fcb->Header.ValidDataLength.QuadPart = Fcb->Header.FileSize.QuadPart;
899 }
900
903 }
904
906 }
907
908 if (NT_SUCCESS(Status)) {
909
910 Fcb->Header.FileSize.QuadPart = Mcb->Inode.i_size = EndOfFile.QuadPart;
912 CcSetFileSizes(FileObject, (PCC_FILE_SIZES)(&(Fcb->Header.AllocationSize)));
913 }
914
915 if (Fcb->Header.FileSize.QuadPart >= 0x80000000 &&
918 Ext2SaveSuper(IrpContext, Vcb);
919 }
920
924 }
925
926
927 Ext2SaveInode( IrpContext, Vcb, &Mcb->Inode);
928
929 DEBUG(DL_IO, ("Ext2SetInformation: FileEndOfFileInformation %wZ EndofFile=%I64xh "
930 "AllocatieonSize=%I64xh FileSize=%I64xh VDL=%I64xh i_size=%I64xh status = %xh\n",
931 &Fcb->Mcb->ShortName, EndOfFile.QuadPart, Fcb->Header.AllocationSize.QuadPart,
932 Fcb->Header.FileSize.QuadPart, Fcb->Header.ValidDataLength.QuadPart,
933 Mcb->Inode.i_size, Status));
934 }
935
936 break;
937
939 {
941 LARGE_INTEGER NewVDL;
942
946 } else {
948 }
949
950 NewVDL = FVDL->ValidDataLength;
951 if ((NewVDL.QuadPart < Fcb->Header.ValidDataLength.QuadPart)) {
954 }
955 if (NewVDL.QuadPart > Fcb->Header.FileSize.QuadPart)
956 NewVDL = Fcb->Header.FileSize;
957
958 if (!MmCanFileBeTruncated(FileObject->SectionObjectPointer,
959 &NewVDL)) {
962 }
963
964 Fcb->Header.ValidDataLength = NewVDL;
967 CcSetFileSizes(FileObject, (PCC_FILE_SIZES)(&(Fcb->Header.AllocationSize)));
968 }
969 }
970
971 break;
972
974 {
976
977 Status = Ext2SetDispositionInfo(IrpContext, Vcb, Fcb, Ccb, FDI->DeleteFile);
978
979 DEBUG(DL_INF, ( "Ext2SetInformation: SetDispositionInformation: DeleteFile=%d %wZ status = %xh\n",
980 FDI->DeleteFile, &Mcb->ShortName, Status));
981 }
982
983 break;
984
986 {
987 Status = Ext2SetRenameInfo(IrpContext, Vcb, Fcb, Ccb);
988 }
989
990 break;
991
992
994 {
995 Status = Ext2SetLinkInfo(IrpContext, Vcb, Fcb, Ccb);
996 }
997
998 break;
999
1000 //
1001 // This is the only set file information request supported on read
1002 // only file systems
1003 //
1005 {
1007
1008 if (Length < sizeof(FILE_POSITION_INFORMATION)) {
1011 }
1012
1014
1016 (FilePositionInformation->CurrentByteOffset.LowPart &
1017 DeviceObject->AlignmentRequirement) ) {
1020 }
1021
1022 FileObject->CurrentByteOffset =
1023 FilePositionInformation->CurrentByteOffset;
1024
1027 }
1028
1029 break;
1030
1031 default:
1032 DEBUG(DL_WRN, ( "Ext2SetInformation: invalid class: %d\n",
1034 Status = STATUS_INVALID_PARAMETER;/* STATUS_INVALID_INFO_CLASS; */
1035 }
1036
1037 } _SEH2_FINALLY {
1038
1039 if (FcbPagingIoResourceAcquired) {
1041 }
1042
1043 if (NT_SUCCESS(Status) && (NotifyFilter != 0)) {
1045 IrpContext,
1046 Vcb,
1047 Mcb,
1050
1051 }
1052
1053 if (FcbMainResourceAcquired) {
1055 }
1056
1057 if (!IrpContext->ExceptionInProgress) {
1058 if (Status == STATUS_PENDING ||
1060 DbgBreak();
1061 Status = Ext2QueueRequest(IrpContext);
1062 } else {
1063 Ext2CompleteIrpContext(IrpContext, Status);
1064 }
1065 }
1066 } _SEH2_END;
1067
1068 return Status;
1069}
1070
1071ULONG
1073 PEXT2_VCB Vcb,
1075 PULONG pMeta
1076)
1077{
1078 ULONG Blocks, Meta =0, Remain;
1079
1080 Blocks = (ULONG)((Size->QuadPart + BLOCK_SIZE - 1) >> BLOCK_BITS);
1081 if (Blocks <= EXT2_NDIR_BLOCKS)
1082 goto errorout;
1083 Blocks -= EXT2_NDIR_BLOCKS;
1084
1085 Meta += 1;
1086 if (Blocks <= Vcb->max_blocks_per_layer[1]) {
1087 goto errorout;
1088 }
1089 Blocks -= Vcb->max_blocks_per_layer[1];
1090
1091level2:
1092
1093 if (Blocks <= Vcb->max_blocks_per_layer[2]) {
1094 Meta += 1 + ((Blocks + BLOCK_SIZE/4 - 1) >> (BLOCK_BITS - 2));
1095 goto errorout;
1096 }
1097 Meta += 1 + BLOCK_SIZE/4;
1098 Blocks -= Vcb->max_blocks_per_layer[2];
1099
1100 if (Blocks > Vcb->max_blocks_per_layer[3]) {
1101 Blocks = Vcb->max_blocks_per_layer[3];
1102 }
1103
1104 ASSERT(Vcb->max_blocks_per_layer[2]);
1105 Remain = Blocks % Vcb->max_blocks_per_layer[2];
1106 Blocks = Blocks / Vcb->max_blocks_per_layer[2];
1107 Meta += 1 + Blocks * (1 + BLOCK_SIZE/4);
1108 if (Remain) {
1109 Blocks = Remain;
1110 goto level2;
1111 }
1112
1113errorout:
1114
1115 if (pMeta)
1116 *pMeta = Meta;
1117 Blocks = (ULONG)((Size->QuadPart + BLOCK_SIZE - 1) >> BLOCK_BITS);
1118 return (Blocks + Meta);
1119}
1120
1123 IN PEXT2_IRP_CONTEXT IrpContext,
1126 IN ULONG Index,
1127 IN BOOLEAN bAlloc,
1128 OUT PULONG pBlock,
1130)
1131{
1133
1134 if (INODE_HAS_EXTENT(&Mcb->Inode)) {
1135 status = Ext2MapExtent(IrpContext, Vcb, Mcb, Index,
1136 bAlloc, pBlock, Number );
1137 } else {
1138 status = Ext2MapIndirect(IrpContext, Vcb, Mcb, Index,
1139 bAlloc, pBlock, Number );
1140 }
1141
1142 return status;
1143}
1144
1145
1148 PEXT2_IRP_CONTEXT IrpContext,
1149 PEXT2_VCB Vcb,
1150 PEXT2_MCB Mcb,
1152)
1153{
1155 ULONG Start = 0;
1156 ULONG End = 0;
1157
1158 Start = (ULONG)((Mcb->Inode.i_size + BLOCK_SIZE - 1) >> BLOCK_BITS);
1159 End = (ULONG)((Size->QuadPart + BLOCK_SIZE - 1) >> BLOCK_BITS);
1160
1161 /* it's a truncate operation, not expanding */
1162 if (Start >= End) {
1163 Size->QuadPart = ((LONGLONG) Start) << BLOCK_BITS;
1164 return STATUS_SUCCESS;
1165 }
1166
1167 /* ignore special files */
1168 if (IsMcbSpecialFile(Mcb)) {
1170 }
1171
1172 /* expandind file extents */
1173 if (INODE_HAS_EXTENT(&Mcb->Inode)) {
1174
1175 status = Ext2ExpandExtent(IrpContext, Vcb, Mcb, Start, End, Size);
1176
1177 } else {
1178
1179 BOOLEAN do_expand;
1180
1181#if EXT2_PRE_ALLOCATION_SUPPORT
1182 do_expand = TRUE;
1183#else
1184 do_expand = (IrpContext->MajorFunction == IRP_MJ_WRITE) ||
1186#endif
1187 if (!do_expand)
1188 goto errorout;
1189
1190 status = Ext2ExpandIndirect(IrpContext, Vcb, Mcb, Start, End, Size);
1191 }
1192
1193errorout:
1194 return status;
1195}
1196
1197
1200 PEXT2_IRP_CONTEXT IrpContext,
1201 PEXT2_VCB Vcb,
1202 PEXT2_MCB Mcb,
1204)
1205{
1207
1208 if (INODE_HAS_EXTENT(&Mcb->Inode)) {
1209 status = Ext2TruncateExtent(IrpContext, Vcb, Mcb, Size);
1210 } else {
1211 status = Ext2TruncateIndirect(IrpContext, Vcb, Mcb, Size);
1212 }
1213
1214 /* check and clear data/meta mcb extents */
1215 if (Size->QuadPart == 0) {
1216
1217 /* check and remove all data extents */
1218 if (Ext2ListExtents(&Mcb->Extents)) {
1219 DbgBreak();
1220 }
1221 Ext2ClearAllExtents(&Mcb->Extents);
1222 /* check and remove all meta extents */
1223 if (Ext2ListExtents(&Mcb->MetaExts)) {
1224 DbgBreak();
1225 }
1226 Ext2ClearAllExtents(&Mcb->MetaExts);
1228 }
1229
1230 return status;
1231}
1232
1235 IN PEXT2_IRP_CONTEXT IrpContext,
1239)
1240{
1241 PEXT2_MCB Mcb = Fcb->Mcb;
1242
1243 if (Mcb->Inode.i_ino == EXT2_ROOT_INO) {
1244 return STATUS_CANNOT_DELETE;
1245 }
1246
1247 if (IsMcbDirectory(Mcb)) {
1248 if (!Ext2IsDirectoryEmpty(IrpContext, Vcb, Mcb)) {
1250 }
1251 }
1252
1253 if (!MmFlushImageSection(&Fcb->SectionObject,
1254 MmFlushForDelete )) {
1255 return STATUS_CANNOT_DELETE;
1256 }
1257
1258 if (IsMcbDirectory(Mcb)) {
1260 Vcb->NotifySync,
1261 &Vcb->NotifyList,
1262 Ccb,
1263 NULL,
1264 FALSE,
1265 FALSE,
1266 0,
1267 NULL,
1268 NULL,
1269 NULL
1270 );
1271 }
1272
1273 return STATUS_SUCCESS;
1274}
1275
1278 PEXT2_IRP_CONTEXT IrpContext,
1279 PEXT2_VCB Vcb,
1280 PEXT2_FCB Fcb,
1281 PEXT2_CCB Ccb,
1282 BOOLEAN bDelete
1283)
1284{
1285 PIRP Irp = IrpContext->Irp;
1288 PEXT2_MCB Mcb = Fcb->Mcb;
1289
1291
1292 DEBUG(DL_INF, ( "Ext2SetDispositionInfo: bDelete=%x\n", bDelete));
1293
1294 if (bDelete) {
1295
1296 DEBUG(DL_INF, ( "Ext2SetDispositionInformation: Removing %wZ.\n",
1297 &Mcb->FullName));
1298
1299 if (Ccb->SymLink || IsInodeSymLink(&Mcb->Inode)) {
1300 /* always allow deleting on symlinks */
1301 } else {
1302 status = Ext2IsFileRemovable(IrpContext, Vcb, Fcb, Ccb);
1303 }
1304
1305 if (NT_SUCCESS(status)) {
1307 IrpSp->FileObject->DeletePending = TRUE;
1308 }
1309
1310 } else {
1311
1313 IrpSp->FileObject->DeletePending = FALSE;
1314 }
1315
1316 return status;
1317}
1318
1321 PEXT2_IRP_CONTEXT IrpContext,
1322 PEXT2_VCB Vcb,
1323 PEXT2_FCB Fcb,
1325)
1326{
1327 PEXT2_MCB Mcb = Fcb->Mcb;
1328
1329 PEXT2_FCB TargetDcb = NULL; /* Dcb of target directory */
1330 PEXT2_MCB TargetMcb = NULL;
1331 PEXT2_FCB ParentDcb = NULL; /* Dcb of it's current parent */
1332 PEXT2_MCB ParentMcb = NULL;
1333
1334 PEXT2_FCB ExistingFcb = NULL; /* Target file Fcb if it exists*/
1335 PEXT2_MCB ExistingMcb = NULL;
1336
1338
1340
1341 PIRP Irp;
1343
1345 PFILE_OBJECT TargetObject;
1346
1347 struct dentry *NewEntry = NULL;
1348
1349 BOOLEAN ReplaceIfExists;
1350 BOOLEAN bMove = FALSE;
1351 BOOLEAN bTargetRemoved = FALSE;
1352
1353 BOOLEAN bFcbLockAcquired = FALSE;
1354
1356
1357 if (Ccb->SymLink) {
1358 Mcb = Ccb->SymLink;
1359 }
1360
1361 if (Mcb->Inode.i_ino == EXT2_ROOT_INO) {
1363 goto errorout;
1364 }
1365
1366 Irp = IrpContext->Irp;
1368
1370 TargetObject = IrpSp->Parameters.SetFile.FileObject;
1371 ReplaceIfExists = IrpSp->Parameters.SetFile.ReplaceIfExists;
1372
1373 FRI = (PFILE_RENAME_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
1374
1375 if (TargetObject == NULL) {
1376
1378
1379 NewName.Buffer = FRI->FileName;
1381
1382 while (NewName.Length > 0 && NewName.Buffer[NewName.Length/2 - 1] == L'\\') {
1383 NewName.Buffer[NewName.Length/2 - 1] = 0;
1384 NewName.Length -= 2;
1385 }
1386
1387 while (NewName.Length > 0 && NewName.Buffer[NewName.Length/2 - 1] != L'\\') {
1388 NewName.Length -= 2;
1389 }
1390
1393
1394 FileName = NewName;
1395
1396 TargetMcb = Mcb->Parent;
1397 if (IsMcbSymLink(TargetMcb)) {
1398 TargetMcb = TargetMcb->Target;
1399 ASSERT(!IsMcbSymLink(TargetMcb));
1400 }
1401
1402 if (TargetMcb == NULL || FileName.Length >= EXT2_NAME_LEN*2) {
1404 goto errorout;
1405 }
1406
1407 } else {
1408
1409 TargetDcb = (PEXT2_FCB)(TargetObject->FsContext);
1410
1411 if (!TargetDcb || TargetDcb->Vcb != Vcb) {
1412
1413 DbgBreak();
1414
1416 goto errorout;
1417 }
1418
1419 TargetMcb = TargetDcb->Mcb;
1420 FileName = TargetObject->FileName;
1421 }
1422
1425 goto errorout;
1426 }
1427
1428 if (TargetMcb->Inode.i_ino == Mcb->Parent->Inode.i_ino) {
1430 &(Mcb->ShortName),
1431 FALSE,
1432 NULL )) {
1434 goto errorout;
1435 }
1436 } else {
1437 bMove = TRUE;
1438 }
1439
1440 if (!bFcbLockAcquired) {
1442 bFcbLockAcquired = TRUE;
1443 }
1444
1445 TargetDcb = TargetMcb->Fcb;
1446 if (TargetDcb == NULL) {
1447 TargetDcb = Ext2AllocateFcb(Vcb, TargetMcb);
1448 }
1449 if (TargetDcb) {
1450 Ext2ReferXcb(&TargetDcb->ReferenceCount);
1451 }
1452
1453 ParentMcb = Mcb->Parent;
1454 ParentDcb = ParentMcb->Fcb;
1455
1456 if ((TargetMcb->Inode.i_ino != ParentMcb->Inode.i_ino)) {
1457
1458 if (ParentDcb == NULL) {
1459 ParentDcb = Ext2AllocateFcb(Vcb, ParentMcb);
1460 }
1461 }
1462 if (ParentDcb) {
1463 Ext2ReferXcb(&ParentDcb->ReferenceCount);
1464 }
1465
1466 if (bFcbLockAcquired) {
1467 ExReleaseResourceLite(&Vcb->FcbLock);
1468 bFcbLockAcquired = FALSE;
1469 }
1470
1471 if (!TargetDcb || !ParentDcb) {
1473 goto errorout;
1474 }
1475
1476 DEBUG(DL_RES, ("Ext2SetRenameInfo: rename %wZ to %wZ\\%wZ\n",
1477 &Mcb->FullName, &TargetMcb->FullName, &FileName));
1478
1480 IrpContext,
1481 Vcb,
1482 &FileName,
1483 TargetMcb,
1484 &ExistingMcb,
1485 0
1486 );
1487
1488 if (NT_SUCCESS(Status) && ExistingMcb != Mcb) {
1489
1490 if (!ReplaceIfExists) {
1491
1493 DEBUG(DL_RES, ("Ext2SetRenameInfo: Target file %wZ exists\n",
1494 &ExistingMcb->FullName));
1495 goto errorout;
1496
1497 } else {
1498
1499 if ( (ExistingFcb = ExistingMcb->Fcb) && !IsMcbSymLink(ExistingMcb) ) {
1500
1501 Status = Ext2IsFileRemovable(IrpContext, Vcb, ExistingFcb, Ccb);
1502 if (!NT_SUCCESS(Status)) {
1503 DEBUG(DL_REN, ("Ext2SetRenameInfo: Target file %wZ cannot be removed.\n",
1504 &ExistingMcb->FullName));
1505 goto errorout;
1506 }
1507 }
1508
1509 Status = Ext2DeleteFile(IrpContext, Vcb, ExistingFcb, ExistingMcb);
1510 if (!NT_SUCCESS(Status)) {
1511 DEBUG(DL_REN, ("Ext2SetRenameInfo: Failed to delete %wZ with status: %xh.\n",
1512 &FileName, Status));
1513
1514 goto errorout;
1515 }
1516
1517 bTargetRemoved = TRUE;
1518 }
1519 }
1520
1521 /* remove directory entry of old name */
1522 Status = Ext2RemoveEntry(IrpContext, Vcb, ParentDcb, Mcb);
1523 if (!NT_SUCCESS(Status)) {
1524 DEBUG(DL_REN, ("Ext2SetRenameInfo: Failed to remove entry %wZ with status %xh.\n",
1525 &Mcb->FullName, Status));
1526 DbgBreak();
1527 goto errorout;
1528 }
1529
1530 /* add new entry for new target name */
1531 Status = Ext2AddEntry(IrpContext, Vcb, TargetDcb, &Mcb->Inode, &FileName, &NewEntry);
1532 if (!NT_SUCCESS(Status)) {
1533 DEBUG(DL_REN, ("Ext2SetRenameInfo: Failed to add entry for %wZ with status: %xh.\n",
1534 &FileName, Status));
1535 Ext2AddEntry(IrpContext, Vcb, ParentDcb, &Mcb->Inode, &Mcb->ShortName, &NewEntry);
1536 goto errorout;
1537 }
1538
1539 /* correct the inode number in .. entry */
1540 if (IsMcbDirectory(Mcb)) {
1542 IrpContext, Vcb, Fcb,
1543 ParentMcb->Inode.i_ino,
1544 TargetMcb->Inode.i_ino );
1545 if (!NT_SUCCESS(Status)) {
1546 DEBUG(DL_REN, ("Ext2SetRenameInfo: Failed to set parent refer of %wZ with %xh.\n",
1547 &Mcb->FullName, Status));
1548 DbgBreak();
1549 goto errorout;
1550 }
1551 }
1552
1553 /* Update current dentry from the newly created one. We need keep the original
1554 dentry to assure children's links are valid if current entry is a directory */
1555 if (Mcb->de) {
1556 char *np = Mcb->de->d_name.name;
1557 *(Mcb->de) = *NewEntry;
1558 NewEntry->d_name.name = np;
1559 }
1560
1561 if (bTargetRemoved) {
1563 IrpContext,
1564 Vcb,
1565 ExistingMcb,
1566 (IsMcbDirectory(ExistingMcb) ?
1570 }
1571
1572 if (NT_SUCCESS(Status)) {
1573
1574 if (bMove) {
1576 IrpContext,
1577 Vcb,
1578 Mcb,
1579 (IsDirectory(Fcb) ?
1583
1584 } else {
1586 IrpContext,
1587 Vcb,
1588 Mcb,
1589 (IsDirectory(Fcb) ?
1593
1594 }
1595
1596 if (TargetMcb->Inode.i_ino != ParentMcb->Inode.i_ino) {
1598 Ext2InsertMcb(Vcb, TargetMcb, Mcb);
1599 }
1600
1601 if (!Ext2BuildName( &Mcb->ShortName,
1602 &FileName, NULL )) {
1604 goto errorout;
1605 }
1606
1607 if (!Ext2BuildName( &Mcb->FullName,
1608 &FileName,
1609 &TargetMcb->FullName)) {
1611 goto errorout;
1612 }
1613
1614 if (bMove) {
1616 IrpContext,
1617 Vcb,
1618 Mcb,
1619 (IsDirectory(Fcb) ?
1623 } else {
1625 IrpContext,
1626 Vcb,
1627 Mcb,
1628 (IsDirectory(Fcb) ?
1632 }
1633 }
1634
1635errorout:
1636
1637 if (bFcbLockAcquired) {
1638 ExReleaseResourceLite(&Vcb->FcbLock);
1639 bFcbLockAcquired = FALSE;
1640 }
1641
1642 if (NewEntry)
1643 Ext2FreeEntry(NewEntry);
1644
1645 if (TargetDcb) {
1647 }
1648
1649 if (ParentDcb) {
1651 }
1652
1653 if (ExistingMcb)
1654 Ext2DerefMcb(ExistingMcb);
1655
1656 return Status;
1657}
1658
1661 PEXT2_IRP_CONTEXT IrpContext,
1662 PEXT2_VCB Vcb,
1663 PEXT2_FCB Fcb,
1665)
1666{
1667 PEXT2_MCB Mcb = Fcb->Mcb;
1668
1669 PEXT2_FCB TargetDcb = NULL; /* Dcb of target directory */
1670 PEXT2_MCB TargetMcb = NULL;
1671 PEXT2_FCB ParentDcb = NULL; /* Dcb of it's current parent */
1672 PEXT2_MCB ParentMcb = NULL;
1673
1674 PEXT2_FCB ExistingFcb = NULL; /* Target file Fcb if it exists*/
1675 PEXT2_MCB ExistingMcb = NULL;
1676 PEXT2_MCB LinkMcb = NULL; /* Mcb for new hardlink */
1677
1679
1681
1682 PIRP Irp;
1684
1686 PFILE_OBJECT TargetObject;
1687
1688 BOOLEAN ReplaceIfExists;
1689 BOOLEAN bTargetRemoved = FALSE;
1690
1691 BOOLEAN bFcbLockAcquired = FALSE;
1692
1694
1695 if (Ccb->SymLink) {
1696 Mcb = Ccb->SymLink;
1697 }
1698
1699 if (IsMcbDirectory(Mcb)) {
1701 goto errorout;
1702 }
1703
1704 Irp = IrpContext->Irp;
1706
1708 TargetObject = IrpSp->Parameters.SetFile.FileObject;
1709 ReplaceIfExists = IrpSp->Parameters.SetFile.ReplaceIfExists;
1710
1711 FLI = (PFILE_LINK_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
1712
1713 if (TargetObject == NULL) {
1714
1716
1717 NewName.Buffer = FLI->FileName;
1719
1720 while (NewName.Length > 0 && NewName.Buffer[NewName.Length/2 - 1] == L'\\') {
1721 NewName.Buffer[NewName.Length/2 - 1] = 0;
1722 NewName.Length -= 2;
1723 }
1724
1725 while (NewName.Length > 0 && NewName.Buffer[NewName.Length/2 - 1] != L'\\') {
1726 NewName.Length -= 2;
1727 }
1728
1731
1732 FileName = NewName;
1733
1734 TargetMcb = Mcb->Parent;
1735 if (IsMcbSymLink(TargetMcb)) {
1736 TargetMcb = TargetMcb->Target;
1737 ASSERT(!IsMcbSymLink(TargetMcb));
1738 }
1739
1740 if (TargetMcb == NULL || FileName.Length >= EXT2_NAME_LEN*2) {
1742 goto errorout;
1743 }
1744
1745 } else {
1746
1747 TargetDcb = (PEXT2_FCB)(TargetObject->FsContext);
1748 if (!TargetDcb || TargetDcb->Vcb != Vcb) {
1749 DbgBreak();
1751 goto errorout;
1752 }
1753
1754 TargetMcb = TargetDcb->Mcb;
1755 FileName = TargetObject->FileName;
1756 }
1757
1760 goto errorout;
1761 }
1762
1763 if (TargetMcb->Inode.i_ino == Mcb->Parent->Inode.i_ino) {
1765 &(Mcb->ShortName),
1766 FALSE,
1767 NULL )) {
1769 goto errorout;
1770 }
1771 }
1772
1774 bFcbLockAcquired = TRUE;
1775
1776 TargetDcb = TargetMcb->Fcb;
1777 if (TargetDcb == NULL) {
1778 TargetDcb = Ext2AllocateFcb(Vcb, TargetMcb);
1779 }
1780 if (TargetDcb) {
1781 Ext2ReferXcb(&TargetDcb->ReferenceCount);
1782 }
1783
1784 ParentMcb = Mcb->Parent;
1785 ParentDcb = ParentMcb->Fcb;
1786
1787 if ((TargetMcb->Inode.i_ino != ParentMcb->Inode.i_ino)) {
1788
1789 if (ParentDcb == NULL) {
1790 ParentDcb = Ext2AllocateFcb(Vcb, ParentMcb);
1791 }
1792 }
1793 if (ParentDcb) {
1794 Ext2ReferXcb(&ParentDcb->ReferenceCount);
1795 }
1796
1797 if (bFcbLockAcquired) {
1798 ExReleaseResourceLite(&Vcb->FcbLock);
1799 bFcbLockAcquired = FALSE;
1800 }
1801
1802 if (!TargetDcb || !ParentDcb) {
1804 goto errorout;
1805 }
1806
1807 DEBUG(DL_RES, ("Ext2SetLinkInfo: %wZ\\%wZ -> %wZ\n",
1808 &TargetMcb->FullName, &FileName, &Mcb->FullName));
1809
1810 Status = Ext2LookupFile(IrpContext, Vcb, &FileName,
1811 TargetMcb, &ExistingMcb, 0);
1812 if (NT_SUCCESS(Status) && ExistingMcb != Mcb) {
1813
1814 if (!ReplaceIfExists) {
1815
1817 DEBUG(DL_RES, ("Ext2SetRenameInfo: Target file %wZ exists\n",
1818 &ExistingMcb->FullName));
1819 goto errorout;
1820
1821 } else {
1822
1823 if ( (ExistingFcb = ExistingMcb->Fcb) && !IsMcbSymLink(ExistingMcb) ) {
1824 Status = Ext2IsFileRemovable(IrpContext, Vcb, ExistingFcb, Ccb);
1825 if (!NT_SUCCESS(Status)) {
1826 DEBUG(DL_REN, ("Ext2SetRenameInfo: Target file %wZ cannot be removed.\n",
1827 &ExistingMcb->FullName));
1828 goto errorout;
1829 }
1830 }
1831
1832 Status = Ext2DeleteFile(IrpContext, Vcb, ExistingFcb, ExistingMcb);
1833 if (!NT_SUCCESS(Status)) {
1834 DEBUG(DL_REN, ("Ext2SetRenameInfo: Failed to delete %wZ with status: %xh.\n",
1835 &FileName, Status));
1836
1837 goto errorout;
1838 }
1839 bTargetRemoved = TRUE;
1840 }
1841 }
1842
1843 /* add new entry for new target name */
1844 Status = Ext2AddEntry(IrpContext, Vcb, TargetDcb, &Mcb->Inode, &FileName, NULL);
1845 if (!NT_SUCCESS(Status)) {
1846 DEBUG(DL_REN, ("Ext2SetLinkInfo: Failed to add entry for %wZ with status: %xh.\n",
1847 &FileName, Status));
1848 goto errorout;
1849 }
1850
1851 if (bTargetRemoved) {
1853 IrpContext,
1854 Vcb,
1855 ExistingMcb,
1856 (IsMcbDirectory(ExistingMcb) ?
1860 }
1861
1862 if (NT_SUCCESS(Status)) {
1863
1864 Ext2LookupFile(IrpContext, Vcb, &FileName, TargetMcb, &LinkMcb, 0);
1865 if (!LinkMcb)
1866 goto errorout;
1867
1869 IrpContext,
1870 Vcb,
1871 LinkMcb,
1874 }
1875
1876errorout:
1877
1878 if (bFcbLockAcquired) {
1879 ExReleaseResourceLite(&Vcb->FcbLock);
1880 bFcbLockAcquired = FALSE;
1881 }
1882
1883 if (TargetDcb) {
1885 }
1886
1887 if (ParentDcb) {
1889 }
1890
1891 if (ExistingMcb)
1892 Ext2DerefMcb(ExistingMcb);
1893
1894 if (LinkMcb)
1895 Ext2DerefMcb(LinkMcb);
1896
1897 return Status;
1898}
1899
1900ULONG
1902{
1903 if (IsMcbSymLink(Mcb)) {
1904 return EXT2_FT_SYMLINK;
1905 }
1906
1907 if (IsMcbDirectory(Mcb)) {
1908 return EXT2_FT_DIR;
1909 }
1910
1911 return EXT2_FT_REG_FILE;
1912}
1913
1916 PEXT2_IRP_CONTEXT IrpContext,
1917 PEXT2_VCB Vcb,
1918 PEXT2_FCB Fcb,
1920)
1921{
1922 PEXT2_FCB Dcb = NULL;
1923
1925
1926 BOOLEAN VcbResourceAcquired = FALSE;
1927 BOOLEAN FcbPagingIoAcquired = FALSE;
1928 BOOLEAN FcbResourceAcquired = FALSE;
1929 BOOLEAN DcbResourceAcquired = FALSE;
1930
1932 LARGE_INTEGER SysTime;
1933
1934 BOOLEAN bFcbLockAcquired = FALSE;
1935
1936 DEBUG(DL_INF, ( "Ext2DeleteFile: File %wZ (%xh) will be deleted!\n",
1937 &Mcb->FullName, Mcb->Inode.i_ino));
1938
1939 if (IsFlagOn(Mcb->Flags, MCB_FILE_DELETED)) {
1940 return STATUS_SUCCESS;
1941 }
1942
1943 if (!IsMcbSymLink(Mcb) && IsMcbDirectory(Mcb)) {
1944 if (!Ext2IsDirectoryEmpty(IrpContext, Vcb, Mcb)) {
1946 }
1947 }
1948
1949 _SEH2_TRY {
1950
1952
1953 ExAcquireResourceExclusiveLite(&Vcb->MainResource, TRUE);
1954 VcbResourceAcquired = TRUE;
1955
1957 bFcbLockAcquired = TRUE;
1958
1959 /* Mcb->Parent could be NULL when working with layered file systems */
1960 if (Mcb->Parent) {
1961 Dcb = Mcb->Parent->Fcb;
1962 if (!Dcb)
1963 Dcb = Ext2AllocateFcb(Vcb, Mcb->Parent);
1964 }
1965 if (Dcb)
1966 Ext2ReferXcb(&Dcb->ReferenceCount);
1967
1968 if (bFcbLockAcquired) {
1969 ExReleaseResourceLite(&Vcb->FcbLock);
1970 bFcbLockAcquired = FALSE;
1971 }
1972
1973 if (Dcb) {
1974 DcbResourceAcquired =
1975 ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
1976
1977 /* remove it's entry form it's parent */
1978 Status = Ext2RemoveEntry(IrpContext, Vcb, Dcb, Mcb);
1979 }
1980
1981 if (NT_SUCCESS(Status)) {
1982
1983 SetFlag(Mcb->Flags, MCB_FILE_DELETED);
1985
1986 if (Fcb) {
1987 FcbResourceAcquired =
1989
1990 FcbPagingIoAcquired =
1992 }
1993
1994 if (DcbResourceAcquired) {
1995 ExReleaseResourceLite(&Dcb->MainResource);
1996 DcbResourceAcquired = FALSE;
1997 }
1998
1999 if (VcbResourceAcquired) {
2000 ExReleaseResourceLite(&Vcb->MainResource);
2001 VcbResourceAcquired = FALSE;
2002 }
2003
2004 if (IsMcbSymLink(Mcb)) {
2005 if (Mcb->Inode.i_nlink > 0) {
2008 }
2009 } else if (!IsMcbDirectory(Mcb)) {
2010 if (Mcb->Inode.i_nlink > 0) {
2012 }
2013 } else {
2014 if (Mcb->Inode.i_nlink >= 2) {
2016 }
2017 }
2018
2019 if (S_ISLNK(Mcb->Inode.i_mode)) {
2020
2021 /* for symlink, we should do differenctly */
2022 if (Mcb->Inode.i_size > EXT2_LINKLEN_IN_INODE) {
2023 Size.QuadPart = (LONGLONG)0;
2024 Status = Ext2TruncateFile(IrpContext, Vcb, Mcb, &Size);
2025 }
2026
2027 } else {
2028
2029 /* truncate file size */
2030 Size.QuadPart = (LONGLONG)0;
2031 Status = Ext2TruncateFile(IrpContext, Vcb, Mcb, &Size);
2032
2033 /* check file offset mappings */
2034 DEBUG(DL_EXT, ("Ext2DeleteFile ...: %wZ\n", &Mcb->FullName));
2035
2036 if (Fcb) {
2037 Fcb->Header.AllocationSize.QuadPart = Size.QuadPart;
2038 if (Fcb->Header.FileSize.QuadPart > Size.QuadPart) {
2039 Fcb->Header.FileSize.QuadPart = Size.QuadPart;
2040 Fcb->Mcb->Inode.i_size = Size.QuadPart;
2041 }
2042 if (Fcb->Header.ValidDataLength.QuadPart > Fcb->Header.FileSize.QuadPart) {
2043 Fcb->Header.ValidDataLength.QuadPart = Fcb->Header.FileSize.QuadPart;
2044 }
2045 } else if (Mcb) {
2046 /* Update the inode's data length . It should be ZERO if succeeds. */
2047 if (Mcb->Inode.i_size > (loff_t)Size.QuadPart) {
2048 Mcb->Inode.i_size = Size.QuadPart;
2049 }
2050 }
2051 }
2052
2053 /* set delete time and free the inode */
2054 KeQuerySystemTime(&SysTime);
2055 Mcb->Inode.i_nlink = 0;
2056 Mcb->Inode.i_dtime = Ext2LinuxTime(SysTime);
2057 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
2058 Ext2FreeInode(IrpContext, Vcb, Mcb->Inode.i_ino, Ext2InodeType(Mcb));
2059 }
2060
2061 } _SEH2_FINALLY {
2062
2063 if (FcbPagingIoAcquired) {
2065 }
2066
2067 if (FcbResourceAcquired) {
2069 }
2070
2071 if (DcbResourceAcquired) {
2072 ExReleaseResourceLite(&Dcb->MainResource);
2073 }
2074
2075 if (bFcbLockAcquired) {
2076 ExReleaseResourceLite(&Vcb->FcbLock);
2077 }
2078
2079 if (VcbResourceAcquired) {
2080 ExReleaseResourceLite(&Vcb->MainResource);
2081 }
2082
2083 if (Dcb) {
2085 }
2086
2088 } _SEH2_END;
2089
2090 DEBUG(DL_INF, ( "Ext2DeleteFile: %wZ Succeed... EXT2SB->S_FREE_BLOCKS = %I64xh .\n",
2091 &Mcb->FullName, ext3_free_blocks_count(SUPER_BLOCK)));
2092
2093 return Status;
2094}
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:80
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:1122
NTSTATUS Ext2IsFileRemovable(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Fcb, IN PEXT2_CCB Ccb)
Definition: fileinfo.c:1234
NTSTATUS Ext2TruncateFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
Definition: fileinfo.c:1199
NTSTATUS Ext2SetLinkInfo(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_CCB Ccb)
Definition: fileinfo.c:1660
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:1915
NTSTATUS Ext2SetRenameInfo(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_CCB Ccb)
Definition: fileinfo.c:1320
NTSTATUS Ext2SetFileInformation(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fileinfo.c:509
ULONG Ext2InodeType(PEXT2_MCB Mcb)
Definition: fileinfo.c:1901
NTSTATUS Ext2SetDispositionInfo(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_CCB Ccb, BOOLEAN bDelete)
Definition: fileinfo.c:1277
static int Ext2IterateAllEa(struct ext4_xattr_ref *xattr_ref, struct ext4_xattr_item *item, BOOL is_last)
Definition: fileinfo.c:33
NTSTATUS Ext2QueryFileInformation(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fileinfo.c:43
NTSTATUS Ext2ExpandFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
Definition: fileinfo.c:1147
ULONG Ext2TotalBlocks(PEXT2_VCB Vcb, PLARGE_INTEGER Size, PULONG pMeta)
Definition: fileinfo.c:1072
_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:780
#define IsMcbSymLink(Mcb)
Definition: ext2fs.h:953
#define DL_WRN
Definition: ext2fs.h:1410
#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:932
#define Ext2FileCanWrite
Definition: ext2fs.h:427
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:955
static ext3_fsblk_t ext3_free_blocks_count(struct ext3_super_block *es)
Definition: ext2fs.h:1704
#define Ext2SetOwnerWritable(m)
Definition: ext2fs.h:408
@ EXT2FCB
Definition: ext2fs.h:458
@ EXT2ICX
Definition: ext2fs.h:460
@ EXT2VCB
Definition: ext2fs.h:457
@ EXT2CCB
Definition: ext2fs.h:459
#define IsDirectory(Fcb)
Definition: ext2fs.h:278
#define IsVcbReadOnly(Vcb)
Definition: ext2fs.h:805
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:959
#define IsMounted(Vcb)
Definition: ext2fs.h:803
#define DL_EXT
Definition: ext2fs.h:1406
NTSTATUS Ext2FreeInode(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Inode, IN ULONG Type)
Definition: generic.c:1692
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:548
#define EXT2_LINKLEN_IN_INODE
Definition: ext2fs.h:76
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:607
NTSTATUS Ext2QueueRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:150
#define Ext2ReferXcb(_C)
Definition: ext2fs.h:967
#define FCB_ALLOC_IN_WRITE
Definition: ext2fs.h:876
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:253
#define DL_INF
Definition: ext2fs.h:1399
#define FCB_PAGE_FILE
Definition: ext2fs.h:872
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:873
#define FCB_ALLOC_IN_SETINFO
Definition: ext2fs.h:877
ULONG Ext2LinuxTime(IN LARGE_INTEGER SysTime)
Definition: misc.c:51
#define SUPER_BLOCK
Definition: ext2fs.h:90
#define ClearLongFlag(_F, _SF)
Definition: ext2fs.h:254
#define S_ISLNK(m)
Definition: ext2fs.h:368
#define Ext2DerefMcb(Mcb)
Definition: ext2fs.h:987
NTSTATUS Ext2SetParentEntry(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Dcb, IN ULONG OldParent, IN ULONG NewParent)
Definition: generic.c:2024
#define DL_REN
Definition: ext2fs.h:1402
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:958
#define IsInodeSymLink(I)
Definition: ext2fs.h:281
#define FCB_DELETE_PENDING
Definition: ext2fs.h:879
BOOLEAN Ext2SaveSuper(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:63
#define DbgBreak()
Definition: ext2fs.h:46
#define FCB_ALLOC_IN_CREATE
Definition: ext2fs.h:875
#define Ext2SetOwnerReadOnly(m)
Definition: ext2fs.h:409
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:948
struct _EXT2_CCB * PEXT2_CCB
#define CCB_LAST_WRITE_UPDATED
Definition: ext2fs.h:1024
NTSTATUS Ext2TruncateIndirect(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
Definition: indirect.c:1079
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:823
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:1947
BOOLEAN Ext2ListExtents(PLARGE_MCB Extents)
Definition: memory.c:558
#define Ext2ReferMcb(Mcb)
Definition: ext2fs.h:986
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:946
#define IsLinkInvalid(Mcb)
Definition: ext2fs.h:961
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:1413
#define DL_RES
Definition: ext2fs.h:1403
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:1817
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 MmFlushImageSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN MMFLUSH_TYPE FlushType)
Definition: section.c:4257
BOOLEAN NTAPI MmCanFileBeTruncated(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN PLARGE_INTEGER NewFileSize)
Definition: section.c:4163
#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:472
PEXT2_FCB Fcb
Definition: ext2fs.h:905
PEXT2_MCB Target
Definition: ext2fs.h:899
struct inode Inode
Definition: ext2fs.h:936
UNICODE_STRING FullName
Definition: ext2fs.h:911
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::@695 d_name
UCHAR MajorFunction
Definition: ext2fs.h:1047
PDEVICE_OBJECT DeviceObject
Definition: ext2fs.h:1051
EXT2_IDENTIFIER Identifier
Definition: ext2fs.h:1038
ULONG Flags
Definition: ext2fs.h:1044
PIRP Irp
Definition: ext2fs.h:1041
PFILE_OBJECT FileObject
Definition: ext2fs.h:1057
BOOLEAN ExceptionInProgress
Definition: ext2fs.h:1069
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