Linux Audio

Check our new training course

Loading...
v6.9.4
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * linux/fs/befs/io.c
 4 *
 5 * Copyright (C) 2001 Will Dyson <will_dyson@pobox.com
 6 *
 7 * Based on portions of file.c and inode.c
 8 * by Makoto Kato (m_kato@ga2.so-net.ne.jp)
 9 *
10 * Many thanks to Dominic Giampaolo, author of Practical File System
11 * Design with the Be File System, for such a helpful book.
12 *
13 */
14
15#include <linux/buffer_head.h>
16
17#include "befs.h"
18#include "io.h"
19
20/*
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.
24 */
25
26struct buffer_head *
27befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr)
28{
29	struct buffer_head *bh;
30	befs_blocknr_t block;
31	struct befs_sb_info *befs_sb = BEFS_SB(sb);
32
33	befs_debug(sb, "---> Enter %s "
34		   "[%u, %hu, %hu]", __func__, iaddr.allocation_group,
35		   iaddr.start, iaddr.len);
36
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;
41	}
42
43	block = iaddr2blockno(sb, &iaddr);
44
45	befs_debug(sb, "%s: offset = %lu", __func__, (unsigned long)block);
46
47	bh = sb_bread(sb, block);
48
49	if (bh == NULL) {
50		befs_error(sb, "Failed to read block %lu",
51			   (unsigned long)block);
52		goto error;
53	}
54
55	befs_debug(sb, "<--- %s", __func__);
56	return bh;
57
58error:
59	befs_debug(sb, "<--- %s ERROR", __func__);
60	return NULL;
61}
v4.10.11
 
 1/*
 2 * linux/fs/befs/io.c
 3 *
 4 * Copyright (C) 2001 Will Dyson <will_dyson@pobox.com
 5 *
 6 * Based on portions of file.c and inode.c
 7 * by Makoto Kato (m_kato@ga2.so-net.ne.jp)
 8 *
 9 * Many thanks to Dominic Giampaolo, author of Practical File System
10 * Design with the Be File System, for such a helpful book.
11 *
12 */
13
14#include <linux/buffer_head.h>
15
16#include "befs.h"
17#include "io.h"
18
19/*
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.
23 */
24
25struct buffer_head *
26befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr)
27{
28	struct buffer_head *bh;
29	befs_blocknr_t block;
30	struct befs_sb_info *befs_sb = BEFS_SB(sb);
31
32	befs_debug(sb, "---> Enter %s "
33		   "[%u, %hu, %hu]", __func__, iaddr.allocation_group,
34		   iaddr.start, iaddr.len);
35
36	if (iaddr.allocation_group > befs_sb->num_ags) {
37		befs_error(sb, "BEFS: Invalid allocation group %u, max is %u",
38			   iaddr.allocation_group, befs_sb->num_ags);
39		goto error;
40	}
41
42	block = iaddr2blockno(sb, &iaddr);
43
44	befs_debug(sb, "%s: offset = %lu", __func__, (unsigned long)block);
45
46	bh = sb_bread(sb, block);
47
48	if (bh == NULL) {
49		befs_error(sb, "Failed to read block %lu",
50			   (unsigned long)block);
51		goto error;
52	}
53
54	befs_debug(sb, "<--- %s", __func__);
55	return bh;
56
57error:
58	befs_debug(sb, "<--- %s ERROR", __func__);
59	return NULL;
60}