13 #include <linux/module.h>
16 #include <linux/slab.h>
22 static int minix_write_inode(
struct inode *
inode,
27 static void minix_evict_inode(
struct inode *
inode)
62 static struct inode *minix_alloc_inode(
struct super_block *sb)
77 static void minix_destroy_inode(
struct inode *inode)
82 static void init_once(
void *
foo)
89 static int init_inodecache(
void)
96 if (minix_inode_cachep ==
NULL)
101 static void destroy_inodecache(
void)
112 .alloc_inode = minix_alloc_inode,
113 .destroy_inode = minix_destroy_inode,
114 .write_inode = minix_write_inode,
115 .evict_inode = minix_evict_inode,
116 .put_super = minix_put_super,
117 .statfs = minix_statfs,
118 .remount_fs = minix_remount,
129 if (*flags & MS_RDONLY) {
148 printk(
"MINIX-fs warning: remounting unchecked fs, "
149 "running fsck is recommended\n");
151 printk(
"MINIX-fs warning: remounting fs with errors, "
152 "running fsck is recommended\n");
157 static int minix_fill_super(
struct super_block *
s,
void *data,
int silent)
159 struct buffer_head *bh;
160 struct buffer_head **
map;
164 struct inode *root_inode;
179 if (!(bh = sb_bread(s, 1)))
249 if (!(sbi->
s_imap[i]=sb_bread(s, block)))
254 if (!(sbi->
s_zmap[i]=sb_bread(s, block)))
268 printk(
"MINIX-fs: file system does not have enough "
269 "imap blocks allocated. Refusing to mount\n");
273 block = minix_blocks_needed(
277 printk(
"MINIX-fs: file system does not have enough "
278 "zmap blocks allocated. Refusing to mount.\n");
283 s->
s_op = &minix_sops;
285 if (IS_ERR(root_inode)) {
286 ret = PTR_ERR(root_inode);
295 if (!(s->
s_flags & MS_RDONLY)) {
301 printk(
"MINIX-fs: mounting unchecked file system, "
302 "running fsck is recommended\n");
304 printk(
"MINIX-fs: mounting file system with errors, "
305 "running fsck is recommended\n");
311 printk(
"MINIX-fs: get root inode failed\n");
315 printk(
"MINIX-fs: bad superblock or unable to read bitmaps\n");
327 printk(
"MINIX-fs: can't allocate map\n");
332 printk(
"MINIX-fs: bad superblock\n");
337 printk(
"VFS: Can't find a Minix filesystem V1 | V2 | V3 "
338 "on device %s.\n", s->
s_id);
344 printk(
"MINIX-fs: blocksize too small for device\n");
348 printk(
"MINIX-fs: unable to read superblock\n");
359 u64 id = huge_encode_dev(sb->
s_bdev->bd_dev);
374 static int minix_get_block(
struct inode *inode,
sector_t block,
375 struct buffer_head *bh_result,
int create)
399 loff_t
pos,
unsigned len,
unsigned flags,
400 struct page **pagep,
void **fsdata)
407 loff_t isize = mapping->
host->i_size;
408 if (pos + len > isize)
421 .readpage = minix_readpage,
422 .writepage = minix_writepage,
423 .write_begin = minix_write_begin,
446 inode->
i_op = &minix_symlink_inode_operations;
455 static struct inode *V1_minix_iget(
struct inode *inode)
457 struct buffer_head * bh;
465 return ERR_PTR(-
EIO);
468 i_uid_write(inode, raw_inode->
i_uid);
469 i_gid_write(inode, raw_inode->
i_gid);
477 for (i = 0; i < 9; i++)
488 static struct inode *V2_minix_iget(
struct inode *inode)
490 struct buffer_head * bh;
498 return ERR_PTR(-
EIO);
501 i_uid_write(inode, raw_inode->
i_uid);
502 i_gid_write(inode, raw_inode->
i_gid);
512 for (i = 0; i < 10; i++)
534 return V1_minix_iget(inode);
536 return V2_minix_iget(inode);
542 static struct buffer_head * V1_minix_update_inode(
struct inode * inode)
544 struct buffer_head * bh;
545 struct minix_inode * raw_inode;
560 else for (i = 0; i < 9; i++)
569 static struct buffer_head * V2_minix_update_inode(
struct inode * inode)
571 struct buffer_head * bh;
589 else for (i = 0; i < 10; i++)
598 struct buffer_head *bh;
601 bh = V1_minix_update_inode(inode);
603 bh = V2_minix_update_inode(inode);
608 if (buffer_req(bh) && !buffer_uptodate(bh)) {
609 printk(
"IO error syncing minix inode [%s:%08lx]\n",
644 int flags,
const char *dev_name,
void *data)
646 return mount_bdev(fs_type, flags, dev_name, data, minix_fill_super);
652 .mount = minix_mount,
657 static int __init init_minix_fs(
void)
659 int err = init_inodecache();
667 destroy_inodecache();
672 static void __exit exit_minix_fs(
void)
675 destroy_inodecache();