Module Name:    src
Committed By:   jdolecek
Date:           Sun Aug 14 11:44:54 UTC 2016

Modified Files:
        src/sys/ufs/ext2fs: ext2fs_inode.c ext2fs_lookup.c ext2fs_vfsops.c
            ext2fs_vnops.c

Log Message:
switch code to use the EXT2_HAS_{COMPAT|ROCOMPAT|INCOMPAT}_FEATURE() macros 
instead of open coding the checks


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/ufs/ext2fs/ext2fs_inode.c
cvs rdiff -u -r1.84 -r1.85 src/sys/ufs/ext2fs/ext2fs_lookup.c
cvs rdiff -u -r1.198 -r1.199 src/sys/ufs/ext2fs/ext2fs_vfsops.c
cvs rdiff -u -r1.122 -r1.123 src/sys/ufs/ext2fs/ext2fs_vnops.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_inode.c
diff -u src/sys/ufs/ext2fs/ext2fs_inode.c:1.85 src/sys/ufs/ext2fs/ext2fs_inode.c:1.86
--- src/sys/ufs/ext2fs/ext2fs_inode.c:1.85	Sat Aug 13 07:40:10 2016
+++ src/sys/ufs/ext2fs/ext2fs_inode.c	Sun Aug 14 11:44:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_inode.c,v 1.85 2016/08/13 07:40:10 christos Exp $	*/
+/*	$NetBSD: ext2fs_inode.c,v 1.86 2016/08/14 11:44:54 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.85 2016/08/13 07:40:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.86 2016/08/14 11:44:54 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -121,8 +121,8 @@ ext2fs_setsize(struct inode *ip, uint64_
 				/* Linux automagically upgrades to REV1 here! */
 				return EFBIG;
 			}
