MCPcopy Create free account
hub / github.com/bobranten/Ext4Fsd / Ext2ExpandFile

Function Ext2ExpandFile

Ext4Fsd/fileinfo.c:1137–1186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1135
1136
1137NTSTATUS
1138Ext2ExpandFile(
1139 PEXT2_IRP_CONTEXT IrpContext,
1140 PEXT2_VCB Vcb,
1141 PEXT2_MCB Mcb,
1142 PLARGE_INTEGER Size
1143)
1144{
1145 NTSTATUS status = STATUS_SUCCESS;
1146 ULONG Start = 0;
1147 ULONG End = 0;
1148
1149 Start = (ULONG)((Mcb->Inode.i_size + BLOCK_SIZE - 1) >> BLOCK_BITS);
1150 End = (ULONG)((Size->QuadPart + BLOCK_SIZE - 1) >> BLOCK_BITS);
1151
1152 /* it's a truncate operation, not expanding */
1153 if (Start >= End) {
1154 Size->QuadPart = ((LONGLONG) Start) << BLOCK_BITS;
1155 return STATUS_SUCCESS;
1156 }
1157
1158 /* ignore special files */
1159 if (IsMcbSpecialFile(Mcb)) {
1160 return STATUS_INVALID_DEVICE_REQUEST;
1161 }
1162
1163 /* expandind file extents */
1164 if (INODE_HAS_EXTENT(&Mcb->Inode)) {
1165
1166 status = Ext2ExpandExtent(IrpContext, Vcb, Mcb, Start, End, Size);
1167
1168 } else {
1169
1170 BOOLEAN do_expand;
1171
1172#if EXT2_PRE_ALLOCATION_SUPPORT
1173 do_expand = TRUE;
1174#else
1175 do_expand = (IrpContext->MajorFunction == IRP_MJ_WRITE) ||
1176 IsMcbDirectory(Mcb);
1177#endif
1178 if (!do_expand)
1179 goto errorout;
1180
1181 status = Ext2ExpandIndirect(IrpContext, Vcb, Mcb, Start, End, Size);
1182 }
1183
1184errorout:
1185 return status;
1186}
1187
1188
1189NTSTATUS

Callers 5

Ext2SetFileInformationFunction · 0.85
Ext2CreateFileFunction · 0.85
Ext2WriteFileFunction · 0.85
ext3_appendFunction · 0.85

Calls 2

Ext2ExpandExtentFunction · 0.85
Ext2ExpandIndirectFunction · 0.85

Tested by

no test coverage detected