| 1012 | } |
| 1013 | |
| 1014 | NTSTATUS |
| 1015 | Ext2TruncateIndirectFast( |
| 1016 | PEXT2_IRP_CONTEXT IrpContext, |
| 1017 | PEXT2_VCB Vcb, |
| 1018 | PEXT2_MCB Mcb |
| 1019 | ) |
| 1020 | { |
| 1021 | LONGLONG Vba; |
| 1022 | LONGLONG Lba; |
| 1023 | LONGLONG Length; |
| 1024 | NTSTATUS Status = STATUS_SUCCESS; |
| 1025 | int i; |
| 1026 | |
| 1027 | /* try to load all indirect blocks if mcb zone is not initialized */ |
| 1028 | if (!IsZoneInited(Mcb)) { |
| 1029 | Status = Ext2InitializeZone(IrpContext, Vcb, Mcb); |
| 1030 | if (!NT_SUCCESS(Status)) { |
| 1031 | DbgBreak(); |
| 1032 | ClearLongFlag(Mcb->Flags, MCB_ZONE_INITED); |
| 1033 | goto errorout; |
| 1034 | } |
| 1035 | } |
| 1036 | |
| 1037 | ASSERT (IsZoneInited(Mcb)); |
| 1038 | |
| 1039 | /* delete all data blocks here */ |
| 1040 | if (FsRtlNumberOfRunsInLargeMcb(&Mcb->Extents) != 0) { |
| 1041 | for (i = 0; FsRtlGetNextLargeMcbEntry(&Mcb->Extents, i, &Vba, &Lba, &Length); i++) { |
| 1042 | /* ignore the non-existing runs */ |
| 1043 | if (-1 == Lba || Vba == 0 || Length <= 0) |
| 1044 | continue; |
| 1045 | /* now do data block free */ |
| 1046 | Ext2FreeBlock(IrpContext, Vcb, (ULONG)(Lba - 1), (ULONG)Length); |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | /* delete all meta blocks here */ |
| 1051 | if (FsRtlNumberOfRunsInLargeMcb(&Mcb->MetaExts) != 0) { |
| 1052 | for (i = 0; FsRtlGetNextLargeMcbEntry(&Mcb->MetaExts, i, &Vba, &Lba, &Length); i++) { |
| 1053 | /* ignore the non-existing runs */ |
| 1054 | if (-1 == Lba || Vba == 0 || Length <= 0) |
| 1055 | continue; |
| 1056 | /* now do meta block free */ |
| 1057 | Ext2FreeBlock(IrpContext, Vcb, (ULONG)(Lba - 1), (ULONG)Length); |
| 1058 | } |
| 1059 | } |
| 1060 | |
| 1061 | /* clear data and meta extents */ |
| 1062 | Ext2ClearAllExtents(&Mcb->Extents); |
| 1063 | Ext2ClearAllExtents(&Mcb->MetaExts); |
| 1064 | ClearFlag(Mcb->Flags, MCB_ZONE_INITED); |
| 1065 | |
| 1066 | /* clear inode blocks & sizes */ |
| 1067 | Mcb->Inode.i_blocks = 0; |
| 1068 | Mcb->Inode.i_size = 0; |
| 1069 | memset(&Mcb->Inode.i_block[0], 0, sizeof(__u32) * 15); |
| 1070 | |
| 1071 | /* the caller will do inode save */ |
no test coverage detected