-			if (!(fs->e2fs.e2fs_features_rocompat
-			    & EXT2F_ROCOMPAT_LARGEFILE)) {
+			if (!EXT2F_HAS_ROCOMPAT_FEATURE(fs,
+			    EXT2F_ROCOMPAT_LARGEFILE)) {
 				fs->e2fs.e2fs_features_rocompat |=
 				    EXT2F_ROCOMPAT_LARGEFILE;
 				fs->e2fs_fmod = 1;
@@ -142,7 +142,7 @@ ext2fs_nblock(struct inode *ip)
 	uint64_t nblock = ip->i_e2fs_nblock;
 	struct m_ext2fs * const fs = ip->i_e2fs;
 
-	if (fs->e2fs.e2fs_features_rocompat & EXT2F_ROCOMPAT_HUGE_FILE) {
+	if (EXT2F_HAS_ROCOMPAT_FEATURE(fs, EXT2F_ROCOMPAT_HUGE_FILE)) {
 		nblock |= (uint64_t)ip->i_e2fs_nblock_high << 32;
 
 		if ((ip->i_e2fs_flags & EXT2_HUGE_FILE)) {
@@ -164,7 +164,7 @@ ext2fs_setnblock(struct inode *ip, uint6
 		return 0;
 	}
 
-	if (!ISSET(fs->e2fs.e2fs_features_rocompat, EXT2F_ROCOMPAT_HUGE_FILE)) 
+	if (!EXT2F_HAS_ROCOMPAT_FEATURE(fs, EXT2F_ROCOMPAT_HUGE_FILE)) 
 		return EFBIG;
 
 	if (nblock <= 0xffffffffffffULL) {

Index: src/sys/ufs/ext2fs/ext2fs_lookup.c
diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.84 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.85
--- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.84	Sat Aug 13 07:40:10 2016
+++ src/sys/ufs/ext2fs/ext2fs_lookup.c	Sun Aug 14 11:44:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_lookup.c,v 1.84 2016/08/13 07:40:10 christos Exp $	*/
+/*	$NetBSD: ext2fs_lookup.c,v 1.85 2016/08/14 11:44:54 jdolecek Exp $	*/
 
 /*
  * Modified for NetBSD 1.2E
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.84 2016/08/13 07:40:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.85 2016/08/14 11:44:54 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -884,8 +884,7 @@ ext2fs_direnter(struct inode *ip, struct
 
 	newdir.e2d_ino = h2fs32(ip->i_number);
 	newdir.e2d_namlen = cnp->cn_namelen;
-	if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 &&
-	    (ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) {
+	if (EXT2F_HAS_INCOMPAT_FEATURE(ip->i_e2fs, EXT2F_INCOMPAT_FTYPE)) {
 		newdir.e2d_type = inot2ext2dt(IFTODT(ip->i_e2fs_mode));
 	} else {
 		newdir.e2d_type = 0;
@@ -1099,8 +1098,7 @@ ext2fs_dirrewrite(struct inode *dp, cons
 	if (error != 0)
 		return error;
 	ep->e2d_ino = h2fs32(ip->i_number);
-	if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 &&
-	    (ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) {
+	if (EXT2F_HAS_INCOMPAT_FEATURE(dp->i_e2fs, EXT2F_INCOMPAT_FTYPE)) {
 		ep->e2d_type = inot2ext2dt(IFTODT(ip->i_e2fs_mode));
 	} else {
 		ep->e2d_type = 0;

Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.198 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.199
--- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.198	Sat Aug 13 07:40:10 2016
+++ src/sys/ufs/ext2fs/ext2fs_vfsops.c	Sun Aug 14 11:44:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vfsops.c,v 1.198 2016/08/13 07:40:10 christos Exp $	*/
+/*	$NetBSD: ext2fs_vfsops.c,v 1.199 2016/08/14 11:44:54 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.198 2016/08/13 07:40:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.199 2016/08/14 11:44:54 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -834,8 +834,7 @@ ext2fs_statvfs(struct mount *mp, struct 
 	    fs->e2fs_itpg;
 	overhead = fs->e2fs.e2fs_first_dblock +
 	    fs->e2fs_ncg * overhead_per_group;
-	if (fs->e2fs.e2fs_rev > E2FS_REV0 &&
-	    fs->e2fs.e2fs_features_rocompat & EXT2F_ROCOMPAT_SPARSESUPER) {
+	if (EXT2F_HAS_ROCOMPAT_FEATURE(fs, EXT2F_ROCOMPAT_SPARSESUPER)) {
 		for (i = 0, ngroups = 0; i < fs->e2fs_ncg; i++) {
 			if (cg_has_sb(i))
 				ngroups++;
@@ -844,8 +843,7 @@ ext2fs_statvfs(struct mount *mp, struct 
 		ngroups = fs->e2fs_ncg;
 	}
 	ngdb = fs->e2fs_ngdb;
-	if (fs->e2fs.e2fs_rev > E2FS_REV0 &&
-	    fs->e2fs.e2fs_features_compat & EXT2F_COMPAT_RESIZE)
+	if (EXT2F_HAS_COMPAT_FEATURE(fs, EXT2F_COMPAT_RESIZE))
 		ngdb += fs->e2fs.e2fs_reserved_ngdb;
 	overhead += ngroups * (1 /* superblock */ + ngdb);
 

Index: src/sys/ufs/ext2fs/ext2fs_vnops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vnops.c:1.122 src/sys/ufs/ext2fs/ext2fs_vnops.c:1.123
--- src/sys/ufs/ext2fs/ext2fs_vnops.c:1.122	Sat Aug 13 07:40:10 2016
+++ src/sys/ufs/ext2fs/ext2fs_vnops.c	Sun Aug 14 11:44:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vnops.c,v 1.122 2016/08/13 07:40:10 christos Exp $	*/
+/*	$NetBSD: ext2fs_vnops.c,v 1.123 2016/08/14 11:44:54 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.122 2016/08/13 07:40:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.123 2016/08/14 11:44:54 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -724,16 +724,14 @@ ext2fs_mkdir(void *v)
 	dirtemplate.dot_ino = h2fs32(ip->i_number);
 	dirtemplate.dot_reclen = h2fs16(12);
 	dirtemplate.dot_namlen = 1;
-	if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 &&
-	    (ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) {
+	if (EXT2F_HAS_INCOMPAT_FEATURE(dp->i_e2fs, EXT2F_INCOMPAT_FTYPE)) {
 		dirtemplate.dot_type = EXT2_FT_DIR;
 	}
 	dirtemplate.dot_name[0] = '.';
 	dirtemplate.dotdot_ino = h2fs32(dp->i_number);
-    dirtemplate.dotdot_reclen = h2fs16(VTOI(dvp)->i_e2fs->e2fs_bsize - 12);
+	dirtemplate.dotdot_reclen = h2fs16(VTOI(dvp)->i_e2fs->e2fs_bsize - 12);
 	dirtemplate.dotdot_namlen = 2;
-	if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 &&
-	    (ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) {
+	if (EXT2F_HAS_INCOMPAT_FEATURE(dp->i_e2fs, EXT2F_INCOMPAT_FTYPE)) {
 		dirtemplate.dotdot_type = EXT2_FT_DIR;
 	}
 	dirtemplate.dotdot_name[0] = dirtemplate.dotdot_name[1] = '.';

Reply via email to