Module Name:    src
Committed By:   maxv
Date:           Mon Feb 23 17:05:59 UTC 2015

Modified Files:
        src/sys/ufs/ext2fs: ext2fs_vfsops.c

Log Message:
Hum. Perhaps I missed a bit of the specification. Let's not be that
severe when checking the superblock.

Should fix ATF.


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/sys/ufs/ext2fs/ext2fs_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/ext2fs/ext2fs_vfsops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.189 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.190
--- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.189	Sun Feb 22 14:55:23 2015
+++ src/sys/ufs/ext2fs/ext2fs_vfsops.c	Mon Feb 23 17:05:58 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vfsops.c,v 1.189 2015/02/22 14:55:23 maxv Exp $	*/
+/*	$NetBSD: ext2fs_vfsops.c,v 1.190 2015/02/23 17:05:58 maxv Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.189 2015/02/22 14:55:23 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.190 2015/02/23 17:05:58 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -1189,11 +1189,11 @@ ext2fs_sbfill(struct m_ext2fs *m_fs, int
 	 * Compute the fields of the superblock
 	 */
 	u32 = fs->e2fs_bcount - fs->e2fs_first_dblock; /* > 0 */
-	if (u32 < fs->e2fs_bpg) {
+	m_fs->e2fs_ncg = howmany(u32, fs->e2fs_bpg);
+	if (m_fs->e2fs_ncg == 0) {
 		printf("ext2fs: invalid number of cylinder groups\n");
 		return EINVAL;
 	}
-	m_fs->e2fs_ncg = howmany(u32, fs->e2fs_bpg);
 
 	m_fs->e2fs_fsbtodb = fs->e2fs_log_bsize + LOG_MINBSIZE - DEV_BSHIFT;
 	m_fs->e2fs_bsize = MINBSIZE << fs->e2fs_log_bsize;
@@ -1201,13 +1201,12 @@ ext2fs_sbfill(struct m_ext2fs *m_fs, int
 	m_fs->e2fs_qbmask = m_fs->e2fs_bsize - 1;
 	m_fs->e2fs_bmask = ~m_fs->e2fs_qbmask;
 
-	if (m_fs->e2fs_bsize < sizeof(struct ext2_gd)) {
+	if ((u32 = m_fs->e2fs_bsize / sizeof(struct ext2_gd)) == 0) {
 		/* Unlikely to happen */
 		printf("ext2fs: invalid block size\n");
 		return EINVAL;
 	}
-	m_fs->e2fs_ngdb =
-	    howmany(m_fs->e2fs_ncg, m_fs->e2fs_bsize / sizeof(struct ext2_gd));
+	m_fs->e2fs_ngdb = howmany(m_fs->e2fs_ncg, u32);
 	if (m_fs->e2fs_ngdb == 0) {
 		printf("ext2fs: invalid number of group descriptor blocks\n");
 		return EINVAL;

Reply via email to