when mounting a filesystem, read the last block in the filesystem
to verify that the device is at least as big as the superblock claims the filesystem is supposed to be, and if it's not then fail the mount. this should help reduce the type of confusion reported in PR 13228.
This commit is contained in:
parent
7c50f65a84
commit
c1d184702f
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ffs_vfsops.c,v 1.93 2002/03/08 20:48:46 thorpej Exp $ */
|
||||
/* $NetBSD: ffs_vfsops.c,v 1.94 2002/03/17 00:02:34 chs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1991, 1993, 1994
|
||||
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.93 2002/03/08 20:48:46 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.94 2002/03/17 00:02:34 chs Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_ffs.h"
|
||||
@ -691,6 +691,21 @@ ffs_mountfs(devvp, mp, p)
|
||||
bp->b_flags |= B_INVAL;
|
||||
brelse(bp);
|
||||
bp = NULL;
|
||||
|
||||
/*
|
||||
* verify that we can access the last block in the fs.
|
||||
*/
|
||||
|
||||
error = bread(devvp, fsbtodb(fs, fs->fs_size - 1), fs->fs_fsize, cred,
|
||||
&bp);
|
||||
if (bp->b_bcount != fs->fs_fsize)
|
||||
error = EINVAL;
|
||||
bp->b_flags |= B_INVAL;
|
||||
if (error)
|
||||
goto out;
|
||||
brelse(bp);
|
||||
bp = NULL;
|
||||
|
||||
fs->fs_ronly = ronly;
|
||||
if (ronly == 0) {
|
||||
fs->fs_clean <<= 1;
|
||||
|
Loading…
Reference in New Issue
Block a user