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

Function Ext2ExpandLast

Ext4Fsd/ext3/indirect.c:24–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23
24NTSTATUS
25Ext2ExpandLast(
26 IN PEXT2_IRP_CONTEXT IrpContext,
27 IN PEXT2_VCB Vcb,
28 IN PEXT2_MCB Mcb,
29 IN ULONG Base,
30 IN ULONG Layer,
31 IN PULONG * Data,
32 IN PULONG Hint,
33 IN PULONG Block,
34 IN OUT PULONG Number
35)
36{
37 PULONG pData = NULL;
38 ULONG i;
39 NTSTATUS Status = STATUS_SUCCESS;
40
41 if (Layer > 0 || IsMcbDirectory(Mcb)) {
42
43 /* allocate buffer for new block */
44 pData = (ULONG *) Ext2AllocatePool(
45 PagedPool,
46 BLOCK_SIZE,
47 EXT2_DATA_MAGIC
48 );
49 if (!pData) {
50 DEBUG(DL_ERR, ( "Ex2ExpandBlock: failed to allocate memory for Data.\n"));
51 Status = STATUS_INSUFFICIENT_RESOURCES;
52 goto errorout;
53 }
54 RtlZeroMemory(pData, BLOCK_SIZE);
55 INC_MEM_COUNT(PS_BLOCK_DATA, pData, BLOCK_SIZE);
56 }
57
58 /* allocate block from disk */
59 Status = Ext2NewBlock(
60 IrpContext,
61 Vcb,
62 (Mcb->Inode.i_ino - 1) / BLOCKS_PER_GROUP,
63 *Hint,
64 Block,
65 Number
66 );
67
68 if (!NT_SUCCESS(Status)) {
69 goto errorout;
70 }
71
72 /* increase inode i_blocks */
73 Mcb->Inode.i_blocks += (*Number << (BLOCK_BITS - 9));
74
75 if (Layer == 0) {
76
77 if (IsMcbDirectory(Mcb)) {
78 /* for directory we need initialize it's entry structure */
79 PEXT2_DIR_ENTRY2 pEntry;
80 pEntry = (PEXT2_DIR_ENTRY2) pData;
81 pEntry->rec_len = (USHORT)(BLOCK_SIZE);

Callers 3

Ext2GetBlockFunction · 0.85
Ext2ExpandBlockFunction · 0.85
Ext2MapIndirectFunction · 0.85

Calls 9

Ext2AllocatePoolFunction · 0.85
Ext2NewBlockFunction · 0.85
Ext2SaveBlockFunction · 0.85
Ext2AddBlockExtentFunction · 0.85
Ext2ClearAllExtentsFunction · 0.85
Ext2AddMcbMetaExtsFunction · 0.85
Ext2SleepFunction · 0.85
Ext2FreePoolFunction · 0.85
Ext2FreeBlockFunction · 0.85

Tested by

no test coverage detected