Module Name: src Committed By: maxv Date: Sun Apr 26 06:19:36 UTC 2015
Modified Files: src/sys/ufs/ffs: ffs_vfsops.c Log Message: ffs_superblock_validate(): check the size of cylinder groups. To generate a diff of this commit: cvs rdiff -u -r1.329 -r1.330 src/sys/ufs/ffs/ffs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/ufs/ffs/ffs_vfsops.c diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.329 src/sys/ufs/ffs/ffs_vfsops.c:1.330 --- src/sys/ufs/ffs/ffs_vfsops.c:1.329 Wed Apr 22 07:27:09 2015 +++ src/sys/ufs/ffs/ffs_vfsops.c Sun Apr 26 06:19:36 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vfsops.c,v 1.329 2015/04/22 07:27:09 maxv Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.330 2015/04/26 06:19:36 maxv Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.329 2015/04/22 07:27:09 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.330 2015/04/26 06:19:36 maxv Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -899,7 +899,7 @@ static int ffs_superblock_validate(struct fs *fs) { int32_t i, fs_bshift = 0, fs_fshift = 0, fs_fragshift = 0, fs_frag; - int32_t fs_inopb; + int32_t fs_inopb, fs_cgsize; /* Check the superblock size */ if (fs->fs_sbsize > SBLOCKSIZE || fs->fs_sbsize < sizeof(struct fs)) @@ -980,6 +980,11 @@ ffs_superblock_validate(struct fs *fs) if (fs->fs_frag != fs_frag) return 0; + /* Check the size of cylinder groups */ + fs_cgsize = ffs_fragroundup(fs, CGSIZE(fs)); + if (fs->fs_cgsize != fs_cgsize) + return 0; + return 1; }