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

Function Ext2MapIndirect

Ext4Fsd/ext3/indirect.c:822–929  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

820}
821
822NTSTATUS
823Ext2MapIndirect(
824 IN PEXT2_IRP_CONTEXT IrpContext,
825 IN PEXT2_VCB Vcb,
826 IN PEXT2_MCB Mcb,
827 IN ULONG Index,
828 IN BOOLEAN bAlloc,
829 OUT PULONG pBlock,
830 OUT PULONG Number
831)
832{
833 ULONG Layer;
834 ULONG Slot;
835
836 ULONG Base = Index;
837
838 NTSTATUS Status = STATUS_SUCCESS;
839
840 *pBlock = 0;
841 *Number = 0;
842
843 for (Layer = 0; Layer < EXT2_BLOCK_TYPES; Layer++) {
844
845 if (Index < Vcb->max_blocks_per_layer[Layer]) {
846
847 ULONG dwRet = 0, dwBlk = 0, dwHint = 0, dwArray = 0;
848
849 Slot = (Layer==0) ? (Index):(Layer + EXT2_NDIR_BLOCKS - 1);
850 dwBlk = Mcb->Inode.i_block[Slot];
851
852 if (dwBlk == 0) {
853
854 if (!bAlloc) {
855
856 *Number = 1;
857 goto errorout;
858
859 } else {
860
861 if (Slot) {
862 dwHint = Mcb->Inode.i_block[Slot - 1];
863 }
864
865 /* allocate and zero block if necessary */
866 *Number = 1;
867 Status = Ext2ExpandLast(
868 IrpContext,
869 Vcb,
870 Mcb,
871 Base,
872 Layer,
873 NULL,
874 &dwHint,
875 &dwBlk,
876 Number
877 );
878
879 if (!NT_SUCCESS(Status)) {

Callers 3

Ext2BlockMapFunction · 0.85
Ext2InitializeZoneFunction · 0.85
ext3_breadFunction · 0.85

Calls 3

Ext2ExpandLastFunction · 0.85
Ext2SaveInodeFunction · 0.85
Ext2GetBlockFunction · 0.85

Tested by

no test coverage detected