From owner-svn-src-stable@FreeBSD.ORG Wed Feb 20 20:56:08 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 18955208; Wed, 20 Feb 2013 20:56:08 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0A83A676; Wed, 20 Feb 2013 20:56:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r1KKu73T026132; Wed, 20 Feb 2013 20:56:07 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r1KKu7vC026129; Wed, 20 Feb 2013 20:56:07 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201302202056.r1KKu7vC026129@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Wed, 20 Feb 2013 20:56:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r247055 - stable/9/sys/fs/ext2fs X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2013 20:56:08 -0000 Author: pfg Date: Wed Feb 20 20:56:07 2013 New Revision: 247055 URL: http://svnweb.freebsd.org/changeset/base/247055 Log: MFC r246347, r246348, r246349, r246350, r246351, r246352: ext2fs: Miscellaneous cleanups and fixes. Use EXT2_LINK_MAX instead of LINK_MAX. Use nitems(). Correct off-by-one errors in FFTODT() and DDTOFT(). Remove useless rootino local variable. Remove unused em_e2fsb definition. Move assignment where it is not dead. Submitted by: Christoph Mallon Modified: stable/9/sys/fs/ext2fs/ext2_lookup.c stable/9/sys/fs/ext2fs/ext2_mount.h stable/9/sys/fs/ext2fs/ext2_vnops.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/fs/ (props changed) Modified: stable/9/sys/fs/ext2fs/ext2_lookup.c ============================================================================== --- stable/9/sys/fs/ext2fs/ext2_lookup.c Wed Feb 20 20:42:56 2013 (r247054) +++ stable/9/sys/fs/ext2fs/ext2_lookup.c Wed Feb 20 20:56:07 2013 (r247055) @@ -88,9 +88,8 @@ static u_char ext2_ft_to_dt[] = { DT_SOCK, /* EXT2_FT_SOCK */ DT_LNK, /* EXT2_FT_SYMLINK */ }; -#define FTTODT(ft) \ - ((ft) > sizeof(ext2_ft_to_dt) / sizeof(ext2_ft_to_dt[0]) ? \ - DT_UNKNOWN : ext2_ft_to_dt[(ft)]) +#define FTTODT(ft) \ + ((ft) < nitems(ext2_ft_to_dt) ? ext2_ft_to_dt[(ft)] : DT_UNKNOWN) static u_char dt_to_ext2_ft[] = { EXT2_FT_UNKNOWN, /* DT_UNKNOWN */ @@ -109,9 +108,8 @@ static u_char dt_to_ext2_ft[] = { EXT2_FT_UNKNOWN, /* unused */ EXT2_FT_UNKNOWN, /* DT_WHT */ }; -#define DTTOFT(dt) \ - ((dt) > sizeof(dt_to_ext2_ft) / sizeof(dt_to_ext2_ft[0]) ? \ - EXT2_FT_UNKNOWN : dt_to_ext2_ft[(dt)]) +#define DTTOFT(dt) \ + ((dt) < nitems(dt_to_ext2_ft) ? dt_to_ext2_ft[(dt)] : EXT2_FT_UNKNOWN) static int ext2_dirbadentry(struct vnode *dp, struct ext2fs_direct_2 *de, int entryoffsetinblock); @@ -1088,7 +1086,7 @@ ext2_checkpath(source, target, cred) struct ucred *cred; { struct vnode *vp; - int error, rootino, namlen; + int error, namlen; struct dirtemplate dirbuf; vp = ITOV(target); @@ -1096,10 +1094,10 @@ ext2_checkpath(source, target, cred) error = EEXIST; goto out; } - rootino = EXT2_ROOTINO; - error = 0; - if (target->i_number == rootino) + if (target->i_number == EXT2_ROOTINO) { + error = 0; goto out; + } for (;;) { if (vp->v_type != VDIR) { @@ -1123,7 +1121,7 @@ ext2_checkpath(source, target, cred) error = EINVAL; break; } - if (dirbuf.dotdot_ino == rootino) + if (dirbuf.dotdot_ino == EXT2_ROOTINO) break; vput(vp); if ((error = VFS_VGET(vp->v_mount, dirbuf.dotdot_ino, Modified: stable/9/sys/fs/ext2fs/ext2_mount.h ============================================================================== --- stable/9/sys/fs/ext2fs/ext2_mount.h Wed Feb 20 20:42:56 2013 (r247054) +++ stable/9/sys/fs/ext2fs/ext2_mount.h Wed Feb 20 20:56:07 2013 (r247055) @@ -48,7 +48,6 @@ struct ext2mount { struct vnode *um_devvp; /* block device mounted vnode */ struct m_ext2fs *um_e2fs; /* EXT2FS */ -#define em_e2fsb um_e2fs->e2fs u_long um_nindir; /* indirect ptrs per block */ u_long um_bptrtodb; /* indir ptr to disk block */ Modified: stable/9/sys/fs/ext2fs/ext2_vnops.c ============================================================================== --- stable/9/sys/fs/ext2fs/ext2_vnops.c Wed Feb 20 20:42:56 2013 (r247054) +++ stable/9/sys/fs/ext2fs/ext2_vnops.c Wed Feb 20 20:56:07 2013 (r247055) @@ -736,7 +736,7 @@ ext2_link(ap) goto out; } ip = VTOI(vp); - if ((nlink_t)ip->i_nlink >= LINK_MAX) { + if ((nlink_t)ip->i_nlink >= EXT2_LINK_MAX) { error = EMLINK; goto out; } @@ -847,7 +847,7 @@ abortit: goto abortit; dp = VTOI(fdvp); ip = VTOI(fvp); - if (ip->i_nlink >= LINK_MAX) { + if (ip->i_nlink >= EXT2_LINK_MAX) { VOP_UNLOCK(fvp, 0); error = EMLINK; goto abortit; @@ -945,7 +945,7 @@ abortit: * parent we don't fool with the link count. */ if (doingdirectory && newparent) { - if ((nlink_t)dp->i_nlink >= LINK_MAX) { + if ((nlink_t)dp->i_nlink >= EXT2_LINK_MAX) { error = EMLINK; goto bad; } @@ -1166,7 +1166,7 @@ ext2_mkdir(ap) panic("ext2_mkdir: no name"); #endif dp = VTOI(dvp); - if ((nlink_t)dp->i_nlink >= LINK_MAX) { + if ((nlink_t)dp->i_nlink >= EXT2_LINK_MAX) { error = EMLINK; goto out; } @@ -1530,7 +1530,7 @@ ext2_pathconf(ap) switch (ap->a_name) { case _PC_LINK_MAX: - *ap->a_retval = LINK_MAX; + *ap->a_retval = EXT2_LINK_MAX; return (0); case _PC_NAME_MAX: *ap->a_retval = NAME_MAX;