10 #include <linux/module.h>
12 #include <linux/slab.h>
18 #include <asm/uaccess.h>
28 #define dprintf(x...) printf(x)
39 struct buffer_head *bh;
49 printf(
"Bad inode number %s:%08lx\n", inode->
i_sb->s_id, ino);
54 bh = sb_bread(inode->
i_sb, block);
56 printf(
"Unable to read inode %s:%08lx\n", inode->
i_sb->s_id,
62 di = (
struct bfs_inode *)bh->b_data + off;
102 if ((ino <
BFS_ROOT_INO) || (ino > BFS_SB(sb)->si_lasti)) {
103 printf(
"Bad inode number %s:%08x\n", sb->
s_id, ino);
104 return ERR_PTR(-
EIO);
111 printf(
"Unable to read inode %s:%08x\n", sb->
s_id, ino);
112 return ERR_PTR(-
EIO);
121 unsigned int ino = (
u16)inode->
i_ino;
122 unsigned long i_sblock;
124 struct buffer_head *bh;
129 di = find_inode(inode->
i_sb, ino, &bh);
148 i_sblock = BFS_I(inode)->i_sblock;
150 di->i_eblock =
cpu_to_le32(BFS_I(inode)->i_eblock);
156 if (buffer_req(bh) && !buffer_uptodate(bh))
164 static void bfs_evict_inode(
struct inode *inode)
166 unsigned long ino = inode->
i_ino;
168 struct buffer_head *bh;
182 di = find_inode(s, inode->
i_ino, &bh);
227 u64 id = huge_encode_dev(s->
s_bdev->bd_dev);
242 static struct inode *bfs_alloc_inode(
struct super_block *sb)
257 static void bfs_destroy_inode(
struct inode *inode)
262 static void init_once(
void *
foo)
269 static int init_inodecache(
void)
276 if (bfs_inode_cachep ==
NULL)
281 static void destroy_inodecache(
void)
292 .alloc_inode = bfs_alloc_inode,
293 .destroy_inode = bfs_destroy_inode,
294 .write_inode = bfs_write_inode,
295 .evict_inode = bfs_evict_inode,
296 .put_super = bfs_put_super,
297 .statfs = bfs_statfs,
308 for (i = BFS_SB(s)->si_lasti; i >= 0; i--) {
310 if (
test_bit(i, BFS_SB(s)->si_imap))
315 printf(
"BFS-fs: %s: lasti=%08lx <%s>\n",
316 prefix, BFS_SB(s)->si_lasti, tmpbuf);
321 static int bfs_fill_super(
struct super_block *s,
void *
data,
int silent)
323 struct buffer_head *bh, *sbh;
326 unsigned i, imap_len;
329 unsigned long i_sblock, i_eblock, i_eoff,
s_size;
339 sbh = sb_bread(s, 0);
345 printf(
"No BFS filesystem on %s (magic=%08x)\n",
350 printf(
"%s is unclean, continuing\n", s->
s_id);
355 printf(
"Superblock is corrupted\n");
362 imap_len = (info->
si_lasti / 8) + 1;
372 ret = PTR_ERR(inode);
397 for (i = BFS_ROOT_INO; i <= info->
si_lasti; i++) {
401 unsigned long eblock;
405 bh = sb_bread(s, block);
411 di = (
struct bfs_inode *)bh->b_data + off;
422 i_sblock > i_eblock ||
426 printf(
"Inode 0x%08x corrupted\n", i);
464 int flags,
const char *dev_name,
void *data)
466 return mount_bdev(fs_type, flags, dev_name, data, bfs_fill_super);
477 static int __init init_bfs_fs(
void)
479 int err = init_inodecache();
487 destroy_inodecache();
492 static void __exit exit_bfs_fs(
void)
495 destroy_inodecache();