23 #include <linux/module.h>
25 #include <linux/slab.h>
47 static void detected_xenix(
struct sysv_sb_info *sbi,
unsigned *max_links)
49 struct buffer_head *bh1 = sbi->
s_bh1;
50 struct buffer_head *bh2 = sbi->
s_bh2;
65 sbi->s_sbd1 = (
char *)sbd1;
66 sbi->s_sbd2 = (
char *)sbd2;
67 sbi->s_sb_fic_count = &sbd1->s_ninode;
68 sbi->s_sb_fic_inodes = &sbd1->s_inode[0];
69 sbi->s_sb_total_free_inodes = &sbd2->s_tinode;
70 sbi->s_bcache_count = &sbd1->s_nfree;
71 sbi->s_bcache = &sbd1->s_free[0];
72 sbi->s_free_blocks = &sbd2->s_tfree;
73 sbi->s_sb_time = &sbd2->s_time;
74 sbi->s_firstdatazone = fs16_to_cpu(sbi, sbd1->s_isize);
75 sbi->s_nzones = fs32_to_cpu(sbi, sbd1->s_fsize);
78 static void detected_sysv4(
struct sysv_sb_info *sbi,
unsigned *max_links)
81 struct buffer_head *bh1 = sbi->
s_bh1;
82 struct buffer_head *bh2 = sbi->
s_bh2;
106 static void detected_sysv2(
struct sysv_sb_info *sbi,
unsigned *max_links)
109 struct buffer_head *bh1 = sbi->
s_bh1;
110 struct buffer_head *bh2 = sbi->
s_bh2;
120 sbi->
s_sbd1 = (
char *)sbd;
121 sbi->
s_sbd2 = (
char *)sbd;
131 sbi->
s_nzones = fs32_to_cpu(sbi, sbd->s_fsize);
134 static void detected_coherent(
struct sysv_sb_info *sbi,
unsigned *max_links)
137 struct buffer_head *bh1 = sbi->
s_bh1;
144 sbi->
s_sbd1 = (
char *)sbd;
145 sbi->
s_sbd2 = (
char *)sbd;
154 sbi->
s_nzones = fs32_to_cpu(sbi, sbd->s_fsize);
157 static void detected_v7(
struct sysv_sb_info *sbi,
unsigned *max_links)
159 struct buffer_head *bh2 = sbi->
s_bh2;
165 sbi->
s_sbd1 = (
char *)sbd;
166 sbi->
s_sbd2 = (
char *)sbd;
175 sbi->
s_nzones = fs32_to_cpu(sbi, sbd->s_fsize);
178 static int detect_xenix(
struct sysv_sb_info *sbi,
struct buffer_head *bh)
187 switch (fs32_to_cpu(sbi, sbd->
s_type)) {
199 static int detect_sysv(
struct sysv_sb_info *sbi,
struct buffer_head *bh)
214 type = fs32_to_cpu(sbi, sbd->
s_type);
216 if (fs16_to_cpu(sbi, sbd->
s_nfree) == 0xffff) {
220 printk(
"SysV FS: SCO EAFS on %s detected, "
221 "forcing read-only mode.\n",
229 if (type > 3 || type < 1)
234 if ((type > 3 || type < 1) && (type > 0x30 || type < 0x10))
243 printk(
"SysV FS: can't handle long file names on %s, "
244 "forcing read-only mode.\n", sb->
s_id);
249 return type >= 0x10 ? type >> 4 :
type;
252 static int detect_coherent(
struct sysv_sb_info *sbi,
struct buffer_head *bh)
265 static int detect_sysv_odd(
struct sysv_sb_info *sbi,
struct buffer_head *bh)
267 int size = detect_sysv(sbi, bh);
269 return size>2 ? 0 :
size;
278 {0, detect_coherent},
279 {9, detect_sysv_odd},
280 {15,detect_sysv_odd},
284 static char *flavour_names[] = {
302 static int complete_read_super(
struct super_block *sb,
int silent,
int size)
305 struct inode *root_inode;
306 char *found = flavour_names[sbi->
s_type];
308 int bsize = 1 << n_bits;
309 int bsize_4 = bsize >> 2;
316 sbi->s_ndatazones = sbi->s_nzones - sbi->s_firstdatazone;
317 sbi->s_inodes_per_block = bsize >> 6;
318 sbi->s_inodes_per_block_1 = (bsize >> 6)-1;
319 sbi->s_inodes_per_block_bits = n_bits-6;
320 sbi->s_ind_per_block = bsize_4;
321 sbi->s_ind_per_block_2 = bsize_4*bsize_4;
322 sbi->s_toobig_block = 10 + bsize_4 * (1 + bsize_4 * (1 + bsize_4));
329 printk(
"VFS: Found a %s FS (block size = %ld) on device %s\n",
340 if (IS_ERR(root_inode)) {
341 printk(
"SysV FS: get root inode failed\n");
346 printk(
"SysV FS: get root dentry failed\n");
352 static int sysv_fill_super(
struct super_block *sb,
void *
data,
int silent)
354 struct buffer_head *bh1, *bh =
NULL;
378 bh = sb_bread(sb, flavours[
i].
block);
381 size = flavours[
i].test(SYSV_SB(sb), bh);
389 blocknr = bh->b_blocknr << 1;
392 bh1 = sb_bread(sb, blocknr);
393 bh = sb_bread(sb, blocknr + 1);
399 blocknr = bh->b_blocknr >> 1;
402 bh1 = bh = sb_bread(sb, blocknr);
411 if (complete_read_super(sb, silent, size))
418 printk(
"oldfs: cannot read superblock\n");
426 printk(
"VFS: unable to find oldfs superblock on device %s\n",
432 printk(
"VFS: oldfs: unsupported block size (%dKb)\n",
437 static int v7_sanity_check(
struct super_block *sb,
struct buffer_head *bh)
441 struct buffer_head *bh2;
455 bh2 = sb_bread(sb, 2);
459 v7i = (
struct sysv_inode *)(bh2->b_data + 64);
461 (fs32_to_cpu(sbi, v7i->
i_size) == 0) ||
462 (fs32_to_cpu(sbi, v7i->
i_size) & 017) ||
473 static int v7_fill_super(
struct super_block *sb,
void *data,
int silent)
476 struct buffer_head *bh;
479 panic(
"V7 FS: bad super-block size");
481 panic(
"sysv fs: bad i-node size");
494 if ((bh = sb_bread(sb, 1)) ==
NULL) {
496 printk(
"VFS: unable to read V7 FS superblock on "
497 "device %s.\n", sb->
s_id);
503 if (v7_sanity_check(sb, bh))
508 if (v7_sanity_check(sb, bh))
516 if (complete_read_super(sb, silent, 1))
530 int flags,
const char *dev_name,
void *data)
532 return mount_bdev(fs_type, flags, dev_name, data, sysv_fill_super);
536 int flags,
const char *dev_name,
void *data)
538 return mount_bdev(fs_type, flags, dev_name, data, v7_fill_super);
557 static int __init init_sysv_fs(
void)
580 static void __exit exit_sysv_fs(
void)