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

Function Ext2DoExtentExpand

Ext4Fsd/ext4/extents.c:104–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102
103
104NTSTATUS
105Ext2DoExtentExpand(
106 IN PEXT2_IRP_CONTEXT IrpContext,
107 IN PEXT2_VCB Vcb,
108 IN PEXT2_MCB Mcb,
109 IN ULONG Index,
110 IN OUT PULONG Block,
111 IN OUT PULONG Number
112)
113{
114 EXT4_EXTENT_HEADER *eh;
115 struct buffer_head bh_got;
116 int rc, flags;
117
118 if (IsMcbDirectory(Mcb) || IrpContext->MajorFunction == IRP_MJ_WRITE) {
119 flags = EXT4_GET_BLOCKS_IO_CONVERT_EXT;
120 } else {
121 flags = EXT4_GET_BLOCKS_IO_CREATE_EXT;
122 }
123
124 memset(&bh_got, 0, sizeof(struct buffer_head));
125 eh = get_ext4_header(&Mcb->Inode);
126
127 if (eh->eh_magic != EXT4_EXT_MAGIC) {
128 ext4_ext_tree_init(IrpContext, NULL, &Mcb->Inode);
129 }
130
131 if ((rc = ext4_ext_get_blocks( IrpContext, NULL, &Mcb->Inode, Index,
132 *Number, &bh_got, 1, flags)) < 0) {
133 DEBUG(DL_ERR, ("Expand Block insufficient resources, Number: %u,"
134 " err: %d\n", *Number, rc));
135 DbgBreak();
136 return Ext2WinntError(rc);
137 }
138
139 if (Number)
140 *Number = rc ? rc : 1;
141 if (Block)
142 *Block = (ULONG)bh_got.b_blocknr;
143
144 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
145
146 return STATUS_SUCCESS;
147}
148
149
150NTSTATUS

Callers 1

Ext2ExpandExtentFunction · 0.85

Calls 4

ext4_ext_tree_initFunction · 0.85
ext4_ext_get_blocksFunction · 0.85
Ext2WinntErrorFunction · 0.85
Ext2SaveInodeFunction · 0.85

Tested by

no test coverage detected