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

Function Ext2ExpandExtent

Ext4Fsd/ext4/extents.c:150–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148
149
150NTSTATUS
151Ext2ExpandExtent(
152 PEXT2_IRP_CONTEXT IrpContext,
153 PEXT2_VCB Vcb,
154 PEXT2_MCB Mcb,
155 ULONG Start,
156 ULONG End,
157 PLARGE_INTEGER Size
158 )
159{
160 ULONG Count = 0, Number = 0, Block = 0;
161 NTSTATUS Status = STATUS_SUCCESS;
162
163 if (End <= Start)
164 return Status;
165
166 while (End > Start + Count) {
167
168 Number = End - Start - Count;
169 Status = Ext2DoExtentExpand(IrpContext, Vcb, Mcb, Start + Count,
170 &Block, &Number);
171 if (!NT_SUCCESS(Status)) {
172 Status = STATUS_INSUFFICIENT_RESOURCES;
173 break;
174 }
175 if (Number == 0) {
176 Status = STATUS_INSUFFICIENT_RESOURCES;
177 break;
178 }
179
180 if (Block && IsZoneInited(Mcb)) {
181 if (!Ext2AddBlockExtent(Vcb, Mcb, Start + Count, Block, Number)) {
182 DbgBreak();
183 ClearFlag(Mcb->Flags, MCB_ZONE_INITED);
184 Ext2ClearAllExtents(&Mcb->Extents);
185 }
186 }
187 Count += Number;
188 }
189
190 Size->QuadPart = ((LONGLONG)(Start + Count)) << BLOCK_BITS;
191
192 /* save inode whatever it succeeds to expand or not */
193 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
194
195 return Status;
196}
197
198
199NTSTATUS

Callers 1

Ext2ExpandFileFunction · 0.85

Calls 4

Ext2DoExtentExpandFunction · 0.85
Ext2AddBlockExtentFunction · 0.85
Ext2ClearAllExtentsFunction · 0.85
Ext2SaveInodeFunction · 0.85

Tested by

no test coverage detected