fixup over ("LiteX: driver for LiteVideo")
[linux/fpc-iii.git] / fs / befs / io.c
blob2caf50a4abbeac087e782af95bacf7c6af163b1c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * linux/fs/befs/io.c
5 * Copyright (C) 2001 Will Dyson <will_dyson@pobox.com
7 * Based on portions of file.c and inode.c
8 * by Makoto Kato (m_kato@ga2.so-net.ne.jp)
10 * Many thanks to Dominic Giampaolo, author of Practical File System
11 * Design with the Be File System, for such a helpful book.
15 #include <linux/buffer_head.h>
17 #include "befs.h"
18 #include "io.h"
21 * Converts befs notion of disk addr to a disk offset and uses
22 * linux kernel function sb_bread() to get the buffer containing
23 * the offset.
26 struct buffer_head *
27 befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr)
29 struct buffer_head *bh;
30 befs_blocknr_t block;
31 struct befs_sb_info *befs_sb = BEFS_SB(sb);
33 befs_debug(sb, "---> Enter %s "
34 "[%u, %hu, %hu]", __func__, iaddr.allocation_group,
35 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, "%s: offset = %lu", __func__, (unsigned long)block);
47 bh = sb_bread(sb, block);
49 if (bh == NULL) {
50 befs_error(sb, "Failed to read block %lu",
51 (unsigned long)block);
52 goto error;
55 befs_debug(sb, "<--- %s", __func__);
56 return bh;
58 error:
59 befs_debug(sb, "<--- %s ERROR", __func__);
60 return NULL;