Add linux-next specific files for 20110716
[linux-2.6/next.git] / fs / befs / io.c
blobddef98aa255dc8001f6e7fdf43169c1591954e9a
1 /*
2 * linux/fs/befs/io.c
4 * Copyright (C) 2001 Will Dyson <will_dyson@pobox.com
6 * Based on portions of file.c and inode.c
7 * by Makoto Kato (m_kato@ga2.so-net.ne.jp)
9 * Many thanks to Dominic Giampaolo, author of Practical File System
10 * Design with the Be File System, for such a helpful book.
14 #include <linux/buffer_head.h>
16 #include "befs.h"
17 #include "io.h"
20 * Converts befs notion of disk addr to a disk offset and uses
21 * linux kernel function sb_bread() to get the buffer containing
22 * the offset. -Will Dyson
26 struct buffer_head *
27 befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr)
29 struct buffer_head *bh = NULL;
30 befs_blocknr_t block = 0;
31 befs_sb_info *befs_sb = BEFS_SB(sb);
33 befs_debug(sb, "---> Enter befs_read_iaddr() "
34 "[%u, %hu, %hu]",
35 iaddr.allocation_group, iaddr.start, iaddr.len);
37 if (iaddr.allocation_group > befs_sb->num_ags) {
38 befs_error(sb, "BEFS: Invalid allocation group %u, max is %u",
39 iaddr.allocation_group, befs_sb->num_ags);
40 goto error;
43 block = iaddr2blockno(sb, &iaddr);
45 befs_debug(sb, "befs_read_iaddr: offset = %lu", block);
47 bh = sb_bread(sb, block);
49 if (bh == NULL) {
50 befs_error(sb, "Failed to read block %lu", block);
51 goto error;
54 befs_debug(sb, "<--- befs_read_iaddr()");
55 return bh;
57 error:
58 befs_debug(sb, "<--- befs_read_iaddr() ERROR");
59 return NULL;
62 struct buffer_head *
63 befs_bread(struct super_block *sb, befs_blocknr_t block)
65 struct buffer_head *bh = NULL;
67 befs_debug(sb, "---> Enter befs_read() %Lu", block);
69 bh = sb_bread(sb, block);
71 if (bh == NULL) {
72 befs_error(sb, "Failed to read block %lu", block);
73 goto error;
76 befs_debug(sb, "<--- befs_read()");
78 return bh;
80 error:
81 befs_debug(sb, "<--- befs_read() ERROR");
82 return NULL;