Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 496ee9b8 authored by Lubomir Rintel's avatar Lubomir Rintel Committed by Al Viro
Browse files

V7: Adjust sanity checks for some volumes



Newly mkfs-ed filesystems from Seventh Edition have last modification
time set to zero, but are otherwise perfectly valid.

Also, tighten up other sanity checks to filter out most filesystems with
different bytesex than we're using.

Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: default avatarLubomir Rintel <lkundrak@v3.sk>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent b76212d7
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -469,7 +469,7 @@ static int v7_fill_super(struct super_block *sb, void *data, int silent)
	v7sb = (struct v7_super_block *) bh->b_data;
	v7sb = (struct v7_super_block *) bh->b_data;
	if (fs16_to_cpu(sbi, v7sb->s_nfree) > V7_NICFREE ||
	if (fs16_to_cpu(sbi, v7sb->s_nfree) > V7_NICFREE ||
	    fs16_to_cpu(sbi, v7sb->s_ninode) > V7_NICINOD ||
	    fs16_to_cpu(sbi, v7sb->s_ninode) > V7_NICINOD ||
	    fs32_to_cpu(sbi, v7sb->s_time) == 0)
	    fs32_to_cpu(sbi, v7sb->s_fsize) > V7_MAXSIZE)
		goto failed;
		goto failed;


	/* plausibility check on root inode: it is a directory,
	/* plausibility check on root inode: it is a directory,
@@ -479,7 +479,9 @@ static int v7_fill_super(struct super_block *sb, void *data, int silent)
	v7i = (struct sysv_inode *)(bh2->b_data + 64);
	v7i = (struct sysv_inode *)(bh2->b_data + 64);
	if ((fs16_to_cpu(sbi, v7i->i_mode) & ~0777) != S_IFDIR ||
	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) == 0) ||
	    (fs32_to_cpu(sbi, v7i->i_size) & 017) != 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;
		goto failed;
	brelse(bh2);
	brelse(bh2);
	bh2 = NULL;
	bh2 = NULL;
+11 −0
Original line number Original line Diff line number Diff line
@@ -148,6 +148,17 @@ struct v7_super_block {
	char    s_fname[6];     /* file system name */
	char    s_fname[6];     /* file system name */
	char    s_fpack[6];     /* file system pack name */
	char    s_fpack[6];     /* file system pack name */
};
};
/* Constants to aid sanity checking */
/* This is not a hard limit, nor enforced by v7 kernel. It's actually just
 * the limit used by Seventh Edition's ls, though is high enough to assume
 * that no reasonable file system would have that much entries in root
 * directory. Thus, if we see anything higher, we just probably got the
 * endiannes wrong. */
#define V7_NFILES	1024
/* The disk addresses are three-byte (despite direct block addresses being
 * aligned word-wise in inode). If the most significant byte is non-zero,
 * something is most likely wrong (not a filesystem, bad bytesex). */
#define V7_MAXSIZE	0x00ffffff


/* Coherent super-block data on disk */
/* Coherent super-block data on disk */
#define COH_NICINOD	100	/* number of inode cache entries */
#define COH_NICINOD	100	/* number of inode cache entries */