0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <linux/buffer_head.h>
0016
0017 #include "befs.h"
0018 #include "io.h"
0019
0020
0021
0022
0023
0024
0025
0026 struct buffer_head *
0027 befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr)
0028 {
0029 struct buffer_head *bh;
0030 befs_blocknr_t block;
0031 struct befs_sb_info *befs_sb = BEFS_SB(sb);
0032
0033 befs_debug(sb, "---> Enter %s "
0034 "[%u, %hu, %hu]", __func__, iaddr.allocation_group,
0035 iaddr.start, iaddr.len);
0036
0037 if (iaddr.allocation_group > befs_sb->num_ags) {
0038 befs_error(sb, "BEFS: Invalid allocation group %u, max is %u",
0039 iaddr.allocation_group, befs_sb->num_ags);
0040 goto error;
0041 }
0042
0043 block = iaddr2blockno(sb, &iaddr);
0044
0045 befs_debug(sb, "%s: offset = %lu", __func__, (unsigned long)block);
0046
0047 bh = sb_bread(sb, block);
0048
0049 if (bh == NULL) {
0050 befs_error(sb, "Failed to read block %lu",
0051 (unsigned long)block);
0052 goto error;
0053 }
0054
0055 befs_debug(sb, "<--- %s", __func__);
0056 return bh;
0057
0058 error:
0059 befs_debug(sb, "<--- %s ERROR", __func__);
0060 return NULL;
0061 }