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

Function Ext2BuildExtents

Ext4Fsd/memory.c:1204–1355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1202}
1203
1204NTSTATUS
1205Ext2BuildExtents(
1206 IN PEXT2_IRP_CONTEXT IrpContext,
1207 IN PEXT2_VCB Vcb,
1208 IN PEXT2_MCB Mcb,
1209 IN ULONGLONG Offset,
1210 IN ULONG Size,
1211 IN BOOLEAN bAlloc,
1212 OUT PEXT2_EXTENT * Chain
1213)
1214{
1215 ULONG Start, End;
1216 ULONG Total = 0;
1217
1218 LONGLONG Lba = 0;
1219 NTSTATUS Status = STATUS_SUCCESS;
1220
1221 PEXT2_EXTENT Extent = NULL;
1222 PEXT2_EXTENT List = *Chain = NULL;
1223
1224 if (!IsZoneInited(Mcb)) {
1225 Status = Ext2InitializeZone(IrpContext, Vcb, Mcb);
1226 if (!NT_SUCCESS(Status)) {
1227 DbgBreak();
1228 }
1229 }
1230
1231 if ((IrpContext && IrpContext->Irp) &&
1232 ((IrpContext->Irp->Flags & IRP_NOCACHE) ||
1233 (IrpContext->Irp->Flags & IRP_PAGING_IO))) {
1234 Size = (Size + SECTOR_SIZE - 1) & (~(SECTOR_SIZE - 1));
1235 }
1236
1237 Start = (ULONG)(Offset >> BLOCK_BITS);
1238 End = (ULONG)((Size + Offset + BLOCK_SIZE - 1) >> BLOCK_BITS);
1239
1240 if (End > (ULONG)((Mcb->Inode.i_size + BLOCK_SIZE - 1) >> BLOCK_BITS) ) {
1241 End = (ULONG)((Mcb->Inode.i_size + BLOCK_SIZE - 1) >> BLOCK_BITS);
1242 }
1243
1244 while (Size > 0 && Start < End) {
1245
1246 ULONG Mapped = 0;
1247 ULONG Length = 0;
1248 ULONG Block = 0;
1249
1250 BOOLEAN rc = FALSE;
1251
1252 /* try to map file offset to ext2 block upon Extents cache */
1253 if (IsZoneInited(Mcb)) {
1254 rc = Ext2LookupBlockExtent(
1255 Vcb,
1256 Mcb,
1257 Start,
1258 &Block,
1259 &Mapped);
1260
1261 if (!rc) {

Callers 5

bmapFunction · 0.85
Ext2QueryExtentMappingsFunction · 0.85
Ext2GetRetrievalPointersFunction · 0.85
Ext2WriteInodeFunction · 0.85
Ext2ReadInodeFunction · 0.85

Calls 6

Ext2InitializeZoneFunction · 0.85
Ext2LookupBlockExtentFunction · 0.85
Ext2BlockMapFunction · 0.85
Ext2AddBlockExtentFunction · 0.85
Ext2ClearAllExtentsFunction · 0.85
Ext2AllocateExtentFunction · 0.85

Tested by

no test coverage detected