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

Function ext3_bread

Ext4Fsd/ext3/htree.c:230–277  ·  view source on GitHub ↗

ext3_bread is safe for meta-data blocks. it's not safe to read file data, since file data is managed by file cache, not volume cache */

Source from the content-addressed store, hash-verified

228/* ext3_bread is safe for meta-data blocks. it's not safe to read file data,
229 since file data is managed by file cache, not volume cache */
230struct buffer_head *ext3_bread(struct ext2_icb *icb, struct inode *inode,
231 unsigned long block, int *err)
232{
233 struct buffer_head * bh = NULL;
234 NTSTATUS status = STATUS_SUCCESS;
235 ULONG lbn = 0, num = 0;
236
237 PEXT2_MCB Mcb = CONTAINING_RECORD(inode, EXT2_MCB, Inode);
238
239 /* for symlink file, read it's target instead */
240 if (NULL != Mcb && IsMcbSymLink(Mcb))
241 Mcb = Mcb->Target;
242 if (NULL == Mcb) {
243 *err = -EINVAL;
244 return NULL;
245 }
246
247 /* mapping file offset to ext2 block */
248 if (INODE_HAS_EXTENT(&Mcb->Inode)) {
249 status = Ext2MapExtent(icb, inode->i_sb->s_priv,
250 Mcb, block, FALSE,
251 &lbn, &num);
252 } else {
253 status = Ext2MapIndirect(icb, inode->i_sb->s_priv,
254 Mcb, block, FALSE,
255 &lbn, &num);
256 }
257
258 if (!NT_SUCCESS(status)) {
259 *err = Ext2LinuxError(status);
260 return bh;
261 }
262
263 bh = sb_getblk(inode->i_sb, lbn);
264 if (!bh) {
265 *err = -ENOMEM;
266 return bh;
267 }
268 if (buffer_uptodate(bh))
269 return bh;
270
271 *err = bh_submit_read(bh);
272 if (*err) {
273 __brelse(bh);
274 return NULL;
275 }
276 return bh;
277}
278
279struct buffer_head *ext3_append(struct ext2_icb *icb, struct inode *inode,
280 ext3_lblk_t *block, int *err)

Callers 10

ext3_appendFunction · 0.85
dx_show_entriesFunction · 0.85
dx_probeFunction · 0.85
ext3_htree_next_blockFunction · 0.85
htree_dirblock_to_treeFunction · 0.85
ext3_dx_find_entryFunction · 0.85
ext3_dx_add_entryFunction · 0.85
ext3_add_entryFunction · 0.85
ext3_is_dir_emptyFunction · 0.85
ext3_find_entryFunction · 0.85

Calls 6

Ext2MapExtentFunction · 0.85
Ext2MapIndirectFunction · 0.85
Ext2LinuxErrorFunction · 0.85
sb_getblkFunction · 0.85
bh_submit_readFunction · 0.85
__brelseFunction · 0.85

Tested by

no test coverage detected