fs/sysv/super.c: add support for non-PDP11 v7 filesystems
This adds byte order autodetection (of PDP-11 and LE filesystems). No attempt is made to detect big-endian filesystems -- were there any? Tested with PDP-11 v7 filesystems and PC-IX maintenance floppy. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Cc: Christoph Hellwig <hch@lst.de> Cc: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
0bcaa65a56
commit
ab654bab04
1 changed files with 51 additions and 24 deletions
|
@ -24,6 +24,7 @@
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/buffer_head.h>
|
#include <linux/buffer_head.h>
|
||||||
|
#include <linux/parser.h>
|
||||||
#include "sysv.h"
|
#include "sysv.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -434,12 +435,46 @@ Ebadsize:
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int v7_sanity_check(struct super_block *sb, struct buffer_head *bh)
|
||||||
|
{
|
||||||
|
struct v7_super_block *v7sb;
|
||||||
|
struct sysv_inode *v7i;
|
||||||
|
struct buffer_head *bh2;
|
||||||
|
struct sysv_sb_info *sbi;
|
||||||
|
|
||||||
|
sbi = sb->s_fs_info;
|
||||||
|
|
||||||
|
/* plausibility check on superblock */
|
||||||
|
v7sb = (struct v7_super_block *) bh->b_data;
|
||||||
|
if (fs16_to_cpu(sbi, v7sb->s_nfree) > V7_NICFREE ||
|
||||||
|
fs16_to_cpu(sbi, v7sb->s_ninode) > V7_NICINOD ||
|
||||||
|
fs32_to_cpu(sbi, v7sb->s_fsize) > V7_MAXSIZE)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* plausibility check on root inode: it is a directory,
|
||||||
|
with a nonzero size that is a multiple of 16 */
|
||||||
|
bh2 = sb_bread(sb, 2);
|
||||||
|
if (bh2 == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
v7i = (struct sysv_inode *)(bh2->b_data + 64);
|
||||||
|
if ((fs16_to_cpu(sbi, v7i->i_mode) & ~0777) != S_IFDIR ||
|
||||||
|
(fs32_to_cpu(sbi, v7i->i_size) == 0) ||
|
||||||
|
(fs32_to_cpu(sbi, v7i->i_size) & 017) ||
|
||||||
|
(fs32_to_cpu(sbi, v7i->i_size) > V7_NFILES *
|
||||||
|
sizeof(struct sysv_dir_entry))) {
|
||||||
|
brelse(bh2);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
brelse(bh2);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int v7_fill_super(struct super_block *sb, void *data, int silent)
|
static int v7_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
{
|
{
|
||||||
struct sysv_sb_info *sbi;
|
struct sysv_sb_info *sbi;
|
||||||
struct buffer_head *bh, *bh2 = NULL;
|
struct buffer_head *bh;
|
||||||
struct v7_super_block *v7sb;
|
|
||||||
struct sysv_inode *v7i;
|
|
||||||
|
|
||||||
if (440 != sizeof (struct v7_super_block))
|
if (440 != sizeof (struct v7_super_block))
|
||||||
panic("V7 FS: bad super-block size");
|
panic("V7 FS: bad super-block size");
|
||||||
|
@ -453,7 +488,6 @@ static int v7_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
sbi->s_sb = sb;
|
sbi->s_sb = sb;
|
||||||
sbi->s_block_base = 0;
|
sbi->s_block_base = 0;
|
||||||
sbi->s_type = FSTYPE_V7;
|
sbi->s_type = FSTYPE_V7;
|
||||||
sbi->s_bytesex = BYTESEX_PDP;
|
|
||||||
sb->s_fs_info = sbi;
|
sb->s_fs_info = sbi;
|
||||||
|
|
||||||
sb_set_blocksize(sb, 512);
|
sb_set_blocksize(sb, 512);
|
||||||
|
@ -465,34 +499,27 @@ static int v7_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* plausibility check on superblock */
|
/* Try PDP-11 UNIX */
|
||||||
v7sb = (struct v7_super_block *) bh->b_data;
|
sbi->s_bytesex = BYTESEX_PDP;
|
||||||
if (fs16_to_cpu(sbi, v7sb->s_nfree) > V7_NICFREE ||
|
if (v7_sanity_check(sb, bh))
|
||||||
fs16_to_cpu(sbi, v7sb->s_ninode) > V7_NICINOD ||
|
goto detected;
|
||||||
fs32_to_cpu(sbi, v7sb->s_fsize) > V7_MAXSIZE)
|
|
||||||
goto failed;
|
|
||||||
|
|
||||||
/* plausibility check on root inode: it is a directory,
|
/* Try PC/IX, v7/x86 */
|
||||||
with a nonzero size that is a multiple of 16 */
|
sbi->s_bytesex = BYTESEX_LE;
|
||||||
if ((bh2 = sb_bread(sb, 2)) == NULL)
|
if (v7_sanity_check(sb, bh))
|
||||||
goto failed;
|
goto detected;
|
||||||
v7i = (struct sysv_inode *)(bh2->b_data + 64);
|
|
||||||
if ((fs16_to_cpu(sbi, v7i->i_mode) & ~0777) != S_IFDIR ||
|
|
||||||
(fs32_to_cpu(sbi, v7i->i_size) == 0) ||
|
|
||||||
(fs32_to_cpu(sbi, v7i->i_size) & 017) ||
|
|
||||||
(fs32_to_cpu(sbi, v7i->i_size) > V7_NFILES *
|
|
||||||
sizeof(struct sysv_dir_entry)))
|
|
||||||
goto failed;
|
|
||||||
brelse(bh2);
|
|
||||||
bh2 = NULL;
|
|
||||||
|
|
||||||
|
goto failed;
|
||||||
|
|
||||||
|
detected:
|
||||||
sbi->s_bh1 = bh;
|
sbi->s_bh1 = bh;
|
||||||
sbi->s_bh2 = bh;
|
sbi->s_bh2 = bh;
|
||||||
if (complete_read_super(sb, silent, 1))
|
if (complete_read_super(sb, silent, 1))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
brelse(bh2);
|
printk(KERN_ERR "VFS: could not find a valid V7 on %s.\n",
|
||||||
|
sb->s_id);
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
kfree(sbi);
|
kfree(sbi);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue