From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 00:42:28 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6BFEE106564A; Sun, 27 Mar 2011 00:42:28 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5AB1D8FC12; Sun, 27 Mar 2011 00:42:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2R0gSDJ041661; Sun, 27 Mar 2011 00:42:28 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2R0gSTi041655; Sun, 27 Mar 2011 00:42:28 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103270042.p2R0gSTi041655@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 27 Mar 2011 00:42:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220047 - in stable/8/sys: conf modules/ufs ufs/ffs ufs/ufs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 00:42:28 -0000 Author: kib Date: Sun Mar 27 00:42:28 2011 New Revision: 220047 URL: http://svn.freebsd.org/changeset/base/220047 Log: MFC r219804: Retire opt_ffs_broken_fixme.h. Modified: stable/8/sys/conf/options stable/8/sys/modules/ufs/Makefile stable/8/sys/ufs/ffs/ffs_vfsops.c stable/8/sys/ufs/ufs/ufs_lookup.c stable/8/sys/ufs/ufs/ufsmount.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/conf/options ============================================================================== --- stable/8/sys/conf/options Sat Mar 26 22:39:23 2011 (r220046) +++ stable/8/sys/conf/options Sun Mar 27 00:42:28 2011 (r220047) @@ -198,6 +198,7 @@ CD9660 opt_dontuse.h CODA opt_dontuse.h EXT2FS opt_dontuse.h FDESCFS opt_dontuse.h +FFS opt_dontuse.h HPFS opt_dontuse.h MSDOSFS opt_dontuse.h NTFS opt_dontuse.h @@ -215,9 +216,6 @@ UNIONFS opt_dontuse.h # Pseudofs debugging PSEUDOFS_TRACE opt_pseudofs.h -# Broken - ffs_snapshot() dependency from ufs_lookup() :-( -FFS opt_ffs_broken_fixme.h - # In-kernel GSS-API KGSSAPI opt_kgssapi.h KGSSAPI_DEBUG opt_kgssapi.h Modified: stable/8/sys/modules/ufs/Makefile ============================================================================== --- stable/8/sys/modules/ufs/Makefile Sat Mar 26 22:39:23 2011 (r220046) +++ stable/8/sys/modules/ufs/Makefile Sun Mar 27 00:42:28 2011 (r220047) @@ -3,8 +3,7 @@ .PATH: ${.CURDIR}/../../ufs/ufs ${.CURDIR}/../../ufs/ffs KMOD= ufs -SRCS= opt_ddb.h opt_directio.h opt_ffs.h opt_ffs_broken_fixme.h \ - opt_quota.h opt_suiddir.h opt_ufs.h \ +SRCS= opt_ddb.h opt_directio.h opt_ffs.h opt_quota.h opt_suiddir.h opt_ufs.h \ vnode_if.h ufs_acl.c ufs_bmap.c ufs_dirhash.c ufs_extattr.c \ ufs_gjournal.c ufs_inode.c ufs_lookup.c ufs_quota.c ufs_vfsops.c \ ufs_vnops.c ffs_alloc.c ffs_balloc.c ffs_inode.c ffs_snapshot.c \ Modified: stable/8/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- stable/8/sys/ufs/ffs/ffs_vfsops.c Sat Mar 26 22:39:23 2011 (r220046) +++ stable/8/sys/ufs/ffs/ffs_vfsops.c Sun Mar 27 00:42:28 2011 (r220047) @@ -792,6 +792,7 @@ ffs_mountfs(devvp, mp, td) ump->um_vfree = ffs_vfree; ump->um_ifree = ffs_ifree; ump->um_rdonly = ffs_rdonly; + ump->um_snapgone = ffs_snapgone; mtx_init(UFS_MTX(ump), "FFS", "FFS Lock", MTX_DEF); bcopy(bp->b_data, ump->um_fs, (u_int)fs->fs_sbsize); if (fs->fs_sbsize < SBLOCKSIZE) Modified: stable/8/sys/ufs/ufs/ufs_lookup.c ============================================================================== --- stable/8/sys/ufs/ufs/ufs_lookup.c Sat Mar 26 22:39:23 2011 (r220046) +++ stable/8/sys/ufs/ufs/ufs_lookup.c Sun Mar 27 00:42:28 2011 (r220047) @@ -37,7 +37,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_ffs_broken_fixme.h" #include "opt_ufs.h" #include "opt_quota.h" @@ -1239,7 +1238,7 @@ out: * when last open reference goes away. */ if (ip != 0 && (ip->i_flags & SF_SNAPSHOT) != 0 && ip->i_effnlink == 0) - ffs_snapgone(ip); + UFS_SNAPGONE(ip); return (error); } @@ -1289,7 +1288,7 @@ ufs_dirrewrite(dp, oip, newinum, newtype * when last open reference goes away. */ if ((oip->i_flags & SF_SNAPSHOT) != 0 && oip->i_effnlink == 0) - ffs_snapgone(oip); + UFS_SNAPGONE(oip); return (error); } Modified: stable/8/sys/ufs/ufs/ufsmount.h ============================================================================== --- stable/8/sys/ufs/ufs/ufsmount.h Sat Mar 26 22:39:23 2011 (r220046) +++ stable/8/sys/ufs/ufs/ufsmount.h Sun Mar 27 00:42:28 2011 (r220047) @@ -95,6 +95,7 @@ struct ufsmount { int (*um_vfree)(struct vnode *, ino_t, int); void (*um_ifree)(struct ufsmount *, struct inode *); int (*um_rdonly)(struct inode *); + void (*um_snapgone)(struct inode *); }; #define UFS_BALLOC(aa, bb, cc, dd, ee, ff) VFSTOUFS((aa)->v_mount)->um_balloc(aa, bb, cc, dd, ee, ff) @@ -105,6 +106,7 @@ struct ufsmount { #define UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc) #define UFS_IFREE(aa, bb) ((aa)->um_ifree(aa, bb)) #define UFS_RDONLY(aa) ((aa)->i_ump->um_rdonly(aa)) +#define UFS_SNAPGONE(aa) ((aa)->i_ump->um_snapgone(aa)) #define UFS_LOCK(aa) mtx_lock(&(aa)->um_lock) #define UFS_UNLOCK(aa) mtx_unlock(&(aa)->um_lock) From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 01:17:25 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CF64E106566C; Sun, 27 Mar 2011 01:17:25 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) by mx1.freebsd.org (Postfix) with ESMTP id 9FD0F8FC17; Sun, 27 Mar 2011 01:17:25 +0000 (UTC) Received: from julian-mac.elischer.org (home-nat.elischer.org [67.100.89.137]) (authenticated bits=0) by vps1.elischer.org (8.14.4/8.14.4) with ESMTP id p2R1HNES006364 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sat, 26 Mar 2011 18:17:24 -0700 (PDT) (envelope-from julian@freebsd.org) Message-ID: <4D8E9037.6090408@freebsd.org> Date: Sat, 26 Mar 2011 18:17:43 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: Andriy Gapon References: <201103261125.p2QBPa19020439@svn.freebsd.org> <4D8DCE0B.5040808@freebsd.org> In-Reply-To: <4D8DCE0B.5040808@freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220032 - in head/sys: amd64/linux32 compat/linux i386/linux X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 01:17:25 -0000 On 3/26/11 4:29 AM, Andriy Gapon wrote: > on 26/03/2011 13:25 Andriy Gapon said the following: >> Author: avg >> Date: Sat Mar 26 11:25:36 2011 >> New Revision: 220032 >> URL: http://svn.freebsd.org/changeset/base/220032 >> >> Log: >> linux compat: add SO_PASSCRED option with basic handling >> >> This seems to have been a part of a bigger patch by dchagin that either >> haven't been committed or committed partially. >> >> Submitted by: dchagin, nox >> MFC after: 2 weeks > Dear linuxulator guys, > > apologies for wading into your territory and possibly making some mess while > there. But I really couldn't wait any longer for these patches to get finally > committed. you have a commit bit. you have shown an interest. All you need to do now is make contact with others in this area and: You are one of the linuxulator guys! congratulations on your new team membership! From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 03:03:29 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A6047106564A; Sun, 27 Mar 2011 03:03:29 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7B4378FC1E; Sun, 27 Mar 2011 03:03:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2R33T6j044522; Sun, 27 Mar 2011 03:03:29 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2R33Tss044521; Sun, 27 Mar 2011 03:03:29 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103270303.p2R33Tss044521@svn.freebsd.org> From: Doug Barton Date: Sun, 27 Mar 2011 03:03:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220048 - in head/etc/periodic: security weekly X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 03:03:29 -0000 Author: dougb Date: Sun Mar 27 03:03:29 2011 New Revision: 220048 URL: http://svn.freebsd.org/changeset/base/220048 Log: Add svn:executable property on remaining period scripts without it Modified: Directory Properties: head/etc/periodic/security/410.logincheck (props changed) head/etc/periodic/security/460.chkportsum (props changed) head/etc/periodic/security/510.ipfdenied (props changed) head/etc/periodic/security/520.pfdenied (props changed) head/etc/periodic/security/610.ipf6denied (props changed) head/etc/periodic/weekly/340.noid (props changed) From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 03:06:58 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C27C1106564A; Sun, 27 Mar 2011 03:06:58 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B18BB8FC14; Sun, 27 Mar 2011 03:06:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2R36w8f044628; Sun, 27 Mar 2011 03:06:58 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2R36wD0044625; Sun, 27 Mar 2011 03:06:58 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103270306.p2R36wD0044625@svn.freebsd.org> From: Doug Barton Date: Sun, 27 Mar 2011 03:06:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220049 - in head/etc/periodic: daily security X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 03:06:58 -0000 Author: dougb Date: Sun Mar 27 03:06:58 2011 New Revision: 220049 URL: http://svn.freebsd.org/changeset/base/220049 Log: Hook the 220.backup-pkgdb script I added to the build unconditionally Hook up 610.ipf6denied based on MK_IPFILTER as 510.ipfdenied is now Poked by: Andrzej Tobola Modified: head/etc/periodic/daily/Makefile head/etc/periodic/security/Makefile Modified: head/etc/periodic/daily/Makefile ============================================================================== --- head/etc/periodic/daily/Makefile Sun Mar 27 03:03:29 2011 (r220048) +++ head/etc/periodic/daily/Makefile Sun Mar 27 03:06:58 2011 (r220049) @@ -6,6 +6,7 @@ FILES= 100.clean-disks \ 110.clean-tmps \ 120.clean-preserve \ 200.backup-passwd \ + 220.backup-pkgdb \ 330.news \ 400.status-disks \ 405.status-ata-raid \ Modified: head/etc/periodic/security/Makefile ============================================================================== --- head/etc/periodic/security/Makefile Sun Mar 27 03:03:29 2011 (r220048) +++ head/etc/periodic/security/Makefile Sun Mar 27 03:06:58 2011 (r220049) @@ -17,6 +17,7 @@ FILES= 100.chksetuid \ .if ${MK_IPFILTER} != "no" FILES+= 510.ipfdenied +FILES+= 610.ipf6denied .endif .if ${MK_IPFW} != "no" From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 03:57:21 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id 07C6F106566B; Sun, 27 Mar 2011 03:57:21 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from 65-241-43-5.globalsuite.net (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id 8FC5A14E19C; Sun, 27 Mar 2011 03:57:19 +0000 (UTC) Message-ID: <4D8EB596.3060706@FreeBSD.org> Date: Sat, 26 Mar 2011 20:57:10 -0700 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.2.15) Gecko/20110326 Thunderbird/3.1.9 MIME-Version: 1.0 To: Alexander Best References: <201103260034.p2Q0YaC0098236@svn.freebsd.org> <20110326015721.GA25582@freebsd.org> In-Reply-To: <20110326015721.GA25582@freebsd.org> X-Enigmail-Version: 1.1.2 OpenPGP: id=1A1ABC84 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220015 - head/usr.sbin/newsyslog X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 03:57:21 -0000 On 03/25/2011 18:57, Alexander Best wrote: > On Sat Mar 26 11, Doug Barton wrote: >> Author: dougb >> Date: Sat Mar 26 00:34:35 2011 >> New Revision: 220015 >> URL: http://svn.freebsd.org/changeset/base/220015 >> >> Log: >> Add an example for the use of the entry to help others >> who are as slow as I am. > > shouldn't that be march 25th? ;) Technically, yes. :) But more importantly it is later than the previous date. Doug >> Discussed with: gordon >> >> Modified: >> head/usr.sbin/newsyslog/newsyslog.conf.5 >> >> Modified: head/usr.sbin/newsyslog/newsyslog.conf.5 >> ============================================================================== >> --- head/usr.sbin/newsyslog/newsyslog.conf.5 Fri Mar 25 22:31:28 2011 (r220014) >> +++ head/usr.sbin/newsyslog/newsyslog.conf.5 Sat Mar 26 00:34:35 2011 (r220015) >> @@ -21,7 +21,7 @@ >> .\" the suitability of this software for any purpose. It is >> .\" provided "as is" without express or implied warranty. >> .\" >> -.Dd January 31, 2011 >> +.Dd February 25, 2011 >> .Dt NEWSYSLOG.CONF 5 >> .Os >> .Sh NAME >> @@ -349,6 +349,11 @@ If this field is not present, then a >> .Dv SIGHUP >> signal will be sent. >> .El >> +.Sh EXAMPLES >> +The following is an example of the >> +.Dq Aq Li include >> +entry: >> +.Dl " /etc/newsyslog-local.conf" >> .Sh SEE ALSO >> .Xr bzip2 1 , >> .Xr gzip 1 , > -- Nothin' ever doesn't change, but nothin' changes much. -- OK Go Breadth of IT experience, and depth of knowledge in the DNS. Yours for the right price. :) http://SupersetSolutions.com/ From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 05:09:21 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E67E4106566C; Sun, 27 Mar 2011 05:09:21 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D4D7F8FC12; Sun, 27 Mar 2011 05:09:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2R59Ldm047183; Sun, 27 Mar 2011 05:09:21 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2R59LTx047179; Sun, 27 Mar 2011 05:09:21 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201103270509.p2R59LTx047179@svn.freebsd.org> From: Navdeep Parhar Date: Sun, 27 Mar 2011 05:09:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220050 - stable/8/sys/dev/cxgbe X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 05:09:22 -0000 Author: np Date: Sun Mar 27 05:09:21 2011 New Revision: 220050 URL: http://svn.freebsd.org/changeset/base/220050 Log: MFC r219944 Do not over-allocate MSI interrupts for the case where each ingress queue has its own interrupt. If the exact number that we need is not a power of 2 and we're using MSI, then switch to interrupt multiplexing. While here, replace the magic numbers with something more readable. Modified: stable/8/sys/dev/cxgbe/adapter.h stable/8/sys/dev/cxgbe/t4_main.c stable/8/sys/dev/cxgbe/t4_sge.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/cxgbe/adapter.h ============================================================================== --- stable/8/sys/dev/cxgbe/adapter.h Sun Mar 27 03:06:58 2011 (r220049) +++ stable/8/sys/dev/cxgbe/adapter.h Sun Mar 27 05:09:21 2011 (r220050) @@ -128,6 +128,13 @@ enum { }; enum { + /* adapter intr_type */ + INTR_INTX = (1 << 0), + INTR_MSI = (1 << 1), + INTR_MSIX = (1 << 2) +}; + +enum { /* adapter flags */ FULL_INIT_DONE = (1 << 0), FW_OK = (1 << 1), Modified: stable/8/sys/dev/cxgbe/t4_main.c ============================================================================== --- stable/8/sys/dev/cxgbe/t4_main.c Sun Mar 27 03:06:58 2011 (r220049) +++ stable/8/sys/dev/cxgbe/t4_main.c Sun Mar 27 05:09:21 2011 (r220050) @@ -205,7 +205,7 @@ SYSCTL_UINT(_hw_cxgbe, OID_AUTO, qsize_r /* * Interrupt types allowed. */ -static int intr_types = 7; +static int intr_types = INTR_MSIX | INTR_MSI | INTR_INTX; TUNABLE_INT("hw.cxgbe.interrupt_types", &intr_types); SYSCTL_UINT(_hw_cxgbe, OID_AUTO, interrupt_types, CTLFLAG_RDTUN, &intr_types, 0, "interrupt types allowed (bits 0, 1, 2 = INTx, MSI, MSI-X respectively)"); @@ -219,7 +219,7 @@ SYSCTL_UINT(_hw_cxgbe, OID_AUTO, interru &intr_fwd, 0, "always use forwarded interrupts"); struct intrs_and_queues { - int intr_type; /* 1, 2, or 4 for INTx, MSI, or MSI-X */ + int intr_type; /* INTx, MSI, or MSI-X */ int nirq; /* Number of vectors */ int intr_fwd; /* Interrupts forwarded */ int ntxq10g; /* # of NIC txq's for each 10G port */ @@ -639,7 +639,7 @@ t4_detach(device_t dev) if (sc->flags & FW_OK) t4_fw_bye(sc, sc->mbox); - if (sc->intr_type == 2 || sc->intr_type == 4) + if (sc->intr_type == INTR_MSI || sc->intr_type == INTR_MSIX) pci_release_msi(dev); if (sc->regs_res) @@ -1152,14 +1152,14 @@ cfg_itype_and_nqueues(struct adapter *sc bzero(iaq, sizeof(*iaq)); nc = mp_ncpus; /* our snapshot of the number of CPUs */ - for (itype = 4; itype; itype >>= 1) { + for (itype = INTR_MSIX; itype; itype >>= 1) { if ((itype & intr_types) == 0) continue; /* not allowed */ - if (itype == 4) + if (itype == INTR_MSIX) navail = pci_msix_count(sc->dev); - else if (itype == 2) + else if (itype == INTR_MSI) navail = pci_msi_count(sc->dev); else navail = 1; @@ -1179,44 +1179,50 @@ cfg_itype_and_nqueues(struct adapter *sc iaq->nirq = n10g * nrxq10g + n1g * nrxq1g + 2; if (iaq->nirq <= navail && intr_fwd == 0) { + if (itype == INTR_MSI && !powerof2(iaq->nirq)) + goto fwd; + /* One for err, one for fwq, and one for each rxq */ iaq->intr_fwd = 0; iaq->nrxq10g = nrxq10g; iaq->nrxq1g = nrxq1g; - if (itype == 2) { - /* # of vectors requested must be power of 2 */ - while (!powerof2(iaq->nirq)) - iaq->nirq++; - KASSERT(iaq->nirq <= navail, - ("%s: bad MSI calculation", __func__)); - } + } else { fwd: iaq->intr_fwd = 1; - iaq->nirq = navail; + + if (navail > nc) { + if (itype == INTR_MSIX) + navail = nc + 1; + + /* navail is and must remain a pow2 for MSI */ + if (itype == INTR_MSI) { + KASSERT(powerof2(navail), + ("%d not power of 2", navail)); + + while (navail / 2 > nc) + navail /= 2; + } + } + iaq->nirq = navail; /* total # of interrupts */ /* * If we have multiple vectors available reserve one * exclusively for errors. The rest will be shared by * the fwq and data. */ - if (navail > 1) { + if (navail > 1) navail--; - - if (navail > nc && itype == 4) - iaq->nirq = nc + 1; - } - iaq->nrxq10g = min(nrxq10g, navail); iaq->nrxq1g = min(nrxq1g, navail); } navail = iaq->nirq; rc = 0; - if (itype == 4) + if (itype == INTR_MSIX) rc = pci_alloc_msix(sc->dev, &navail); - else if (itype == 2) + else if (itype == INTR_MSI) rc = pci_alloc_msi(sc->dev, &navail); if (rc == 0) { @@ -1481,10 +1487,10 @@ t4_set_desc(struct adapter *sc) struct adapter_params *p = &sc->params; snprintf(buf, sizeof(buf), - "Chelsio %s (rev %d) %d port %sNIC PCIe-x%d %s, S/N:%s, E/C:%s", + "Chelsio %s (rev %d) %d port %sNIC PCIe-x%d %d %s, S/N:%s, E/C:%s", p->vpd.id, p->rev, p->nports, is_offload(sc) ? "R" : "", - p->pci.width, (sc->intr_type == 4 ) ? "MSI-X" : - (sc->intr_type == 2) ? "MSI" : "INTx", p->vpd.sn, p->vpd.ec); + p->pci.width, sc->intr_count, sc->intr_type == INTR_MSIX ? "MSI-X" : + (sc->intr_type == INTR_MSI ? "MSI" : "INTx"), p->vpd.sn, p->vpd.ec); device_set_desc_copy(sc->dev, buf); } Modified: stable/8/sys/dev/cxgbe/t4_sge.c ============================================================================== --- stable/8/sys/dev/cxgbe/t4_sge.c Sun Mar 27 03:06:58 2011 (r220049) +++ stable/8/sys/dev/cxgbe/t4_sge.c Sun Mar 27 05:09:21 2011 (r220050) @@ -468,7 +468,7 @@ t4_intr_err(void *arg) { struct adapter *sc = arg; - if (sc->intr_type == 1) + if (sc->intr_type == INTR_INTX) t4_write_reg(sc, MYPF_REG(A_PCIE_PF_CLI), 0); t4_slow_intr_handler(sc); From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 08:32:48 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0131F106566B; Sun, 27 Mar 2011 08:32:48 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E65ED8FC08; Sun, 27 Mar 2011 08:32:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2R8Wlin051255; Sun, 27 Mar 2011 08:32:47 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2R8Wlq7051253; Sun, 27 Mar 2011 08:32:47 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103270832.p2R8Wlq7051253@svn.freebsd.org> From: Adrian Chadd Date: Sun, 27 Mar 2011 08:32:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220051 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 08:32:48 -0000 Author: adrian Date: Sun Mar 27 08:32:47 2011 New Revision: 220051 URL: http://svn.freebsd.org/changeset/base/220051 Log: Add some missing flags needed for AR913x/AR724x USB to correctly operate. The AR913x/AR724x USB lives at a different offset to the AR71xx USB, so this needs to be either adjusted for in a subsequent commit, or updated in hints for kernels compiled for those platforms. Submitted by: Luiz Otavio O Souzau Modified: head/sys/mips/atheros/ar71xx_ehci.c Modified: head/sys/mips/atheros/ar71xx_ehci.c ============================================================================== --- head/sys/mips/atheros/ar71xx_ehci.c Sun Mar 27 05:09:21 2011 (r220050) +++ head/sys/mips/atheros/ar71xx_ehci.c Sun Mar 27 08:32:47 2011 (r220051) @@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #define EHCI_HC_DEVSTR "AR71XX Integrated USB 2.0 controller" @@ -192,6 +193,19 @@ ar71xx_ehci_attach(device_t self) * register following a port enable. */ sc->sc_flags = EHCI_SCFLG_SETMODE; + + switch (ar71xx_soc) { + case AR71XX_SOC_AR7241: + case AR71XX_SOC_AR7242: + case AR71XX_SOC_AR9130: + case AR71XX_SOC_AR9132: + sc->sc_flags |= EHCI_SCFLG_TT | EHCI_SCFLG_NORESTERM; + break; + default: + /* fallthrough */ + break; + } + (void) ehci_reset(sc); err = ehci_init(sc); From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 08:44:28 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 264FA1065673; Sun, 27 Mar 2011 08:44:28 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F122E8FC12; Sun, 27 Mar 2011 08:44:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2R8iRxF051533; Sun, 27 Mar 2011 08:44:27 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2R8iROR051530; Sun, 27 Mar 2011 08:44:27 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103270844.p2R8iROR051530@svn.freebsd.org> From: Adrian Chadd Date: Sun, 27 Mar 2011 08:44:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220052 - in head/sys: conf mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 08:44:28 -0000 Author: adrian Date: Sun Mar 27 08:44:27 2011 New Revision: 220052 URL: http://svn.freebsd.org/changeset/base/220052 Log: Add an option - AR71XX_REALMEM - which overrides the amount of memory detected from Redboot, or overrides the "otherwise" case if no Redboot information was found. Some AR71XX platforms don't use Redboot (eg TP-LINK devices using UBoot; some later Ubiquiti devices which apparently also use UBoot) and at least one plain out lies - the Ubiquiti LS-SR71A Redboot says there's 16mb of RAM when in fact there's 32mb. A more "clean" solution will be needed at a later date. Modified: head/sys/conf/options head/sys/mips/atheros/ar71xx_machdep.c Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Sun Mar 27 08:32:47 2011 (r220051) +++ head/sys/conf/options Sun Mar 27 08:44:27 2011 (r220052) @@ -872,3 +872,9 @@ SDP opt_ofed.h SDP_DEBUG opt_ofed.h IPOIB_DEBUG opt_ofed.h IPOIB_CM opt_ofed.h + +# At least one of the AR71XX ubiquiti boards has a Redboot configuration +# that "lies" about the amount of RAM it has. Until a cleaner method is +# defined, this option will suffice in overriding what Redboot says. +AR71XX_REALMEM opt_global.h + Modified: head/sys/mips/atheros/ar71xx_machdep.c ============================================================================== --- head/sys/mips/atheros/ar71xx_machdep.c Sun Mar 27 08:32:47 2011 (r220051) +++ head/sys/mips/atheros/ar71xx_machdep.c Sun Mar 27 08:44:27 2011 (r220052) @@ -180,6 +180,20 @@ platform_start(__register_t a0 __unused, if (realmem == 0) realmem = btoc(32*1024*1024); + /* + * Allow build-time override in case Redboot lies + * or in other situations (eg where there's u-boot) + * where there isn't (yet) a convienent method of + * being told how much RAM is available. + * + * This happens on at least the Ubiquiti LS-SR71A + * board, where redboot says there's 16mb of RAM + * but in fact there's 32mb. + */ +#if defined(AR71XX_REALMEM) + realmem = btoc(MIPS_REALMEM); +#endif + /* phys_avail regions are in bytes */ phys_avail[0] = MIPS_KSEG0_TO_PHYS(kernel_kseg0_end); phys_avail[1] = ctob(realmem); From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 08:47:55 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B07CC1065670; Sun, 27 Mar 2011 08:47:55 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A16068FC14; Sun, 27 Mar 2011 08:47:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2R8ltcs051637; Sun, 27 Mar 2011 08:47:55 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2R8ltJJ051633; Sun, 27 Mar 2011 08:47:55 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103270847.p2R8ltJJ051633@svn.freebsd.org> From: Adrian Chadd Date: Sun, 27 Mar 2011 08:47:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220053 - in head/sys: conf dev/ath X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 08:47:55 -0000 Author: adrian Date: Sun Mar 27 08:47:55 2011 New Revision: 220053 URL: http://svn.freebsd.org/changeset/base/220053 Log: Rename AH_ENABLE_11N to ATH_ENABLE_11 - the HAL supports 11n by default but the ath driver doesn't. This is a much more consistent name. Modified: head/sys/conf/options head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_athvar.h Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Sun Mar 27 08:44:27 2011 (r220052) +++ head/sys/conf/options Sun Mar 27 08:47:55 2011 (r220053) @@ -768,6 +768,7 @@ ATH_TXBUF opt_ath.h ATH_RXBUF opt_ath.h ATH_DIAGAPI opt_ath.h ATH_TX99_DIAG opt_ath.h +ATH_ENABLE_11N opt_ah.h # options for the Atheros hal AH_SUPPORT_AR5416 opt_ah.h @@ -784,7 +785,6 @@ AH_NEED_DESC_SWAP opt_ah.h AH_USE_INIPDGAIN opt_ah.h AH_MAXCHAN opt_ah.h AH_RXCFG_SDMAMW_4BYTES opt_ah.h -AH_ENABLE_11N opt_ah.h # options for the Broadcom BCM43xx driver (bwi) BWI_DEBUG opt_bwi.h Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Sun Mar 27 08:44:27 2011 (r220052) +++ head/sys/dev/ath/if_ath.c Sun Mar 27 08:47:55 2011 (r220053) @@ -612,7 +612,7 @@ ath_attach(u_int16_t devid, struct ath_s * Don't think of doing that unless you know what you're doing. */ -#ifdef AH_ENABLE_11N +#ifdef ATH_ENABLE_11N /* * Query HT capabilities */ Modified: head/sys/dev/ath/if_athvar.h ============================================================================== --- head/sys/dev/ath/if_athvar.h Sun Mar 27 08:44:27 2011 (r220052) +++ head/sys/dev/ath/if_athvar.h Sun Mar 27 08:47:55 2011 (r220053) @@ -46,7 +46,7 @@ /* * 802.11n requires more TX and RX buffers to do AMPDU. */ -#ifdef AH_ENABLE_11N +#ifdef ATH_ENABLE_11N #define ATH_TXBUF 512 #define ATH_RXBUF 512 #endif From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 10:35:39 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A55D3106566B; Sun, 27 Mar 2011 10:35:39 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 95DB58FC20; Sun, 27 Mar 2011 10:35:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RAZdqI053834; Sun, 27 Mar 2011 10:35:39 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RAZd2l053832; Sun, 27 Mar 2011 10:35:39 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103271035.p2RAZd2l053832@svn.freebsd.org> From: Adrian Chadd Date: Sun, 27 Mar 2011 10:35:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220054 - head/sys/dev/ath X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 10:35:39 -0000 Author: adrian Date: Sun Mar 27 10:35:39 2011 New Revision: 220054 URL: http://svn.freebsd.org/changeset/base/220054 Log: Fix typo. Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Sun Mar 27 08:47:55 2011 (r220053) +++ head/sys/dev/ath/if_ath.c Sun Mar 27 10:35:39 2011 (r220054) @@ -1930,9 +1930,9 @@ ath_calcrxfilter(struct ath_softc *sc) #if 0 /* - * Enable hardware PS-POLL only for hostap mode; + * Enable hardware PS-POLL RX only for hostap mode; * STA mode sends PS-POLL frames but never - * sends them. + * receives them. */ if (ath_hal_getcapability(ah, HAL_CAP_HAS_PSPOLL, 0, NULL) == HAL_OK && From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 12:53:20 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 608AF106566B; Sun, 27 Mar 2011 12:53:20 +0000 (UTC) (envelope-from ume@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 501DB8FC0A; Sun, 27 Mar 2011 12:53:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RCrKhH058678; Sun, 27 Mar 2011 12:53:20 GMT (envelope-from ume@svn.freebsd.org) Received: (from ume@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RCrK6h058676; Sun, 27 Mar 2011 12:53:20 GMT (envelope-from ume@svn.freebsd.org) Message-Id: <201103271253.p2RCrK6h058676@svn.freebsd.org> From: Hajimu UMEMOTO Date: Sun, 27 Mar 2011 12:53:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220055 - head/usr.bin/su X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 12:53:20 -0000 Author: ume Date: Sun Mar 27 12:53:20 2011 New Revision: 220055 URL: http://svn.freebsd.org/changeset/base/220055 Log: getpwnam(3) may return NULL. Requested by: nork Reviewed by: Takeharu KATO , nork MFC after: 1 week Modified: head/usr.bin/su/su.c Modified: head/usr.bin/su/su.c ============================================================================== --- head/usr.bin/su/su.c Sun Mar 27 10:35:39 2011 (r220054) +++ head/usr.bin/su/su.c Sun Mar 27 12:53:20 2011 (r220055) @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) { static char *cleanenv; - struct passwd *pwd; + struct passwd *pwd = NULL; struct pam_conv conv = { openpam_ttyconv, NULL }; enum tristate iscsh; login_cap_t *lc; @@ -255,8 +255,9 @@ main(int argc, char *argv[]) /* get current login name, real uid and shell */ ruid = getuid(); username = getlogin(); - pwd = getpwnam(username); - if (username == NULL || pwd == NULL || pwd->pw_uid != ruid) + if (username != NULL) + pwd = getpwnam(username); + if (pwd == NULL || pwd->pw_uid != ruid) pwd = getpwuid(ruid); if (pwd == NULL) { #ifdef USE_BSM_AUDIT From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 13:55:36 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C7121065670; Sun, 27 Mar 2011 13:55:36 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 312CE8FC08; Sun, 27 Mar 2011 13:55:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RDta0U059960; Sun, 27 Mar 2011 13:55:36 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RDta4Z059958; Sun, 27 Mar 2011 13:55:36 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103271355.p2RDta4Z059958@svn.freebsd.org> From: Adrian Chadd Date: Sun, 27 Mar 2011 13:55:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220056 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 13:55:36 -0000 Author: adrian Date: Sun Mar 27 13:55:35 2011 New Revision: 220056 URL: http://svn.freebsd.org/changeset/base/220056 Log: Refactor out the ar71xx mac address code into something that's just for Redboot. At some point we're going to need to build options for different boot environments - for example, the UBoot setups I've seen simply have the MAC address hard-coded at a fixed location in flash. The OpenWRT support simply yanks the if_arge MAC directly from that in code, rather than trying to find a uboot environment to pull it from. Modified: head/sys/mips/atheros/ar71xx_machdep.c Modified: head/sys/mips/atheros/ar71xx_machdep.c ============================================================================== --- head/sys/mips/atheros/ar71xx_machdep.c Sun Mar 27 12:53:20 2011 (r220055) +++ head/sys/mips/atheros/ar71xx_machdep.c Sun Mar 27 13:55:35 2011 (r220056) @@ -139,13 +139,39 @@ platform_trap_exit(void) } +/* + * Obtain the MAC address via the Redboot environment. + */ +static void +ar71xx_redboot_get_macaddr(void) +{ + char *var; + int count = 0; + + /* + * "ethaddr" is passed via envp on RedBoot platforms + * "kmac" is passed via argv on RouterBOOT platforms + */ + if ((var = getenv("ethaddr")) != NULL || + (var = getenv("kmac")) != NULL) { + count = sscanf(var, "%x%*c%x%*c%x%*c%x%*c%x%*c%x", + &ar711_base_mac[0], &ar711_base_mac[1], + &ar711_base_mac[2], &ar711_base_mac[3], + &ar711_base_mac[4], &ar711_base_mac[5]); + if (count < 6) + memset(ar711_base_mac, 0, + sizeof(ar711_base_mac)); + freeenv(var); + } +} + void platform_start(__register_t a0 __unused, __register_t a1 __unused, __register_t a2 __unused, __register_t a3 __unused) { uint64_t platform_counter_freq; - int argc, i, count = 0; - char **argv, **envp, *var; + int argc, i; + char **argv, **envp; vm_offset_t kernend; /* @@ -252,21 +278,8 @@ platform_start(__register_t a0 __unused, else printf ("envp is invalid\n"); - /* - * "ethaddr" is passed via envp on RedBoot platforms - * "kmac" is passed via argv on RouterBOOT platforms - */ - if ((var = getenv("ethaddr")) != NULL || - (var = getenv("kmac")) != NULL) { - count = sscanf(var, "%x%*c%x%*c%x%*c%x%*c%x%*c%x", - &ar711_base_mac[0], &ar711_base_mac[1], - &ar711_base_mac[2], &ar711_base_mac[3], - &ar711_base_mac[4], &ar711_base_mac[5]); - if (count < 6) - memset(ar711_base_mac, 0, - sizeof(ar711_base_mac)); - freeenv(var); - } + /* Redboot if_arge MAC address is in the environment */ + ar71xx_redboot_get_macaddr(); init_param2(physmem); mips_cpu_init(); From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 14:20:48 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F3EEE106564A; Sun, 27 Mar 2011 14:20:47 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E2DA48FC14; Sun, 27 Mar 2011 14:20:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2REKlNv060577; Sun, 27 Mar 2011 14:20:47 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2REKlV3060575; Sun, 27 Mar 2011 14:20:47 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201103271420.p2REKlV3060575@svn.freebsd.org> From: Josh Paetzel Date: Sun, 27 Mar 2011 14:20:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220057 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 14:20:48 -0000 Author: jpaetzel Date: Sun Mar 27 14:20:47 2011 New Revision: 220057 URL: http://svn.freebsd.org/changeset/base/220057 Log: Increase size of boot partition to give breathing room in the future. Approved by: kib (mentor) Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Sun Mar 27 13:55:35 2011 (r220056) +++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Sun Mar 27 14:20:47 2011 (r220057) @@ -596,7 +596,7 @@ init_gpt_full_disk() echo_log "Running gpart on ${_intDISK}" rc_halt "gpart create -s GPT ${_intDISK}" - rc_halt "gpart add -b 34 -s 64 -t freebsd-boot ${_intDISK}" + rc_halt "gpart add -b 34 -s 128 -t freebsd-boot ${_intDISK}" echo_log "Stamping boot sector on ${_intDISK}" rc_halt "gpart bootcode -b /boot/pmbr ${_intDISK}" From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 16:18:51 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7412C1065670; Sun, 27 Mar 2011 16:18:51 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 61EF28FC18; Sun, 27 Mar 2011 16:18:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RGIpx0062859; Sun, 27 Mar 2011 16:18:51 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RGIpmn062856; Sun, 27 Mar 2011 16:18:51 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201103271618.p2RGIpmn062856@svn.freebsd.org> From: Alan Cox Date: Sun, 27 Mar 2011 16:18:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220058 - in head/sys/amd64: amd64 include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 16:18:51 -0000 Author: alc Date: Sun Mar 27 16:18:51 2011 New Revision: 220058 URL: http://svn.freebsd.org/changeset/base/220058 Log: Amd64 doesn't have a lazypmap ipi. Modified: head/sys/amd64/amd64/mp_machdep.c head/sys/amd64/include/smp.h Modified: head/sys/amd64/amd64/mp_machdep.c ============================================================================== --- head/sys/amd64/amd64/mp_machdep.c Sun Mar 27 14:20:47 2011 (r220057) +++ head/sys/amd64/amd64/mp_machdep.c Sun Mar 27 16:18:51 2011 (r220058) @@ -116,7 +116,6 @@ u_long *ipi_invlrng_counts[MAXCPU]; u_long *ipi_invlpg_counts[MAXCPU]; u_long *ipi_invlcache_counts[MAXCPU]; u_long *ipi_rendezvous_counts[MAXCPU]; -u_long *ipi_lazypmap_counts[MAXCPU]; static u_long *ipi_hardclock_counts[MAXCPU]; #endif @@ -1620,8 +1619,6 @@ mp_ipi_intrcnt(void *dummy) intrcnt_add(buf, &ipi_ast_counts[i]); snprintf(buf, sizeof(buf), "cpu%d:rendezvous", i); intrcnt_add(buf, &ipi_rendezvous_counts[i]); - snprintf(buf, sizeof(buf), "cpu%d:lazypmap", i); - intrcnt_add(buf, &ipi_lazypmap_counts[i]); snprintf(buf, sizeof(buf), "cpu%d:hardclock", i); intrcnt_add(buf, &ipi_hardclock_counts[i]); } Modified: head/sys/amd64/include/smp.h ============================================================================== --- head/sys/amd64/include/smp.h Sun Mar 27 14:20:47 2011 (r220057) +++ head/sys/amd64/include/smp.h Sun Mar 27 16:18:51 2011 (r220058) @@ -41,7 +41,6 @@ extern u_long *ipi_invlrng_counts[MAXCPU extern u_long *ipi_invlpg_counts[MAXCPU]; extern u_long *ipi_invlcache_counts[MAXCPU]; extern u_long *ipi_rendezvous_counts[MAXCPU]; -extern u_long *ipi_lazypmap_counts[MAXCPU]; #endif /* IPI handlers */ From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 16:57:54 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B9067106566C; Sun, 27 Mar 2011 16:57:54 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A57CE8FC14; Sun, 27 Mar 2011 16:57:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RGvsbb063698; Sun, 27 Mar 2011 16:57:54 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RGvs2m063692; Sun, 27 Mar 2011 16:57:54 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201103271657.p2RGvs2m063692@svn.freebsd.org> From: Josh Paetzel Date: Sun, 27 Mar 2011 16:57:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220059 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 16:57:54 -0000 Author: jpaetzel Date: Sun Mar 27 16:57:54 2011 New Revision: 220059 URL: http://svn.freebsd.org/changeset/base/220059 Log: Fix a syntax error in a little-used function. Replace expr with $(()) Replace grep > /dev/null with grep -q Replace "$?" = "0" with $? -eq 0 in tests Consolidate export statements with variable assignment Replace tests for ! -z with -n Approved by: kib (mentor) Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh head/usr.sbin/pc-sysinstall/backend/functions-disk.sh head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh head/usr.sbin/pc-sysinstall/backend/functions-ftp.sh head/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh head/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh head/usr.sbin/pc-sysinstall/backend/functions-localize.sh head/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh head/usr.sbin/pc-sysinstall/backend/functions-networking.sh head/usr.sbin/pc-sysinstall/backend/functions-packages.sh head/usr.sbin/pc-sysinstall/backend/functions-parse.sh head/usr.sbin/pc-sysinstall/backend/functions-runcommands.sh head/usr.sbin/pc-sysinstall/backend/functions-unmount.sh head/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh head/usr.sbin/pc-sysinstall/backend/functions-users.sh head/usr.sbin/pc-sysinstall/backend/functions.sh head/usr.sbin/pc-sysinstall/backend/parseconfig.sh head/usr.sbin/pc-sysinstall/backend/startautoinstall.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Sun Mar 27 16:18:51 2011 (r220058) +++ head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Sun Mar 27 16:57:54 2011 (r220059) @@ -33,14 +33,14 @@ check_for_enc_pass() CURLINE="${1}" get_next_cfg_line "${CFGF}" "${CURLINE}" - echo ${VAL} | grep "^encpass=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo ${VAL} | grep -q "^encpass=" 2>/dev/null + if [ $? -eq 0 ] ; then # Found a password, return it get_value_from_string "${VAL}" return fi - VAL="" ; export VAL + export VAL="" return }; @@ -51,17 +51,17 @@ get_fs_line_xvars() ACTIVEDEV="${1}" LINE="${2}" - echo $LINE | grep ' (' >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo $LINE | grep -q ' (' 2>/dev/null + if [ $? -eq 0 ] ; then # See if we are looking for ZFS specific options - echo $LINE | grep '^ZFS' >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo $LINE | grep -q '^ZFS' 2>/dev/null + if [ $? -eq 0 ] ; then ZTYPE="NONE" ZFSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" - echo $ZFSVARS | grep -E "^(disk|file|mirror|raidz(1|2)?|spare|log|cache):" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2)?|spare|log|cache):" 2>/dev/null + if [ $? -eq 0 ] ; then ZTYPE=`echo $ZFSVARS | cut -f1 -d:` ZFSVARS=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"` fi @@ -79,8 +79,7 @@ get_fs_line_xvars() fi # End of xtra-options block # If we got here, set VAR to empty and export - VAR="" - export VAR + export VAR="" return }; @@ -94,12 +93,12 @@ setup_zfs_mirror_parts() for _zvars in $_mirrline do echo "Looping through _zvars: $_zvars" >>${LOGOUT} - echo "$_zvars" | grep "${2}" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then continue ; fi + echo "$_zvars" | grep -q "${2}" 2>/dev/null + if [ $? -eq 0 ] ; then continue ; fi if [ -z "$_zvars" ] ; then continue ; fi is_disk "$_zvars" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + if [ $? -eq 0 ] ; then echo "Setting up ZFS mirror disk $_zvars" >>${LOGOUT} init_gpt_full_disk "$_zvars" >/dev/null 2>/dev/null rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${_zvars}" >/dev/null 2>/dev/null @@ -138,12 +137,12 @@ gen_glabel_name() while Z=1 do - glabel status | grep "${NAME}${NUM}" >/dev/null 2>/dev/null - if [ "$?" != "0" ] + glabel status | grep -q "${NAME}${NUM}" 2>/dev/null + if [ $? -ne 0 ] then break else - NUM="`expr ${NUM} + 1`" + NUM=$((NUM+1)) fi if [ $NUM -gt $MAXNUM ] @@ -154,8 +153,7 @@ gen_glabel_name() done - VAL="${NAME}${NUM}" - export VAL + export VAL="${NAME}${NUM}" }; # Function to setup partitions using gpart @@ -180,8 +178,8 @@ setup_gpart_partitions() while read line do # Check for data on this slice - echo $line | grep "^${_dTag}-part=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^${_dTag}-part=" 2>/dev/null + if [ $? -eq 0 ] then FOUNDPARTS="0" # Found a slice- entry, lets get the slice info @@ -194,8 +192,8 @@ setup_gpart_partitions() MNT=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 3` # Check if we have a .eli extension on this FS - echo ${FS} | grep ".eli" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo ${FS} | grep -q ".eli" 2>/dev/null + if [ $? -eq 0 ] then FS="`echo ${FS} | cut -d '.' -f 1`" ENC="ON" @@ -210,9 +208,9 @@ setup_gpart_partitions() # Check if the user tried to setup / as an encrypted partition check_for_mount "${MNT}" "/" - if [ "${?}" = "0" -a "${ENC}" = "ON" ] + if [ $? -eq 0 -a "${ENC}" = "ON" ] then - USINGENCROOT="0" ; export USINGENCROOT + export USINGENCROOT="0" fi # Now check that these values are sane @@ -223,13 +221,13 @@ setup_gpart_partitions() # Check that we have a valid size number expr $SIZE + 1 >/dev/null 2>/dev/null - if [ "$?" != "0" ]; then + if [ $? -ne 0 ]; then exit_err "ERROR: The size specified on $line is invalid" fi # Check that the mount-point starts with / - echo "$MNT" | grep -e "^/" -e "^none" >/dev/null 2>/dev/null - if [ "$?" != "0" ]; then + echo "$MNT" | grep -qe "^/" -e "^none" 2>/dev/null + if [ $? -ne 0 ]; then exit_err "ERROR: The mount-point specified on $line is invalid" fi @@ -242,19 +240,19 @@ setup_gpart_partitions() # Check if we found a valid root partition check_for_mount "${MNT}" "/" - if [ "${?}" = "0" ] ; then - FOUNDROOT="1" ; export FOUNDROOT + if [ $? -eq 0 ] ; then + export FOUNDROOT="1" if [ "${CURPART}" = "2" -a "$_pType" = "gpt" ] ; then - FOUNDROOT="0" ; export FOUNDROOT + export FOUNDROOT="0" fi if [ "${CURPART}" = "1" -a "$_pType" = "mbr" ] ; then - FOUNDROOT="0" ; export FOUNDROOT + export FOUNDROOT="0" fi fi check_for_mount "${MNT}" "/boot" - if [ "${?}" = "0" ] ; then - USINGBOOTPART="0" ; export USINGBOOTPART + if [ $? -eq 0 ] ; then + export USINGBOOTPART="0" if [ "${CURPART}" != "2" -a "${_pType}" = "gpt" ] ; then exit_err "/boot partition must be first partition" fi @@ -280,8 +278,8 @@ setup_gpart_partitions() XTRAOPTS="${VAR}" # Check if using zfs mirror - echo ${XTRAOPTS} | grep "mirror" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo ${XTRAOPTS} | grep -q "mirror" 2>/dev/null + if [ $? -eq 0 ] ; then if [ "${_pType}" = "gpt" ] ; then XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}p${CURPART}") else @@ -325,10 +323,10 @@ setup_gpart_partitions() # Clear out any headers sleep 2 - dd if=/dev/zero of=${_pDisk}p${CURPART} count=2048 >/dev/null 2>/dev/null + dd if=/dev/zero of=${_pDisk}p${CURPART} count=2048 2>/dev/null # If we have a enc password, save it as well - if [ ! -z "${ENCPASS}" ] ; then + if [ -n "${ENCPASS}" ] ; then echo "${ENCPASS}" >${PARTDIR}-enc/${_pDisk}p${CURPART}-encpass fi else @@ -336,10 +334,10 @@ setup_gpart_partitions() echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}:${IMAGE}" >${PARTDIR}/${_wSlice}${PARTLETTER} # Clear out any headers sleep 2 - dd if=/dev/zero of=${_wSlice}${PARTLETTER} count=2048 >/dev/null 2>/dev/null + dd if=/dev/zero of=${_wSlice}${PARTLETTER} count=2048 2>/dev/null # If we have a enc password, save it as well - if [ ! -z "${ENCPASS}" ] ; then + if [ -n "${ENCPASS}" ] ; then echo "${ENCPASS}" >${PARTDIR}-enc/${_wSlice}${PARTLETTER}-encpass fi fi @@ -347,11 +345,11 @@ setup_gpart_partitions() # Increment our parts counter if [ "$_pType" = "gpt" ] ; then - CURPART="`expr ${CURPART} + 1`" + CURPART=$((CURPART+1)) # If this is a gpt partition, we can continue and skip the MBR part letter stuff continue else - CURPART="`expr ${CURPART} + 1`" + CURPART=$((CURPART+1)) if [ "$CURPART" = "3" ] ; then CURPART="4" ; fi fi @@ -370,8 +368,8 @@ setup_gpart_partitions() fi # End of subsection locating a slice in config - echo $line | grep "^commitDiskLabel" >/dev/null 2>/dev/null - if [ "$?" = "0" -a "${FOUNDPARTS}" = "0" ] + echo $line | grep -q "^commitDiskLabel" 2>/dev/null + if [ $? -eq 0 -a "${FOUNDPARTS}" = "0" ] then # If this is the boot disk, stamp the right gptboot @@ -455,20 +453,17 @@ setup_disk_label() done # Setup some files which we'll be referring to - LABELLIST="${TMPDIR}/workingLabels" - export LABELLIST + export LABELLIST="${TMPDIR}/workingLabels" rm $LABELLIST >/dev/null 2>/dev/null # Set our flag to determine if we've got a valid root partition in this setup - FOUNDROOT="-1" - export FOUNDROOT + export FOUNDROOT="-1" # Check if we are using a /boot partition - USINGBOOTPART="1" - export USINGBOOTPART + export USINGBOOTPART="1" # Set encryption on root check - USINGENCROOT="1" ; export USINGENCROOT + export USINGENCROOT="1" # Make the tmp directory where we'll store FS info & mount-points rm -rf ${PARTDIR} >/dev/null 2>/dev/null @@ -516,8 +511,8 @@ check_fstab_mbr() then PARTLETTER=`echo "$SLICE" | sed -E 's|^.+([a-h])$|\1|'` - cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/$' >/dev/null 2>&1 - if [ "$?" = "0" ] + cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/$' 2>&1 + if [ $? -eq 0 ] then if [ "${PARTLETTER}" = "a" ] then @@ -532,8 +527,8 @@ check_fstab_mbr() export ROOTIMAGE fi - cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/boot$' >/dev/null 2>&1 - if [ "$?" = "0" ] + cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/boot$' 2>&1 + if [ $? -eq 0 ] then if [ "${PARTLETTER}" = "a" ] then @@ -567,8 +562,8 @@ check_fstab_gpt() then PARTNUMBER=`echo "${SLICE}" | sed -E 's|^.+p([0-9]*)$|\1|'` - cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/$' >/dev/null 2>&1 - if [ "$?" = "0" ] + cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/$' 2>&1 + if [ $? -eq 0 ] then if [ "${PARTNUMBER}" = "2" ] then @@ -583,8 +578,8 @@ check_fstab_gpt() export ROOTIMAGE fi - cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/boot$' >/dev/null 2>&1 - if [ "$?" = "0" ] + cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/boot$' 2>&1 + if [ $? -eq 0 ] then if [ "${PARTNUMBER}" = "2" ] then @@ -645,7 +640,7 @@ check_disk_layout() do F=1 mount ${slice} /mnt 2>/dev/null - if [ "$?" != "0" ] + if [ $? -ne 0 ] then continue fi @@ -661,7 +656,7 @@ check_disk_layout() F="$?" fi - if [ "${F}" = "0" ] + if [ ${F} -eq 0 ] then umount /mnt break Modified: head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh Sun Mar 27 16:18:51 2011 (r220058) +++ head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh Sun Mar 27 16:57:54 2011 (r220059) @@ -46,27 +46,27 @@ zfs_cleanup_unmount() then # Make sure we haven't already added the zfs boot line when # Creating a dedicated "/boot" partition - cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep "vfs.root.mountfrom=" >/dev/null 2>/dev/null - if [ "$?" != "0" ] ; then + cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q "vfs.root.mountfrom=" 2>/dev/null + if [ $? -ne 0 ] ; then echo "vfs.root.mountfrom=\"zfs:${ZPOOLNAME}\"" >> ${FSMNT}/boot/loader.conf fi - FOUNDZFSROOT="${ZPOOLNAME}" ; export FOUNDZFSROOT + export FOUNDZFSROOT="${ZPOOLNAME}" fi done FOUNDZFS="1" fi done - if [ ! -z "${FOUNDZFS}" ] + if [ -n "${FOUNDZFS}" ] then # Check if we need to add our ZFS flags to rc.conf, src.conf and loader.conf - cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep 'zfs_load="YES"' >/dev/null 2>/dev/null - if [ "$?" != "0" ] + cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'zfs_load="YES"' 2>/dev/null + if [ $? -ne 0 ] then echo 'zfs_load="YES"' >>${FSMNT}/boot/loader.conf fi - cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep 'zfs_enable="YES"' >/dev/null 2>/dev/null - if [ "$?" != "0" ] + cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep -q 'zfs_enable="YES"' 2>/dev/null + if [ $? -ne 0 ] then echo 'zfs_enable="YES"' >>${FSMNT}/etc/rc.conf fi @@ -172,7 +172,7 @@ setup_fstab() # Figure out if we are using a glabel, or the raw name for this entry - if [ ! -z "${PARTLABEL}" ] + if [ -n "${PARTLABEL}" ] then DEVICE="label/${PARTLABEL}" else @@ -190,7 +190,7 @@ setup_fstab() # Set our ROOTFSTYPE for loader.conf if necessary check_for_mount "${PARTMNT}" "/" - if [ "$?" = "0" ] ; then + if [ $? -eq 0 ] ; then if [ "${PARTFS}" = "ZFS" ] ; then ROOTFSTYPE="zfs" XPOOLNAME=$(get_zpool_name "${PART}") @@ -263,12 +263,12 @@ setup_gmirror() sleep 3 - NUM="`expr ${NUM} + 1`" + NUM=$((NUM+1)) done - cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep 'geom_mirror_load="YES"' >/dev/null 2>/dev/null - if [ "$?" != "0" ] + cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'geom_mirror_load="YES"' 2>/dev/null + if [ $? -ne 0 ] then echo 'geom_mirror_load="YES"' >>${FSMNT}/boot/loader.conf fi @@ -304,8 +304,8 @@ setup_geli_loading() done # Make sure we have geom_eli set to load at boot - cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep 'geom_eli_load="YES"' >/dev/null 2>/dev/null - if [ "$?" != "0" ] + cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'geom_eli_load="YES"' 2>/dev/null + if [ $? -ne 0 ] then echo 'geom_eli_load="YES"' >>${FSMNT}/boot/loader.conf fi @@ -360,8 +360,8 @@ setup_gjournal() { # Make sure we have geom_journal set to load at boot - cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep 'geom_journal_load="YES"' >/dev/null 2>/dev/null - if [ "$?" != "0" ] + cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'geom_journal_load="YES"' 2>/dev/null + if [ $? -ne 0 ] then echo 'geom_journal_load="YES"' >>${FSMNT}/boot/loader.conf fi @@ -385,14 +385,14 @@ set_root_pw() echo_log "Setting root password" # Check if setting plaintext password - if [ ! -z "${PW}" ] ; then + if [ -n "${PW}" ] ; then echo "${PW}" > ${FSMNT}/.rootpw run_chroot_cmd "cat /.rootpw | pw usermod root -h 0" rc_halt "rm ${FSMNT}/.rootpw" fi # Check if setting encrypted password - if [ ! -z "${ENCPW}" ] ; then + if [ -n "${ENCPW}" ] ; then echo "${ENCPW}" > ${FSMNT}/.rootpw run_chroot_cmd "cat /.rootpw | pw usermod root -H 0" rc_halt "rm ${FSMNT}/.rootpw" @@ -405,7 +405,7 @@ run_final_cleanup() { # Check if we need to run any gmirror setup ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null - if [ "$?" = "0" ] + if [ $? -eq 0 ] then # Lets setup gmirror now setup_gmirror @@ -413,7 +413,7 @@ run_final_cleanup() # Check if we need to save any geli keys ls ${GELIKEYDIR}/* >/dev/null 2>/dev/null - if [ "$?" = "0" ] + if [ $? -eq 0 ] then # Lets setup geli loading setup_geli_loading Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Sun Mar 27 16:18:51 2011 (r220058) +++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Sun Mar 27 16:57:54 2011 (r220059) @@ -32,7 +32,7 @@ is_disk() { for _dsk in `sysctl -n kern.disks` do - if [ "$_dsk" = "${1}" ] ; then return 0 ; fi + [ "$_dsk" = "${1}" ] && return 0 done return 1 @@ -47,8 +47,8 @@ get_partition_sysid_mbr() fdisk ${DISK} >${TMPDIR}/disk-${DISK} 2>/dev/null while read i do - echo "$i" | grep "The data for partition" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo "$i" | grep -q "The data for partition" 2>/dev/null + if [ $? -eq 0 ] ; then INPART="0" PART="`echo ${i} | cut -d ' ' -f 5`" if [ "$PART" = "$PARTNUM" ] ; then @@ -58,8 +58,8 @@ get_partition_sysid_mbr() # In the partition section if [ "$INPART" = "1" ] ; then - echo "$i" | grep "^sysid" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo "$i" | grep -q "^sysid" 2>/dev/null + if [ $? -eq 0 ] ; then SYSID="`echo ${i} | tr -s '\t' ' ' | cut -d ' ' -f 2`" break fi @@ -69,8 +69,7 @@ get_partition_sysid_mbr() done < ${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} - VAL="${SYSID}" - export VAL + export VAL="${SYSID}" }; # Get the partitions MBR label @@ -82,8 +81,8 @@ get_partition_label_mbr() fdisk ${DISK} >${TMPDIR}/disk-${DISK} 2>/dev/null while read i do - echo "$i" | grep "The data for partition" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo "$i" | grep -q "The data for partition" 2>/dev/null + if [ $? -eq 0 ] ; then INPART="0" PART="`echo ${i} | cut -d ' ' -f 5`" if [ "$PART" = "$PARTNUM" ] ; then @@ -93,8 +92,8 @@ get_partition_label_mbr() # In the partition section if [ "$INPART" = "1" ] ; then - echo "$i" | grep "^sysid" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo "$i" | grep -q "^sysid" 2>/dev/null + if [ $? -eq 0 ] ; then LABEL="`echo ${i} | tr -s '\t' ' ' | cut -d ',' -f 2-10`" break fi @@ -104,8 +103,7 @@ get_partition_label_mbr() done < ${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} - VAL="${LABEL}" - export VAL + export VAL="${LABEL}" }; # Get a GPT partitions label @@ -125,8 +123,7 @@ get_partition_label_gpt() done <${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} - VAL="${LABEL}" - export VAL + export VAL="${LABEL}" }; # Get a partitions startblock @@ -146,8 +143,7 @@ get_partition_startblock() done <${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} - VAL="${SB}" - export VAL + export VAL="${SB}" }; # Get a partitions blocksize @@ -167,16 +163,15 @@ get_partition_blocksize() done <${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} - VAL="${BS}" - export VAL + export VAL="${BS}" }; # Function which returns the partitions on a target disk get_disk_partitions() { gpart show ${1} >/dev/null 2>/dev/null - if [ "$?" != "0" ] ; then - VAL="" ; export VAL + if [ $? -ne 0 ] ; then + export VAL="" return fi @@ -198,35 +193,35 @@ get_disk_partitions() fi done - VAL="${RSLICES}" ; export VAL + export VAL="${RSLICES}" }; # Function which returns a target disks cylinders get_disk_cyl() { cyl=`diskinfo -v ${1} | grep "# Cylinders" | tr -s ' ' | cut -f 2` - VAL="${cyl}" ; export VAL + export VAL="${cyl}" }; # Function which returns a target disks sectors get_disk_sectors() { sec=`diskinfo -v ${1} | grep "# Sectors" | tr -s ' ' | cut -f 2` - VAL="${sec}" ; export VAL + export VAL="${sec}" }; # Function which returns a target disks heads get_disk_heads() { head=`diskinfo -v ${1} | grep "# Heads" | tr -s ' ' | cut -f 2` - VAL="${head}" ; export VAL + export VAL="${head}" }; # Function which returns a target disks mediasize in sectors get_disk_mediasize() { mediasize=`diskinfo -v ${1} | grep "# mediasize in sectors" | tr -s ' ' | cut -f 2` - VAL="${mediasize}" ; export VAL + export VAL="${mediasize}" }; # Function which exports all zpools, making them safe to overwrite potentially @@ -288,8 +283,8 @@ stop_all_gmirror() GPROV="`gmirror list | grep ". Name: mirror/" | cut -d '/' -f 2`" for gprov in $GPROV do - gmirror list | grep "Name: ${DISK}" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + gmirror list | grep -q "Name: ${DISK}" 2>/dev/null + if [ $? -eq 0 ] then echo_log "Stopping mirror $gprov $DISK" rc_nohalt "gmirror remove $gprov $DISK" @@ -306,8 +301,8 @@ stop_all_geli() for i in `ls ${_geld}*` do - echo $i | grep '.eli' >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $i | grep -q '.eli' 2>/dev/null + if [ $? -eq 0 ] then echo_log "Detaching GELI on ${i}" rc_halt "geli detach ${i}" @@ -335,8 +330,8 @@ setup_disk_slice() # We are ready to start setting up the disks, lets read the config and do the actions while read line do - echo $line | grep "^disk${disknum}=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^disk${disknum}=" 2>/dev/null + if [ $? -eq 0 ] then # Found a disk= entry, lets get the disk we are working on @@ -362,8 +357,8 @@ setup_disk_slice() fi # Lets look if this device will be mirrored on another disk - echo $line | grep "^mirror=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^mirror=" 2>/dev/null + if [ $? -eq 0 ] then # Found a disk= entry, lets get the disk we are working on @@ -379,8 +374,8 @@ setup_disk_slice() fi # Lets see if we have been given a mirror balance choice - echo $line | grep "^mirrorbal=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^mirrorbal=" 2>/dev/null + if [ $? -eq 0 ] then # Found a disk= entry, lets get the disk we are working on @@ -389,8 +384,8 @@ setup_disk_slice() MIRRORBAL="$VAL" fi - echo $line | grep "^partition=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^partition=" 2>/dev/null + if [ $? -eq 0 ] then # Found a partition= entry, lets read / set it get_value_from_string "${line}" @@ -413,7 +408,7 @@ setup_disk_slice() then LASTSLICE="1" else - LASTSLICE="`expr $LASTSLICE + 1`" + LASTSLICE=$((LASTSLICE+1)) fi if [ $LASTSLICE -gt 4 ] @@ -425,8 +420,8 @@ setup_disk_slice() fi # Check if we have an image file defined - echo $line | grep "^image=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo $line | grep -q "^image=" 2>/dev/null + if [ $? eq 0 ] ; then # Found an image= entry, lets read / set it get_value_from_string "${line}" strip_white_space "$VAL" @@ -437,8 +432,8 @@ setup_disk_slice() fi # Check if we have a partscheme specified - echo $line | grep "^partscheme=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo $line | grep -q "^partscheme=" 2>/dev/null + if [ $? -eq 0 ] ; then # Found a partscheme= entry, lets read / set it get_value_from_string "${line}" strip_white_space "$VAL" @@ -448,8 +443,8 @@ setup_disk_slice() fi fi - echo $line | grep "^bootManager=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^bootManager=" 2>/dev/null + if [ $? -eq 0 ] then # Found a bootManager= entry, lets read /set it get_value_from_string "${line}" @@ -457,8 +452,8 @@ setup_disk_slice() BMANAGER="$VAL" fi - echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^commitDiskPart" 2>/dev/null + if [ $? -eq 0 ] then # Found our flag to commit this disk setup / lets do sanity check and do it if [ ! -z "${DISK}" -a ! -z "${PTYPE}" ] @@ -520,7 +515,7 @@ setup_disk_slice() fi # Save any mirror config - if [ ! -z "$MIRRORDISK" ] + if [ -n "$MIRRORDISK" ] then # Default to round-robin if the user didn't specify if [ -z "$MIRRORBAL" ] @@ -532,7 +527,7 @@ setup_disk_slice() # Increment our disk counter to look for next disk and unset unset BMANAGER PTYPE DISK MIRRORDISK MIRRORBAL PSCHEME IMAGE - disknum="`expr $disknum + 1`" + disknum=$((disknum+1)) else exit_err "ERROR: commitDiskPart was called without procceding disk= and partition= entries!!!" fi @@ -548,7 +543,7 @@ stop_gjournal() _gdsk="$1" # Check if we need to shutdown any journals on this drive ls /dev/${_gdsk}*.journal >/dev/null 2>/dev/null - if [ "$?" = "0" ] + if [ $? -eq 0 ] then cd /dev for i in `ls ${_gdsk}*.journal` @@ -569,7 +564,7 @@ clear_backup_gpt_table() # Make sure this is a valid number is_num "${dSize}" >/dev/null 2>/dev/null - if [ "$?" != "0" ] ; then return ; fi + [ $? -ne 0 ] && return # Die backup label, DIE echo_log "Clearing gpt backup table location on disk" @@ -697,7 +692,7 @@ run_gpart_full() run_gpart_slice() { DISK=$1 - if [ ! -z "$2" ] + if [ -n "$2" ] then BMANAGER="$2" fi @@ -757,7 +752,7 @@ run_gpart_free() { DISK=$1 SLICENUM=$2 - if [ ! -z "$3" ] + if [ -n "$3" ] then BMANAGER="$3" fi @@ -770,7 +765,7 @@ run_gpart_free() # Working on the first slice, make sure we have MBR setup gpart show ${DISK} >/dev/null 2>/dev/null - if [ "$?" != "0" -a "$SLICENUM" = "1" ] ; then + if [ $? -ne 0 -a "$SLICENUM" = "1" ] ; then echo_log "Initializing disk, no existing MBR setup" rc_halt "gpart create -s mbr ${DISK}" fi @@ -781,12 +776,12 @@ run_gpart_free() startblock="63" else # Lets figure out where the prior slice ends - checkslice="`expr ${slicenum} - 1`" + checkslice=$((slicenum-1)) # Get starting block of this slice sblk=`gpart show ${DISK} | grep -v ${DISK} | tr -s '\t' ' ' | sed '/^$/d' | grep " ${checkslice} " | cut -d ' ' -f 2` blksize=`gpart show ${DISK} | grep -v ${DISK} | tr -s '\t' ' ' | sed '/^$/d' | grep " ${checkslice} " | cut -d ' ' -f 3` - startblock="`expr ${sblk} + ${blksize}`" + startblock=$((sblk+blksiz)) fi # No slice after the new slice, lets figure out the free space remaining and use it @@ -803,12 +798,12 @@ run_gpart_free() sec="${VAL}" # Multiply them all together to get our total blocks - totalblocks="`expr ${cyl} \* ${head}`" - totalblocks="`expr ${totalblocks} \* ${sec}`" + totalblocks=$((cyl*head)) + totalblocks=$((totalblocks*sec)) # Now set the ending block to the total disk block size - sizeblock="`expr ${totalblocks} - ${startblock}`" + sizeblock=$((totalblocks-startblock)) # Install new partition setup echo_log "Running gpart on ${DISK}" Modified: head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh Sun Mar 27 16:18:51 2011 (r220058) +++ head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh Sun Mar 27 16:57:54 2011 (r220059) @@ -59,7 +59,7 @@ start_extract_uzip_tar() MDDEVICE=`mdconfig -a -t vnode -o readonly -f ${INSFILE}` mkdir -p ${FSMNT}.uzip mount -r /dev/${MDDEVICE}.uzip ${FSMNT}.uzip - if [ "$?" != "0" ] + if [ $? -ne 0 ] then exit_err "ERROR: Failed mounting the ${INSFILE}" fi @@ -67,7 +67,7 @@ start_extract_uzip_tar() # Copy over all the files now! tar cvf - . 2>/dev/null | tar -xpv -C ${FSMNT} ${TAROPTS} -f - 2>&1 | tee -a ${FSMNT}/.tar-extract.log - if [ "$?" != "0" ] + if [ $? -ne 0 ] then cd / echo "TAR failure occurred:" >>${LOGOUT} @@ -84,7 +84,7 @@ start_extract_uzip_tar() ;; tar) tar -xpv -C ${FSMNT} -f ${INSFILE} ${TAROPTS} >&1 2>&1 - if [ "$?" != "0" ] + if [ $? -ne 0 ] then exit_err "ERROR: Failed extracting the tar image" fi @@ -127,7 +127,7 @@ start_extract_split() then echo_log "Extracting" `basename ${dir}` echo "y" | sh install.sh >/dev/null - if [ "$?" != "0" ] + if [ $? -ne 0 ] then exit_err "ERROR: Failed extracting ${dir}" fi @@ -143,7 +143,7 @@ start_extract_split() then echo_log "Extracting" `basename ${KERNELS}` echo "y" | sh install.sh generic >/dev/null - if [ "$?" != "0" ] + if [ $? -ne 0 ] then exit_err "ERROR: Failed extracting ${KERNELS}" fi @@ -160,7 +160,7 @@ start_extract_split() then echo_log "Extracting" `basename ${SOURCE}` echo "y" | sh install.sh all >/dev/null - if [ "$?" != "0" ] + if [ $? -ne 0 ] then exit_err "ERROR: Failed extracting ${SOURCE}" fi @@ -202,7 +202,7 @@ fetch_install_file() fetch_file "${FTPPATH}/${INSFILE}.md5" "${OUTFILE}.md5" "0" # Done fetching, now reset the INSFILE to our downloaded archived - INSFILE="${OUTFILE}" ; export INSFILE + export INSFILE="${OUTFILE}" }; @@ -244,7 +244,7 @@ fetch_split_files() NETRC="${OUTFILE}/.netrc" - cat<"${NETRC}" + cat <"${NETRC}" machine ${FTPHOST} login anonymous password anonymous @@ -255,14 +255,14 @@ EOF for d in ${DIRS} do - cat<>"${NETRC}" + cat <>"${NETRC}" cd ${FTPDIR}/${d} lcd ${OUTFILE}/${d} mreget * EOF done - cat<>"${NETRC}" + cat <>"${NETRC}" bye @@ -272,7 +272,7 @@ EOF echo "$ INSTALL" | ftp -N "${NETRC}" "${FTPHOST}" # Done fetching, now reset the INSFILE to our downloaded archived - INSFILE="${OUTFILE}" ; export INSFILE + export INSFILE="${OUTFILE}" } # Function which does the rsync download from the server specified in cfg @@ -283,27 +283,27 @@ start_rsync_copy() if [ -z "${VAL}" ]; then exit_err "ERROR: rsyncPath is unset! Please check your config and try again." fi - RSYNCPATH="${VAL}" ; export RSYNCPATH + export RSYNCPATH="${VAL}" get_value_from_cfg rsyncHost if [ -z "${VAL}" ]; then exit_err "ERROR: rsyncHost is unset! Please check your config and try again." fi - RSYNCHOST="${VAL}" ; export RSYNCHOST + export RSYNCHOST="${VAL}" get_value_from_cfg rsyncUser if [ -z "${VAL}" ]; then exit_err "ERROR: rsyncUser is unset! Please check your config and try again." fi - RSYNCUSER="${VAL}" ; export RSYNCUSER + export RSYNCUSER="${VAL}" get_value_from_cfg rsyncPort if [ -z "${VAL}" ]; then exit_err "ERROR: rsyncPort is unset! Please check your config and try again." fi - RSYNCPORT="${VAL}" ; export RSYNCPORT + export RSYNCPORT="${VAL}" - COUNT="1" + COUNT=1 while z=1 do @@ -317,14 +317,14 @@ start_rsync_copy() --rsync-path="rsync --fake-super" \ -e "ssh -p ${RSYNCPORT}" \ ${RSYNCUSER}@${RSYNCHOST}:${RSYNCPATH}/./ ${FSMNT} - if [ "$?" != "0" ] + if [ $? -ne 0 ] then echo "Rsync failed! Tries: ${COUNT}" else break fi - COUNT="`expr ${COUNT} + 1`" + COUNT=$((COUNT+1)) done }; @@ -339,8 +339,8 @@ start_image_install() # We are ready to start mounting, lets read the config and do it while read line do - echo $line | grep "^disk0=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^disk0=" 2>/dev/null + if [ $? -eq 0 ] then # Found a disk= entry, lets get the disk we are working on get_value_from_string "${line}" @@ -348,11 +348,11 @@ start_image_install() DISK="$VAL" fi - echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^commitDiskPart" 2>/dev/null + if [ $? -eq 0 ] then # Found our flag to commit this disk setup / lets do sanity check and do it - if [ ! -z "${DISK}" ] + if [ -n "${DISK}" ] then # Write the image @@ -376,9 +376,9 @@ init_extraction() # Figure out what file we are using to install from via the config get_value_from_cfg installFile *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 17:22:31 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id DB08D106564A; Sun, 27 Mar 2011 17:22:31 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from 65-241-43-5.globalsuite.net (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id 8A44D15542F; Sun, 27 Mar 2011 17:22:31 +0000 (UTC) Message-ID: <4D8F7257.50207@FreeBSD.org> Date: Sun, 27 Mar 2011 10:22:31 -0700 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.2.15) Gecko/20110326 Thunderbird/3.1.9 MIME-Version: 1.0 To: Josh Paetzel References: <201103271657.p2RGvs2m063692@svn.freebsd.org> In-Reply-To: <201103271657.p2RGvs2m063692@svn.freebsd.org> X-Enigmail-Version: 1.1.2 OpenPGP: id=1A1ABC84 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, kib@FreeBSD.org Subject: Re: svn commit: r220059 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 17:22:32 -0000 On 03/27/2011 09:57, Josh Paetzel wrote: > Log: > Fix a syntax error in a little-used function. Since this is unique vs. all the other changes, IMO it should have been a separate commit. It doesn't hurt anything to split things up into multiple commits, and often helps make things more understandable down the road. > Replace expr with $(()) > Replace tests for ! -z with -n Good. :) > Replace grep> /dev/null with grep -q > Consolidate export statements with variable assignment These 2 make the code slightly less portable, but in this case I don't think that's a problem at all. > Replace "$?" = "0" with $? -eq 0 in tests Excellent! hth, Doug -- Nothin' ever doesn't change, but nothin' changes much. -- OK Go Breadth of IT experience, and depth of knowledge in the DNS. Yours for the right price. :) http://SupersetSolutions.com/ From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 19:56:55 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B481106566B; Sun, 27 Mar 2011 19:56:55 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6FD758FC18; Sun, 27 Mar 2011 19:56:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RJutoR067493; Sun, 27 Mar 2011 19:56:55 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RJutha067490; Sun, 27 Mar 2011 19:56:55 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103271956.p2RJutha067490@svn.freebsd.org> From: Mikolaj Golub Date: Sun, 27 Mar 2011 19:56:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220062 - head/sys/geom/gate X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 19:56:55 -0000 Author: trociny Date: Sun Mar 27 19:56:55 2011 New Revision: 220062 URL: http://svn.freebsd.org/changeset/base/220062 Log: In g_gate_create() there is a window between when g_gate_softc is registered in g_gate_units array and when its sc_provider field is filled. If during this period g_gate_units is accessed by another thread that is checking for provider name collision the crash is possible. Fix this by adding sc_name field to struct g_gate_softc. In g_gate_create() when g_gate_softc is created but sc_provider is still not sc_name points to provider name stored in the local array. Approved by: pjd (mentor) Reported by: Freddie Cash MFC after: 1 week Modified: head/sys/geom/gate/g_gate.c head/sys/geom/gate/g_gate.h Modified: head/sys/geom/gate/g_gate.c ============================================================================== --- head/sys/geom/gate/g_gate.c Sun Mar 27 19:29:18 2011 (r220061) +++ head/sys/geom/gate/g_gate.c Sun Mar 27 19:56:55 2011 (r220062) @@ -409,13 +409,14 @@ g_gate_create(struct g_gate_ctl_create * for (unit = 0; unit < g_gate_maxunits; unit++) { if (g_gate_units[unit] == NULL) continue; - if (strcmp(name, g_gate_units[unit]->sc_provider->name) != 0) + if (strcmp(name, g_gate_units[unit]->sc_name) != 0) continue; mtx_unlock(&g_gate_units_lock); mtx_destroy(&sc->sc_queue_mtx); free(sc, M_GATE); return (EEXIST); } + sc->sc_name = name; g_gate_units[sc->sc_unit] = sc; g_gate_nunits++; mtx_unlock(&g_gate_units_lock); @@ -434,6 +435,9 @@ g_gate_create(struct g_gate_ctl_create * sc->sc_provider = pp; g_error_provider(pp, 0); g_topology_unlock(); + mtx_lock(&g_gate_units_lock); + sc->sc_name = sc->sc_provider->name; + mtx_unlock(&g_gate_units_lock); if (sc->sc_timeout > 0) { callout_reset(&sc->sc_callout, sc->sc_timeout * hz, Modified: head/sys/geom/gate/g_gate.h ============================================================================== --- head/sys/geom/gate/g_gate.h Sun Mar 27 19:29:18 2011 (r220061) +++ head/sys/geom/gate/g_gate.h Sun Mar 27 19:56:55 2011 (r220062) @@ -76,6 +76,7 @@ * 'P:' means 'Protected by'. */ struct g_gate_softc { + char *sc_name; /* P: (read-only) */ int sc_unit; /* P: (read-only) */ int sc_ref; /* P: g_gate_list_mtx */ struct g_provider *sc_provider; /* P: (read-only) */ @@ -96,7 +97,6 @@ struct g_gate_softc { LIST_ENTRY(g_gate_softc) sc_next; /* P: g_gate_list_mtx */ char sc_info[G_GATE_INFOSIZE]; /* P: (read-only) */ }; -#define sc_name sc_provider->geom->name #define G_GATE_DEBUG(lvl, ...) do { \ if (g_gate_debug >= (lvl)) { \ From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 20:08:09 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0CA86106564A; Sun, 27 Mar 2011 20:08:09 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 93CB28FC16; Sun, 27 Mar 2011 20:08:08 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p2RK848E027769 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 27 Mar 2011 23:08:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p2RK84Yp068527; Sun, 27 Mar 2011 23:08:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p2RK84cO068526; Sun, 27 Mar 2011 23:08:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 27 Mar 2011 23:08:04 +0300 From: Kostik Belousov To: Mikolaj Golub Message-ID: <20110327200804.GM78089@deviant.kiev.zoral.com.ua> References: <201103271956.p2RJutha067490@svn.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Jps4F43PgwelbvkV" Content-Disposition: inline In-Reply-To: <201103271956.p2RJutha067490@svn.freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220062 - head/sys/geom/gate X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 20:08:09 -0000 --Jps4F43PgwelbvkV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Mar 27, 2011 at 07:56:55PM +0000, Mikolaj Golub wrote: > Author: trociny > Date: Sun Mar 27 19:56:55 2011 > New Revision: 220062 > URL: http://svn.freebsd.org/changeset/base/220062 >=20 > Log: > In g_gate_create() there is a window between when g_gate_softc is > registered in g_gate_units array and when its sc_provider field is > filled. If during this period g_gate_units is accessed by another > thread that is checking for provider name collision the crash is > possible. > =20 > Fix this by adding sc_name field to struct g_gate_softc. In > g_gate_create() when g_gate_softc is created but sc_provider is still > not sc_name points to provider name stored in the local array. > =20 > Approved by: pjd (mentor) > Reported by: Freddie Cash > MFC after: 1 week >=20 > Modified: > head/sys/geom/gate/g_gate.c > head/sys/geom/gate/g_gate.h >=20 > Modified: head/sys/geom/gate/g_gate.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/geom/gate/g_gate.c Sun Mar 27 19:29:18 2011 (r220061) > +++ head/sys/geom/gate/g_gate.c Sun Mar 27 19:56:55 2011 (r220062) > @@ -409,13 +409,14 @@ g_gate_create(struct g_gate_ctl_create * > for (unit =3D 0; unit < g_gate_maxunits; unit++) { > if (g_gate_units[unit] =3D=3D NULL) > continue; > - if (strcmp(name, g_gate_units[unit]->sc_provider->name) !=3D 0) > + if (strcmp(name, g_gate_units[unit]->sc_name) !=3D 0) > continue; > mtx_unlock(&g_gate_units_lock); > mtx_destroy(&sc->sc_queue_mtx); > free(sc, M_GATE); > return (EEXIST); > } > + sc->sc_name =3D name; > g_gate_units[sc->sc_unit] =3D sc; > g_gate_nunits++; > mtx_unlock(&g_gate_units_lock); > @@ -434,6 +435,9 @@ g_gate_create(struct g_gate_ctl_create * > sc->sc_provider =3D pp; > g_error_provider(pp, 0); > g_topology_unlock(); > + mtx_lock(&g_gate_units_lock); > + sc->sc_name =3D sc->sc_provider->name; > + mtx_unlock(&g_gate_units_lock); I think you do not need a mutex locked around the single assignment. As I understand, sc_provider->name is constant ? --Jps4F43PgwelbvkV Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk2PmSMACgkQC3+MBN1Mb4h/QgCgj0A2+WWl8o01tgozAZqHh7Rn wnIAn0FB2V8Netfa/TelAUxmZ7UhjBHl =K3f0 -----END PGP SIGNATURE----- --Jps4F43PgwelbvkV-- From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 20:35:33 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 009A01065677; Sun, 27 Mar 2011 20:35:33 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E35F78FC08; Sun, 27 Mar 2011 20:35:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RKZWK6068379; Sun, 27 Mar 2011 20:35:32 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RKZWBt068377; Sun, 27 Mar 2011 20:35:32 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201103272035.p2RKZWBt068377@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Sun, 27 Mar 2011 20:35:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220063 - stable/8/sbin/geom/class/part X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 20:35:33 -0000 Author: ae Date: Sun Mar 27 20:35:32 2011 New Revision: 220063 URL: http://svn.freebsd.org/changeset/base/220063 Log: MFC r219573: Document GEOM_PART_EBR_COMPAT option. MFC r219581: Fix grammar. Pointed out: Ben Kaduk Modified: stable/8/sbin/geom/class/part/gpart.8 Directory Properties: stable/8/sbin/geom/class/part/ (props changed) Modified: stable/8/sbin/geom/class/part/gpart.8 ============================================================================== --- stable/8/sbin/geom/class/part/gpart.8 Sun Mar 27 19:56:55 2011 (r220062) +++ stable/8/sbin/geom/class/part/gpart.8 Sun Mar 27 20:35:32 2011 (r220063) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 9, 2011 +.Dd March 12, 2011 .Dt GPART 8 .Os .Sh NAME @@ -38,6 +38,7 @@ lines in your kernel configuration file: .Cd "options GEOM_PART_APM" .Cd "options GEOM_PART_BSD" .Cd "options GEOM_PART_EBR" +.Cd "options GEOM_PART_EBR_COMPAT" .Cd "options GEOM_PART_GPT" .Cd "options GEOM_PART_MBR" .Cd "options GEOM_PART_PC98" @@ -58,6 +59,11 @@ The option adds support for the Extended Boot Record (EBR), which is used to define a logical partition. The +.Dv GEOM_PART_EBR_COMPAT +option enables backward compatibility for partition names +in the EBR scheme. Also it makes impossible any types of actions +with such partitions. +The .Dv GEOM_PART_GPT option adds support for the GUID Partition Table (GPT) found on Intel Itanium computers and Intel-based Macintosh computers. From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 20:49:19 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5EE22106564A; Sun, 27 Mar 2011 20:49:19 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 9469F8FC14; Sun, 27 Mar 2011 20:49:18 +0000 (UTC) Received: by fxm11 with SMTP id 11so2838697fxm.13 for ; Sun, 27 Mar 2011 13:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:x-comment-to :sender:date:in-reply-to:message-id:user-agent:mime-version :content-type; bh=pHscf/kDwVDlYGckvhSnWOv1Isiy/Z4OCfODqVt4ioA=; b=BH8kZXhKDU8WFGGPYOpVU7vRcfYZLAA0sagicNwJOcEiymsZwFrYBdxTzYofUBbdvK fijyxNUnWngYSW0Xp3iRL92fRJ5Zpnvl2VlIphtF5enlveKqnEfxmJRx8M2ooTvb0JEL xBc2E3O0LEYkxsClWN55x1LL21A6UxEXQbEHw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:x-comment-to:sender:date:in-reply-to :message-id:user-agent:mime-version:content-type; b=UtMpXoWHhTuU3iHPeo99lrORDA6/CpmYDGuAsl+airV+kM8PO7NH960v/96UnQK/Wh FRLVNvlM5qB8eZwlRNQtwOqtEVwMOcC+lebcI2cAjpzB0X3wIsrvAbRY4LJCRlOxfvQ9 NBGEQsN1BvVXSsMI/nkLSQocDSSKYAOnTT6mQ= Received: by 10.223.29.4 with SMTP id o4mr3602524fac.27.1301258957502; Sun, 27 Mar 2011 13:49:17 -0700 (PDT) Received: from localhost ([95.69.172.154]) by mx.google.com with ESMTPS id e23sm1208644faa.18.2011.03.27.13.49.16 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 27 Mar 2011 13:49:16 -0700 (PDT) From: Mikolaj Golub To: Kostik Belousov References: <201103271956.p2RJutha067490@svn.freebsd.org> <20110327200804.GM78089@deviant.kiev.zoral.com.ua> X-Comment-To: Kostik Belousov Sender: Mikolaj Golub Date: Sun, 27 Mar 2011 23:49:15 +0300 In-Reply-To: <20110327200804.GM78089@deviant.kiev.zoral.com.ua> (Kostik Belousov's message of "Sun, 27 Mar 2011 23:08:04 +0300") Message-ID: <86fwq8e1bo.fsf@kopusha.home.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220062 - head/sys/geom/gate X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 20:49:19 -0000 On Sun, 27 Mar 2011 23:08:04 +0300 Kostik Belousov wrote: KB> On Sun, Mar 27, 2011 at 07:56:55PM +0000, Mikolaj Golub wrote: >> Author: trociny >> Date: Sun Mar 27 19:56:55 2011 >> New Revision: 220062 >> URL: http://svn.freebsd.org/changeset/base/220062 >> >> Log: >> In g_gate_create() there is a window between when g_gate_softc is >> registered in g_gate_units array and when its sc_provider field is >> filled. If during this period g_gate_units is accessed by another >> thread that is checking for provider name collision the crash is >> possible. >> >> Fix this by adding sc_name field to struct g_gate_softc. In >> g_gate_create() when g_gate_softc is created but sc_provider is still >> not sc_name points to provider name stored in the local array. >> >> Approved by: pjd (mentor) >> Reported by: Freddie Cash >> MFC after: 1 week >> >> Modified: >> head/sys/geom/gate/g_gate.c >> head/sys/geom/gate/g_gate.h >> >> Modified: head/sys/geom/gate/g_gate.c >> ============================================================================== >> --- head/sys/geom/gate/g_gate.c Sun Mar 27 19:29:18 2011 (r220061) >> +++ head/sys/geom/gate/g_gate.c Sun Mar 27 19:56:55 2011 (r220062) >> @@ -409,13 +409,14 @@ g_gate_create(struct g_gate_ctl_create * >> for (unit = 0; unit < g_gate_maxunits; unit++) { >> if (g_gate_units[unit] == NULL) >> continue; >> - if (strcmp(name, g_gate_units[unit]->sc_provider->name) != 0) >> + if (strcmp(name, g_gate_units[unit]->sc_name) != 0) >> continue; >> mtx_unlock(&g_gate_units_lock); >> mtx_destroy(&sc->sc_queue_mtx); >> free(sc, M_GATE); >> return (EEXIST); >> } >> + sc->sc_name = name; >> g_gate_units[sc->sc_unit] = sc; >> g_gate_nunits++; >> mtx_unlock(&g_gate_units_lock); >> @@ -434,6 +435,9 @@ g_gate_create(struct g_gate_ctl_create * >> sc->sc_provider = pp; >> g_error_provider(pp, 0); >> g_topology_unlock(); >> + mtx_lock(&g_gate_units_lock); >> + sc->sc_name = sc->sc_provider->name; >> + mtx_unlock(&g_gate_units_lock); KB> I think you do not need a mutex locked around the single assignment. KB> As I understand, sc_provider->name is constant ? Is the following scenario impossible? Thread A is looking for name collision and is accessing g_gate_units[unit]->sc_name of the unit that is being created by a thread B, so sc_name is pointing to thread B local buffer. At this time the thread B creates provider, does sc->sc_name = sc->sc_provider->name and returns from g_gate_create(). Thread A, if it is still working with g_gate_units[unit]->sc_name, is accessing invalid memory. -- Mikolaj Golub From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 21:06:42 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 924D7106566B; Sun, 27 Mar 2011 21:06:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 2ECDB8FC13; Sun, 27 Mar 2011 21:06:41 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p2RL6c53031406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Mar 2011 00:06:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p2RL6ccY068865; Mon, 28 Mar 2011 00:06:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p2RL6c9H068864; Mon, 28 Mar 2011 00:06:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 28 Mar 2011 00:06:38 +0300 From: Kostik Belousov To: Mikolaj Golub Message-ID: <20110327210638.GO78089@deviant.kiev.zoral.com.ua> References: <201103271956.p2RJutha067490@svn.freebsd.org> <20110327200804.GM78089@deviant.kiev.zoral.com.ua> <86fwq8e1bo.fsf@kopusha.home.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bF/koNWjw4RKgJoH" Content-Disposition: inline In-Reply-To: <86fwq8e1bo.fsf@kopusha.home.net> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220062 - head/sys/geom/gate X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 21:06:42 -0000 --bF/koNWjw4RKgJoH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Mar 27, 2011 at 11:49:15PM +0300, Mikolaj Golub wrote: >=20 > On Sun, 27 Mar 2011 23:08:04 +0300 Kostik Belousov wrote: >=20 > KB> On Sun, Mar 27, 2011 at 07:56:55PM +0000, Mikolaj Golub wrote: > >> Author: trociny > >> Date: Sun Mar 27 19:56:55 2011 > >> New Revision: 220062 > >> URL: http://svn.freebsd.org/changeset/base/220062 > >>=20 > >> Log: > >> In g_gate_create() there is a window between when g_gate_softc is > >> registered in g_gate_units array and when its sc_provider field is > >> filled. If during this period g_gate_units is accessed by another > >> thread that is checking for provider name collision the crash is > >> possible. > >> =20 > >> Fix this by adding sc_name field to struct g_gate_softc. In > >> g_gate_create() when g_gate_softc is created but sc_provider is sti= ll > >> not sc_name points to provider name stored in the local array. > >> =20 > >> Approved by: pjd (mentor) > >> Reported by: Freddie Cash > >> MFC after: 1 week > >>=20 > >> Modified: > >> head/sys/geom/gate/g_gate.c > >> head/sys/geom/gate/g_gate.h > >>=20 > >> Modified: head/sys/geom/gate/g_gate.c > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > >> --- head/sys/geom/gate/g_gate.c Sun Mar 27 19:29:18 2011 = (r220061) > >> +++ head/sys/geom/gate/g_gate.c Sun Mar 27 19:56:55 2011 = (r220062) > >> @@ -409,13 +409,14 @@ g_gate_create(struct g_gate_ctl_create * > >> for (unit =3D 0; unit < g_gate_maxunits; unit++) { > >> if (g_gate_units[unit] =3D=3D NULL) > >> continue; > >> - if (strcmp(name, g_gate_units[unit]->sc_provider->na= me) !=3D 0) > >> + if (strcmp(name, g_gate_units[unit]->sc_name) !=3D 0) > >> continue; > >> mtx_unlock(&g_gate_units_lock); > >> mtx_destroy(&sc->sc_queue_mtx); > >> free(sc, M_GATE); > >> return (EEXIST); > >> } > >> + sc->sc_name =3D name; > >> g_gate_units[sc->sc_unit] =3D sc; > >> g_gate_nunits++; > >> mtx_unlock(&g_gate_units_lock); > >> @@ -434,6 +435,9 @@ g_gate_create(struct g_gate_ctl_create * > >> sc->sc_provider =3D pp; > >> g_error_provider(pp, 0); > >> g_topology_unlock(); > >> + mtx_lock(&g_gate_units_lock); > >> + sc->sc_name =3D sc->sc_provider->name; > >> + mtx_unlock(&g_gate_units_lock); > KB> I think you do not need a mutex locked around the single assignment. > KB> As I understand, sc_provider->name is constant ? >=20 > Is the following scenario impossible? >=20 > Thread A is looking for name collision and is accessing > g_gate_units[unit]->sc_name of the unit that is being created by a thread= B, > so sc_name is pointing to thread B local buffer. At this time the thread B > creates provider, does sc->sc_name =3D sc->sc_provider->name and returns = from > g_gate_create(). Thread A, if it is still working with > g_gate_units[unit]->sc_name, is accessing invalid memory. Ok, name is local variable. Apparently, what you need is a barrier. It would be enough to do sc->sc_name =3D sc->sc_provider->name; mtx_lock(&g_gate_units_lock); mtx_unlock(&g_gate_units_lock); The change is fine as is. --bF/koNWjw4RKgJoH Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk2Ppt0ACgkQC3+MBN1Mb4gKPgCfVcIJo1XtYN4nG1gd/akhD2o9 KUYAnRIFG+ZjE+9FLCexAdSG7D+PCFo0 =797P -----END PGP SIGNATURE----- --bF/koNWjw4RKgJoH-- From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 22:12:51 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A3301065672; Sun, 27 Mar 2011 22:12:51 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 67DF28FC12; Sun, 27 Mar 2011 22:12:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMCpwq070434; Sun, 27 Mar 2011 22:12:51 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMCpuR070431; Sun, 27 Mar 2011 22:12:51 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272212.p2RMCpuR070431@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:12:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220064 - stable/8/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:12:51 -0000 Author: yongari Date: Sun Mar 27 22:12:51 2011 New Revision: 220064 URL: http://svn.freebsd.org/changeset/base/220064 Log: MFC r218786: Always check memory allocation failure. If driver encounter memory allocation error, do not attach driver. Reviewed by: marius Modified: stable/8/sys/dev/dc/if_dc.c stable/8/sys/dev/dc/if_dcreg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 20:35:32 2011 (r220063) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:12:51 2011 (r220064) @@ -287,11 +287,11 @@ static void dc_reset(struct dc_softc *); static int dc_list_rx_init(struct dc_softc *); static int dc_list_tx_init(struct dc_softc *); -static void dc_read_srom(struct dc_softc *, int); -static void dc_parse_21143_srom(struct dc_softc *); -static void dc_decode_leaf_sia(struct dc_softc *, struct dc_eblock_sia *); -static void dc_decode_leaf_mii(struct dc_softc *, struct dc_eblock_mii *); -static void dc_decode_leaf_sym(struct dc_softc *, struct dc_eblock_sym *); +static int dc_read_srom(struct dc_softc *, int); +static int dc_parse_21143_srom(struct dc_softc *); +static int dc_decode_leaf_sia(struct dc_softc *, struct dc_eblock_sia *); +static int dc_decode_leaf_mii(struct dc_softc *, struct dc_eblock_mii *); +static int dc_decode_leaf_sym(struct dc_softc *, struct dc_eblock_sym *); static void dc_apply_fixup(struct dc_softc *, int); #ifdef DC_USEIOSPACE @@ -1615,12 +1615,16 @@ dc_apply_fixup(struct dc_softc *sc, int } } -static void +static int dc_decode_leaf_sia(struct dc_softc *sc, struct dc_eblock_sia *l) { struct dc_mediainfo *m; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); + if (m == NULL) { + device_printf(sc->dc_dev, "Could not allocate mediainfo\n"); + return (ENOMEM); + } switch (l->dc_sia_code & ~DC_SIA_CODE_EXT) { case DC_SIA_CODE_10BT: m->dc_media = IFM_10_T; @@ -1657,14 +1661,19 @@ dc_decode_leaf_sia(struct dc_softc *sc, sc->dc_mi = m; sc->dc_pmode = DC_PMODE_SIA; + return (0); } -static void +static int dc_decode_leaf_sym(struct dc_softc *sc, struct dc_eblock_sym *l) { struct dc_mediainfo *m; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); + if (m == NULL) { + device_printf(sc->dc_dev, "Could not allocate mediainfo\n"); + return (ENOMEM); + } if (l->dc_sym_code == DC_SYM_CODE_100BT) m->dc_media = IFM_100_TX; @@ -1678,15 +1687,20 @@ dc_decode_leaf_sym(struct dc_softc *sc, sc->dc_mi = m; sc->dc_pmode = DC_PMODE_SYM; + return (0); } -static void +static int dc_decode_leaf_mii(struct dc_softc *sc, struct dc_eblock_mii *l) { struct dc_mediainfo *m; u_int8_t *p; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); + if (m == NULL) { + device_printf(sc->dc_dev, "Could not allocate mediainfo\n"); + return (ENOMEM); + } /* We abuse IFM_AUTO to represent MII. */ m->dc_media = IFM_AUTO; m->dc_gp_len = l->dc_gpr_len; @@ -1701,24 +1715,30 @@ dc_decode_leaf_mii(struct dc_softc *sc, m->dc_next = sc->dc_mi; sc->dc_mi = m; + return (0); } -static void +static int dc_read_srom(struct dc_softc *sc, int bits) { int size; - size = 2 << bits; + size = DC_ROM_SIZE(bits); sc->dc_srom = malloc(size, M_DEVBUF, M_NOWAIT); + if (sc->dc_srom == NULL) { + device_printf(sc->dc_dev, "Could not allocate SROM buffer\n"); + return (ENOMEM); + } dc_read_eeprom(sc, (caddr_t)sc->dc_srom, 0, (size / 2), 0); + return (0); } -static void +static int dc_parse_21143_srom(struct dc_softc *sc) { struct dc_leaf_hdr *lhdr; struct dc_eblock_hdr *hdr; - int have_mii, i, loff; + int error, have_mii, i, loff; char *ptr; have_mii = 0; @@ -1745,20 +1765,21 @@ dc_parse_21143_srom(struct dc_softc *sc) */ ptr = (char *)lhdr; ptr += sizeof(struct dc_leaf_hdr) - 1; + error = 0; for (i = 0; i < lhdr->dc_mcnt; i++) { hdr = (struct dc_eblock_hdr *)ptr; switch (hdr->dc_type) { case DC_EBLOCK_MII: - dc_decode_leaf_mii(sc, (struct dc_eblock_mii *)hdr); + error = dc_decode_leaf_mii(sc, (struct dc_eblock_mii *)hdr); break; case DC_EBLOCK_SIA: if (! have_mii) - dc_decode_leaf_sia(sc, + error = dc_decode_leaf_sia(sc, (struct dc_eblock_sia *)hdr); break; case DC_EBLOCK_SYM: if (! have_mii) - dc_decode_leaf_sym(sc, + error = dc_decode_leaf_sym(sc, (struct dc_eblock_sym *)hdr); break; default: @@ -1768,6 +1789,7 @@ dc_parse_21143_srom(struct dc_softc *sc) ptr += (hdr->dc_len & 0x7F); ptr++; } + return (error); } static void @@ -1834,6 +1856,7 @@ dc_attach(device_t dev) sc->dc_info = dc_devtype(dev); revision = pci_get_revid(dev); + error = 0; /* Get the eeprom width, but PNIC and XIRCOM have diff eeprom */ if (sc->dc_info->dc_devid != DC_DEVID(DC_VENDORID_LO, DC_DEVICEID_82C168) && @@ -1847,7 +1870,9 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_POLL | DC_TX_USE_TX_INTR; sc->dc_flags |= DC_REDUCED_MII_POLL; /* Save EEPROM contents so we can parse them later. */ - dc_read_srom(sc, sc->dc_romwidth); + error = dc_read_srom(sc, sc->dc_romwidth); + if (error != 0) + goto fail; break; case DC_DEVID(DC_VENDORID_DAVICOM, DC_DEVICEID_DM9009): case DC_DEVID(DC_VENDORID_DAVICOM, DC_DEVICEID_DM9100): @@ -1866,7 +1891,9 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_USE_TX_INTR; sc->dc_flags |= DC_TX_ADMTEK_WAR; sc->dc_pmode = DC_PMODE_MII; - dc_read_srom(sc, sc->dc_romwidth); + error = dc_read_srom(sc, sc->dc_romwidth); + if (error != 0) + goto fail; break; case DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN983): case DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN985): @@ -1933,6 +1960,12 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_STORENFWD | DC_TX_INTR_ALWAYS; sc->dc_flags |= DC_PNIC_RX_BUG_WAR; sc->dc_pnic_rx_buf = malloc(DC_RXLEN * 5, M_DEVBUF, M_NOWAIT); + if (sc->dc_pnic_rx_buf == NULL) { + device_printf(sc->dc_dev, + "Could not allocate PNIC RX buffer\n"); + error = ENOMEM; + goto fail; + } if (revision < DC_REVISION_82C169) sc->dc_pmode = DC_PMODE_SYM; break; @@ -1958,7 +1991,9 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_INTR_ALWAYS; sc->dc_flags |= DC_REDUCED_MII_POLL; sc->dc_pmode = DC_PMODE_MII; - dc_read_srom(sc, sc->dc_romwidth); + error = dc_read_srom(sc, sc->dc_romwidth); + if (error != 0) + goto fail; break; default: device_printf(dev, "unknown device: %x\n", @@ -1989,9 +2024,11 @@ dc_attach(device_t dev) * The tricky ones are the Macronix/PNIC II and the * Intel 21143. */ - if (DC_IS_INTEL(sc)) - dc_parse_21143_srom(sc); - else if (DC_IS_MACRONIX(sc) || DC_IS_PNICII(sc)) { + if (DC_IS_INTEL(sc)) { + error = dc_parse_21143_srom(sc); + if (error != 0) + goto fail; + } else if (DC_IS_MACRONIX(sc) || DC_IS_PNICII(sc)) { if (sc->dc_type == DC_TYPE_98713) sc->dc_pmode = DC_PMODE_MII; else Modified: stable/8/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 20:35:32 2011 (r220063) +++ stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 22:12:51 2011 (r220064) @@ -1063,6 +1063,8 @@ struct dc_softc { * SROM nonsense. */ +#define DC_ROM_SIZE(bits) (2 << (bits)) + #define DC_IB_CTLRCNT 0x13 #define DC_IB_LEAF0_CNUM 0x1A #define DC_IB_LEAF0_OFFSET 0x1B From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 22:14:14 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 87B241065674; Sun, 27 Mar 2011 22:14:14 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 757CF8FC0C; Sun, 27 Mar 2011 22:14:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMEE13070494; Sun, 27 Mar 2011 22:14:14 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMEEQJ070491; Sun, 27 Mar 2011 22:14:14 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272214.p2RMEEQJ070491@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:14:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220065 - stable/7/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:14:14 -0000 Author: yongari Date: Sun Mar 27 22:14:14 2011 New Revision: 220065 URL: http://svn.freebsd.org/changeset/base/220065 Log: MFC r218786: Always check memory allocation failure. If driver encounter memory allocation error, do not attach driver. Reviewed by: marius Modified: stable/7/sys/dev/dc/if_dc.c stable/7/sys/dev/dc/if_dcreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:12:51 2011 (r220064) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:14:14 2011 (r220065) @@ -287,11 +287,11 @@ static void dc_reset(struct dc_softc *); static int dc_list_rx_init(struct dc_softc *); static int dc_list_tx_init(struct dc_softc *); -static void dc_read_srom(struct dc_softc *, int); -static void dc_parse_21143_srom(struct dc_softc *); -static void dc_decode_leaf_sia(struct dc_softc *, struct dc_eblock_sia *); -static void dc_decode_leaf_mii(struct dc_softc *, struct dc_eblock_mii *); -static void dc_decode_leaf_sym(struct dc_softc *, struct dc_eblock_sym *); +static int dc_read_srom(struct dc_softc *, int); +static int dc_parse_21143_srom(struct dc_softc *); +static int dc_decode_leaf_sia(struct dc_softc *, struct dc_eblock_sia *); +static int dc_decode_leaf_mii(struct dc_softc *, struct dc_eblock_mii *); +static int dc_decode_leaf_sym(struct dc_softc *, struct dc_eblock_sym *); static void dc_apply_fixup(struct dc_softc *, int); #ifdef DC_USEIOSPACE @@ -1616,12 +1616,16 @@ dc_apply_fixup(struct dc_softc *sc, int } } -static void +static int dc_decode_leaf_sia(struct dc_softc *sc, struct dc_eblock_sia *l) { struct dc_mediainfo *m; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); + if (m == NULL) { + device_printf(sc->dc_dev, "Could not allocate mediainfo\n"); + return (ENOMEM); + } switch (l->dc_sia_code & ~DC_SIA_CODE_EXT) { case DC_SIA_CODE_10BT: m->dc_media = IFM_10_T; @@ -1658,14 +1662,19 @@ dc_decode_leaf_sia(struct dc_softc *sc, sc->dc_mi = m; sc->dc_pmode = DC_PMODE_SIA; + return (0); } -static void +static int dc_decode_leaf_sym(struct dc_softc *sc, struct dc_eblock_sym *l) { struct dc_mediainfo *m; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); + if (m == NULL) { + device_printf(sc->dc_dev, "Could not allocate mediainfo\n"); + return (ENOMEM); + } if (l->dc_sym_code == DC_SYM_CODE_100BT) m->dc_media = IFM_100_TX; @@ -1679,15 +1688,20 @@ dc_decode_leaf_sym(struct dc_softc *sc, sc->dc_mi = m; sc->dc_pmode = DC_PMODE_SYM; + return (0); } -static void +static int dc_decode_leaf_mii(struct dc_softc *sc, struct dc_eblock_mii *l) { struct dc_mediainfo *m; u_int8_t *p; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); + if (m == NULL) { + device_printf(sc->dc_dev, "Could not allocate mediainfo\n"); + return (ENOMEM); + } /* We abuse IFM_AUTO to represent MII. */ m->dc_media = IFM_AUTO; m->dc_gp_len = l->dc_gpr_len; @@ -1702,24 +1716,30 @@ dc_decode_leaf_mii(struct dc_softc *sc, m->dc_next = sc->dc_mi; sc->dc_mi = m; + return (0); } -static void +static int dc_read_srom(struct dc_softc *sc, int bits) { int size; - size = 2 << bits; + size = DC_ROM_SIZE(bits); sc->dc_srom = malloc(size, M_DEVBUF, M_NOWAIT); + if (sc->dc_srom == NULL) { + device_printf(sc->dc_dev, "Could not allocate SROM buffer\n"); + return (ENOMEM); + } dc_read_eeprom(sc, (caddr_t)sc->dc_srom, 0, (size / 2), 0); + return (0); } -static void +static int dc_parse_21143_srom(struct dc_softc *sc) { struct dc_leaf_hdr *lhdr; struct dc_eblock_hdr *hdr; - int have_mii, i, loff; + int error, have_mii, i, loff; char *ptr; have_mii = 0; @@ -1746,20 +1766,21 @@ dc_parse_21143_srom(struct dc_softc *sc) */ ptr = (char *)lhdr; ptr += sizeof(struct dc_leaf_hdr) - 1; + error = 0; for (i = 0; i < lhdr->dc_mcnt; i++) { hdr = (struct dc_eblock_hdr *)ptr; switch (hdr->dc_type) { case DC_EBLOCK_MII: - dc_decode_leaf_mii(sc, (struct dc_eblock_mii *)hdr); + error = dc_decode_leaf_mii(sc, (struct dc_eblock_mii *)hdr); break; case DC_EBLOCK_SIA: if (! have_mii) - dc_decode_leaf_sia(sc, + error = dc_decode_leaf_sia(sc, (struct dc_eblock_sia *)hdr); break; case DC_EBLOCK_SYM: if (! have_mii) - dc_decode_leaf_sym(sc, + error = dc_decode_leaf_sym(sc, (struct dc_eblock_sym *)hdr); break; default: @@ -1769,6 +1790,7 @@ dc_parse_21143_srom(struct dc_softc *sc) ptr += (hdr->dc_len & 0x7F); ptr++; } + return (error); } static void @@ -1835,6 +1857,7 @@ dc_attach(device_t dev) sc->dc_info = dc_devtype(dev); revision = pci_get_revid(dev); + error = 0; /* Get the eeprom width, but PNIC and XIRCOM have diff eeprom */ if (sc->dc_info->dc_devid != DC_DEVID(DC_VENDORID_LO, DC_DEVICEID_82C168) && @@ -1848,7 +1871,9 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_POLL | DC_TX_USE_TX_INTR; sc->dc_flags |= DC_REDUCED_MII_POLL; /* Save EEPROM contents so we can parse them later. */ - dc_read_srom(sc, sc->dc_romwidth); + error = dc_read_srom(sc, sc->dc_romwidth); + if (error != 0) + goto fail; break; case DC_DEVID(DC_VENDORID_DAVICOM, DC_DEVICEID_DM9009): case DC_DEVID(DC_VENDORID_DAVICOM, DC_DEVICEID_DM9100): @@ -1867,7 +1892,9 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_USE_TX_INTR; sc->dc_flags |= DC_TX_ADMTEK_WAR; sc->dc_pmode = DC_PMODE_MII; - dc_read_srom(sc, sc->dc_romwidth); + error = dc_read_srom(sc, sc->dc_romwidth); + if (error != 0) + goto fail; break; case DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN983): case DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN985): @@ -1934,6 +1961,12 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_STORENFWD | DC_TX_INTR_ALWAYS; sc->dc_flags |= DC_PNIC_RX_BUG_WAR; sc->dc_pnic_rx_buf = malloc(DC_RXLEN * 5, M_DEVBUF, M_NOWAIT); + if (sc->dc_pnic_rx_buf == NULL) { + device_printf(sc->dc_dev, + "Could not allocate PNIC RX buffer\n"); + error = ENOMEM; + goto fail; + } if (revision < DC_REVISION_82C169) sc->dc_pmode = DC_PMODE_SYM; break; @@ -1959,7 +1992,9 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_INTR_ALWAYS; sc->dc_flags |= DC_REDUCED_MII_POLL; sc->dc_pmode = DC_PMODE_MII; - dc_read_srom(sc, sc->dc_romwidth); + error = dc_read_srom(sc, sc->dc_romwidth); + if (error != 0) + goto fail; break; default: device_printf(dev, "unknown device: %x\n", @@ -1990,9 +2025,11 @@ dc_attach(device_t dev) * The tricky ones are the Macronix/PNIC II and the * Intel 21143. */ - if (DC_IS_INTEL(sc)) - dc_parse_21143_srom(sc); - else if (DC_IS_MACRONIX(sc) || DC_IS_PNICII(sc)) { + if (DC_IS_INTEL(sc)) { + error = dc_parse_21143_srom(sc); + if (error != 0) + goto fail; + } else if (DC_IS_MACRONIX(sc) || DC_IS_PNICII(sc)) { if (sc->dc_type == DC_TYPE_98713) sc->dc_pmode = DC_PMODE_MII; else Modified: stable/7/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 22:12:51 2011 (r220064) +++ stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 22:14:14 2011 (r220065) @@ -1063,6 +1063,8 @@ struct dc_softc { * SROM nonsense. */ +#define DC_ROM_SIZE(bits) (2 << (bits)) + #define DC_IB_CTLRCNT 0x13 #define DC_IB_LEAF0_CNUM 0x1A #define DC_IB_LEAF0_OFFSET 0x1B From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 22:20:45 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E8851065787; Sun, 27 Mar 2011 22:20:45 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0BE128FC1A; Sun, 27 Mar 2011 22:20:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMKi86070719; Sun, 27 Mar 2011 22:20:44 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMKiha070716; Sun, 27 Mar 2011 22:20:44 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272220.p2RMKiha070716@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:20:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220066 - stable/8/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:20:45 -0000 Author: yongari Date: Sun Mar 27 22:20:44 2011 New Revision: 220066 URL: http://svn.freebsd.org/changeset/base/220066 Log: MFC r213841,218787-218788: r213841: It seems some multi-port dc(4) controllers shares SROM of the first port such that reading station address from second port always returned 0xFF:0xFF:0xFF:0xFF:0xFF:0xFF Unfortunately it seems there is no easy way to know whether SROM is shared or not. Workaround the issue by traversing dc(4) device list and see whether we're using second port and use station address of controller 0 as base station address of second port. PR: kern/79262 r218787: When driver have to use base softc due to lack of SROM on second port, copy SROM information from base softc as well and run SROM parser again. This change is necessary for some dual port controllers to make dc(4) correctly detect PHY media based on first port configuration table. While I'm here add a check for validity of the base softc before duplicating SROM contents from base softc. If driver failed to attach to the first port it can access invalid area. PR: kern/79262 Reviewed by: marius r218788: Apply special PHY initialization code for 21143 controllers before any other media configuration. Otherwise some 21143 controller cannot establish a link. While I'm here remove the PHY initialization code in dc_setcfg(). Since dc_setcfg() is called whenever link state is changed, having the PHY initialization code in dc_setcfg() resulted in continuous link flips. After driver resets SIA, use default SIA transmit/receive configuration instead of disabling autosense/autonegotiation. Otherwise, controller fails to establish a link as well as losing auto-negotiation capability. For manual media configuration, always configure 21143 controller with specified media to ensure media change. This change makes ANA-6922 establish link with/without auto-negotiation. While I'm here be more strict on link UP/DOWN detection logic. Many thanks to marius who fixed several bugs in initial patch and even tested the patch on a couple of dc(4) controllers. PR: kern/79262 Reviewed by: marius Tested by: marius Modified: stable/8/sys/dev/dc/if_dc.c stable/8/sys/dev/dc/if_dcreg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:14:14 2011 (r220065) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:20:44 2011 (r220066) @@ -293,6 +293,7 @@ static int dc_decode_leaf_sia(struct dc_ static int dc_decode_leaf_mii(struct dc_softc *, struct dc_eblock_mii *); static int dc_decode_leaf_sym(struct dc_softc *, struct dc_eblock_sym *); static void dc_apply_fixup(struct dc_softc *, int); +static int dc_check_multiport(struct dc_softc *); #ifdef DC_USEIOSPACE #define DC_RES SYS_RES_IOPORT @@ -943,23 +944,45 @@ static void dc_miibus_statchg(device_t dev) { struct dc_softc *sc; + struct ifnet *ifp; struct mii_data *mii; struct ifmedia *ifm; sc = device_get_softc(dev); - if (DC_IS_ADMTEK(sc)) - return; mii = device_get_softc(sc->dc_miibus); + ifp = sc->dc_ifp; + if (mii == NULL || ifp == NULL || + (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + return; + ifm = &mii->mii_media; if (DC_IS_DAVICOM(sc) && IFM_SUBTYPE(ifm->ifm_media) == IFM_HPNA_1) { dc_setcfg(sc, ifm->ifm_media); sc->dc_if_media = ifm->ifm_media; - } else { - dc_setcfg(sc, mii->mii_media_active); - sc->dc_if_media = mii->mii_media_active; + return; } + + sc->dc_link = 0; + if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == + (IFM_ACTIVE | IFM_AVALID)) { + switch (IFM_SUBTYPE(mii->mii_media_active)) { + case IFM_10_T: + case IFM_100_TX: + sc->dc_link = 1; + break; + default: + break; + } + } + if (sc->dc_link == 0) + return; + + sc->dc_if_media = mii->mii_media_active; + if (DC_IS_ADMTEK(sc)) + return; + dc_setcfg(sc, mii->mii_media_active); } /* @@ -1403,8 +1426,6 @@ dc_setcfg(struct dc_softc *sc, int media if (!DC_IS_DAVICOM(sc)) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); DC_CLRBIT(sc, DC_10BTCTRL, 0xFFFF); - if (DC_IS_INTEL(sc)) - dc_apply_fixup(sc, IFM_AUTO); } else { if (DC_IS_PNIC(sc)) { DC_PN_GPIO_SETBIT(sc, DC_PN_GPIO_SPEEDSEL); @@ -1414,10 +1435,6 @@ dc_setcfg(struct dc_softc *sc, int media DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PCS); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_SCRAMBLER); - if (DC_IS_INTEL(sc)) - dc_apply_fixup(sc, - (media & IFM_GMASK) == IFM_FDX ? - IFM_100_TX | IFM_FDX : IFM_100_TX); } } @@ -1441,8 +1458,6 @@ dc_setcfg(struct dc_softc *sc, int media if (!DC_IS_DAVICOM(sc)) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); DC_CLRBIT(sc, DC_10BTCTRL, 0xFFFF); - if (DC_IS_INTEL(sc)) - dc_apply_fixup(sc, IFM_AUTO); } else { if (DC_IS_PNIC(sc)) { DC_PN_GPIO_CLRBIT(sc, DC_PN_GPIO_SPEEDSEL); @@ -1462,9 +1477,6 @@ dc_setcfg(struct dc_softc *sc, int media DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET); DC_CLRBIT(sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL); - dc_apply_fixup(sc, - (media & IFM_GMASK) == IFM_FDX ? - IFM_10_T | IFM_FDX : IFM_10_T); DELAY(20000); } } @@ -1536,7 +1548,7 @@ dc_reset(struct dc_softc *sc) */ if (DC_IS_INTEL(sc)) { DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET); - CSR_WRITE_4(sc, DC_10BTCTRL, 0); + CSR_WRITE_4(sc, DC_10BTCTRL, 0xFFFFFFFF); CSR_WRITE_4(sc, DC_WATCHDOG, 0); } } @@ -1814,6 +1826,7 @@ dc_attach(device_t dev) u_int32_t command; struct dc_softc *sc; struct ifnet *ifp; + struct dc_mediainfo *m; u_int32_t reg, revision; int error, i, mac_offset, phy, rid, tmp; u_int8_t *mac; @@ -2097,6 +2110,36 @@ dc_attach(device_t dev) break; } + bcopy(eaddr, sc->dc_eaddr, sizeof(eaddr)); + /* + * If we still have invalid station address, see whether we can + * find station address for chip 0. Some multi-port controllers + * just store station address for chip 0 if they have a shared + * SROM. + */ + if ((sc->dc_eaddr[0] == 0 && (sc->dc_eaddr[1] & ~0xffff) == 0) || + (sc->dc_eaddr[0] == 0xffffffff && + (sc->dc_eaddr[1] & 0xffff) == 0xffff)) { + error = dc_check_multiport(sc); + if (error == 0) { + bcopy(sc->dc_eaddr, eaddr, sizeof(eaddr)); + /* Extract media information. */ + if (DC_IS_INTEL(sc) && sc->dc_srom != NULL) { + while (sc->dc_mi != NULL) { + m = sc->dc_mi->dc_next; + free(sc->dc_mi, M_DEVBUF); + sc->dc_mi = m; + } + error = dc_parse_21143_srom(sc); + if (error != 0) + goto fail; + } + } else if (error == ENOMEM) + goto fail; + else + error = 0; + } + /* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */ error = bus_dma_tag_create(bus_get_dma_tag(dev), PAGE_SIZE, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, @@ -2931,11 +2974,8 @@ dc_tick(void *xsc) */ if ((DC_HAS_BROKEN_RXSTATE(sc) || (CSR_READ_4(sc, DC_ISR) & DC_ISR_RX_STATE) == DC_RXSTATE_WAIT) && - sc->dc_cdata.dc_tx_cnt == 0) { + sc->dc_cdata.dc_tx_cnt == 0) mii_tick(mii); - if (!(mii->mii_media_status & IFM_ACTIVE)) - sc->dc_link = 0; - } } } else mii_tick(mii); @@ -2959,12 +2999,8 @@ dc_tick(void *xsc) * that time, packets will stay in the send queue, and once the * link comes up, they will be flushed out to the wire. */ - if (!sc->dc_link && mii->mii_media_status & IFM_ACTIVE && - IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) { - sc->dc_link++; - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - dc_start_locked(ifp); - } + if (sc->dc_link != 0 && !IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + dc_start_locked(ifp); if (sc->dc_flags & DC_21143_NWAY && !sc->dc_link) callout_reset(&sc->dc_stat_ch, hz/10, dc_tick, sc); @@ -3389,6 +3425,7 @@ dc_init_locked(struct dc_softc *sc) { struct ifnet *ifp = sc->dc_ifp; struct mii_data *mii; + struct ifmedia *ifm; DC_LOCK_ASSERT(sc); @@ -3399,6 +3436,10 @@ dc_init_locked(struct dc_softc *sc) */ dc_stop(sc); dc_reset(sc); + if (DC_IS_INTEL(sc)) { + ifm = &mii->mii_media; + dc_apply_fixup(sc, ifm->ifm_media); + } /* * Set cache alignment and burst length. @@ -3542,12 +3583,12 @@ dc_init_locked(struct dc_softc *sc) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON); CSR_WRITE_4(sc, DC_RXSTART, 0xFFFFFFFF); - mii_mediachg(mii); - dc_setcfg(sc, sc->dc_if_media); - ifp->if_drv_flags |= IFF_DRV_RUNNING; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + mii_mediachg(mii); + dc_setcfg(sc, sc->dc_if_media); + /* Don't start the ticker if this is a homePNA link. */ if (IFM_SUBTYPE(mii->mii_media.ifm_media) == IFM_HPNA_1) sc->dc_link = 1; @@ -3578,7 +3619,9 @@ dc_ifmedia_upd(struct ifnet *ifp) mii_mediachg(mii); ifm = &mii->mii_media; - if (DC_IS_DAVICOM(sc) && + if (DC_IS_INTEL(sc)) + dc_setcfg(sc, ifm->ifm_media); + else if (DC_IS_DAVICOM(sc) && IFM_SUBTYPE(ifm->ifm_media) == IFM_HPNA_1) dc_setcfg(sc, ifm->ifm_media); else @@ -3839,3 +3882,52 @@ dc_shutdown(device_t dev) return (0); } + +static int +dc_check_multiport(struct dc_softc *sc) +{ + struct dc_softc *dsc; + devclass_t dc; + device_t child; + uint8_t *eaddr; + int unit; + + dc = devclass_find("dc"); + for (unit = 0; unit < devclass_get_maxunit(dc); unit++) { + child = devclass_get_device(dc, unit); + if (child == NULL) + continue; + if (child == sc->dc_dev) + continue; + if (device_get_parent(child) != device_get_parent(sc->dc_dev)) + continue; + if (unit > device_get_unit(sc->dc_dev)) + continue; + if (device_is_attached(child) == 0) + continue; + dsc = device_get_softc(child); + device_printf(sc->dc_dev, + "Using station address of %s as base\n", + device_get_nameunit(child)); + bcopy(dsc->dc_eaddr, sc->dc_eaddr, ETHER_ADDR_LEN); + eaddr = (uint8_t *)sc->dc_eaddr; + eaddr[5]++; + /* Prepare SROM to parse again. */ + if (DC_IS_INTEL(sc) && dsc->dc_srom != NULL && + sc->dc_romwidth != 0) { + free(sc->dc_srom, M_DEVBUF); + sc->dc_romwidth = dsc->dc_romwidth; + sc->dc_srom = malloc(DC_ROM_SIZE(sc->dc_romwidth), + M_DEVBUF, M_NOWAIT); + if (sc->dc_srom == NULL) { + device_printf(sc->dc_dev, + "Could not allocate SROM buffer\n"); + return (ENOMEM); + } + bcopy(dsc->dc_srom, sc->dc_srom, + DC_ROM_SIZE(sc->dc_romwidth)); + } + return (0); + } + return (ENOENT); +} Modified: stable/8/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 22:14:14 2011 (r220065) +++ stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 22:20:44 2011 (r220066) @@ -745,6 +745,7 @@ struct dc_softc { int dc_if_media; u_int32_t dc_flags; u_int32_t dc_txthresh; + u_int32_t dc_eaddr[2]; u_int8_t *dc_srom; struct dc_mediainfo *dc_mi; struct dc_list_data *dc_ldata; From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 22:21:52 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7D3B31065672; Sun, 27 Mar 2011 22:21:52 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6AA498FC21; Sun, 27 Mar 2011 22:21:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMLqHs070778; Sun, 27 Mar 2011 22:21:52 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMLqFQ070775; Sun, 27 Mar 2011 22:21:52 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272221.p2RMLqFQ070775@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:21:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220067 - stable/7/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:21:52 -0000 Author: yongari Date: Sun Mar 27 22:21:52 2011 New Revision: 220067 URL: http://svn.freebsd.org/changeset/base/220067 Log: MFC r213841,218787-218788: r213841: It seems some multi-port dc(4) controllers shares SROM of the first port such that reading station address from second port always returned 0xFF:0xFF:0xFF:0xFF:0xFF:0xFF Unfortunately it seems there is no easy way to know whether SROM is shared or not. Workaround the issue by traversing dc(4) device list and see whether we're using second port and use station address of controller 0 as base station address of second port. PR: kern/79262 r218787: When driver have to use base softc due to lack of SROM on second port, copy SROM information from base softc as well and run SROM parser again. This change is necessary for some dual port controllers to make dc(4) correctly detect PHY media based on first port configuration table. While I'm here add a check for validity of the base softc before duplicating SROM contents from base softc. If driver failed to attach to the first port it can access invalid area. PR: kern/79262 Reviewed by: marius r218788: Apply special PHY initialization code for 21143 controllers before any other media configuration. Otherwise some 21143 controller cannot establish a link. While I'm here remove the PHY initialization code in dc_setcfg(). Since dc_setcfg() is called whenever link state is changed, having the PHY initialization code in dc_setcfg() resulted in continuous link flips. After driver resets SIA, use default SIA transmit/receive configuration instead of disabling autosense/autonegotiation. Otherwise, controller fails to establish a link as well as losing auto-negotiation capability. For manual media configuration, always configure 21143 controller with specified media to ensure media change. This change makes ANA-6922 establish link with/without auto-negotiation. While I'm here be more strict on link UP/DOWN detection logic. Many thanks to marius who fixed several bugs in initial patch and even tested the patch on a couple of dc(4) controllers. PR: kern/79262 Reviewed by: marius Tested by: marius Modified: stable/7/sys/dev/dc/if_dc.c stable/7/sys/dev/dc/if_dcreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:20:44 2011 (r220066) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:21:52 2011 (r220067) @@ -293,6 +293,7 @@ static int dc_decode_leaf_sia(struct dc_ static int dc_decode_leaf_mii(struct dc_softc *, struct dc_eblock_mii *); static int dc_decode_leaf_sym(struct dc_softc *, struct dc_eblock_sym *); static void dc_apply_fixup(struct dc_softc *, int); +static int dc_check_multiport(struct dc_softc *); #ifdef DC_USEIOSPACE #define DC_RES SYS_RES_IOPORT @@ -944,23 +945,45 @@ static void dc_miibus_statchg(device_t dev) { struct dc_softc *sc; + struct ifnet *ifp; struct mii_data *mii; struct ifmedia *ifm; sc = device_get_softc(dev); - if (DC_IS_ADMTEK(sc)) - return; mii = device_get_softc(sc->dc_miibus); + ifp = sc->dc_ifp; + if (mii == NULL || ifp == NULL || + (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + return; + ifm = &mii->mii_media; if (DC_IS_DAVICOM(sc) && IFM_SUBTYPE(ifm->ifm_media) == IFM_HPNA_1) { dc_setcfg(sc, ifm->ifm_media); sc->dc_if_media = ifm->ifm_media; - } else { - dc_setcfg(sc, mii->mii_media_active); - sc->dc_if_media = mii->mii_media_active; + return; } + + sc->dc_link = 0; + if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == + (IFM_ACTIVE | IFM_AVALID)) { + switch (IFM_SUBTYPE(mii->mii_media_active)) { + case IFM_10_T: + case IFM_100_TX: + sc->dc_link = 1; + break; + default: + break; + } + } + if (sc->dc_link == 0) + return; + + sc->dc_if_media = mii->mii_media_active; + if (DC_IS_ADMTEK(sc)) + return; + dc_setcfg(sc, mii->mii_media_active); } /* @@ -1404,8 +1427,6 @@ dc_setcfg(struct dc_softc *sc, int media if (!DC_IS_DAVICOM(sc)) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); DC_CLRBIT(sc, DC_10BTCTRL, 0xFFFF); - if (DC_IS_INTEL(sc)) - dc_apply_fixup(sc, IFM_AUTO); } else { if (DC_IS_PNIC(sc)) { DC_PN_GPIO_SETBIT(sc, DC_PN_GPIO_SPEEDSEL); @@ -1415,10 +1436,6 @@ dc_setcfg(struct dc_softc *sc, int media DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PCS); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_SCRAMBLER); - if (DC_IS_INTEL(sc)) - dc_apply_fixup(sc, - (media & IFM_GMASK) == IFM_FDX ? - IFM_100_TX | IFM_FDX : IFM_100_TX); } } @@ -1442,8 +1459,6 @@ dc_setcfg(struct dc_softc *sc, int media if (!DC_IS_DAVICOM(sc)) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); DC_CLRBIT(sc, DC_10BTCTRL, 0xFFFF); - if (DC_IS_INTEL(sc)) - dc_apply_fixup(sc, IFM_AUTO); } else { if (DC_IS_PNIC(sc)) { DC_PN_GPIO_CLRBIT(sc, DC_PN_GPIO_SPEEDSEL); @@ -1463,9 +1478,6 @@ dc_setcfg(struct dc_softc *sc, int media DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET); DC_CLRBIT(sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL); - dc_apply_fixup(sc, - (media & IFM_GMASK) == IFM_FDX ? - IFM_10_T | IFM_FDX : IFM_10_T); DELAY(20000); } } @@ -1537,7 +1549,7 @@ dc_reset(struct dc_softc *sc) */ if (DC_IS_INTEL(sc)) { DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET); - CSR_WRITE_4(sc, DC_10BTCTRL, 0); + CSR_WRITE_4(sc, DC_10BTCTRL, 0xFFFFFFFF); CSR_WRITE_4(sc, DC_WATCHDOG, 0); } } @@ -1815,6 +1827,7 @@ dc_attach(device_t dev) u_int32_t command; struct dc_softc *sc; struct ifnet *ifp; + struct dc_mediainfo *m; u_int32_t reg, revision; int error, i, mac_offset, phy, rid, tmp; u_int8_t *mac; @@ -2098,6 +2111,36 @@ dc_attach(device_t dev) break; } + bcopy(eaddr, sc->dc_eaddr, sizeof(eaddr)); + /* + * If we still have invalid station address, see whether we can + * find station address for chip 0. Some multi-port controllers + * just store station address for chip 0 if they have a shared + * SROM. + */ + if ((sc->dc_eaddr[0] == 0 && (sc->dc_eaddr[1] & ~0xffff) == 0) || + (sc->dc_eaddr[0] == 0xffffffff && + (sc->dc_eaddr[1] & 0xffff) == 0xffff)) { + error = dc_check_multiport(sc); + if (error == 0) { + bcopy(sc->dc_eaddr, eaddr, sizeof(eaddr)); + /* Extract media information. */ + if (DC_IS_INTEL(sc) && sc->dc_srom != NULL) { + while (sc->dc_mi != NULL) { + m = sc->dc_mi->dc_next; + free(sc->dc_mi, M_DEVBUF); + sc->dc_mi = m; + } + error = dc_parse_21143_srom(sc); + if (error != 0) + goto fail; + } + } else if (error == ENOMEM) + goto fail; + else + error = 0; + } + /* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */ error = bus_dma_tag_create(bus_get_dma_tag(dev), PAGE_SIZE, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, @@ -2928,11 +2971,8 @@ dc_tick(void *xsc) */ if ((DC_HAS_BROKEN_RXSTATE(sc) || (CSR_READ_4(sc, DC_ISR) & DC_ISR_RX_STATE) == DC_RXSTATE_WAIT) && - sc->dc_cdata.dc_tx_cnt == 0) { + sc->dc_cdata.dc_tx_cnt == 0) mii_tick(mii); - if (!(mii->mii_media_status & IFM_ACTIVE)) - sc->dc_link = 0; - } } } else mii_tick(mii); @@ -2956,12 +2996,8 @@ dc_tick(void *xsc) * that time, packets will stay in the send queue, and once the * link comes up, they will be flushed out to the wire. */ - if (!sc->dc_link && mii->mii_media_status & IFM_ACTIVE && - IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) { - sc->dc_link++; - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - dc_start_locked(ifp); - } + if (sc->dc_link != 0 && !IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + dc_start_locked(ifp); if (sc->dc_flags & DC_21143_NWAY && !sc->dc_link) callout_reset(&sc->dc_stat_ch, hz/10, dc_tick, sc); @@ -3384,6 +3420,7 @@ dc_init_locked(struct dc_softc *sc) { struct ifnet *ifp = sc->dc_ifp; struct mii_data *mii; + struct ifmedia *ifm; DC_LOCK_ASSERT(sc); @@ -3394,6 +3431,10 @@ dc_init_locked(struct dc_softc *sc) */ dc_stop(sc); dc_reset(sc); + if (DC_IS_INTEL(sc)) { + ifm = &mii->mii_media; + dc_apply_fixup(sc, ifm->ifm_media); + } /* * Set cache alignment and burst length. @@ -3537,12 +3578,12 @@ dc_init_locked(struct dc_softc *sc) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON); CSR_WRITE_4(sc, DC_RXSTART, 0xFFFFFFFF); - mii_mediachg(mii); - dc_setcfg(sc, sc->dc_if_media); - ifp->if_drv_flags |= IFF_DRV_RUNNING; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + mii_mediachg(mii); + dc_setcfg(sc, sc->dc_if_media); + /* Don't start the ticker if this is a homePNA link. */ if (IFM_SUBTYPE(mii->mii_media.ifm_media) == IFM_HPNA_1) sc->dc_link = 1; @@ -3573,7 +3614,9 @@ dc_ifmedia_upd(struct ifnet *ifp) mii_mediachg(mii); ifm = &mii->mii_media; - if (DC_IS_DAVICOM(sc) && + if (DC_IS_INTEL(sc)) + dc_setcfg(sc, ifm->ifm_media); + else if (DC_IS_DAVICOM(sc) && IFM_SUBTYPE(ifm->ifm_media) == IFM_HPNA_1) dc_setcfg(sc, ifm->ifm_media); else @@ -3834,3 +3877,52 @@ dc_shutdown(device_t dev) return (0); } + +static int +dc_check_multiport(struct dc_softc *sc) +{ + struct dc_softc *dsc; + devclass_t dc; + device_t child; + uint8_t *eaddr; + int unit; + + dc = devclass_find("dc"); + for (unit = 0; unit < devclass_get_maxunit(dc); unit++) { + child = devclass_get_device(dc, unit); + if (child == NULL) + continue; + if (child == sc->dc_dev) + continue; + if (device_get_parent(child) != device_get_parent(sc->dc_dev)) + continue; + if (unit > device_get_unit(sc->dc_dev)) + continue; + if (device_is_attached(child) == 0) + continue; + dsc = device_get_softc(child); + device_printf(sc->dc_dev, + "Using station address of %s as base\n", + device_get_nameunit(child)); + bcopy(dsc->dc_eaddr, sc->dc_eaddr, ETHER_ADDR_LEN); + eaddr = (uint8_t *)sc->dc_eaddr; + eaddr[5]++; + /* Prepare SROM to parse again. */ + if (DC_IS_INTEL(sc) && dsc->dc_srom != NULL && + sc->dc_romwidth != 0) { + free(sc->dc_srom, M_DEVBUF); + sc->dc_romwidth = dsc->dc_romwidth; + sc->dc_srom = malloc(DC_ROM_SIZE(sc->dc_romwidth), + M_DEVBUF, M_NOWAIT); + if (sc->dc_srom == NULL) { + device_printf(sc->dc_dev, + "Could not allocate SROM buffer\n"); + return (ENOMEM); + } + bcopy(dsc->dc_srom, sc->dc_srom, + DC_ROM_SIZE(sc->dc_romwidth)); + } + return (0); + } + return (ENOENT); +} Modified: stable/7/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 22:20:44 2011 (r220066) +++ stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 22:21:52 2011 (r220067) @@ -745,6 +745,7 @@ struct dc_softc { int dc_if_media; u_int32_t dc_flags; u_int32_t dc_txthresh; + u_int32_t dc_eaddr[2]; u_int8_t *dc_srom; struct dc_mediainfo *dc_mi; struct dc_list_data *dc_ldata; From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 22:31:17 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CBF99106564A; Sun, 27 Mar 2011 22:31:17 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AED318FC14; Sun, 27 Mar 2011 22:31:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMVHJY071115; Sun, 27 Mar 2011 22:31:17 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMVHR6071112; Sun, 27 Mar 2011 22:31:17 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272231.p2RMVHR6071112@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:31:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220068 - stable/8/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:31:17 -0000 Author: yongari Date: Sun Mar 27 22:31:17 2011 New Revision: 220068 URL: http://svn.freebsd.org/changeset/base/220068 Log: MFC r218789,218820,218826-218828: r218789: Remove use case of DC_TX_ONE. It was used to limit queue just 1 TX frame in DM910x controllers. In r67595(more than 10 years ago) it was replaced to use "Store and Forward" mode and made controller generate TX completion interrupt for every frame. r218820: For controllers that have TX interrupt moderation capability, request TX completion interrupt for every 8-th frames. Previously dc(4) requested TX completion interrupt if number of queued TX descriptors is greater than 64. This caused a lot of TX completion interrupt under high TX load once driver queued more than 64 TX descriptors. It's quite normal to see more than 64 queued TX descriptors under high TX load. This change reduces the number of TX completion interrupts to be less than 17k under high TX load. Because this change does not generate TX completion interrupt for each frame, add reclaiming transmitted buffers in dc_tick not to generate false watchdog timeouts. While I'm here add check for queued descriptors in dc_txeof() since there is no more work to do when there is no pending descriptors. r218826: Make sure to clear status word of TX descriptor in dc_list_tx_init(). Do not update if_opackets if the transmission had failed. r218827: There is no need to execute filter configuration when driver is not running. Remove wrong driver state change in dc_setfilt_xircom(). While I'm here nuke unnecessary assignments. r218828: Fix a long standing bug where driver handed over RX descriptor ownership to controller before completion of access to the descriptor. Driver is faking up status word so it should not give ownership to controller until it completes RX processing. Modified: stable/8/sys/dev/dc/if_dc.c stable/8/sys/dev/dc/if_dcreg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:21:52 2011 (r220067) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:31:17 2011 (r220068) @@ -1334,7 +1334,6 @@ dc_setfilt_xircom(struct dc_softc *sc) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON); - ifp->if_drv_flags |= IFF_DRV_RUNNING; sframe->dc_status = htole32(DC_TXSTAT_OWN); CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF); @@ -2466,13 +2465,15 @@ dc_list_tx_init(struct dc_softc *sc) nexti = 0; else nexti = i + 1; + ld->dc_tx_list[i].dc_status = 0; + ld->dc_tx_list[i].dc_ctl = 0; + ld->dc_tx_list[i].dc_data = 0; ld->dc_tx_list[i].dc_next = htole32(DC_TXDESC(sc, nexti)); cd->dc_tx_chain[i] = NULL; - ld->dc_tx_list[i].dc_data = 0; - ld->dc_tx_list[i].dc_ctl = 0; } cd->dc_tx_prod = cd->dc_tx_cons = cd->dc_tx_cnt = 0; + cd->dc_tx_pkts = 0; bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); @@ -2670,7 +2671,6 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, * the status word to make it look like a successful * frame reception. */ - dc_newbuf(sc, i, 0); bcopy(ptr, mtod(m, char *), total_len); cur_rx->dc_status = htole32(rxstat | DC_RXSTAT_FIRSTFRAG); } @@ -2841,6 +2841,9 @@ dc_txeof(struct dc_softc *sc) int idx; u_int32_t ctl, txstat; + if (sc->dc_cdata.dc_tx_cnt == 0) + return; + ifp = sc->dc_ifp; /* @@ -2912,11 +2915,10 @@ dc_txeof(struct dc_softc *sc) dc_init_locked(sc); return; } - } - + } else + ifp->if_opackets++; ifp->if_collisions += (txstat & DC_TXSTAT_COLLCNT) >> 3; - ifp->if_opackets++; if (sc->dc_cdata.dc_tx_chain[idx] != NULL) { bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_tx_map[idx], @@ -2952,6 +2954,13 @@ dc_tick(void *xsc) ifp = sc->dc_ifp; mii = device_get_softc(sc->dc_miibus); + /* + * Reclaim transmitted frames for controllers that do + * not generate TX completion interrupt for every frame. + */ + if (sc->dc_flags & DC_TX_USE_TX_INTR) + dc_txeof(sc); + if (sc->dc_flags & DC_REDUCED_MII_POLL) { if (sc->dc_flags & DC_21143_NWAY) { r = CSR_READ_4(sc, DC_10BTSTAT); @@ -3322,8 +3331,11 @@ dc_encap(struct dc_softc *sc, struct mbu htole32(DC_TXCTL_FINT); if (sc->dc_flags & DC_TX_INTR_ALWAYS) sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); - if (sc->dc_flags & DC_TX_USE_TX_INTR && sc->dc_cdata.dc_tx_cnt > 64) + if (sc->dc_flags & DC_TX_USE_TX_INTR && + ++sc->dc_cdata.dc_tx_pkts >= 8) { + sc->dc_cdata.dc_tx_pkts = 0; sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); + } sc->dc_ldata->dc_tx_list[first].dc_status = htole32(DC_TXSTAT_OWN); bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_tx_map[idx], @@ -3391,11 +3403,6 @@ dc_start_locked(struct ifnet *ifp) * to him. */ BPF_MTAP(ifp, m_head); - - if (sc->dc_flags & DC_TX_ONE) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; - break; - } } if (queued > 0) { @@ -3687,14 +3694,13 @@ dc_ioctl(struct ifnet *ifp, u_long comma } sc->dc_if_flags = ifp->if_flags; DC_UNLOCK(sc); - error = 0; break; case SIOCADDMULTI: case SIOCDELMULTI: DC_LOCK(sc); - dc_setfilt(sc); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + dc_setfilt(sc); DC_UNLOCK(sc); - error = 0; break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: Modified: stable/8/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 22:21:52 2011 (r220067) +++ stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 22:31:17 2011 (r220068) @@ -495,6 +495,7 @@ struct dc_chain_data { bus_dmamap_t dc_tx_map[DC_TX_LIST_CNT]; u_int32_t *dc_sbuf; u_int8_t dc_pad[DC_MIN_FRAMELEN]; + int dc_tx_pkts; int dc_tx_first; int dc_tx_prod; int dc_tx_cons; @@ -780,7 +781,6 @@ struct dc_softc { #define DC_128BIT_HASH 0x00001000 #define DC_64BIT_HASH 0x00002000 #define DC_TULIP_LEDS 0x00004000 -#define DC_TX_ONE 0x00008000 #define DC_TX_ALIGN 0x00010000 /* align mbuf on tx */ /* From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 22:32:14 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7621F106566C; Sun, 27 Mar 2011 22:32:14 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 63A478FC08; Sun, 27 Mar 2011 22:32:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMWEBX071171; Sun, 27 Mar 2011 22:32:14 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMWEhP071168; Sun, 27 Mar 2011 22:32:14 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272232.p2RMWEhP071168@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:32:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220069 - stable/7/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:32:14 -0000 Author: yongari Date: Sun Mar 27 22:32:14 2011 New Revision: 220069 URL: http://svn.freebsd.org/changeset/base/220069 Log: MFC r218789,218820,218826-218828: r218789: Remove use case of DC_TX_ONE. It was used to limit queue just 1 TX frame in DM910x controllers. In r67595(more than 10 years ago) it was replaced to use "Store and Forward" mode and made controller generate TX completion interrupt for every frame. r218820: For controllers that have TX interrupt moderation capability, request TX completion interrupt for every 8-th frames. Previously dc(4) requested TX completion interrupt if number of queued TX descriptors is greater than 64. This caused a lot of TX completion interrupt under high TX load once driver queued more than 64 TX descriptors. It's quite normal to see more than 64 queued TX descriptors under high TX load. This change reduces the number of TX completion interrupts to be less than 17k under high TX load. Because this change does not generate TX completion interrupt for each frame, add reclaiming transmitted buffers in dc_tick not to generate false watchdog timeouts. While I'm here add check for queued descriptors in dc_txeof() since there is no more work to do when there is no pending descriptors. r218826: Make sure to clear status word of TX descriptor in dc_list_tx_init(). Do not update if_opackets if the transmission had failed. r218827: There is no need to execute filter configuration when driver is not running. Remove wrong driver state change in dc_setfilt_xircom(). While I'm here nuke unnecessary assignments. r218828: Fix a long standing bug where driver handed over RX descriptor ownership to controller before completion of access to the descriptor. Driver is faking up status word so it should not give ownership to controller until it completes RX processing. Modified: stable/7/sys/dev/dc/if_dc.c stable/7/sys/dev/dc/if_dcreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:31:17 2011 (r220068) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:32:14 2011 (r220069) @@ -1335,7 +1335,6 @@ dc_setfilt_xircom(struct dc_softc *sc) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON); - ifp->if_drv_flags |= IFF_DRV_RUNNING; sframe->dc_status = htole32(DC_TXSTAT_OWN); CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF); @@ -2467,13 +2466,15 @@ dc_list_tx_init(struct dc_softc *sc) nexti = 0; else nexti = i + 1; + ld->dc_tx_list[i].dc_status = 0; + ld->dc_tx_list[i].dc_ctl = 0; + ld->dc_tx_list[i].dc_data = 0; ld->dc_tx_list[i].dc_next = htole32(DC_TXDESC(sc, nexti)); cd->dc_tx_chain[i] = NULL; - ld->dc_tx_list[i].dc_data = 0; - ld->dc_tx_list[i].dc_ctl = 0; } cd->dc_tx_prod = cd->dc_tx_cons = cd->dc_tx_cnt = 0; + cd->dc_tx_pkts = 0; bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); @@ -2671,7 +2672,6 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, * the status word to make it look like a successful * frame reception. */ - dc_newbuf(sc, i, 0); bcopy(ptr, mtod(m, char *), total_len); cur_rx->dc_status = htole32(rxstat | DC_RXSTAT_FIRSTFRAG); } @@ -2838,6 +2838,9 @@ dc_txeof(struct dc_softc *sc) int idx; u_int32_t ctl, txstat; + if (sc->dc_cdata.dc_tx_cnt == 0) + return; + ifp = sc->dc_ifp; /* @@ -2909,11 +2912,10 @@ dc_txeof(struct dc_softc *sc) dc_init_locked(sc); return; } - } - + } else + ifp->if_opackets++; ifp->if_collisions += (txstat & DC_TXSTAT_COLLCNT) >> 3; - ifp->if_opackets++; if (sc->dc_cdata.dc_tx_chain[idx] != NULL) { bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_tx_map[idx], @@ -2949,6 +2951,13 @@ dc_tick(void *xsc) ifp = sc->dc_ifp; mii = device_get_softc(sc->dc_miibus); + /* + * Reclaim transmitted frames for controllers that do + * not generate TX completion interrupt for every frame. + */ + if (sc->dc_flags & DC_TX_USE_TX_INTR) + dc_txeof(sc); + if (sc->dc_flags & DC_REDUCED_MII_POLL) { if (sc->dc_flags & DC_21143_NWAY) { r = CSR_READ_4(sc, DC_10BTSTAT); @@ -3317,8 +3326,11 @@ dc_encap(struct dc_softc *sc, struct mbu htole32(DC_TXCTL_FINT); if (sc->dc_flags & DC_TX_INTR_ALWAYS) sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); - if (sc->dc_flags & DC_TX_USE_TX_INTR && sc->dc_cdata.dc_tx_cnt > 64) + if (sc->dc_flags & DC_TX_USE_TX_INTR && + ++sc->dc_cdata.dc_tx_pkts >= 8) { + sc->dc_cdata.dc_tx_pkts = 0; sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); + } sc->dc_ldata->dc_tx_list[first].dc_status = htole32(DC_TXSTAT_OWN); bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_tx_map[idx], @@ -3386,11 +3398,6 @@ dc_start_locked(struct ifnet *ifp) * to him. */ BPF_MTAP(ifp, m_head); - - if (sc->dc_flags & DC_TX_ONE) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; - break; - } } if (queued > 0) { @@ -3682,14 +3689,13 @@ dc_ioctl(struct ifnet *ifp, u_long comma } sc->dc_if_flags = ifp->if_flags; DC_UNLOCK(sc); - error = 0; break; case SIOCADDMULTI: case SIOCDELMULTI: DC_LOCK(sc); - dc_setfilt(sc); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + dc_setfilt(sc); DC_UNLOCK(sc); - error = 0; break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: Modified: stable/7/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 22:31:17 2011 (r220068) +++ stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 22:32:14 2011 (r220069) @@ -495,6 +495,7 @@ struct dc_chain_data { bus_dmamap_t dc_tx_map[DC_TX_LIST_CNT]; u_int32_t *dc_sbuf; u_int8_t dc_pad[DC_MIN_FRAMELEN]; + int dc_tx_pkts; int dc_tx_first; int dc_tx_prod; int dc_tx_cons; @@ -780,7 +781,6 @@ struct dc_softc { #define DC_128BIT_HASH 0x00001000 #define DC_64BIT_HASH 0x00002000 #define DC_TULIP_LEDS 0x00004000 -#define DC_TX_ONE 0x00008000 #define DC_TX_ALIGN 0x00010000 /* align mbuf on tx */ /* From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 22:32:45 2011 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D34E106566B; Sun, 27 Mar 2011 22:32:45 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id B31518FC16; Sun, 27 Mar 2011 22:32:44 +0000 (UTC) Received: from 63.imp.bsdimp.com (63.imp.bsdimp.com [10.0.0.63] (may be forged)) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id p2RMTS0A076694; Sun, 27 Mar 2011 16:29:28 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <4D8F7257.50207@FreeBSD.org> Date: Sun, 27 Mar 2011 16:29:28 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201103271657.p2RGvs2m063692@svn.freebsd.org> <4D8F7257.50207@FreeBSD.org> To: Doug Barton X-Mailer: Apple Mail (2.1082) Cc: Josh Paetzel , svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, kib@FreeBSD.org Subject: Re: svn commit: r220059 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:32:45 -0000 On Mar 27, 2011, at 11:22 AM, Doug Barton wrote: > On 03/27/2011 09:57, Josh Paetzel wrote: >> Replace "$?" =3D "0" with $? -eq 0 in tests >=20 > Excellent! Most of the time I've found that moving the command up to the if makes = the code clearer too. At jobs I've had in the past when I've written = code similar to what we have here, it almost always got flagged... Warner From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 22:36:16 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C64EC106566B; Sun, 27 Mar 2011 22:36:16 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B42298FC0C; Sun, 27 Mar 2011 22:36:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMaGFC071392; Sun, 27 Mar 2011 22:36:16 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMaGdO071390; Sun, 27 Mar 2011 22:36:16 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272236.p2RMaGdO071390@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:36:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220070 - stable/8/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:36:17 -0000 Author: yongari Date: Sun Mar 27 22:36:16 2011 New Revision: 220070 URL: http://svn.freebsd.org/changeset/base/220070 Log: MFC r218830-218831: r218830: Send frames only when there is a valid link and driver is running as well as controller has enough free TX descriptors. Remove check for number of queued frames before attempting to transmit. I guess it was added to allow draining queued frames even if there is no link. I'm under the impression this type of check should be done in upper layer. No other drivers in tree do that. r218831: Rearrange interrupt handler a bit and remove forever loop. Previously dc(4) always checked whether there is pending interrupts and this consumed a lot of CPU cycles in interrupt handler. Limit the number of processing for TX/RX frames to 16. Also allow sending frames in the loop not to starve TX under high RX load. Reading DC_ISR register should be protected with driver lock, otherwise interrupt handler could be run(e.g. link state change) before the completion of dc_init_locked(). While I'm here remove unneeded code. Modified: stable/8/sys/dev/dc/if_dc.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:32:14 2011 (r220069) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:36:16 2011 (r220070) @@ -3135,16 +3135,19 @@ dc_intr(void *arg) struct dc_softc *sc; struct ifnet *ifp; u_int32_t status; + int curpkts, n; sc = arg; if (sc->suspended) return; - if ((CSR_READ_4(sc, DC_ISR) & DC_INTRS) == 0) - return; - DC_LOCK(sc); + status = CSR_READ_4(sc, DC_ISR); + if (status == 0xFFFFFFFF || (status & DC_INTRS) == 0) { + DC_UNLOCK(sc); + return; + } ifp = sc->dc_ifp; #ifdef DEVICE_POLLING if (ifp->if_capenable & IFCAP_POLLING) { @@ -3152,26 +3155,16 @@ dc_intr(void *arg) return; } #endif - - /* Suppress unwanted interrupts */ - if (!(ifp->if_flags & IFF_UP)) { - if (CSR_READ_4(sc, DC_ISR) & DC_INTRS) - dc_stop(sc); - DC_UNLOCK(sc); - return; - } - /* Disable interrupts. */ CSR_WRITE_4(sc, DC_IMR, 0x00000000); - while (((status = CSR_READ_4(sc, DC_ISR)) & DC_INTRS) && - status != 0xFFFFFFFF && - (ifp->if_drv_flags & IFF_DRV_RUNNING)) { - + for (n = 16; n > 0; n--) { + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + break; + /* Ack interrupts. */ CSR_WRITE_4(sc, DC_ISR, status); if (status & DC_ISR_RX_OK) { - int curpkts; curpkts = ifp->if_ipackets; dc_rxeof(sc); if (curpkts == ifp->if_ipackets) { @@ -3196,7 +3189,6 @@ dc_intr(void *arg) if ((status & DC_ISR_RX_WATDOGTIMEO) || (status & DC_ISR_RX_NOBUF)) { - int curpkts; curpkts = ifp->if_ipackets; dc_rxeof(sc); if (curpkts == ifp->if_ipackets) { @@ -3205,17 +3197,23 @@ dc_intr(void *arg) } } + if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + dc_start_locked(ifp); + if (status & DC_ISR_BUS_ERR) { dc_reset(sc); dc_init_locked(sc); + DC_UNLOCK(sc); + return; } + status = CSR_READ_4(sc, DC_ISR); + if (status == 0xFFFFFFFF || (status & DC_INTRS) == 0) + break; } /* Re-enable interrupts. */ - CSR_WRITE_4(sc, DC_IMR, DC_INTRS); - - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - dc_start_locked(ifp); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + CSR_WRITE_4(sc, DC_IMR, DC_INTRS); DC_UNLOCK(sc); } @@ -3375,10 +3373,8 @@ dc_start_locked(struct ifnet *ifp) DC_LOCK_ASSERT(sc); - if (!sc->dc_link && ifp->if_snd.ifq_len < 10) - return; - - if (ifp->if_drv_flags & IFF_DRV_OACTIVE) + if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != + IFF_DRV_RUNNING || sc->dc_link == 0) return; idx = sc->dc_cdata.dc_tx_first = sc->dc_cdata.dc_tx_prod; From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 22:37:29 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 075911065670; Sun, 27 Mar 2011 22:37:29 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E949F8FC12; Sun, 27 Mar 2011 22:37:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMbShT071450; Sun, 27 Mar 2011 22:37:28 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMbSWV071448; Sun, 27 Mar 2011 22:37:28 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272237.p2RMbSWV071448@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:37:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220071 - stable/7/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:37:29 -0000 Author: yongari Date: Sun Mar 27 22:37:28 2011 New Revision: 220071 URL: http://svn.freebsd.org/changeset/base/220071 Log: MFC r218830-218831: r218830: Send frames only when there is a valid link and driver is running as well as controller has enough free TX descriptors. Remove check for number of queued frames before attempting to transmit. I guess it was added to allow draining queued frames even if there is no link. I'm under the impression this type of check should be done in upper layer. No other drivers in tree do that. r218831: Rearrange interrupt handler a bit and remove forever loop. Previously dc(4) always checked whether there is pending interrupts and this consumed a lot of CPU cycles in interrupt handler. Limit the number of processing for TX/RX frames to 16. Also allow sending frames in the loop not to starve TX under high RX load. Reading DC_ISR register should be protected with driver lock, otherwise interrupt handler could be run(e.g. link state change) before the completion of dc_init_locked(). While I'm here remove unneeded code. Modified: stable/7/sys/dev/dc/if_dc.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:36:16 2011 (r220070) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:37:28 2011 (r220071) @@ -3130,16 +3130,19 @@ dc_intr(void *arg) struct dc_softc *sc; struct ifnet *ifp; u_int32_t status; + int curpkts, n; sc = arg; if (sc->suspended) return; - if ((CSR_READ_4(sc, DC_ISR) & DC_INTRS) == 0) - return; - DC_LOCK(sc); + status = CSR_READ_4(sc, DC_ISR); + if (status == 0xFFFFFFFF || (status & DC_INTRS) == 0) { + DC_UNLOCK(sc); + return; + } ifp = sc->dc_ifp; #ifdef DEVICE_POLLING if (ifp->if_capenable & IFCAP_POLLING) { @@ -3147,26 +3150,16 @@ dc_intr(void *arg) return; } #endif - - /* Suppress unwanted interrupts */ - if (!(ifp->if_flags & IFF_UP)) { - if (CSR_READ_4(sc, DC_ISR) & DC_INTRS) - dc_stop(sc); - DC_UNLOCK(sc); - return; - } - /* Disable interrupts. */ CSR_WRITE_4(sc, DC_IMR, 0x00000000); - while (((status = CSR_READ_4(sc, DC_ISR)) & DC_INTRS) && - status != 0xFFFFFFFF && - (ifp->if_drv_flags & IFF_DRV_RUNNING)) { - + for (n = 16; n > 0; n--) { + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + break; + /* Ack interrupts. */ CSR_WRITE_4(sc, DC_ISR, status); if (status & DC_ISR_RX_OK) { - int curpkts; curpkts = ifp->if_ipackets; dc_rxeof(sc); if (curpkts == ifp->if_ipackets) { @@ -3191,7 +3184,6 @@ dc_intr(void *arg) if ((status & DC_ISR_RX_WATDOGTIMEO) || (status & DC_ISR_RX_NOBUF)) { - int curpkts; curpkts = ifp->if_ipackets; dc_rxeof(sc); if (curpkts == ifp->if_ipackets) { @@ -3200,17 +3192,23 @@ dc_intr(void *arg) } } + if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + dc_start_locked(ifp); + if (status & DC_ISR_BUS_ERR) { dc_reset(sc); dc_init_locked(sc); + DC_UNLOCK(sc); + return; } + status = CSR_READ_4(sc, DC_ISR); + if (status == 0xFFFFFFFF || (status & DC_INTRS) == 0) + break; } /* Re-enable interrupts. */ - CSR_WRITE_4(sc, DC_IMR, DC_INTRS); - - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - dc_start_locked(ifp); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + CSR_WRITE_4(sc, DC_IMR, DC_INTRS); DC_UNLOCK(sc); } @@ -3370,10 +3368,8 @@ dc_start_locked(struct ifnet *ifp) DC_LOCK_ASSERT(sc); - if (!sc->dc_link && ifp->if_snd.ifq_len < 10) - return; - - if (ifp->if_drv_flags & IFF_DRV_OACTIVE) + if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != + IFF_DRV_RUNNING || sc->dc_link == 0) return; idx = sc->dc_cdata.dc_tx_first = sc->dc_cdata.dc_tx_prod; From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 22:48:59 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38E64106566C; Sun, 27 Mar 2011 22:48:59 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 251058FC0A; Sun, 27 Mar 2011 22:48:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMmxp9071711; Sun, 27 Mar 2011 22:48:59 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMmxOQ071708; Sun, 27 Mar 2011 22:48:59 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272248.p2RMmxOQ071708@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:48:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220072 - stable/8/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:48:59 -0000 Author: yongari Date: Sun Mar 27 22:48:58 2011 New Revision: 220072 URL: http://svn.freebsd.org/changeset/base/220072 Log: MFC r218832: Split common TX/RX descriptor DMA tag to TX and RX DMA tags respectively and fix all bus_dma(9) issues seen when bounce buffers are used. o Setup frame handling had no bus_dmamap_sync(9) which prevented driver from configuring RX filter. Add missing bus_dmamap_sync(9) in both dc_setfilt_21143()/dc_setfilt_xircom() and dc_txeof(). o Use bus_addr_t for DMA segment instead of using u_int32_t. o Introduce dc_dma_alloc()/dc_dma_free() functions to allocate/free DMA'able memory. o Create two DMA descriptor list for each TX/RX lists. This change will minimize the size of bounce buffers that would be used in each TX/RX path. Previously driver had to copy both TX/RX lists when bounce buffer is active. o 21143 data sheet says descriptor list requires 4 bytes alignment. Remove PAGE_SIZE alignment restriction and use sizeof(struct dc_dec). o Setup frame requires 4 bytes alignment. Remove PAGE_SIZE alignment restriction and use sizeof(struct dc_dec). o Add missing DMA map unload for both setup frame and TX/RX descriptor list. o Overhaul RX handling logic such that make driver always allocate new RX buffer with dc_newbuf(). Previously driver allowed to copy received frame with m_devget(9) after passing the descriptor ownership to controller. This can lead to passing wrong frame to upper stack. o Introduce dc_discard_rxbuf() which will discard received frame and reuse loaded DMA map and RX mbuf. o Correct several wrong bus_dmamap_sync(9) usage in dc_rxeof and dc_txeof. The TX/RX descriptor lists are updated by both driver and HW so READ/WRITE semantics should be used. o If driver failed to allocate new RX buffer, update if_iqdrops counter instead of if_ierrors since driver received the frame without errors. o Make sure to unload loaded setup frame DMA map in dc_txeof and clear the mark of setup frame of the TX descriptor in dc_txeof(). o Add check for possible TX descriptor overruns in dc_encap() and move check for free buffer to caller, dc_start_locked(). o Swap the loaded DMA map and the last DMA map for multi-segmented frames. Since dc_txeof() assumes the last descriptor of the frame has the DMA map, driver should swap the first and the last DMA map in dc_encap(). Previously driver tried to unload not-yet-loaded DMA map such that the loaded DMA map was not unloaded at all for multi-segmented frames. o Rewrite DC_RXDESC/DC_TXDESC macro to simpler one. o Remove definition of ETHER_ALIGN, it's already defined in ethernet.h. With this changes, dc(4) works with bounce buffers and it shall also fix issues which might have shown in PAE environments. Tested by: marius Modified: stable/8/sys/dev/dc/if_dc.c stable/8/sys/dev/dc/if_dcreg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:37:28 2011 (r220071) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:48:58 2011 (r220072) @@ -233,7 +233,8 @@ static int dc_detach(device_t); static int dc_suspend(device_t); static int dc_resume(device_t); static const struct dc_type *dc_devtype(device_t); -static int dc_newbuf(struct dc_softc *, int, int); +static void dc_discard_rxbuf(struct dc_softc *, int); +static int dc_newbuf(struct dc_softc *, int); static int dc_encap(struct dc_softc *, struct mbuf **); static void dc_pnic_rx_bug_war(struct dc_softc *, int); static int dc_rx_resync(struct dc_softc *); @@ -253,6 +254,10 @@ static int dc_shutdown(device_t); static int dc_ifmedia_upd(struct ifnet *); static void dc_ifmedia_sts(struct ifnet *, struct ifmediareq *); +static int dc_dma_alloc(struct dc_softc *); +static void dc_dma_free(struct dc_softc *); +static void dc_dma_map_addr(void *, bus_dma_segment_t *, int, int); + static void dc_delay(struct dc_softc *); static void dc_eeprom_idle(struct dc_softc *); static void dc_eeprom_putbyte(struct dc_softc *, int); @@ -1087,11 +1092,11 @@ dc_setfilt_21143(struct dc_softc *sc) i = sc->dc_cdata.dc_tx_prod; DC_INC(sc->dc_cdata.dc_tx_prod, DC_TX_LIST_CNT); sc->dc_cdata.dc_tx_cnt++; - sframe = &sc->dc_ldata->dc_tx_list[i]; + sframe = &sc->dc_ldata.dc_tx_list[i]; sp = sc->dc_cdata.dc_sbuf; bzero(sp, DC_SFRAME_LEN); - sframe->dc_data = htole32(sc->dc_saddr); + sframe->dc_data = htole32(DC_ADDR_LO(sc->dc_saddr)); sframe->dc_ctl = htole32(DC_SFRAME_LEN | DC_TXCTL_SETUP | DC_TXCTL_TLINK | DC_FILTER_HASHPERF | DC_TXCTL_FINT); @@ -1130,6 +1135,7 @@ dc_setfilt_21143(struct dc_softc *sc) sp[41] = DC_SP_MAC(eaddr[2]); sframe->dc_status = htole32(DC_TXSTAT_OWN); + bus_dmamap_sync(sc->dc_stag, sc->dc_smap, BUS_DMASYNC_PREWRITE); CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF); /* @@ -1290,11 +1296,11 @@ dc_setfilt_xircom(struct dc_softc *sc) i = sc->dc_cdata.dc_tx_prod; DC_INC(sc->dc_cdata.dc_tx_prod, DC_TX_LIST_CNT); sc->dc_cdata.dc_tx_cnt++; - sframe = &sc->dc_ldata->dc_tx_list[i]; + sframe = &sc->dc_ldata.dc_tx_list[i]; sp = sc->dc_cdata.dc_sbuf; bzero(sp, DC_SFRAME_LEN); - sframe->dc_data = htole32(sc->dc_saddr); + sframe->dc_data = htole32(DC_ADDR_LO(sc->dc_saddr)); sframe->dc_ctl = htole32(DC_SFRAME_LEN | DC_TXCTL_SETUP | DC_TXCTL_TLINK | DC_FILTER_HASHPERF | DC_TXCTL_FINT); @@ -1335,6 +1341,7 @@ dc_setfilt_xircom(struct dc_softc *sc) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON); sframe->dc_status = htole32(DC_TXSTAT_OWN); + bus_dmamap_sync(sc->dc_stag, sc->dc_smap, BUS_DMASYNC_PREWRITE); CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF); /* @@ -1806,7 +1813,7 @@ dc_parse_21143_srom(struct dc_softc *sc) static void dc_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error) { - u_int32_t *paddr; + bus_addr_t *paddr; KASSERT(nseg == 1, ("%s: wrong number of segments (%d)", __func__, nseg)); @@ -1814,6 +1821,208 @@ dc_dma_map_addr(void *arg, bus_dma_segme *paddr = segs->ds_addr; } +static int +dc_dma_alloc(struct dc_softc *sc) +{ + int error, i; + + error = bus_dma_tag_create(bus_get_dma_tag(sc->dc_dev), 1, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT, 0, + NULL, NULL, &sc->dc_ptag); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate parent DMA tag\n"); + goto fail; + } + + /* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */ + error = bus_dma_tag_create(sc->dc_ptag, DC_LIST_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, DC_RX_LIST_SZ, 1, + DC_RX_LIST_SZ, 0, NULL, NULL, &sc->dc_rx_ltag); + if (error) { + device_printf(sc->dc_dev, "failed to create RX list DMA tag\n"); + goto fail; + } + + error = bus_dma_tag_create(sc->dc_ptag, DC_LIST_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, DC_TX_LIST_SZ, 1, + DC_TX_LIST_SZ, 0, NULL, NULL, &sc->dc_tx_ltag); + if (error) { + device_printf(sc->dc_dev, "failed to create TX list DMA tag\n"); + goto fail; + } + + /* RX descriptor list. */ + error = bus_dmamem_alloc(sc->dc_rx_ltag, + (void **)&sc->dc_ldata.dc_rx_list, BUS_DMA_NOWAIT | + BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->dc_rx_lmap); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate DMA'able memory for RX list\n"); + goto fail; + } + error = bus_dmamap_load(sc->dc_rx_ltag, sc->dc_rx_lmap, + sc->dc_ldata.dc_rx_list, DC_RX_LIST_SZ, dc_dma_map_addr, + &sc->dc_ldata.dc_rx_list_paddr, BUS_DMA_NOWAIT); + if (error) { + device_printf(sc->dc_dev, + "failed to load DMA'able memory for RX list\n"); + goto fail; + } + /* TX descriptor list. */ + error = bus_dmamem_alloc(sc->dc_tx_ltag, + (void **)&sc->dc_ldata.dc_tx_list, BUS_DMA_NOWAIT | + BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->dc_tx_lmap); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate DMA'able memory for TX list\n"); + goto fail; + } + error = bus_dmamap_load(sc->dc_tx_ltag, sc->dc_tx_lmap, + sc->dc_ldata.dc_tx_list, DC_TX_LIST_SZ, dc_dma_map_addr, + &sc->dc_ldata.dc_tx_list_paddr, BUS_DMA_NOWAIT); + if (error) { + device_printf(sc->dc_dev, + "cannot load DMA'able memory for TX list\n"); + goto fail; + } + + /* + * Allocate a busdma tag and DMA safe memory for the multicast + * setup frame. + */ + error = bus_dma_tag_create(sc->dc_ptag, DC_LIST_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, + DC_SFRAME_LEN + DC_MIN_FRAMELEN, 1, DC_SFRAME_LEN + DC_MIN_FRAMELEN, + 0, NULL, NULL, &sc->dc_stag); + if (error) { + device_printf(sc->dc_dev, + "failed to create DMA tag for setup frame\n"); + goto fail; + } + error = bus_dmamem_alloc(sc->dc_stag, (void **)&sc->dc_cdata.dc_sbuf, + BUS_DMA_NOWAIT, &sc->dc_smap); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate DMA'able memory for setup frame\n"); + goto fail; + } + error = bus_dmamap_load(sc->dc_stag, sc->dc_smap, sc->dc_cdata.dc_sbuf, + DC_SFRAME_LEN, dc_dma_map_addr, &sc->dc_saddr, BUS_DMA_NOWAIT); + if (error) { + device_printf(sc->dc_dev, + "cannot load DMA'able memory for setup frame\n"); + goto fail; + } + + /* Allocate a busdma tag for RX mbufs. */ + error = bus_dma_tag_create(sc->dc_ptag, DC_RXBUF_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, + MCLBYTES, 1, MCLBYTES, 0, NULL, NULL, &sc->dc_rx_mtag); + if (error) { + device_printf(sc->dc_dev, "failed to create RX mbuf tag\n"); + goto fail; + } + + /* Allocate a busdma tag for TX mbufs. */ + error = bus_dma_tag_create(sc->dc_ptag, 1, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, + MCLBYTES * DC_MAXFRAGS, DC_MAXFRAGS, MCLBYTES, + 0, NULL, NULL, &sc->dc_tx_mtag); + if (error) { + device_printf(sc->dc_dev, "failed to create TX mbuf tag\n"); + goto fail; + } + + /* Create the TX/RX busdma maps. */ + for (i = 0; i < DC_TX_LIST_CNT; i++) { + error = bus_dmamap_create(sc->dc_tx_mtag, 0, + &sc->dc_cdata.dc_tx_map[i]); + if (error) { + device_printf(sc->dc_dev, + "failed to create TX mbuf dmamap\n"); + goto fail; + } + } + for (i = 0; i < DC_RX_LIST_CNT; i++) { + error = bus_dmamap_create(sc->dc_rx_mtag, 0, + &sc->dc_cdata.dc_rx_map[i]); + if (error) { + device_printf(sc->dc_dev, + "failed to create RX mbuf dmamap\n"); + goto fail; + } + } + error = bus_dmamap_create(sc->dc_rx_mtag, 0, &sc->dc_sparemap); + if (error) { + device_printf(sc->dc_dev, + "failed to create spare RX mbuf dmamap\n"); + goto fail; + } + +fail: + return (error); +} + +static void +dc_dma_free(struct dc_softc *sc) +{ + int i; + + /* RX buffers. */ + if (sc->dc_rx_mtag != NULL) { + for (i = 0; i < DC_RX_LIST_CNT; i++) { + if (sc->dc_cdata.dc_rx_map[i] != NULL) + bus_dmamap_destroy(sc->dc_rx_mtag, + sc->dc_cdata.dc_rx_map[i]); + } + if (sc->dc_sparemap != NULL) + bus_dmamap_destroy(sc->dc_rx_mtag, sc->dc_sparemap); + bus_dma_tag_destroy(sc->dc_rx_mtag); + } + + /* TX buffers. */ + if (sc->dc_rx_mtag != NULL) { + for (i = 0; i < DC_TX_LIST_CNT; i++) { + if (sc->dc_cdata.dc_tx_map[i] != NULL) + bus_dmamap_destroy(sc->dc_tx_mtag, + sc->dc_cdata.dc_tx_map[i]); + } + bus_dma_tag_destroy(sc->dc_tx_mtag); + } + + /* RX descriptor list. */ + if (sc->dc_rx_ltag) { + if (sc->dc_rx_lmap != NULL) + bus_dmamap_unload(sc->dc_rx_ltag, sc->dc_rx_lmap); + if (sc->dc_rx_lmap != NULL && sc->dc_ldata.dc_rx_list != NULL) + bus_dmamem_free(sc->dc_rx_ltag, sc->dc_ldata.dc_rx_list, + sc->dc_rx_lmap); + bus_dma_tag_destroy(sc->dc_rx_ltag); + } + + /* TX descriptor list. */ + if (sc->dc_tx_ltag) { + if (sc->dc_tx_lmap != NULL) + bus_dmamap_unload(sc->dc_tx_ltag, sc->dc_tx_lmap); + if (sc->dc_tx_lmap != NULL && sc->dc_ldata.dc_tx_list != NULL) + bus_dmamem_free(sc->dc_tx_ltag, sc->dc_ldata.dc_tx_list, + sc->dc_tx_lmap); + bus_dma_tag_destroy(sc->dc_tx_ltag); + } + + /* multicast setup frame. */ + if (sc->dc_stag) { + if (sc->dc_smap != NULL) + bus_dmamap_unload(sc->dc_stag, sc->dc_smap); + if (sc->dc_smap != NULL && sc->dc_cdata.dc_sbuf != NULL) + bus_dmamem_free(sc->dc_stag, sc->dc_cdata.dc_sbuf, + sc->dc_smap); + bus_dma_tag_destroy(sc->dc_stag); + } +} + /* * Attach the interface. Allocate softc structures, do ifmedia * setup and ethernet/BPF attach. @@ -1827,7 +2036,7 @@ dc_attach(device_t dev) struct ifnet *ifp; struct dc_mediainfo *m; u_int32_t reg, revision; - int error, i, mac_offset, phy, rid, tmp; + int error, mac_offset, phy, rid, tmp; u_int8_t *mac; sc = device_get_softc(dev); @@ -2139,96 +2348,8 @@ dc_attach(device_t dev) error = 0; } - /* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */ - error = bus_dma_tag_create(bus_get_dma_tag(dev), PAGE_SIZE, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - sizeof(struct dc_list_data), 1, sizeof(struct dc_list_data), - 0, NULL, NULL, &sc->dc_ltag); - if (error) { - device_printf(dev, "failed to allocate busdma tag\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamem_alloc(sc->dc_ltag, (void **)&sc->dc_ldata, - BUS_DMA_NOWAIT | BUS_DMA_ZERO, &sc->dc_lmap); - if (error) { - device_printf(dev, "failed to allocate DMA safe memory\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamap_load(sc->dc_ltag, sc->dc_lmap, sc->dc_ldata, - sizeof(struct dc_list_data), dc_dma_map_addr, &sc->dc_laddr, - BUS_DMA_NOWAIT); - if (error) { - device_printf(dev, "cannot get address of the descriptors\n"); - error = ENXIO; + if ((error = dc_dma_alloc(sc)) != 0) goto fail; - } - - /* - * Allocate a busdma tag and DMA safe memory for the multicast - * setup frame. - */ - error = bus_dma_tag_create(bus_get_dma_tag(dev), PAGE_SIZE, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - DC_SFRAME_LEN + DC_MIN_FRAMELEN, 1, DC_SFRAME_LEN + DC_MIN_FRAMELEN, - 0, NULL, NULL, &sc->dc_stag); - if (error) { - device_printf(dev, "failed to allocate busdma tag\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamem_alloc(sc->dc_stag, (void **)&sc->dc_cdata.dc_sbuf, - BUS_DMA_NOWAIT, &sc->dc_smap); - if (error) { - device_printf(dev, "failed to allocate DMA safe memory\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamap_load(sc->dc_stag, sc->dc_smap, sc->dc_cdata.dc_sbuf, - DC_SFRAME_LEN, dc_dma_map_addr, &sc->dc_saddr, BUS_DMA_NOWAIT); - if (error) { - device_printf(dev, "cannot get address of the descriptors\n"); - error = ENXIO; - goto fail; - } - - /* Allocate a busdma tag for mbufs. */ - error = bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - MCLBYTES * DC_MAXFRAGS, DC_MAXFRAGS, MCLBYTES, - 0, NULL, NULL, &sc->dc_mtag); - if (error) { - device_printf(dev, "failed to allocate busdma tag\n"); - error = ENXIO; - goto fail; - } - - /* Create the TX/RX busdma maps. */ - for (i = 0; i < DC_TX_LIST_CNT; i++) { - error = bus_dmamap_create(sc->dc_mtag, 0, - &sc->dc_cdata.dc_tx_map[i]); - if (error) { - device_printf(dev, "failed to init TX ring\n"); - error = ENXIO; - goto fail; - } - } - for (i = 0; i < DC_RX_LIST_CNT; i++) { - error = bus_dmamap_create(sc->dc_mtag, 0, - &sc->dc_cdata.dc_rx_map[i]); - if (error) { - device_printf(dev, "failed to init RX ring\n"); - error = ENXIO; - goto fail; - } - } - error = bus_dmamap_create(sc->dc_mtag, 0, &sc->dc_sparemap); - if (error) { - device_printf(dev, "failed to init RX ring\n"); - error = ENXIO; - goto fail; - } ifp = sc->dc_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { @@ -2377,7 +2498,6 @@ dc_detach(device_t dev) struct dc_softc *sc; struct ifnet *ifp; struct dc_mediainfo *m; - int i; sc = device_get_softc(dev); KASSERT(mtx_initialized(&sc->dc_mtx), ("dc mutex not initialized")); @@ -2412,27 +2532,7 @@ dc_detach(device_t dev) if (ifp) if_free(ifp); - if (sc->dc_cdata.dc_sbuf != NULL) - bus_dmamem_free(sc->dc_stag, sc->dc_cdata.dc_sbuf, sc->dc_smap); - if (sc->dc_ldata != NULL) - bus_dmamem_free(sc->dc_ltag, sc->dc_ldata, sc->dc_lmap); - if (sc->dc_mtag) { - for (i = 0; i < DC_TX_LIST_CNT; i++) - if (sc->dc_cdata.dc_tx_map[i] != NULL) - bus_dmamap_destroy(sc->dc_mtag, - sc->dc_cdata.dc_tx_map[i]); - for (i = 0; i < DC_RX_LIST_CNT; i++) - if (sc->dc_cdata.dc_rx_map[i] != NULL) - bus_dmamap_destroy(sc->dc_mtag, - sc->dc_cdata.dc_rx_map[i]); - bus_dmamap_destroy(sc->dc_mtag, sc->dc_sparemap); - } - if (sc->dc_stag) - bus_dma_tag_destroy(sc->dc_stag); - if (sc->dc_mtag) - bus_dma_tag_destroy(sc->dc_mtag); - if (sc->dc_ltag) - bus_dma_tag_destroy(sc->dc_ltag); + dc_dma_free(sc); free(sc->dc_pnic_rx_buf, M_DEVBUF); @@ -2459,7 +2559,7 @@ dc_list_tx_init(struct dc_softc *sc) int i, nexti; cd = &sc->dc_cdata; - ld = sc->dc_ldata; + ld = &sc->dc_ldata; for (i = 0; i < DC_TX_LIST_CNT; i++) { if (i == DC_TX_LIST_CNT - 1) nexti = 0; @@ -2474,7 +2574,7 @@ dc_list_tx_init(struct dc_softc *sc) cd->dc_tx_prod = cd->dc_tx_cons = cd->dc_tx_cnt = 0; cd->dc_tx_pkts = 0; - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, + bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -2493,10 +2593,10 @@ dc_list_rx_init(struct dc_softc *sc) int i, nexti; cd = &sc->dc_cdata; - ld = sc->dc_ldata; + ld = &sc->dc_ldata; for (i = 0; i < DC_RX_LIST_CNT; i++) { - if (dc_newbuf(sc, i, 1) != 0) + if (dc_newbuf(sc, i) != 0) return (ENOBUFS); if (i == DC_RX_LIST_CNT - 1) nexti = 0; @@ -2506,7 +2606,7 @@ dc_list_rx_init(struct dc_softc *sc) } cd->dc_rx_prod = 0; - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -2515,23 +2615,18 @@ dc_list_rx_init(struct dc_softc *sc) * Initialize an RX descriptor and attach an MBUF cluster. */ static int -dc_newbuf(struct dc_softc *sc, int i, int alloc) +dc_newbuf(struct dc_softc *sc, int i) { - struct mbuf *m_new; - bus_dmamap_t tmp; + struct mbuf *m; + bus_dmamap_t map; bus_dma_segment_t segs[1]; int error, nseg; - if (alloc) { - m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); - if (m_new == NULL) - return (ENOBUFS); - } else { - m_new = sc->dc_cdata.dc_rx_chain[i]; - m_new->m_data = m_new->m_ext.ext_buf; - } - m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; - m_adj(m_new, sizeof(u_int64_t)); + m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if (m == NULL) + return (ENOBUFS); + m->m_len = m->m_pkthdr.len = MCLBYTES; + m_adj(m, sizeof(u_int64_t)); /* * If this is a PNIC chip, zero the buffer. This is part @@ -2539,31 +2634,31 @@ dc_newbuf(struct dc_softc *sc, int i, in * 82c169 chips. */ if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) - bzero(mtod(m_new, char *), m_new->m_len); + bzero(mtod(m, char *), m->m_len); - /* No need to remap the mbuf if we're reusing it. */ - if (alloc) { - error = bus_dmamap_load_mbuf_sg(sc->dc_mtag, sc->dc_sparemap, - m_new, segs, &nseg, 0); - if (error) { - m_freem(m_new); - return (error); - } - KASSERT(nseg == 1, - ("%s: wrong number of segments (%d)", __func__, nseg)); - sc->dc_ldata->dc_rx_list[i].dc_data = htole32(segs->ds_addr); - bus_dmamap_unload(sc->dc_mtag, sc->dc_cdata.dc_rx_map[i]); - tmp = sc->dc_cdata.dc_rx_map[i]; - sc->dc_cdata.dc_rx_map[i] = sc->dc_sparemap; - sc->dc_sparemap = tmp; - sc->dc_cdata.dc_rx_chain[i] = m_new; + error = bus_dmamap_load_mbuf_sg(sc->dc_rx_mtag, sc->dc_sparemap, + m, segs, &nseg, 0); + if (error) { + m_freem(m); + return (error); } - - sc->dc_ldata->dc_rx_list[i].dc_ctl = htole32(DC_RXCTL_RLINK | DC_RXLEN); - sc->dc_ldata->dc_rx_list[i].dc_status = htole32(DC_RXSTAT_OWN); - bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_rx_map[i], + KASSERT(nseg == 1, ("%s: wrong number of segments (%d)", __func__, + nseg)); + if (sc->dc_cdata.dc_rx_chain[i] != NULL) + bus_dmamap_unload(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i]); + + map = sc->dc_cdata.dc_rx_map[i]; + sc->dc_cdata.dc_rx_map[i] = sc->dc_sparemap; + sc->dc_sparemap = map; + sc->dc_cdata.dc_rx_chain[i] = m; + bus_dmamap_sync(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i], BUS_DMASYNC_PREREAD); - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, + + sc->dc_ldata.dc_rx_list[i].dc_ctl = htole32(DC_RXCTL_RLINK | DC_RXLEN); + sc->dc_ldata.dc_rx_list[i].dc_data = + htole32(DC_ADDR_LO(segs[0].ds_addr)); + sc->dc_ldata.dc_rx_list[i].dc_status = htole32(DC_RXSTAT_OWN); + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -2632,13 +2727,13 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, u_int32_t rxstat = 0; i = sc->dc_pnic_rx_bug_save; - cur_rx = &sc->dc_ldata->dc_rx_list[idx]; + cur_rx = &sc->dc_ldata.dc_rx_list[idx]; ptr = sc->dc_pnic_rx_buf; bzero(ptr, DC_RXLEN * 5); /* Copy all the bytes from the bogus buffers. */ while (1) { - c = &sc->dc_ldata->dc_rx_list[i]; + c = &sc->dc_ldata.dc_rx_list[i]; rxstat = le32toh(c->dc_status); m = sc->dc_cdata.dc_rx_chain[i]; bcopy(mtod(m, char *), ptr, DC_RXLEN); @@ -2646,7 +2741,7 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, /* If this is the last buffer, break out. */ if (i == idx || rxstat & DC_RXSTAT_LASTFRAG) break; - dc_newbuf(sc, i, 0); + dc_discard_rxbuf(sc, i); DC_INC(i, DC_RX_LIST_CNT); } @@ -2695,7 +2790,9 @@ dc_rx_resync(struct dc_softc *sc) pos = sc->dc_cdata.dc_rx_prod; for (i = 0; i < DC_RX_LIST_CNT; i++) { - cur_rx = &sc->dc_ldata->dc_rx_list[pos]; + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, + BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); + cur_rx = &sc->dc_ldata.dc_rx_list[pos]; if (!(le32toh(cur_rx->dc_status) & DC_RXSTAT_OWN)) break; DC_INC(pos, DC_RX_LIST_CNT); @@ -2711,6 +2808,22 @@ dc_rx_resync(struct dc_softc *sc) return (EAGAIN); } +static void +dc_discard_rxbuf(struct dc_softc *sc, int i) +{ + struct mbuf *m; + + if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) { + m = sc->dc_cdata.dc_rx_chain[i]; + bzero(mtod(m, char *), m->m_len); + } + + sc->dc_ldata.dc_rx_list[i].dc_ctl = htole32(DC_RXCTL_RLINK | DC_RXLEN); + sc->dc_ldata.dc_rx_list[i].dc_status = htole32(DC_RXSTAT_OWN); + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_PREREAD | + BUS_DMASYNC_PREWRITE); +} + /* * A frame has been uploaded: pass the resulting mbuf chain up to * the higher level protocols. @@ -2718,7 +2831,7 @@ dc_rx_resync(struct dc_softc *sc) static int dc_rxeof(struct dc_softc *sc) { - struct mbuf *m, *m0; + struct mbuf *m; struct ifnet *ifp; struct dc_desc *cur_rx; int i, total_len, rx_npkts; @@ -2727,13 +2840,13 @@ dc_rxeof(struct dc_softc *sc) DC_LOCK_ASSERT(sc); ifp = sc->dc_ifp; - i = sc->dc_cdata.dc_rx_prod; - total_len = 0; rx_npkts = 0; - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, BUS_DMASYNC_POSTREAD); - while (!(le32toh(sc->dc_ldata->dc_rx_list[i].dc_status) & - DC_RXSTAT_OWN)) { + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_POSTREAD | + BUS_DMASYNC_POSTWRITE); + for (i = sc->dc_cdata.dc_rx_prod; + (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0; + DC_INC(i, DC_RX_LIST_CNT)) { #ifdef DEVICE_POLLING if (ifp->if_capenable & IFCAP_POLLING) { if (sc->rxcycles <= 0) @@ -2741,10 +2854,12 @@ dc_rxeof(struct dc_softc *sc) sc->rxcycles--; } #endif - cur_rx = &sc->dc_ldata->dc_rx_list[i]; + cur_rx = &sc->dc_ldata.dc_rx_list[i]; rxstat = le32toh(cur_rx->dc_status); + if ((rxstat & DC_RXSTAT_OWN) != 0) + break; m = sc->dc_cdata.dc_rx_chain[i]; - bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_rx_map[i], + bus_dmamap_sync(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i], BUS_DMASYNC_POSTREAD); total_len = DC_RXBYTES(rxstat); @@ -2752,10 +2867,8 @@ dc_rxeof(struct dc_softc *sc) if ((rxstat & DC_WHOLEFRAME) != DC_WHOLEFRAME) { if (rxstat & DC_RXSTAT_FIRSTFRAG) sc->dc_pnic_rx_bug_save = i; - if ((rxstat & DC_RXSTAT_LASTFRAG) == 0) { - DC_INC(i, DC_RX_LIST_CNT); + if ((rxstat & DC_RXSTAT_LASTFRAG) == 0) continue; - } dc_pnic_rx_bug_war(sc, i); rxstat = le32toh(cur_rx->dc_status); total_len = DC_RXBYTES(rxstat); @@ -2777,11 +2890,10 @@ dc_rxeof(struct dc_softc *sc) ifp->if_ierrors++; if (rxstat & DC_RXSTAT_COLLSEEN) ifp->if_collisions++; - dc_newbuf(sc, i, 0); - if (rxstat & DC_RXSTAT_CRCERR) { - DC_INC(i, DC_RX_LIST_CNT); + dc_discard_rxbuf(sc, i); + if (rxstat & DC_RXSTAT_CRCERR) continue; - } else { + else { dc_init_locked(sc); return (rx_npkts); } @@ -2800,23 +2912,27 @@ dc_rxeof(struct dc_softc *sc) * if the allocation fails, then use m_devget and leave the * existing buffer in the receive ring. */ - if (dc_newbuf(sc, i, 1) == 0) { - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = m->m_len = total_len; - DC_INC(i, DC_RX_LIST_CNT); - } else -#endif + if (dc_newbuf(sc, i) != 0) { + dc_discard_rxbuf(sc, i); + ifp->if_iqdrops++; + continue; + } + m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.len = m->m_len = total_len; +#else { + struct mbuf *m0; + m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, ifp, NULL); - dc_newbuf(sc, i, 0); - DC_INC(i, DC_RX_LIST_CNT); + dc_discard_rxbuf(sc, i); if (m0 == NULL) { - ifp->if_ierrors++; + ifp->if_iqdrops++; continue; } m = m0; } +#endif ifp->if_ipackets++; DC_UNLOCK(sc); @@ -2836,9 +2952,9 @@ dc_rxeof(struct dc_softc *sc) static void dc_txeof(struct dc_softc *sc) { - struct dc_desc *cur_tx = NULL; + struct dc_desc *cur_tx; struct ifnet *ifp; - int idx; + int idx, setup; u_int32_t ctl, txstat; if (sc->dc_cdata.dc_tx_cnt == 0) @@ -2850,36 +2966,40 @@ dc_txeof(struct dc_softc *sc) * Go through our tx list and free mbufs for those * frames that have been transmitted. */ - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, BUS_DMASYNC_POSTREAD); - idx = sc->dc_cdata.dc_tx_cons; - while (idx != sc->dc_cdata.dc_tx_prod) { - - cur_tx = &sc->dc_ldata->dc_tx_list[idx]; + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_tx_lmap, BUS_DMASYNC_POSTREAD | + BUS_DMASYNC_POSTWRITE); + setup = 0; + for (idx = sc->dc_cdata.dc_tx_cons; idx != sc->dc_cdata.dc_tx_prod; + DC_INC(idx, DC_TX_LIST_CNT), sc->dc_cdata.dc_tx_cnt--) { + cur_tx = &sc->dc_ldata.dc_tx_list[idx]; txstat = le32toh(cur_tx->dc_status); ctl = le32toh(cur_tx->dc_ctl); if (txstat & DC_TXSTAT_OWN) break; - if (!(ctl & DC_TXCTL_LASTFRAG) || ctl & DC_TXCTL_SETUP) { - if (ctl & DC_TXCTL_SETUP) { - /* - * Yes, the PNIC is so brain damaged - * that it will sometimes generate a TX - * underrun error while DMAing the RX - * filter setup frame. If we detect this, - * we have to send the setup frame again, - * or else the filter won't be programmed - * correctly. - */ - if (DC_IS_PNIC(sc)) { - if (txstat & DC_TXSTAT_ERRSUM) - dc_setfilt(sc); - } - sc->dc_cdata.dc_tx_chain[idx] = NULL; + if (sc->dc_cdata.dc_tx_chain[idx] == NULL) + continue; + + if (ctl & DC_TXCTL_SETUP) { + cur_tx->dc_ctl = htole32(ctl & ~DC_TXCTL_SETUP); + setup++; + bus_dmamap_sync(sc->dc_stag, sc->dc_smap, + BUS_DMASYNC_POSTWRITE); + /* + * Yes, the PNIC is so brain damaged + * that it will sometimes generate a TX + * underrun error while DMAing the RX + * filter setup frame. If we detect this, + * we have to send the setup frame again, + * or else the filter won't be programmed + * correctly. + */ + if (DC_IS_PNIC(sc)) { + if (txstat & DC_TXSTAT_ERRSUM) + dc_setfilt(sc); } - sc->dc_cdata.dc_tx_cnt--; - DC_INC(idx, DC_TX_LIST_CNT); + sc->dc_cdata.dc_tx_chain[idx] = NULL; continue; } @@ -2919,26 +3039,22 @@ dc_txeof(struct dc_softc *sc) ifp->if_opackets++; ifp->if_collisions += (txstat & DC_TXSTAT_COLLCNT) >> 3; - if (sc->dc_cdata.dc_tx_chain[idx] != NULL) { - bus_dmamap_sync(sc->dc_mtag, - sc->dc_cdata.dc_tx_map[idx], - BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(sc->dc_mtag, - sc->dc_cdata.dc_tx_map[idx]); - m_freem(sc->dc_cdata.dc_tx_chain[idx]); - sc->dc_cdata.dc_tx_chain[idx] = NULL; - } - - sc->dc_cdata.dc_tx_cnt--; - DC_INC(idx, DC_TX_LIST_CNT); + bus_dmamap_sync(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], + BUS_DMASYNC_POSTWRITE); + bus_dmamap_unload(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx]); + m_freem(sc->dc_cdata.dc_tx_chain[idx]); + sc->dc_cdata.dc_tx_chain[idx] = NULL; } sc->dc_cdata.dc_tx_cons = idx; - if (DC_TX_LIST_CNT - sc->dc_cdata.dc_tx_cnt > DC_TX_LIST_RSVD) + if (sc->dc_cdata.dc_tx_cnt <= DC_TX_LIST_CNT - DC_TX_LIST_RSVD) { ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - - if (sc->dc_cdata.dc_tx_cnt == 0) - sc->dc_wdog_timer = 0; + if (sc->dc_cdata.dc_tx_cnt == 0) + sc->dc_wdog_timer = 0; + } + if (setup > 0) + bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); } static void @@ -3226,16 +3342,11 @@ static int dc_encap(struct dc_softc *sc, struct mbuf **m_head) { bus_dma_segment_t segs[DC_MAXFRAGS]; + bus_dmamap_t map; struct dc_desc *f; struct mbuf *m; int cur, defragged, error, first, frag, i, idx, nseg; - /* - * If there's no way we can send any packets, return now. - */ - if (DC_TX_LIST_CNT - sc->dc_cdata.dc_tx_cnt <= DC_TX_LIST_RSVD) - return (ENOBUFS); - m = NULL; defragged = 0; if (sc->dc_flags & DC_TX_COALESCE && @@ -3269,7 +3380,7 @@ dc_encap(struct dc_softc *sc, struct mbu } idx = sc->dc_cdata.dc_tx_prod; - error = bus_dmamap_load_mbuf_sg(sc->dc_mtag, + error = bus_dmamap_load_mbuf_sg(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], *m_head, segs, &nseg, 0); if (error == EFBIG) { if (defragged != 0 || (m = m_collapse(*m_head, M_DONTWAIT, @@ -3279,7 +3390,7 @@ dc_encap(struct dc_softc *sc, struct mbu return (defragged != 0 ? error : ENOBUFS); } *m_head = m; - error = bus_dmamap_load_mbuf_sg(sc->dc_mtag, + error = bus_dmamap_load_mbuf_sg(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], *m_head, segs, &nseg, 0); if (error != 0) { m_freem(*m_head); @@ -3296,26 +3407,34 @@ dc_encap(struct dc_softc *sc, struct mbu return (EIO); } + /* Check descriptor overruns. */ + if (sc->dc_cdata.dc_tx_cnt + nseg > DC_TX_LIST_CNT - DC_TX_LIST_RSVD) { + bus_dmamap_unload(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx]); + return (ENOBUFS); + } + bus_dmamap_sync(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], + BUS_DMASYNC_PREWRITE); + first = cur = frag = sc->dc_cdata.dc_tx_prod; for (i = 0; i < nseg; i++) { if ((sc->dc_flags & DC_TX_ADMTEK_WAR) && (frag == (DC_TX_LIST_CNT - 1)) && (first != sc->dc_cdata.dc_tx_first)) { - bus_dmamap_unload(sc->dc_mtag, + bus_dmamap_unload(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[first]); m_freem(*m_head); *m_head = NULL; return (ENOBUFS); } - f = &sc->dc_ldata->dc_tx_list[frag]; + f = &sc->dc_ldata.dc_tx_list[frag]; f->dc_ctl = htole32(DC_TXCTL_TLINK | segs[i].ds_len); if (i == 0) { f->dc_status = 0; f->dc_ctl |= htole32(DC_TXCTL_FIRSTFRAG); } else f->dc_status = htole32(DC_TXSTAT_OWN); - f->dc_data = htole32(segs[i].ds_addr); + f->dc_data = htole32(DC_ADDR_LO(segs[i].ds_addr)); cur = frag; DC_INC(frag, DC_TX_LIST_CNT); } @@ -3323,23 +3442,30 @@ dc_encap(struct dc_softc *sc, struct mbu sc->dc_cdata.dc_tx_prod = frag; sc->dc_cdata.dc_tx_cnt += nseg; sc->dc_cdata.dc_tx_chain[cur] = *m_head; - sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_LASTFRAG); + sc->dc_ldata.dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_LASTFRAG); if (sc->dc_flags & DC_TX_INTR_FIRSTFRAG) - sc->dc_ldata->dc_tx_list[first].dc_ctl |= + sc->dc_ldata.dc_tx_list[first].dc_ctl |= htole32(DC_TXCTL_FINT); if (sc->dc_flags & DC_TX_INTR_ALWAYS) - sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); + sc->dc_ldata.dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); if (sc->dc_flags & DC_TX_USE_TX_INTR && ++sc->dc_cdata.dc_tx_pkts >= 8) { sc->dc_cdata.dc_tx_pkts = 0; - sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); + sc->dc_ldata.dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); } - sc->dc_ldata->dc_tx_list[first].dc_status = htole32(DC_TXSTAT_OWN); + sc->dc_ldata.dc_tx_list[first].dc_status = htole32(DC_TXSTAT_OWN); + + bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + + /* + * Swap the last and the first dmamaps to ensure the map for + * this transmission is placed at the last descriptor. + */ + map = sc->dc_cdata.dc_tx_map[cur]; + sc->dc_cdata.dc_tx_map[cur] = sc->dc_cdata.dc_tx_map[first]; + sc->dc_cdata.dc_tx_map[first] = map; - bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_tx_map[idx], - BUS_DMASYNC_PREWRITE); - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, - BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -3365,9 +3491,8 @@ static void dc_start_locked(struct ifnet *ifp) { struct dc_softc *sc; - struct mbuf *m_head = NULL; - unsigned int queued = 0; - int idx; + struct mbuf *m_head; + int queued; sc = ifp->if_softc; @@ -3377,9 +3502,16 @@ dc_start_locked(struct ifnet *ifp) IFF_DRV_RUNNING || sc->dc_link == 0) return; - idx = sc->dc_cdata.dc_tx_first = sc->dc_cdata.dc_tx_prod; + sc->dc_cdata.dc_tx_first = sc->dc_cdata.dc_tx_prod; - while (sc->dc_cdata.dc_tx_chain[idx] == NULL) { + for (queued = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd); ) { + /* + * If there's no way we can send any packets, return now. + */ + if (sc->dc_cdata.dc_tx_cnt > DC_TX_LIST_CNT - DC_TX_LIST_RSVD) { + ifp->if_drv_flags |= IFF_DRV_OACTIVE; + break; + } IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -3391,7 +3523,6 @@ dc_start_locked(struct ifnet *ifp) ifp->if_drv_flags |= IFF_DRV_OACTIVE; break; } - idx = sc->dc_cdata.dc_tx_prod; queued++; /* @@ -3778,7 +3909,7 @@ dc_stop(struct dc_softc *sc) DC_LOCK_ASSERT(sc); ifp = sc->dc_ifp; - ld = sc->dc_ldata; + ld = &sc->dc_ldata; cd = &sc->dc_cdata; callout_stop(&sc->dc_stat_ch); @@ -3798,11 +3929,17 @@ dc_stop(struct dc_softc *sc) */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 22:50:10 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 437801065674; Sun, 27 Mar 2011 22:50:10 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2FA528FC1B; Sun, 27 Mar 2011 22:50:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMoASR071776; Sun, 27 Mar 2011 22:50:10 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMoAgH071773; Sun, 27 Mar 2011 22:50:10 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272250.p2RMoAgH071773@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:50:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220073 - stable/7/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:50:10 -0000 Author: yongari Date: Sun Mar 27 22:50:09 2011 New Revision: 220073 URL: http://svn.freebsd.org/changeset/base/220073 Log: MFC r218832: Split common TX/RX descriptor DMA tag to TX and RX DMA tags respectively and fix all bus_dma(9) issues seen when bounce buffers are used. o Setup frame handling had no bus_dmamap_sync(9) which prevented driver from configuring RX filter. Add missing bus_dmamap_sync(9) in both dc_setfilt_21143()/dc_setfilt_xircom() and dc_txeof(). o Use bus_addr_t for DMA segment instead of using u_int32_t. o Introduce dc_dma_alloc()/dc_dma_free() functions to allocate/free DMA'able memory. o Create two DMA descriptor list for each TX/RX lists. This change will minimize the size of bounce buffers that would be used in each TX/RX path. Previously driver had to copy both TX/RX lists when bounce buffer is active. o 21143 data sheet says descriptor list requires 4 bytes alignment. Remove PAGE_SIZE alignment restriction and use sizeof(struct dc_dec). o Setup frame requires 4 bytes alignment. Remove PAGE_SIZE alignment restriction and use sizeof(struct dc_dec). o Add missing DMA map unload for both setup frame and TX/RX descriptor list. o Overhaul RX handling logic such that make driver always allocate new RX buffer with dc_newbuf(). Previously driver allowed to copy received frame with m_devget(9) after passing the descriptor ownership to controller. This can lead to passing wrong frame to upper stack. o Introduce dc_discard_rxbuf() which will discard received frame and reuse loaded DMA map and RX mbuf. o Correct several wrong bus_dmamap_sync(9) usage in dc_rxeof and dc_txeof. The TX/RX descriptor lists are updated by both driver and HW so READ/WRITE semantics should be used. o If driver failed to allocate new RX buffer, update if_iqdrops counter instead of if_ierrors since driver received the frame without errors. o Make sure to unload loaded setup frame DMA map in dc_txeof and clear the mark of setup frame of the TX descriptor in dc_txeof(). o Add check for possible TX descriptor overruns in dc_encap() and move check for free buffer to caller, dc_start_locked(). o Swap the loaded DMA map and the last DMA map for multi-segmented frames. Since dc_txeof() assumes the last descriptor of the frame has the DMA map, driver should swap the first and the last DMA map in dc_encap(). Previously driver tried to unload not-yet-loaded DMA map such that the loaded DMA map was not unloaded at all for multi-segmented frames. o Rewrite DC_RXDESC/DC_TXDESC macro to simpler one. o Remove definition of ETHER_ALIGN, it's already defined in ethernet.h. With this changes, dc(4) works with bounce buffers and it shall also fix issues which might have shown in PAE environments. Tested by: marius Modified: stable/7/sys/dev/dc/if_dc.c stable/7/sys/dev/dc/if_dcreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:48:58 2011 (r220072) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:50:09 2011 (r220073) @@ -233,7 +233,8 @@ static int dc_detach(device_t); static int dc_suspend(device_t); static int dc_resume(device_t); static const struct dc_type *dc_devtype(device_t); -static int dc_newbuf(struct dc_softc *, int, int); +static void dc_discard_rxbuf(struct dc_softc *, int); +static int dc_newbuf(struct dc_softc *, int); static int dc_encap(struct dc_softc *, struct mbuf **); static void dc_pnic_rx_bug_war(struct dc_softc *, int); static int dc_rx_resync(struct dc_softc *); @@ -253,6 +254,10 @@ static int dc_shutdown(device_t); static int dc_ifmedia_upd(struct ifnet *); static void dc_ifmedia_sts(struct ifnet *, struct ifmediareq *); +static int dc_dma_alloc(struct dc_softc *); +static void dc_dma_free(struct dc_softc *); +static void dc_dma_map_addr(void *, bus_dma_segment_t *, int, int); + static void dc_delay(struct dc_softc *); static void dc_eeprom_idle(struct dc_softc *); static void dc_eeprom_putbyte(struct dc_softc *, int); @@ -1088,11 +1093,11 @@ dc_setfilt_21143(struct dc_softc *sc) i = sc->dc_cdata.dc_tx_prod; DC_INC(sc->dc_cdata.dc_tx_prod, DC_TX_LIST_CNT); sc->dc_cdata.dc_tx_cnt++; - sframe = &sc->dc_ldata->dc_tx_list[i]; + sframe = &sc->dc_ldata.dc_tx_list[i]; sp = sc->dc_cdata.dc_sbuf; bzero(sp, DC_SFRAME_LEN); - sframe->dc_data = htole32(sc->dc_saddr); + sframe->dc_data = htole32(DC_ADDR_LO(sc->dc_saddr)); sframe->dc_ctl = htole32(DC_SFRAME_LEN | DC_TXCTL_SETUP | DC_TXCTL_TLINK | DC_FILTER_HASHPERF | DC_TXCTL_FINT); @@ -1131,6 +1136,7 @@ dc_setfilt_21143(struct dc_softc *sc) sp[41] = DC_SP_MAC(eaddr[2]); sframe->dc_status = htole32(DC_TXSTAT_OWN); + bus_dmamap_sync(sc->dc_stag, sc->dc_smap, BUS_DMASYNC_PREWRITE); CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF); /* @@ -1291,11 +1297,11 @@ dc_setfilt_xircom(struct dc_softc *sc) i = sc->dc_cdata.dc_tx_prod; DC_INC(sc->dc_cdata.dc_tx_prod, DC_TX_LIST_CNT); sc->dc_cdata.dc_tx_cnt++; - sframe = &sc->dc_ldata->dc_tx_list[i]; + sframe = &sc->dc_ldata.dc_tx_list[i]; sp = sc->dc_cdata.dc_sbuf; bzero(sp, DC_SFRAME_LEN); - sframe->dc_data = htole32(sc->dc_saddr); + sframe->dc_data = htole32(DC_ADDR_LO(sc->dc_saddr)); sframe->dc_ctl = htole32(DC_SFRAME_LEN | DC_TXCTL_SETUP | DC_TXCTL_TLINK | DC_FILTER_HASHPERF | DC_TXCTL_FINT); @@ -1336,6 +1342,7 @@ dc_setfilt_xircom(struct dc_softc *sc) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON); sframe->dc_status = htole32(DC_TXSTAT_OWN); + bus_dmamap_sync(sc->dc_stag, sc->dc_smap, BUS_DMASYNC_PREWRITE); CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF); /* @@ -1807,7 +1814,7 @@ dc_parse_21143_srom(struct dc_softc *sc) static void dc_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error) { - u_int32_t *paddr; + bus_addr_t *paddr; KASSERT(nseg == 1, ("%s: wrong number of segments (%d)", __func__, nseg)); @@ -1815,6 +1822,208 @@ dc_dma_map_addr(void *arg, bus_dma_segme *paddr = segs->ds_addr; } +static int +dc_dma_alloc(struct dc_softc *sc) +{ + int error, i; + + error = bus_dma_tag_create(bus_get_dma_tag(sc->dc_dev), 1, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT, 0, + NULL, NULL, &sc->dc_ptag); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate parent DMA tag\n"); + goto fail; + } + + /* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */ + error = bus_dma_tag_create(sc->dc_ptag, DC_LIST_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, DC_RX_LIST_SZ, 1, + DC_RX_LIST_SZ, 0, NULL, NULL, &sc->dc_rx_ltag); + if (error) { + device_printf(sc->dc_dev, "failed to create RX list DMA tag\n"); + goto fail; + } + + error = bus_dma_tag_create(sc->dc_ptag, DC_LIST_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, DC_TX_LIST_SZ, 1, + DC_TX_LIST_SZ, 0, NULL, NULL, &sc->dc_tx_ltag); + if (error) { + device_printf(sc->dc_dev, "failed to create TX list DMA tag\n"); + goto fail; + } + + /* RX descriptor list. */ + error = bus_dmamem_alloc(sc->dc_rx_ltag, + (void **)&sc->dc_ldata.dc_rx_list, BUS_DMA_NOWAIT | + BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->dc_rx_lmap); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate DMA'able memory for RX list\n"); + goto fail; + } + error = bus_dmamap_load(sc->dc_rx_ltag, sc->dc_rx_lmap, + sc->dc_ldata.dc_rx_list, DC_RX_LIST_SZ, dc_dma_map_addr, + &sc->dc_ldata.dc_rx_list_paddr, BUS_DMA_NOWAIT); + if (error) { + device_printf(sc->dc_dev, + "failed to load DMA'able memory for RX list\n"); + goto fail; + } + /* TX descriptor list. */ + error = bus_dmamem_alloc(sc->dc_tx_ltag, + (void **)&sc->dc_ldata.dc_tx_list, BUS_DMA_NOWAIT | + BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->dc_tx_lmap); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate DMA'able memory for TX list\n"); + goto fail; + } + error = bus_dmamap_load(sc->dc_tx_ltag, sc->dc_tx_lmap, + sc->dc_ldata.dc_tx_list, DC_TX_LIST_SZ, dc_dma_map_addr, + &sc->dc_ldata.dc_tx_list_paddr, BUS_DMA_NOWAIT); + if (error) { + device_printf(sc->dc_dev, + "cannot load DMA'able memory for TX list\n"); + goto fail; + } + + /* + * Allocate a busdma tag and DMA safe memory for the multicast + * setup frame. + */ + error = bus_dma_tag_create(sc->dc_ptag, DC_LIST_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, + DC_SFRAME_LEN + DC_MIN_FRAMELEN, 1, DC_SFRAME_LEN + DC_MIN_FRAMELEN, + 0, NULL, NULL, &sc->dc_stag); + if (error) { + device_printf(sc->dc_dev, + "failed to create DMA tag for setup frame\n"); + goto fail; + } + error = bus_dmamem_alloc(sc->dc_stag, (void **)&sc->dc_cdata.dc_sbuf, + BUS_DMA_NOWAIT, &sc->dc_smap); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate DMA'able memory for setup frame\n"); + goto fail; + } + error = bus_dmamap_load(sc->dc_stag, sc->dc_smap, sc->dc_cdata.dc_sbuf, + DC_SFRAME_LEN, dc_dma_map_addr, &sc->dc_saddr, BUS_DMA_NOWAIT); + if (error) { + device_printf(sc->dc_dev, + "cannot load DMA'able memory for setup frame\n"); + goto fail; + } + + /* Allocate a busdma tag for RX mbufs. */ + error = bus_dma_tag_create(sc->dc_ptag, DC_RXBUF_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, + MCLBYTES, 1, MCLBYTES, 0, NULL, NULL, &sc->dc_rx_mtag); + if (error) { + device_printf(sc->dc_dev, "failed to create RX mbuf tag\n"); + goto fail; + } + + /* Allocate a busdma tag for TX mbufs. */ + error = bus_dma_tag_create(sc->dc_ptag, 1, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, + MCLBYTES * DC_MAXFRAGS, DC_MAXFRAGS, MCLBYTES, + 0, NULL, NULL, &sc->dc_tx_mtag); + if (error) { + device_printf(sc->dc_dev, "failed to create TX mbuf tag\n"); + goto fail; + } + + /* Create the TX/RX busdma maps. */ + for (i = 0; i < DC_TX_LIST_CNT; i++) { + error = bus_dmamap_create(sc->dc_tx_mtag, 0, + &sc->dc_cdata.dc_tx_map[i]); + if (error) { + device_printf(sc->dc_dev, + "failed to create TX mbuf dmamap\n"); + goto fail; + } + } + for (i = 0; i < DC_RX_LIST_CNT; i++) { + error = bus_dmamap_create(sc->dc_rx_mtag, 0, + &sc->dc_cdata.dc_rx_map[i]); + if (error) { + device_printf(sc->dc_dev, + "failed to create RX mbuf dmamap\n"); + goto fail; + } + } + error = bus_dmamap_create(sc->dc_rx_mtag, 0, &sc->dc_sparemap); + if (error) { + device_printf(sc->dc_dev, + "failed to create spare RX mbuf dmamap\n"); + goto fail; + } + +fail: + return (error); +} + +static void +dc_dma_free(struct dc_softc *sc) +{ + int i; + + /* RX buffers. */ + if (sc->dc_rx_mtag != NULL) { + for (i = 0; i < DC_RX_LIST_CNT; i++) { + if (sc->dc_cdata.dc_rx_map[i] != NULL) + bus_dmamap_destroy(sc->dc_rx_mtag, + sc->dc_cdata.dc_rx_map[i]); + } + if (sc->dc_sparemap != NULL) + bus_dmamap_destroy(sc->dc_rx_mtag, sc->dc_sparemap); + bus_dma_tag_destroy(sc->dc_rx_mtag); + } + + /* TX buffers. */ + if (sc->dc_rx_mtag != NULL) { + for (i = 0; i < DC_TX_LIST_CNT; i++) { + if (sc->dc_cdata.dc_tx_map[i] != NULL) + bus_dmamap_destroy(sc->dc_tx_mtag, + sc->dc_cdata.dc_tx_map[i]); + } + bus_dma_tag_destroy(sc->dc_tx_mtag); + } + + /* RX descriptor list. */ + if (sc->dc_rx_ltag) { + if (sc->dc_rx_lmap != NULL) + bus_dmamap_unload(sc->dc_rx_ltag, sc->dc_rx_lmap); + if (sc->dc_rx_lmap != NULL && sc->dc_ldata.dc_rx_list != NULL) + bus_dmamem_free(sc->dc_rx_ltag, sc->dc_ldata.dc_rx_list, + sc->dc_rx_lmap); + bus_dma_tag_destroy(sc->dc_rx_ltag); + } + + /* TX descriptor list. */ + if (sc->dc_tx_ltag) { + if (sc->dc_tx_lmap != NULL) + bus_dmamap_unload(sc->dc_tx_ltag, sc->dc_tx_lmap); + if (sc->dc_tx_lmap != NULL && sc->dc_ldata.dc_tx_list != NULL) + bus_dmamem_free(sc->dc_tx_ltag, sc->dc_ldata.dc_tx_list, + sc->dc_tx_lmap); + bus_dma_tag_destroy(sc->dc_tx_ltag); + } + + /* multicast setup frame. */ + if (sc->dc_stag) { + if (sc->dc_smap != NULL) + bus_dmamap_unload(sc->dc_stag, sc->dc_smap); + if (sc->dc_smap != NULL && sc->dc_cdata.dc_sbuf != NULL) + bus_dmamem_free(sc->dc_stag, sc->dc_cdata.dc_sbuf, + sc->dc_smap); + bus_dma_tag_destroy(sc->dc_stag); + } +} + /* * Attach the interface. Allocate softc structures, do ifmedia * setup and ethernet/BPF attach. @@ -1828,7 +2037,7 @@ dc_attach(device_t dev) struct ifnet *ifp; struct dc_mediainfo *m; u_int32_t reg, revision; - int error, i, mac_offset, phy, rid, tmp; + int error, mac_offset, phy, rid, tmp; u_int8_t *mac; sc = device_get_softc(dev); @@ -2140,96 +2349,8 @@ dc_attach(device_t dev) error = 0; } - /* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */ - error = bus_dma_tag_create(bus_get_dma_tag(dev), PAGE_SIZE, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - sizeof(struct dc_list_data), 1, sizeof(struct dc_list_data), - 0, NULL, NULL, &sc->dc_ltag); - if (error) { - device_printf(dev, "failed to allocate busdma tag\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamem_alloc(sc->dc_ltag, (void **)&sc->dc_ldata, - BUS_DMA_NOWAIT | BUS_DMA_ZERO, &sc->dc_lmap); - if (error) { - device_printf(dev, "failed to allocate DMA safe memory\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamap_load(sc->dc_ltag, sc->dc_lmap, sc->dc_ldata, - sizeof(struct dc_list_data), dc_dma_map_addr, &sc->dc_laddr, - BUS_DMA_NOWAIT); - if (error) { - device_printf(dev, "cannot get address of the descriptors\n"); - error = ENXIO; - goto fail; - } - - /* - * Allocate a busdma tag and DMA safe memory for the multicast - * setup frame. - */ - error = bus_dma_tag_create(bus_get_dma_tag(dev), PAGE_SIZE, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - DC_SFRAME_LEN + DC_MIN_FRAMELEN, 1, DC_SFRAME_LEN + DC_MIN_FRAMELEN, - 0, NULL, NULL, &sc->dc_stag); - if (error) { - device_printf(dev, "failed to allocate busdma tag\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamem_alloc(sc->dc_stag, (void **)&sc->dc_cdata.dc_sbuf, - BUS_DMA_NOWAIT, &sc->dc_smap); - if (error) { - device_printf(dev, "failed to allocate DMA safe memory\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamap_load(sc->dc_stag, sc->dc_smap, sc->dc_cdata.dc_sbuf, - DC_SFRAME_LEN, dc_dma_map_addr, &sc->dc_saddr, BUS_DMA_NOWAIT); - if (error) { - device_printf(dev, "cannot get address of the descriptors\n"); - error = ENXIO; - goto fail; - } - - /* Allocate a busdma tag for mbufs. */ - error = bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - MCLBYTES * DC_MAXFRAGS, DC_MAXFRAGS, MCLBYTES, - 0, NULL, NULL, &sc->dc_mtag); - if (error) { - device_printf(dev, "failed to allocate busdma tag\n"); - error = ENXIO; + if ((error = dc_dma_alloc(sc)) != 0) goto fail; - } - - /* Create the TX/RX busdma maps. */ - for (i = 0; i < DC_TX_LIST_CNT; i++) { - error = bus_dmamap_create(sc->dc_mtag, 0, - &sc->dc_cdata.dc_tx_map[i]); - if (error) { - device_printf(dev, "failed to init TX ring\n"); - error = ENXIO; - goto fail; - } - } - for (i = 0; i < DC_RX_LIST_CNT; i++) { - error = bus_dmamap_create(sc->dc_mtag, 0, - &sc->dc_cdata.dc_rx_map[i]); - if (error) { - device_printf(dev, "failed to init RX ring\n"); - error = ENXIO; - goto fail; - } - } - error = bus_dmamap_create(sc->dc_mtag, 0, &sc->dc_sparemap); - if (error) { - device_printf(dev, "failed to init RX ring\n"); - error = ENXIO; - goto fail; - } ifp = sc->dc_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { @@ -2378,7 +2499,6 @@ dc_detach(device_t dev) struct dc_softc *sc; struct ifnet *ifp; struct dc_mediainfo *m; - int i; sc = device_get_softc(dev); KASSERT(mtx_initialized(&sc->dc_mtx), ("dc mutex not initialized")); @@ -2413,27 +2533,7 @@ dc_detach(device_t dev) if (ifp) if_free(ifp); - if (sc->dc_cdata.dc_sbuf != NULL) - bus_dmamem_free(sc->dc_stag, sc->dc_cdata.dc_sbuf, sc->dc_smap); - if (sc->dc_ldata != NULL) - bus_dmamem_free(sc->dc_ltag, sc->dc_ldata, sc->dc_lmap); - if (sc->dc_mtag) { - for (i = 0; i < DC_TX_LIST_CNT; i++) - if (sc->dc_cdata.dc_tx_map[i] != NULL) - bus_dmamap_destroy(sc->dc_mtag, - sc->dc_cdata.dc_tx_map[i]); - for (i = 0; i < DC_RX_LIST_CNT; i++) - if (sc->dc_cdata.dc_rx_map[i] != NULL) - bus_dmamap_destroy(sc->dc_mtag, - sc->dc_cdata.dc_rx_map[i]); - bus_dmamap_destroy(sc->dc_mtag, sc->dc_sparemap); - } - if (sc->dc_stag) - bus_dma_tag_destroy(sc->dc_stag); - if (sc->dc_mtag) - bus_dma_tag_destroy(sc->dc_mtag); - if (sc->dc_ltag) - bus_dma_tag_destroy(sc->dc_ltag); + dc_dma_free(sc); free(sc->dc_pnic_rx_buf, M_DEVBUF); @@ -2460,7 +2560,7 @@ dc_list_tx_init(struct dc_softc *sc) int i, nexti; cd = &sc->dc_cdata; - ld = sc->dc_ldata; + ld = &sc->dc_ldata; for (i = 0; i < DC_TX_LIST_CNT; i++) { if (i == DC_TX_LIST_CNT - 1) nexti = 0; @@ -2475,7 +2575,7 @@ dc_list_tx_init(struct dc_softc *sc) cd->dc_tx_prod = cd->dc_tx_cons = cd->dc_tx_cnt = 0; cd->dc_tx_pkts = 0; - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, + bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -2494,10 +2594,10 @@ dc_list_rx_init(struct dc_softc *sc) int i, nexti; cd = &sc->dc_cdata; - ld = sc->dc_ldata; + ld = &sc->dc_ldata; for (i = 0; i < DC_RX_LIST_CNT; i++) { - if (dc_newbuf(sc, i, 1) != 0) + if (dc_newbuf(sc, i) != 0) return (ENOBUFS); if (i == DC_RX_LIST_CNT - 1) nexti = 0; @@ -2507,7 +2607,7 @@ dc_list_rx_init(struct dc_softc *sc) } cd->dc_rx_prod = 0; - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -2516,23 +2616,18 @@ dc_list_rx_init(struct dc_softc *sc) * Initialize an RX descriptor and attach an MBUF cluster. */ static int -dc_newbuf(struct dc_softc *sc, int i, int alloc) +dc_newbuf(struct dc_softc *sc, int i) { - struct mbuf *m_new; - bus_dmamap_t tmp; + struct mbuf *m; + bus_dmamap_t map; bus_dma_segment_t segs[1]; int error, nseg; - if (alloc) { - m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); - if (m_new == NULL) - return (ENOBUFS); - } else { - m_new = sc->dc_cdata.dc_rx_chain[i]; - m_new->m_data = m_new->m_ext.ext_buf; - } - m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; - m_adj(m_new, sizeof(u_int64_t)); + m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if (m == NULL) + return (ENOBUFS); + m->m_len = m->m_pkthdr.len = MCLBYTES; + m_adj(m, sizeof(u_int64_t)); /* * If this is a PNIC chip, zero the buffer. This is part @@ -2540,31 +2635,31 @@ dc_newbuf(struct dc_softc *sc, int i, in * 82c169 chips. */ if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) - bzero(mtod(m_new, char *), m_new->m_len); + bzero(mtod(m, char *), m->m_len); - /* No need to remap the mbuf if we're reusing it. */ - if (alloc) { - error = bus_dmamap_load_mbuf_sg(sc->dc_mtag, sc->dc_sparemap, - m_new, segs, &nseg, 0); - if (error) { - m_freem(m_new); - return (error); - } - KASSERT(nseg == 1, - ("%s: wrong number of segments (%d)", __func__, nseg)); - sc->dc_ldata->dc_rx_list[i].dc_data = htole32(segs->ds_addr); - bus_dmamap_unload(sc->dc_mtag, sc->dc_cdata.dc_rx_map[i]); - tmp = sc->dc_cdata.dc_rx_map[i]; - sc->dc_cdata.dc_rx_map[i] = sc->dc_sparemap; - sc->dc_sparemap = tmp; - sc->dc_cdata.dc_rx_chain[i] = m_new; + error = bus_dmamap_load_mbuf_sg(sc->dc_rx_mtag, sc->dc_sparemap, + m, segs, &nseg, 0); + if (error) { + m_freem(m); + return (error); } - - sc->dc_ldata->dc_rx_list[i].dc_ctl = htole32(DC_RXCTL_RLINK | DC_RXLEN); - sc->dc_ldata->dc_rx_list[i].dc_status = htole32(DC_RXSTAT_OWN); - bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_rx_map[i], + KASSERT(nseg == 1, ("%s: wrong number of segments (%d)", __func__, + nseg)); + if (sc->dc_cdata.dc_rx_chain[i] != NULL) + bus_dmamap_unload(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i]); + + map = sc->dc_cdata.dc_rx_map[i]; + sc->dc_cdata.dc_rx_map[i] = sc->dc_sparemap; + sc->dc_sparemap = map; + sc->dc_cdata.dc_rx_chain[i] = m; + bus_dmamap_sync(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i], BUS_DMASYNC_PREREAD); - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, + + sc->dc_ldata.dc_rx_list[i].dc_ctl = htole32(DC_RXCTL_RLINK | DC_RXLEN); + sc->dc_ldata.dc_rx_list[i].dc_data = + htole32(DC_ADDR_LO(segs[0].ds_addr)); + sc->dc_ldata.dc_rx_list[i].dc_status = htole32(DC_RXSTAT_OWN); + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -2633,13 +2728,13 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, u_int32_t rxstat = 0; i = sc->dc_pnic_rx_bug_save; - cur_rx = &sc->dc_ldata->dc_rx_list[idx]; + cur_rx = &sc->dc_ldata.dc_rx_list[idx]; ptr = sc->dc_pnic_rx_buf; bzero(ptr, DC_RXLEN * 5); /* Copy all the bytes from the bogus buffers. */ while (1) { - c = &sc->dc_ldata->dc_rx_list[i]; + c = &sc->dc_ldata.dc_rx_list[i]; rxstat = le32toh(c->dc_status); m = sc->dc_cdata.dc_rx_chain[i]; bcopy(mtod(m, char *), ptr, DC_RXLEN); @@ -2647,7 +2742,7 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, /* If this is the last buffer, break out. */ if (i == idx || rxstat & DC_RXSTAT_LASTFRAG) break; - dc_newbuf(sc, i, 0); + dc_discard_rxbuf(sc, i); DC_INC(i, DC_RX_LIST_CNT); } @@ -2696,7 +2791,9 @@ dc_rx_resync(struct dc_softc *sc) pos = sc->dc_cdata.dc_rx_prod; for (i = 0; i < DC_RX_LIST_CNT; i++) { - cur_rx = &sc->dc_ldata->dc_rx_list[pos]; + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, + BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); + cur_rx = &sc->dc_ldata.dc_rx_list[pos]; if (!(le32toh(cur_rx->dc_status) & DC_RXSTAT_OWN)) break; DC_INC(pos, DC_RX_LIST_CNT); @@ -2712,6 +2809,22 @@ dc_rx_resync(struct dc_softc *sc) return (EAGAIN); } +static void +dc_discard_rxbuf(struct dc_softc *sc, int i) +{ + struct mbuf *m; + + if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) { + m = sc->dc_cdata.dc_rx_chain[i]; + bzero(mtod(m, char *), m->m_len); + } + + sc->dc_ldata.dc_rx_list[i].dc_ctl = htole32(DC_RXCTL_RLINK | DC_RXLEN); + sc->dc_ldata.dc_rx_list[i].dc_status = htole32(DC_RXSTAT_OWN); + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_PREREAD | + BUS_DMASYNC_PREWRITE); +} + /* * A frame has been uploaded: pass the resulting mbuf chain up to * the higher level protocols. @@ -2719,20 +2832,21 @@ dc_rx_resync(struct dc_softc *sc) static void dc_rxeof(struct dc_softc *sc) { - struct mbuf *m, *m0; + struct mbuf *m; struct ifnet *ifp; struct dc_desc *cur_rx; - int i, total_len = 0; + int i, total_len; u_int32_t rxstat; DC_LOCK_ASSERT(sc); ifp = sc->dc_ifp; - i = sc->dc_cdata.dc_rx_prod; - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, BUS_DMASYNC_POSTREAD); - while (!(le32toh(sc->dc_ldata->dc_rx_list[i].dc_status) & - DC_RXSTAT_OWN)) { + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_POSTREAD | + BUS_DMASYNC_POSTWRITE); + for (i = sc->dc_cdata.dc_rx_prod; + (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0; + DC_INC(i, DC_RX_LIST_CNT)) { #ifdef DEVICE_POLLING if (ifp->if_capenable & IFCAP_POLLING) { if (sc->rxcycles <= 0) @@ -2740,10 +2854,12 @@ dc_rxeof(struct dc_softc *sc) sc->rxcycles--; } #endif - cur_rx = &sc->dc_ldata->dc_rx_list[i]; + cur_rx = &sc->dc_ldata.dc_rx_list[i]; rxstat = le32toh(cur_rx->dc_status); + if ((rxstat & DC_RXSTAT_OWN) != 0) + break; m = sc->dc_cdata.dc_rx_chain[i]; - bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_rx_map[i], + bus_dmamap_sync(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i], BUS_DMASYNC_POSTREAD); total_len = DC_RXBYTES(rxstat); @@ -2751,10 +2867,8 @@ dc_rxeof(struct dc_softc *sc) if ((rxstat & DC_WHOLEFRAME) != DC_WHOLEFRAME) { if (rxstat & DC_RXSTAT_FIRSTFRAG) sc->dc_pnic_rx_bug_save = i; - if ((rxstat & DC_RXSTAT_LASTFRAG) == 0) { - DC_INC(i, DC_RX_LIST_CNT); + if ((rxstat & DC_RXSTAT_LASTFRAG) == 0) continue; - } dc_pnic_rx_bug_war(sc, i); rxstat = le32toh(cur_rx->dc_status); total_len = DC_RXBYTES(rxstat); @@ -2776,11 +2890,10 @@ dc_rxeof(struct dc_softc *sc) ifp->if_ierrors++; if (rxstat & DC_RXSTAT_COLLSEEN) ifp->if_collisions++; - dc_newbuf(sc, i, 0); - if (rxstat & DC_RXSTAT_CRCERR) { - DC_INC(i, DC_RX_LIST_CNT); + dc_discard_rxbuf(sc, i); + if (rxstat & DC_RXSTAT_CRCERR) continue; - } else { + else { dc_init_locked(sc); return; } @@ -2799,23 +2912,27 @@ dc_rxeof(struct dc_softc *sc) * if the allocation fails, then use m_devget and leave the * existing buffer in the receive ring. */ - if (dc_newbuf(sc, i, 1) == 0) { - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = m->m_len = total_len; - DC_INC(i, DC_RX_LIST_CNT); - } else -#endif + if (dc_newbuf(sc, i) != 0) { + dc_discard_rxbuf(sc, i); + ifp->if_iqdrops++; + continue; + } + m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.len = m->m_len = total_len; +#else { + struct mbuf *m0; + m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, ifp, NULL); - dc_newbuf(sc, i, 0); - DC_INC(i, DC_RX_LIST_CNT); + dc_discard_rxbuf(sc, i); if (m0 == NULL) { - ifp->if_ierrors++; + ifp->if_iqdrops++; continue; } m = m0; } +#endif ifp->if_ipackets++; DC_UNLOCK(sc); @@ -2833,9 +2950,9 @@ dc_rxeof(struct dc_softc *sc) static void dc_txeof(struct dc_softc *sc) { - struct dc_desc *cur_tx = NULL; + struct dc_desc *cur_tx; struct ifnet *ifp; - int idx; + int idx, setup; u_int32_t ctl, txstat; if (sc->dc_cdata.dc_tx_cnt == 0) @@ -2847,36 +2964,40 @@ dc_txeof(struct dc_softc *sc) * Go through our tx list and free mbufs for those * frames that have been transmitted. */ - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, BUS_DMASYNC_POSTREAD); - idx = sc->dc_cdata.dc_tx_cons; - while (idx != sc->dc_cdata.dc_tx_prod) { - - cur_tx = &sc->dc_ldata->dc_tx_list[idx]; + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_tx_lmap, BUS_DMASYNC_POSTREAD | + BUS_DMASYNC_POSTWRITE); + setup = 0; + for (idx = sc->dc_cdata.dc_tx_cons; idx != sc->dc_cdata.dc_tx_prod; + DC_INC(idx, DC_TX_LIST_CNT), sc->dc_cdata.dc_tx_cnt--) { + cur_tx = &sc->dc_ldata.dc_tx_list[idx]; txstat = le32toh(cur_tx->dc_status); ctl = le32toh(cur_tx->dc_ctl); if (txstat & DC_TXSTAT_OWN) break; - if (!(ctl & DC_TXCTL_LASTFRAG) || ctl & DC_TXCTL_SETUP) { - if (ctl & DC_TXCTL_SETUP) { - /* - * Yes, the PNIC is so brain damaged - * that it will sometimes generate a TX - * underrun error while DMAing the RX - * filter setup frame. If we detect this, - * we have to send the setup frame again, - * or else the filter won't be programmed - * correctly. - */ - if (DC_IS_PNIC(sc)) { - if (txstat & DC_TXSTAT_ERRSUM) - dc_setfilt(sc); - } - sc->dc_cdata.dc_tx_chain[idx] = NULL; + if (sc->dc_cdata.dc_tx_chain[idx] == NULL) + continue; + + if (ctl & DC_TXCTL_SETUP) { + cur_tx->dc_ctl = htole32(ctl & ~DC_TXCTL_SETUP); + setup++; + bus_dmamap_sync(sc->dc_stag, sc->dc_smap, + BUS_DMASYNC_POSTWRITE); + /* + * Yes, the PNIC is so brain damaged + * that it will sometimes generate a TX + * underrun error while DMAing the RX + * filter setup frame. If we detect this, + * we have to send the setup frame again, + * or else the filter won't be programmed + * correctly. + */ + if (DC_IS_PNIC(sc)) { + if (txstat & DC_TXSTAT_ERRSUM) + dc_setfilt(sc); } - sc->dc_cdata.dc_tx_cnt--; - DC_INC(idx, DC_TX_LIST_CNT); + sc->dc_cdata.dc_tx_chain[idx] = NULL; continue; } @@ -2916,26 +3037,22 @@ dc_txeof(struct dc_softc *sc) ifp->if_opackets++; ifp->if_collisions += (txstat & DC_TXSTAT_COLLCNT) >> 3; - if (sc->dc_cdata.dc_tx_chain[idx] != NULL) { - bus_dmamap_sync(sc->dc_mtag, - sc->dc_cdata.dc_tx_map[idx], - BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(sc->dc_mtag, - sc->dc_cdata.dc_tx_map[idx]); - m_freem(sc->dc_cdata.dc_tx_chain[idx]); - sc->dc_cdata.dc_tx_chain[idx] = NULL; - } - - sc->dc_cdata.dc_tx_cnt--; - DC_INC(idx, DC_TX_LIST_CNT); + bus_dmamap_sync(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], + BUS_DMASYNC_POSTWRITE); + bus_dmamap_unload(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx]); + m_freem(sc->dc_cdata.dc_tx_chain[idx]); + sc->dc_cdata.dc_tx_chain[idx] = NULL; } sc->dc_cdata.dc_tx_cons = idx; - if (DC_TX_LIST_CNT - sc->dc_cdata.dc_tx_cnt > DC_TX_LIST_RSVD) + if (sc->dc_cdata.dc_tx_cnt <= DC_TX_LIST_CNT - DC_TX_LIST_RSVD) { ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - - if (sc->dc_cdata.dc_tx_cnt == 0) - sc->dc_wdog_timer = 0; + if (sc->dc_cdata.dc_tx_cnt == 0) + sc->dc_wdog_timer = 0; + } + if (setup > 0) + bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); } static void @@ -3221,16 +3338,11 @@ static int dc_encap(struct dc_softc *sc, struct mbuf **m_head) { bus_dma_segment_t segs[DC_MAXFRAGS]; + bus_dmamap_t map; struct dc_desc *f; struct mbuf *m; int cur, defragged, error, first, frag, i, idx, nseg; - /* - * If there's no way we can send any packets, return now. - */ - if (DC_TX_LIST_CNT - sc->dc_cdata.dc_tx_cnt <= DC_TX_LIST_RSVD) - return (ENOBUFS); - m = NULL; defragged = 0; if (sc->dc_flags & DC_TX_COALESCE && @@ -3264,7 +3376,7 @@ dc_encap(struct dc_softc *sc, struct mbu } idx = sc->dc_cdata.dc_tx_prod; - error = bus_dmamap_load_mbuf_sg(sc->dc_mtag, + error = bus_dmamap_load_mbuf_sg(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], *m_head, segs, &nseg, 0); if (error == EFBIG) { if (defragged != 0 || (m = m_collapse(*m_head, M_DONTWAIT, @@ -3274,7 +3386,7 @@ dc_encap(struct dc_softc *sc, struct mbu return (defragged != 0 ? error : ENOBUFS); } *m_head = m; - error = bus_dmamap_load_mbuf_sg(sc->dc_mtag, + error = bus_dmamap_load_mbuf_sg(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], *m_head, segs, &nseg, 0); if (error != 0) { m_freem(*m_head); @@ -3291,26 +3403,34 @@ dc_encap(struct dc_softc *sc, struct mbu return (EIO); } + /* Check descriptor overruns. */ + if (sc->dc_cdata.dc_tx_cnt + nseg > DC_TX_LIST_CNT - DC_TX_LIST_RSVD) { + bus_dmamap_unload(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx]); + return (ENOBUFS); + } + bus_dmamap_sync(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], + BUS_DMASYNC_PREWRITE); + first = cur = frag = sc->dc_cdata.dc_tx_prod; for (i = 0; i < nseg; i++) { if ((sc->dc_flags & DC_TX_ADMTEK_WAR) && (frag == (DC_TX_LIST_CNT - 1)) && (first != sc->dc_cdata.dc_tx_first)) { - bus_dmamap_unload(sc->dc_mtag, + bus_dmamap_unload(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[first]); m_freem(*m_head); *m_head = NULL; return (ENOBUFS); } - f = &sc->dc_ldata->dc_tx_list[frag]; + f = &sc->dc_ldata.dc_tx_list[frag]; f->dc_ctl = htole32(DC_TXCTL_TLINK | segs[i].ds_len); if (i == 0) { f->dc_status = 0; f->dc_ctl |= htole32(DC_TXCTL_FIRSTFRAG); } else f->dc_status = htole32(DC_TXSTAT_OWN); - f->dc_data = htole32(segs[i].ds_addr); + f->dc_data = htole32(DC_ADDR_LO(segs[i].ds_addr)); cur = frag; DC_INC(frag, DC_TX_LIST_CNT); } @@ -3318,23 +3438,30 @@ dc_encap(struct dc_softc *sc, struct mbu sc->dc_cdata.dc_tx_prod = frag; sc->dc_cdata.dc_tx_cnt += nseg; sc->dc_cdata.dc_tx_chain[cur] = *m_head; - sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_LASTFRAG); + sc->dc_ldata.dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_LASTFRAG); if (sc->dc_flags & DC_TX_INTR_FIRSTFRAG) - sc->dc_ldata->dc_tx_list[first].dc_ctl |= + sc->dc_ldata.dc_tx_list[first].dc_ctl |= htole32(DC_TXCTL_FINT); if (sc->dc_flags & DC_TX_INTR_ALWAYS) - sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); + sc->dc_ldata.dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); if (sc->dc_flags & DC_TX_USE_TX_INTR && ++sc->dc_cdata.dc_tx_pkts >= 8) { sc->dc_cdata.dc_tx_pkts = 0; - sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); + sc->dc_ldata.dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); } - sc->dc_ldata->dc_tx_list[first].dc_status = htole32(DC_TXSTAT_OWN); + sc->dc_ldata.dc_tx_list[first].dc_status = htole32(DC_TXSTAT_OWN); + + bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + + /* + * Swap the last and the first dmamaps to ensure the map for + * this transmission is placed at the last descriptor. + */ + map = sc->dc_cdata.dc_tx_map[cur]; + sc->dc_cdata.dc_tx_map[cur] = sc->dc_cdata.dc_tx_map[first]; + sc->dc_cdata.dc_tx_map[first] = map; - bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_tx_map[idx], - BUS_DMASYNC_PREWRITE); - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, - BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -3360,9 +3487,8 @@ static void dc_start_locked(struct ifnet *ifp) { struct dc_softc *sc; - struct mbuf *m_head = NULL; - unsigned int queued = 0; - int idx; + struct mbuf *m_head; + int queued; sc = ifp->if_softc; @@ -3372,9 +3498,16 @@ dc_start_locked(struct ifnet *ifp) IFF_DRV_RUNNING || sc->dc_link == 0) return; - idx = sc->dc_cdata.dc_tx_first = sc->dc_cdata.dc_tx_prod; + sc->dc_cdata.dc_tx_first = sc->dc_cdata.dc_tx_prod; - while (sc->dc_cdata.dc_tx_chain[idx] == NULL) { + for (queued = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd); ) { + /* + * If there's no way we can send any packets, return now. + */ + if (sc->dc_cdata.dc_tx_cnt > DC_TX_LIST_CNT - DC_TX_LIST_RSVD) { + ifp->if_drv_flags |= IFF_DRV_OACTIVE; + break; + } IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -3386,7 +3519,6 @@ dc_start_locked(struct ifnet *ifp) ifp->if_drv_flags |= IFF_DRV_OACTIVE; break; } - idx = sc->dc_cdata.dc_tx_prod; queued++; /* @@ -3773,7 +3905,7 @@ dc_stop(struct dc_softc *sc) DC_LOCK_ASSERT(sc); ifp = sc->dc_ifp; - ld = sc->dc_ldata; + ld = &sc->dc_ldata; cd = &sc->dc_cdata; callout_stop(&sc->dc_stat_ch); @@ -3793,11 +3925,17 @@ dc_stop(struct dc_softc *sc) */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 23:02:13 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA19C106566C; Sun, 27 Mar 2011 23:02:12 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D77708FC12; Sun, 27 Mar 2011 23:02:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RN2Cug072104; Sun, 27 Mar 2011 23:02:12 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RN2C1i072102; Sun, 27 Mar 2011 23:02:12 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272302.p2RN2C1i072102@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 23:02:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220074 - stable/8/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 23:02:13 -0000 Author: yongari Date: Sun Mar 27 23:02:12 2011 New Revision: 220074 URL: http://svn.freebsd.org/changeset/base/220074 Log: MFC r218833,218964: r218833: Count how many frames driver lost in interrupt handler. This register is cleared on read so make sure to clear it in driver initialization phase. r218964: Remove unnecessary controller reinitialization which resulted in link flips during alias address insertion or dhclient operation. While I'm here remove dc_reset() in DC_ISR_BUS_ERR case. Device is fully reinitialized again in dc_init_locked(). Modified: stable/8/sys/dev/dc/if_dc.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:50:09 2011 (r220073) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 23:02:12 2011 (r220074) @@ -2894,6 +2894,7 @@ dc_rxeof(struct dc_softc *sc) if (rxstat & DC_RXSTAT_CRCERR) continue; else { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); return (rx_npkts); } @@ -3032,6 +3033,7 @@ dc_txeof(struct dc_softc *sc) if (txstat & DC_TXSTAT_LATECOLL) ifp->if_collisions++; if (!(txstat & DC_TXSTAT_UNDERRUN)) { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); return; } @@ -3143,8 +3145,10 @@ dc_tx_underrun(struct dc_softc *sc) u_int32_t isr; int i; - if (DC_IS_DAVICOM(sc)) + if (DC_IS_DAVICOM(sc)) { + sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); + } if (DC_IS_INTEL(sc)) { /* @@ -3164,6 +3168,7 @@ dc_tx_underrun(struct dc_softc *sc) device_printf(sc->dc_dev, "%s: failed to force tx to idle state\n", __func__); + sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } } @@ -3236,7 +3241,7 @@ dc_poll(struct ifnet *ifp, enum poll_cmd if (status & DC_ISR_BUS_ERR) { if_printf(ifp, "%s: bus error\n", __func__); - dc_reset(sc); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } } @@ -3250,7 +3255,7 @@ dc_intr(void *arg) { struct dc_softc *sc; struct ifnet *ifp; - u_int32_t status; + u_int32_t r, status; int curpkts, n; sc = arg; @@ -3305,6 +3310,8 @@ dc_intr(void *arg) if ((status & DC_ISR_RX_WATDOGTIMEO) || (status & DC_ISR_RX_NOBUF)) { + r = CSR_READ_4(sc, DC_FRAMESDISCARDED); + ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff); curpkts = ifp->if_ipackets; dc_rxeof(sc); if (curpkts == ifp->if_ipackets) { @@ -3317,7 +3324,7 @@ dc_intr(void *arg) dc_start_locked(ifp); if (status & DC_ISR_BUS_ERR) { - dc_reset(sc); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); DC_UNLOCK(sc); return; @@ -3563,6 +3570,9 @@ dc_init_locked(struct dc_softc *sc) DC_LOCK_ASSERT(sc); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + return; + mii = device_get_softc(sc->dc_miibus); /* @@ -3723,6 +3733,9 @@ dc_init_locked(struct dc_softc *sc) mii_mediachg(mii); dc_setcfg(sc, sc->dc_if_media); + /* Clear missed frames and overflow counter. */ + CSR_READ_4(sc, DC_FRAMESDISCARDED); + /* Don't start the ticker if this is a homePNA link. */ if (IFM_SUBTYPE(mii->mii_media.ifm_media) == IFM_HPNA_1) sc->dc_link = 1; @@ -3813,6 +3826,7 @@ dc_ioctl(struct ifnet *ifp, u_long comma dc_setfilt(sc); } else { sc->dc_txthresh = 0; + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } } else { @@ -3885,8 +3899,7 @@ dc_watchdog(void *xsc) ifp->if_oerrors++; device_printf(sc->dc_dev, "watchdog timeout\n"); - dc_stop(sc); - dc_reset(sc); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 23:03:15 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AF848106566C; Sun, 27 Mar 2011 23:03:15 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9CEFD8FC1C; Sun, 27 Mar 2011 23:03:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RN3FoK072173; Sun, 27 Mar 2011 23:03:15 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RN3FQt072171; Sun, 27 Mar 2011 23:03:15 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272303.p2RN3FQt072171@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 23:03:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220075 - stable/7/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 23:03:15 -0000 Author: yongari Date: Sun Mar 27 23:03:15 2011 New Revision: 220075 URL: http://svn.freebsd.org/changeset/base/220075 Log: MFC r218833,218964: r218833: Count how many frames driver lost in interrupt handler. This register is cleared on read so make sure to clear it in driver initialization phase. r218964: Remove unnecessary controller reinitialization which resulted in link flips during alias address insertion or dhclient operation. While I'm here remove dc_reset() in DC_ISR_BUS_ERR case. Device is fully reinitialized again in dc_init_locked(). Modified: stable/7/sys/dev/dc/if_dc.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 23:02:12 2011 (r220074) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 23:03:15 2011 (r220075) @@ -2894,6 +2894,7 @@ dc_rxeof(struct dc_softc *sc) if (rxstat & DC_RXSTAT_CRCERR) continue; else { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); return; } @@ -3030,6 +3031,7 @@ dc_txeof(struct dc_softc *sc) if (txstat & DC_TXSTAT_LATECOLL) ifp->if_collisions++; if (!(txstat & DC_TXSTAT_UNDERRUN)) { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); return; } @@ -3141,8 +3143,10 @@ dc_tx_underrun(struct dc_softc *sc) u_int32_t isr; int i; - if (DC_IS_DAVICOM(sc)) + if (DC_IS_DAVICOM(sc)) { + sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); + } if (DC_IS_INTEL(sc)) { /* @@ -3162,6 +3166,7 @@ dc_tx_underrun(struct dc_softc *sc) device_printf(sc->dc_dev, "%s: failed to force tx to idle state\n", __func__); + sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } } @@ -3233,7 +3238,7 @@ dc_poll(struct ifnet *ifp, enum poll_cmd if (status & DC_ISR_BUS_ERR) { if_printf(ifp, "%s: bus error\n", __func__); - dc_reset(sc); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } } @@ -3246,7 +3251,7 @@ dc_intr(void *arg) { struct dc_softc *sc; struct ifnet *ifp; - u_int32_t status; + u_int32_t r, status; int curpkts, n; sc = arg; @@ -3301,6 +3306,8 @@ dc_intr(void *arg) if ((status & DC_ISR_RX_WATDOGTIMEO) || (status & DC_ISR_RX_NOBUF)) { + r = CSR_READ_4(sc, DC_FRAMESDISCARDED); + ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff); curpkts = ifp->if_ipackets; dc_rxeof(sc); if (curpkts == ifp->if_ipackets) { @@ -3313,7 +3320,7 @@ dc_intr(void *arg) dc_start_locked(ifp); if (status & DC_ISR_BUS_ERR) { - dc_reset(sc); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); DC_UNLOCK(sc); return; @@ -3559,6 +3566,9 @@ dc_init_locked(struct dc_softc *sc) DC_LOCK_ASSERT(sc); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + return; + mii = device_get_softc(sc->dc_miibus); /* @@ -3719,6 +3729,9 @@ dc_init_locked(struct dc_softc *sc) mii_mediachg(mii); dc_setcfg(sc, sc->dc_if_media); + /* Clear missed frames and overflow counter. */ + CSR_READ_4(sc, DC_FRAMESDISCARDED); + /* Don't start the ticker if this is a homePNA link. */ if (IFM_SUBTYPE(mii->mii_media.ifm_media) == IFM_HPNA_1) sc->dc_link = 1; @@ -3809,6 +3822,7 @@ dc_ioctl(struct ifnet *ifp, u_long comma dc_setfilt(sc); } else { sc->dc_txthresh = 0; + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } } else { @@ -3881,8 +3895,7 @@ dc_watchdog(void *xsc) ifp->if_oerrors++; device_printf(sc->dc_dev, "watchdog timeout\n"); - dc_stop(sc); - dc_reset(sc); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 23:08:02 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 271FA1065676; Sun, 27 Mar 2011 23:08:02 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 131408FC15; Sun, 27 Mar 2011 23:08:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RN82ZC072352; Sun, 27 Mar 2011 23:08:02 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RN82CX072349; Sun, 27 Mar 2011 23:08:02 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272308.p2RN82CX072349@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 23:08:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220076 - stable/8/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 23:08:02 -0000 Author: yongari Date: Sun Mar 27 23:08:01 2011 New Revision: 220076 URL: http://svn.freebsd.org/changeset/base/220076 Log: MFC r218834-218835: r218834: Consistently use a tab character instead of space after #define. No functional changes. r218835: s/u_intXX_t/uintXX_t/g Modified: stable/8/sys/dev/dc/if_dc.c stable/8/sys/dev/dc/if_dcreg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 23:03:15 2011 (r220075) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 23:08:01 2011 (r220076) @@ -127,7 +127,7 @@ __FBSDID("$FreeBSD$"); #include #include -#define DC_USEIOSPACE +#define DC_USEIOSPACE #include @@ -261,16 +261,16 @@ static void dc_dma_map_addr(void *, bus_ static void dc_delay(struct dc_softc *); static void dc_eeprom_idle(struct dc_softc *); static void dc_eeprom_putbyte(struct dc_softc *, int); -static void dc_eeprom_getword(struct dc_softc *, int, u_int16_t *); -static void dc_eeprom_getword_pnic(struct dc_softc *, int, u_int16_t *); -static void dc_eeprom_getword_xircom(struct dc_softc *, int, u_int16_t *); +static void dc_eeprom_getword(struct dc_softc *, int, uint16_t *); +static void dc_eeprom_getword_pnic(struct dc_softc *, int, uint16_t *); +static void dc_eeprom_getword_xircom(struct dc_softc *, int, uint16_t *); static void dc_eeprom_width(struct dc_softc *); static void dc_read_eeprom(struct dc_softc *, caddr_t, int, int, int); static void dc_mii_writebit(struct dc_softc *, int); static int dc_mii_readbit(struct dc_softc *); static void dc_mii_sync(struct dc_softc *); -static void dc_mii_send(struct dc_softc *, u_int32_t, int); +static void dc_mii_send(struct dc_softc *, uint32_t, int); static int dc_mii_readreg(struct dc_softc *, struct dc_mii_frame *); static int dc_mii_writereg(struct dc_softc *, struct dc_mii_frame *); static int dc_miibus_readreg(device_t, int, int); @@ -301,11 +301,11 @@ static void dc_apply_fixup(struct dc_sof static int dc_check_multiport(struct dc_softc *); #ifdef DC_USEIOSPACE -#define DC_RES SYS_RES_IOPORT -#define DC_RID DC_PCI_CFBIO +#define DC_RES SYS_RES_IOPORT +#define DC_RID DC_PCI_CFBIO #else -#define DC_RES SYS_RES_MEMORY -#define DC_RID DC_PCI_CFBMA +#define DC_RES SYS_RES_MEMORY +#define DC_RID DC_PCI_CFBMA #endif static device_method_t dc_methods[] = { @@ -341,14 +341,14 @@ static devclass_t dc_devclass; DRIVER_MODULE(dc, pci, dc_driver, dc_devclass, 0, 0); DRIVER_MODULE(miibus, dc, miibus_driver, miibus_devclass, 0, 0); -#define DC_SETBIT(sc, reg, x) \ +#define DC_SETBIT(sc, reg, x) \ CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) | (x)) -#define DC_CLRBIT(sc, reg, x) \ +#define DC_CLRBIT(sc, reg, x) \ CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) & ~(x)) -#define SIO_SET(x) DC_SETBIT(sc, DC_SIO, (x)) -#define SIO_CLR(x) DC_CLRBIT(sc, DC_SIO, (x)) +#define SIO_SET(x) DC_SETBIT(sc, DC_SIO, (x)) +#define SIO_CLR(x) DC_CLRBIT(sc, DC_SIO, (x)) static void dc_delay(struct dc_softc *sc) @@ -495,10 +495,10 @@ dc_eeprom_putbyte(struct dc_softc *sc, i * the EEPROM. */ static void -dc_eeprom_getword_pnic(struct dc_softc *sc, int addr, u_int16_t *dest) +dc_eeprom_getword_pnic(struct dc_softc *sc, int addr, uint16_t *dest) { int i; - u_int32_t r; + uint32_t r; CSR_WRITE_4(sc, DC_PN_SIOCTL, DC_PN_EEOPCODE_READ | addr); @@ -506,7 +506,7 @@ dc_eeprom_getword_pnic(struct dc_softc * DELAY(1); r = CSR_READ_4(sc, DC_SIO); if (!(r & DC_PN_SIOCTL_BUSY)) { - *dest = (u_int16_t)(r & 0xFFFF); + *dest = (uint16_t)(r & 0xFFFF); return; } } @@ -518,17 +518,17 @@ dc_eeprom_getword_pnic(struct dc_softc * * the EEPROM, too. */ static void -dc_eeprom_getword_xircom(struct dc_softc *sc, int addr, u_int16_t *dest) +dc_eeprom_getword_xircom(struct dc_softc *sc, int addr, uint16_t *dest) { SIO_SET(DC_SIO_ROMSEL | DC_SIO_ROMCTL_READ); addr *= 2; CSR_WRITE_4(sc, DC_ROM, addr | 0x160); - *dest = (u_int16_t)CSR_READ_4(sc, DC_SIO) & 0xff; + *dest = (uint16_t)CSR_READ_4(sc, DC_SIO) & 0xff; addr += 1; CSR_WRITE_4(sc, DC_ROM, addr | 0x160); - *dest |= ((u_int16_t)CSR_READ_4(sc, DC_SIO) & 0xff) << 8; + *dest |= ((uint16_t)CSR_READ_4(sc, DC_SIO) & 0xff) << 8; SIO_CLR(DC_SIO_ROMSEL | DC_SIO_ROMCTL_READ); } @@ -537,10 +537,10 @@ dc_eeprom_getword_xircom(struct dc_softc * Read a word of data stored in the EEPROM at address 'addr.' */ static void -dc_eeprom_getword(struct dc_softc *sc, int addr, u_int16_t *dest) +dc_eeprom_getword(struct dc_softc *sc, int addr, uint16_t *dest) { int i; - u_int16_t word = 0; + uint16_t word = 0; /* Force EEPROM to idle state. */ dc_eeprom_idle(sc); @@ -586,7 +586,7 @@ static void dc_read_eeprom(struct dc_softc *sc, caddr_t dest, int off, int cnt, int be) { int i; - u_int16_t word = 0, *ptr; + uint16_t word = 0, *ptr; for (i = 0; i < cnt; i++) { if (DC_IS_PNIC(sc)) @@ -595,7 +595,7 @@ dc_read_eeprom(struct dc_softc *sc, cadd dc_eeprom_getword_xircom(sc, off + i, &word); else dc_eeprom_getword(sc, off + i, &word); - ptr = (u_int16_t *)(dest + (i * 2)); + ptr = (uint16_t *)(dest + (i * 2)); if (be) *ptr = be16toh(word); else @@ -680,7 +680,7 @@ dc_mii_sync(struct dc_softc *sc) * Clock a series of bits through the MII. */ static void -dc_mii_send(struct dc_softc *sc, u_int32_t bits, int cnt) +dc_mii_send(struct dc_softc *sc, uint32_t bits, int cnt) { int i; @@ -1016,9 +1016,9 @@ dc_miibus_mediainit(device_t dev) ifmedia_add(ifm, IFM_ETHER | IFM_HPNA_1, 0, NULL); } -#define DC_BITS_512 9 -#define DC_BITS_128 7 -#define DC_BITS_64 6 +#define DC_BITS_512 9 +#define DC_BITS_128 7 +#define DC_BITS_64 6 static uint32_t dc_mchash_le(struct dc_softc *sc, const uint8_t *addr) @@ -1082,7 +1082,7 @@ dc_setfilt_21143(struct dc_softc *sc) { uint16_t eaddr[(ETHER_ADDR_LEN+1)/2]; struct dc_desc *sframe; - u_int32_t h, *sp; + uint32_t h, *sp; struct ifmultiaddr *ifma; struct ifnet *ifp; int i; @@ -1156,7 +1156,7 @@ dc_setfilt_admtek(struct dc_softc *sc) struct ifnet *ifp; struct ifmultiaddr *ifma; int h = 0; - u_int32_t hashes[2] = { 0, 0 }; + uint32_t hashes[2] = { 0, 0 }; ifp = sc->dc_ifp; @@ -1217,7 +1217,7 @@ dc_setfilt_asix(struct dc_softc *sc) struct ifnet *ifp; struct ifmultiaddr *ifma; int h = 0; - u_int32_t hashes[2] = { 0, 0 }; + uint32_t hashes[2] = { 0, 0 }; ifp = sc->dc_ifp; @@ -1287,7 +1287,7 @@ dc_setfilt_xircom(struct dc_softc *sc) struct ifnet *ifp; struct ifmultiaddr *ifma; struct dc_desc *sframe; - u_int32_t h, *sp; + uint32_t h, *sp; int i; ifp = sc->dc_ifp; @@ -1379,7 +1379,7 @@ static void dc_setcfg(struct dc_softc *sc, int media) { int i, restart = 0, watchdogreg; - u_int32_t isr; + uint32_t isr; if (IFM_SUBTYPE(media) == IFM_NONE) return; @@ -1563,8 +1563,8 @@ static const struct dc_type * dc_devtype(device_t dev) { const struct dc_type *t; - u_int32_t devid; - u_int8_t rev; + uint32_t devid; + uint8_t rev; t = dc_devs; devid = pci_get_devid(dev); @@ -1607,9 +1607,9 @@ static void dc_apply_fixup(struct dc_softc *sc, int media) { struct dc_mediainfo *m; - u_int8_t *p; + uint8_t *p; int i; - u_int32_t reg; + uint32_t reg; m = sc->dc_mi; @@ -1668,11 +1668,11 @@ dc_decode_leaf_sia(struct dc_softc *sc, if (l->dc_sia_code & DC_SIA_CODE_EXT) { m->dc_gp_len = 2; m->dc_gp_ptr = - (u_int8_t *)&l->dc_un.dc_sia_ext.dc_sia_gpio_ctl; + (uint8_t *)&l->dc_un.dc_sia_ext.dc_sia_gpio_ctl; } else { m->dc_gp_len = 2; m->dc_gp_ptr = - (u_int8_t *)&l->dc_un.dc_sia_noext.dc_sia_gpio_ctl; + (uint8_t *)&l->dc_un.dc_sia_noext.dc_sia_gpio_ctl; } m->dc_next = sc->dc_mi; @@ -1699,7 +1699,7 @@ dc_decode_leaf_sym(struct dc_softc *sc, m->dc_media = IFM_100_TX | IFM_FDX; m->dc_gp_len = 2; - m->dc_gp_ptr = (u_int8_t *)&l->dc_sym_gpio_ctl; + m->dc_gp_ptr = (uint8_t *)&l->dc_sym_gpio_ctl; m->dc_next = sc->dc_mi; sc->dc_mi = m; @@ -1712,7 +1712,7 @@ static int dc_decode_leaf_mii(struct dc_softc *sc, struct dc_eblock_mii *l) { struct dc_mediainfo *m; - u_int8_t *p; + uint8_t *p; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); if (m == NULL) { @@ -1723,7 +1723,7 @@ dc_decode_leaf_mii(struct dc_softc *sc, m->dc_media = IFM_AUTO; m->dc_gp_len = l->dc_gpr_len; - p = (u_int8_t *)l; + p = (uint8_t *)l; p += sizeof(struct dc_eblock_mii); m->dc_gp_ptr = p; p += 2 * l->dc_gpr_len; @@ -2031,13 +2031,13 @@ static int dc_attach(device_t dev) { uint32_t eaddr[(ETHER_ADDR_LEN+3)/4]; - u_int32_t command; + uint32_t command; struct dc_softc *sc; struct ifnet *ifp; struct dc_mediainfo *m; - u_int32_t reg, revision; + uint32_t reg, revision; int error, mac_offset, phy, rid, tmp; - u_int8_t *mac; + uint8_t *mac; sc = device_get_softc(dev); sc->dc_dev = dev; @@ -2715,7 +2715,7 @@ dc_newbuf(struct dc_softc *sc, int i) * the time. */ -#define DC_WHOLEFRAME (DC_RXSTAT_FIRSTFRAG | DC_RXSTAT_LASTFRAG) +#define DC_WHOLEFRAME (DC_RXSTAT_FIRSTFRAG | DC_RXSTAT_LASTFRAG) static void dc_pnic_rx_bug_war(struct dc_softc *sc, int idx) { @@ -2724,7 +2724,7 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, struct mbuf *m = NULL; unsigned char *ptr; int i, total_len; - u_int32_t rxstat = 0; + uint32_t rxstat = 0; i = sc->dc_pnic_rx_bug_save; cur_rx = &sc->dc_ldata.dc_rx_list[idx]; @@ -2835,7 +2835,7 @@ dc_rxeof(struct dc_softc *sc) struct ifnet *ifp; struct dc_desc *cur_rx; int i, total_len, rx_npkts; - u_int32_t rxstat; + uint32_t rxstat; DC_LOCK_ASSERT(sc); @@ -2956,7 +2956,7 @@ dc_txeof(struct dc_softc *sc) struct dc_desc *cur_tx; struct ifnet *ifp; int idx, setup; - u_int32_t ctl, txstat; + uint32_t ctl, txstat; if (sc->dc_cdata.dc_tx_cnt == 0) return; @@ -3065,7 +3065,7 @@ dc_tick(void *xsc) struct dc_softc *sc; struct mii_data *mii; struct ifnet *ifp; - u_int32_t r; + uint32_t r; sc = xsc; DC_LOCK_ASSERT(sc); @@ -3142,7 +3142,7 @@ dc_tick(void *xsc) static void dc_tx_underrun(struct dc_softc *sc) { - u_int32_t isr; + uint32_t isr; int i; if (DC_IS_DAVICOM(sc)) { @@ -3212,7 +3212,7 @@ dc_poll(struct ifnet *ifp, enum poll_cmd dc_start_locked(ifp); if (cmd == POLL_AND_CHECK_STATUS) { /* also check status register */ - u_int32_t status; + uint32_t status; status = CSR_READ_4(sc, DC_ISR); status &= (DC_ISR_RX_WATDOGTIMEO | DC_ISR_RX_NOBUF | @@ -3226,7 +3226,7 @@ dc_poll(struct ifnet *ifp, enum poll_cmd CSR_WRITE_4(sc, DC_ISR, status); if (status & (DC_ISR_RX_WATDOGTIMEO | DC_ISR_RX_NOBUF)) { - u_int32_t r = CSR_READ_4(sc, DC_FRAMESDISCARDED); + uint32_t r = CSR_READ_4(sc, DC_FRAMESDISCARDED); ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff); if (dc_rx_resync(sc)) @@ -3255,7 +3255,7 @@ dc_intr(void *arg) { struct dc_softc *sc; struct ifnet *ifp; - u_int32_t r, status; + uint32_t r, status; int curpkts, n; sc = arg; @@ -3917,7 +3917,7 @@ dc_stop(struct dc_softc *sc) struct dc_list_data *ld; struct dc_chain_data *cd; int i; - u_int32_t ctl; + uint32_t ctl; DC_LOCK_ASSERT(sc); Modified: stable/8/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 23:03:15 2011 (r220075) +++ stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 23:08:01 2011 (r220076) @@ -36,23 +36,23 @@ * 21143 and clone common register definitions. */ -#define DC_BUSCTL 0x00 /* bus control */ -#define DC_TXSTART 0x08 /* tx start demand */ -#define DC_RXSTART 0x10 /* rx start demand */ -#define DC_RXADDR 0x18 /* rx descriptor list start addr */ -#define DC_TXADDR 0x20 /* tx descriptor list start addr */ -#define DC_ISR 0x28 /* interrupt status register */ -#define DC_NETCFG 0x30 /* network config register */ -#define DC_IMR 0x38 /* interrupt mask */ -#define DC_FRAMESDISCARDED 0x40 /* # of discarded frames */ -#define DC_SIO 0x48 /* MII and ROM/EEPROM access */ -#define DC_ROM 0x50 /* ROM programming address */ -#define DC_TIMER 0x58 /* general timer */ -#define DC_10BTSTAT 0x60 /* SIA status */ -#define DC_SIARESET 0x68 /* SIA connectivity */ -#define DC_10BTCTRL 0x70 /* SIA transmit and receive */ -#define DC_WATCHDOG 0x78 /* SIA and general purpose port */ -#define DC_SIAGP 0x78 /* SIA and general purpose port (X3201) */ +#define DC_BUSCTL 0x00 /* bus control */ +#define DC_TXSTART 0x08 /* tx start demand */ +#define DC_RXSTART 0x10 /* rx start demand */ +#define DC_RXADDR 0x18 /* rx descriptor list start addr */ +#define DC_TXADDR 0x20 /* tx descriptor list start addr */ +#define DC_ISR 0x28 /* interrupt status register */ +#define DC_NETCFG 0x30 /* network config register */ +#define DC_IMR 0x38 /* interrupt mask */ +#define DC_FRAMESDISCARDED 0x40 /* # of discarded frames */ +#define DC_SIO 0x48 /* MII and ROM/EEPROM access */ +#define DC_ROM 0x50 /* ROM programming address */ +#define DC_TIMER 0x58 /* general timer */ +#define DC_10BTSTAT 0x60 /* SIA status */ +#define DC_SIARESET 0x68 /* SIA connectivity */ +#define DC_10BTCTRL 0x70 /* SIA transmit and receive */ +#define DC_WATCHDOG 0x78 /* SIA and general purpose port */ +#define DC_SIAGP 0x78 /* SIA and general purpose port (X3201) */ /* * There are two general 'types' of MX chips that we need to be @@ -64,427 +64,427 @@ * 'magic' numbers we write to CSR16. The PNIC II falls into the * 98713A/98715/98715A/98725 category. */ -#define DC_TYPE_98713 0x1 -#define DC_TYPE_98713A 0x2 -#define DC_TYPE_987x5 0x3 +#define DC_TYPE_98713 0x1 +#define DC_TYPE_98713A 0x2 +#define DC_TYPE_987x5 0x3 /* Other type of supported chips. */ -#define DC_TYPE_21143 0x4 /* Intel 21143 */ -#define DC_TYPE_ASIX 0x5 /* ASIX AX88140A/AX88141 */ -#define DC_TYPE_AL981 0x6 /* ADMtek AL981 Comet */ -#define DC_TYPE_AN983 0x7 /* ADMtek AN983 Centaur */ -#define DC_TYPE_DM9102 0x8 /* Davicom DM9102 */ -#define DC_TYPE_PNICII 0x9 /* 82c115 PNIC II */ -#define DC_TYPE_PNIC 0xA /* 82c168/82c169 PNIC I */ +#define DC_TYPE_21143 0x4 /* Intel 21143 */ +#define DC_TYPE_ASIX 0x5 /* ASIX AX88140A/AX88141 */ +#define DC_TYPE_AL981 0x6 /* ADMtek AL981 Comet */ +#define DC_TYPE_AN983 0x7 /* ADMtek AN983 Centaur */ +#define DC_TYPE_DM9102 0x8 /* Davicom DM9102 */ +#define DC_TYPE_PNICII 0x9 /* 82c115 PNIC II */ +#define DC_TYPE_PNIC 0xA /* 82c168/82c169 PNIC I */ #define DC_TYPE_XIRCOM 0xB /* Xircom X3201 */ -#define DC_TYPE_CONEXANT 0xC /* Conexant LANfinity RS7112 */ +#define DC_TYPE_CONEXANT 0xC /* Conexant LANfinity RS7112 */ -#define DC_IS_MACRONIX(x) \ +#define DC_IS_MACRONIX(x) \ (x->dc_type == DC_TYPE_98713 || \ x->dc_type == DC_TYPE_98713A || \ x->dc_type == DC_TYPE_987x5) -#define DC_IS_ADMTEK(x) \ +#define DC_IS_ADMTEK(x) \ (x->dc_type == DC_TYPE_AL981 || \ x->dc_type == DC_TYPE_AN983) -#define DC_IS_INTEL(x) (x->dc_type == DC_TYPE_21143) -#define DC_IS_ASIX(x) (x->dc_type == DC_TYPE_ASIX) -#define DC_IS_COMET(x) (x->dc_type == DC_TYPE_AL981) -#define DC_IS_CENTAUR(x) (x->dc_type == DC_TYPE_AN983) -#define DC_IS_DAVICOM(x) (x->dc_type == DC_TYPE_DM9102) -#define DC_IS_PNICII(x) (x->dc_type == DC_TYPE_PNICII) -#define DC_IS_PNIC(x) (x->dc_type == DC_TYPE_PNIC) +#define DC_IS_INTEL(x) (x->dc_type == DC_TYPE_21143) +#define DC_IS_ASIX(x) (x->dc_type == DC_TYPE_ASIX) +#define DC_IS_COMET(x) (x->dc_type == DC_TYPE_AL981) +#define DC_IS_CENTAUR(x) (x->dc_type == DC_TYPE_AN983) +#define DC_IS_DAVICOM(x) (x->dc_type == DC_TYPE_DM9102) +#define DC_IS_PNICII(x) (x->dc_type == DC_TYPE_PNICII) +#define DC_IS_PNIC(x) (x->dc_type == DC_TYPE_PNIC) #define DC_IS_XIRCOM(x) (x->dc_type == DC_TYPE_XIRCOM) -#define DC_IS_CONEXANT(x) (x->dc_type == DC_TYPE_CONEXANT) +#define DC_IS_CONEXANT(x) (x->dc_type == DC_TYPE_CONEXANT) /* MII/symbol mode port types */ -#define DC_PMODE_MII 0x1 -#define DC_PMODE_SYM 0x2 -#define DC_PMODE_SIA 0x3 +#define DC_PMODE_MII 0x1 +#define DC_PMODE_SYM 0x2 +#define DC_PMODE_SIA 0x3 /* * Bus control bits. */ -#define DC_BUSCTL_RESET 0x00000001 -#define DC_BUSCTL_ARBITRATION 0x00000002 -#define DC_BUSCTL_SKIPLEN 0x0000007C -#define DC_BUSCTL_BUF_BIGENDIAN 0x00000080 -#define DC_BUSCTL_BURSTLEN 0x00003F00 -#define DC_BUSCTL_CACHEALIGN 0x0000C000 -#define DC_BUSCTL_TXPOLL 0x000E0000 -#define DC_BUSCTL_DBO 0x00100000 -#define DC_BUSCTL_MRME 0x00200000 -#define DC_BUSCTL_MRLE 0x00800000 -#define DC_BUSCTL_MWIE 0x01000000 -#define DC_BUSCTL_ONNOW_ENB 0x04000000 - -#define DC_SKIPLEN_1LONG 0x00000004 -#define DC_SKIPLEN_2LONG 0x00000008 -#define DC_SKIPLEN_3LONG 0x00000010 -#define DC_SKIPLEN_4LONG 0x00000020 -#define DC_SKIPLEN_5LONG 0x00000040 - -#define DC_CACHEALIGN_NONE 0x00000000 -#define DC_CACHEALIGN_8LONG 0x00004000 -#define DC_CACHEALIGN_16LONG 0x00008000 -#define DC_CACHEALIGN_32LONG 0x0000C000 - -#define DC_BURSTLEN_USECA 0x00000000 -#define DC_BURSTLEN_1LONG 0x00000100 -#define DC_BURSTLEN_2LONG 0x00000200 -#define DC_BURSTLEN_4LONG 0x00000400 -#define DC_BURSTLEN_8LONG 0x00000800 -#define DC_BURSTLEN_16LONG 0x00001000 -#define DC_BURSTLEN_32LONG 0x00002000 - -#define DC_TXPOLL_OFF 0x00000000 -#define DC_TXPOLL_1 0x00020000 -#define DC_TXPOLL_2 0x00040000 -#define DC_TXPOLL_3 0x00060000 -#define DC_TXPOLL_4 0x00080000 -#define DC_TXPOLL_5 0x000A0000 -#define DC_TXPOLL_6 0x000C0000 -#define DC_TXPOLL_7 0x000E0000 +#define DC_BUSCTL_RESET 0x00000001 +#define DC_BUSCTL_ARBITRATION 0x00000002 +#define DC_BUSCTL_SKIPLEN 0x0000007C +#define DC_BUSCTL_BUF_BIGENDIAN 0x00000080 +#define DC_BUSCTL_BURSTLEN 0x00003F00 +#define DC_BUSCTL_CACHEALIGN 0x0000C000 +#define DC_BUSCTL_TXPOLL 0x000E0000 +#define DC_BUSCTL_DBO 0x00100000 +#define DC_BUSCTL_MRME 0x00200000 +#define DC_BUSCTL_MRLE 0x00800000 +#define DC_BUSCTL_MWIE 0x01000000 +#define DC_BUSCTL_ONNOW_ENB 0x04000000 + +#define DC_SKIPLEN_1LONG 0x00000004 +#define DC_SKIPLEN_2LONG 0x00000008 +#define DC_SKIPLEN_3LONG 0x00000010 +#define DC_SKIPLEN_4LONG 0x00000020 +#define DC_SKIPLEN_5LONG 0x00000040 + +#define DC_CACHEALIGN_NONE 0x00000000 +#define DC_CACHEALIGN_8LONG 0x00004000 +#define DC_CACHEALIGN_16LONG 0x00008000 +#define DC_CACHEALIGN_32LONG 0x0000C000 + +#define DC_BURSTLEN_USECA 0x00000000 +#define DC_BURSTLEN_1LONG 0x00000100 +#define DC_BURSTLEN_2LONG 0x00000200 +#define DC_BURSTLEN_4LONG 0x00000400 +#define DC_BURSTLEN_8LONG 0x00000800 +#define DC_BURSTLEN_16LONG 0x00001000 +#define DC_BURSTLEN_32LONG 0x00002000 + +#define DC_TXPOLL_OFF 0x00000000 +#define DC_TXPOLL_1 0x00020000 +#define DC_TXPOLL_2 0x00040000 +#define DC_TXPOLL_3 0x00060000 +#define DC_TXPOLL_4 0x00080000 +#define DC_TXPOLL_5 0x000A0000 +#define DC_TXPOLL_6 0x000C0000 +#define DC_TXPOLL_7 0x000E0000 /* * Interrupt status bits. */ -#define DC_ISR_TX_OK 0x00000001 -#define DC_ISR_TX_IDLE 0x00000002 -#define DC_ISR_TX_NOBUF 0x00000004 -#define DC_ISR_TX_JABBERTIMEO 0x00000008 -#define DC_ISR_LINKGOOD 0x00000010 -#define DC_ISR_TX_UNDERRUN 0x00000020 -#define DC_ISR_RX_OK 0x00000040 -#define DC_ISR_RX_NOBUF 0x00000080 -#define DC_ISR_RX_READ 0x00000100 -#define DC_ISR_RX_WATDOGTIMEO 0x00000200 -#define DC_ISR_TX_EARLY 0x00000400 -#define DC_ISR_TIMER_EXPIRED 0x00000800 -#define DC_ISR_LINKFAIL 0x00001000 -#define DC_ISR_BUS_ERR 0x00002000 -#define DC_ISR_RX_EARLY 0x00004000 -#define DC_ISR_ABNORMAL 0x00008000 -#define DC_ISR_NORMAL 0x00010000 -#define DC_ISR_RX_STATE 0x000E0000 -#define DC_ISR_TX_STATE 0x00700000 -#define DC_ISR_BUSERRTYPE 0x03800000 -#define DC_ISR_100MBPSLINK 0x08000000 -#define DC_ISR_MAGICKPACK 0x10000000 - -#define DC_RXSTATE_STOPPED 0x00000000 /* 000 - Stopped */ -#define DC_RXSTATE_FETCH 0x00020000 /* 001 - Fetching descriptor */ -#define DC_RXSTATE_ENDCHECK 0x00040000 /* 010 - check for rx end */ -#define DC_RXSTATE_WAIT 0x00060000 /* 011 - waiting for packet */ -#define DC_RXSTATE_SUSPEND 0x00080000 /* 100 - suspend rx */ -#define DC_RXSTATE_CLOSE 0x000A0000 /* 101 - close tx desc */ -#define DC_RXSTATE_FLUSH 0x000C0000 /* 110 - flush from FIFO */ -#define DC_RXSTATE_DEQUEUE 0x000E0000 /* 111 - dequeue from FIFO */ +#define DC_ISR_TX_OK 0x00000001 +#define DC_ISR_TX_IDLE 0x00000002 +#define DC_ISR_TX_NOBUF 0x00000004 +#define DC_ISR_TX_JABBERTIMEO 0x00000008 +#define DC_ISR_LINKGOOD 0x00000010 +#define DC_ISR_TX_UNDERRUN 0x00000020 +#define DC_ISR_RX_OK 0x00000040 +#define DC_ISR_RX_NOBUF 0x00000080 +#define DC_ISR_RX_READ 0x00000100 +#define DC_ISR_RX_WATDOGTIMEO 0x00000200 +#define DC_ISR_TX_EARLY 0x00000400 +#define DC_ISR_TIMER_EXPIRED 0x00000800 +#define DC_ISR_LINKFAIL 0x00001000 +#define DC_ISR_BUS_ERR 0x00002000 +#define DC_ISR_RX_EARLY 0x00004000 +#define DC_ISR_ABNORMAL 0x00008000 +#define DC_ISR_NORMAL 0x00010000 +#define DC_ISR_RX_STATE 0x000E0000 +#define DC_ISR_TX_STATE 0x00700000 +#define DC_ISR_BUSERRTYPE 0x03800000 +#define DC_ISR_100MBPSLINK 0x08000000 +#define DC_ISR_MAGICKPACK 0x10000000 + +#define DC_RXSTATE_STOPPED 0x00000000 /* 000 - Stopped */ +#define DC_RXSTATE_FETCH 0x00020000 /* 001 - Fetching descriptor */ +#define DC_RXSTATE_ENDCHECK 0x00040000 /* 010 - check for rx end */ +#define DC_RXSTATE_WAIT 0x00060000 /* 011 - waiting for packet */ +#define DC_RXSTATE_SUSPEND 0x00080000 /* 100 - suspend rx */ +#define DC_RXSTATE_CLOSE 0x000A0000 /* 101 - close tx desc */ +#define DC_RXSTATE_FLUSH 0x000C0000 /* 110 - flush from FIFO */ +#define DC_RXSTATE_DEQUEUE 0x000E0000 /* 111 - dequeue from FIFO */ #define DC_HAS_BROKEN_RXSTATE(x) \ (DC_IS_CENTAUR(x) || DC_IS_CONEXANT(x) || (DC_IS_DAVICOM(x) && \ pci_get_revid((x)->dc_dev) >= DC_REVISION_DM9102A)) -#define DC_TXSTATE_RESET 0x00000000 /* 000 - reset */ -#define DC_TXSTATE_FETCH 0x00100000 /* 001 - fetching descriptor */ -#define DC_TXSTATE_WAITEND 0x00200000 /* 010 - wait for tx end */ -#define DC_TXSTATE_READING 0x00300000 /* 011 - read and enqueue */ -#define DC_TXSTATE_RSVD 0x00400000 /* 100 - reserved */ -#define DC_TXSTATE_SETUP 0x00500000 /* 101 - setup packet */ -#define DC_TXSTATE_SUSPEND 0x00600000 /* 110 - suspend tx */ -#define DC_TXSTATE_CLOSE 0x00700000 /* 111 - close tx desc */ +#define DC_TXSTATE_RESET 0x00000000 /* 000 - reset */ +#define DC_TXSTATE_FETCH 0x00100000 /* 001 - fetching descriptor */ +#define DC_TXSTATE_WAITEND 0x00200000 /* 010 - wait for tx end */ +#define DC_TXSTATE_READING 0x00300000 /* 011 - read and enqueue */ +#define DC_TXSTATE_RSVD 0x00400000 /* 100 - reserved */ +#define DC_TXSTATE_SETUP 0x00500000 /* 101 - setup packet */ +#define DC_TXSTATE_SUSPEND 0x00600000 /* 110 - suspend tx */ +#define DC_TXSTATE_CLOSE 0x00700000 /* 111 - close tx desc */ /* * Network config bits. */ -#define DC_NETCFG_RX_HASHPERF 0x00000001 -#define DC_NETCFG_RX_ON 0x00000002 -#define DC_NETCFG_RX_HASHONLY 0x00000004 -#define DC_NETCFG_RX_BADFRAMES 0x00000008 -#define DC_NETCFG_RX_INVFILT 0x00000010 -#define DC_NETCFG_BACKOFFCNT 0x00000020 -#define DC_NETCFG_RX_PROMISC 0x00000040 -#define DC_NETCFG_RX_ALLMULTI 0x00000080 -#define DC_NETCFG_FULLDUPLEX 0x00000200 -#define DC_NETCFG_LOOPBACK 0x00000C00 -#define DC_NETCFG_FORCECOLL 0x00001000 -#define DC_NETCFG_TX_ON 0x00002000 -#define DC_NETCFG_TX_THRESH 0x0000C000 -#define DC_NETCFG_TX_BACKOFF 0x00020000 -#define DC_NETCFG_PORTSEL 0x00040000 /* 0 == 10, 1 == 100 */ -#define DC_NETCFG_HEARTBEAT 0x00080000 -#define DC_NETCFG_STORENFWD 0x00200000 -#define DC_NETCFG_SPEEDSEL 0x00400000 /* 1 == 10, 0 == 100 */ -#define DC_NETCFG_PCS 0x00800000 -#define DC_NETCFG_SCRAMBLER 0x01000000 -#define DC_NETCFG_NO_RXCRC 0x02000000 -#define DC_NETCFG_RX_ALL 0x40000000 -#define DC_NETCFG_CAPEFFECT 0x80000000 - -#define DC_OPMODE_NORM 0x00000000 -#define DC_OPMODE_INTLOOP 0x00000400 -#define DC_OPMODE_EXTLOOP 0x00000800 +#define DC_NETCFG_RX_HASHPERF 0x00000001 +#define DC_NETCFG_RX_ON 0x00000002 +#define DC_NETCFG_RX_HASHONLY 0x00000004 +#define DC_NETCFG_RX_BADFRAMES 0x00000008 +#define DC_NETCFG_RX_INVFILT 0x00000010 +#define DC_NETCFG_BACKOFFCNT 0x00000020 +#define DC_NETCFG_RX_PROMISC 0x00000040 +#define DC_NETCFG_RX_ALLMULTI 0x00000080 +#define DC_NETCFG_FULLDUPLEX 0x00000200 +#define DC_NETCFG_LOOPBACK 0x00000C00 +#define DC_NETCFG_FORCECOLL 0x00001000 +#define DC_NETCFG_TX_ON 0x00002000 +#define DC_NETCFG_TX_THRESH 0x0000C000 +#define DC_NETCFG_TX_BACKOFF 0x00020000 +#define DC_NETCFG_PORTSEL 0x00040000 /* 0 == 10, 1 == 100 */ +#define DC_NETCFG_HEARTBEAT 0x00080000 +#define DC_NETCFG_STORENFWD 0x00200000 +#define DC_NETCFG_SPEEDSEL 0x00400000 /* 1 == 10, 0 == 100 */ +#define DC_NETCFG_PCS 0x00800000 +#define DC_NETCFG_SCRAMBLER 0x01000000 +#define DC_NETCFG_NO_RXCRC 0x02000000 +#define DC_NETCFG_RX_ALL 0x40000000 +#define DC_NETCFG_CAPEFFECT 0x80000000 + +#define DC_OPMODE_NORM 0x00000000 +#define DC_OPMODE_INTLOOP 0x00000400 +#define DC_OPMODE_EXTLOOP 0x00000800 #if 0 -#define DC_TXTHRESH_72BYTES 0x00000000 -#define DC_TXTHRESH_96BYTES 0x00004000 -#define DC_TXTHRESH_128BYTES 0x00008000 -#define DC_TXTHRESH_160BYTES 0x0000C000 +#define DC_TXTHRESH_72BYTES 0x00000000 +#define DC_TXTHRESH_96BYTES 0x00004000 +#define DC_TXTHRESH_128BYTES 0x00008000 +#define DC_TXTHRESH_160BYTES 0x0000C000 #endif -#define DC_TXTHRESH_MIN 0x00000000 -#define DC_TXTHRESH_INC 0x00004000 -#define DC_TXTHRESH_MAX 0x0000C000 +#define DC_TXTHRESH_MIN 0x00000000 +#define DC_TXTHRESH_INC 0x00004000 +#define DC_TXTHRESH_MAX 0x0000C000 /* * Interrupt mask bits. */ -#define DC_IMR_TX_OK 0x00000001 -#define DC_IMR_TX_IDLE 0x00000002 -#define DC_IMR_TX_NOBUF 0x00000004 -#define DC_IMR_TX_JABBERTIMEO 0x00000008 -#define DC_IMR_LINKGOOD 0x00000010 -#define DC_IMR_TX_UNDERRUN 0x00000020 -#define DC_IMR_RX_OK 0x00000040 -#define DC_IMR_RX_NOBUF 0x00000080 -#define DC_IMR_RX_READ 0x00000100 -#define DC_IMR_RX_WATDOGTIMEO 0x00000200 -#define DC_IMR_TX_EARLY 0x00000400 -#define DC_IMR_TIMER_EXPIRED 0x00000800 -#define DC_IMR_LINKFAIL 0x00001000 -#define DC_IMR_BUS_ERR 0x00002000 -#define DC_IMR_RX_EARLY 0x00004000 -#define DC_IMR_ABNORMAL 0x00008000 -#define DC_IMR_NORMAL 0x00010000 -#define DC_IMR_100MBPSLINK 0x08000000 -#define DC_IMR_MAGICKPACK 0x10000000 +#define DC_IMR_TX_OK 0x00000001 +#define DC_IMR_TX_IDLE 0x00000002 +#define DC_IMR_TX_NOBUF 0x00000004 +#define DC_IMR_TX_JABBERTIMEO 0x00000008 +#define DC_IMR_LINKGOOD 0x00000010 +#define DC_IMR_TX_UNDERRUN 0x00000020 +#define DC_IMR_RX_OK 0x00000040 +#define DC_IMR_RX_NOBUF 0x00000080 +#define DC_IMR_RX_READ 0x00000100 +#define DC_IMR_RX_WATDOGTIMEO 0x00000200 +#define DC_IMR_TX_EARLY 0x00000400 +#define DC_IMR_TIMER_EXPIRED 0x00000800 +#define DC_IMR_LINKFAIL 0x00001000 +#define DC_IMR_BUS_ERR 0x00002000 +#define DC_IMR_RX_EARLY 0x00004000 +#define DC_IMR_ABNORMAL 0x00008000 +#define DC_IMR_NORMAL 0x00010000 +#define DC_IMR_100MBPSLINK 0x08000000 +#define DC_IMR_MAGICKPACK 0x10000000 -#define DC_INTRS \ +#define DC_INTRS \ (DC_IMR_RX_OK|DC_IMR_TX_OK|DC_IMR_RX_NOBUF|DC_IMR_RX_WATDOGTIMEO|\ DC_IMR_TX_NOBUF|DC_IMR_TX_UNDERRUN|DC_IMR_BUS_ERR| \ DC_IMR_ABNORMAL|DC_IMR_NORMAL/*|DC_IMR_TX_EARLY*/) /* * Serial I/O (EEPROM/ROM) bits. */ -#define DC_SIO_EE_CS 0x00000001 /* EEPROM chip select */ -#define DC_SIO_EE_CLK 0x00000002 /* EEPROM clock */ -#define DC_SIO_EE_DATAIN 0x00000004 /* EEPROM data output */ -#define DC_SIO_EE_DATAOUT 0x00000008 /* EEPROM data input */ -#define DC_SIO_ROMDATA4 0x00000010 -#define DC_SIO_ROMDATA5 0x00000020 -#define DC_SIO_ROMDATA6 0x00000040 -#define DC_SIO_ROMDATA7 0x00000080 -#define DC_SIO_EESEL 0x00000800 -#define DC_SIO_ROMSEL 0x00001000 -#define DC_SIO_ROMCTL_WRITE 0x00002000 -#define DC_SIO_ROMCTL_READ 0x00004000 -#define DC_SIO_MII_CLK 0x00010000 /* MDIO clock */ -#define DC_SIO_MII_DATAOUT 0x00020000 /* MDIO data out */ -#define DC_SIO_MII_DIR 0x00040000 /* MDIO dir */ -#define DC_SIO_MII_DATAIN 0x00080000 /* MDIO data in */ - -#define DC_EECMD_WRITE 0x140 -#define DC_EECMD_READ 0x180 -#define DC_EECMD_ERASE 0x1c0 +#define DC_SIO_EE_CS 0x00000001 /* EEPROM chip select */ +#define DC_SIO_EE_CLK 0x00000002 /* EEPROM clock */ +#define DC_SIO_EE_DATAIN 0x00000004 /* EEPROM data output */ +#define DC_SIO_EE_DATAOUT 0x00000008 /* EEPROM data input */ +#define DC_SIO_ROMDATA4 0x00000010 +#define DC_SIO_ROMDATA5 0x00000020 +#define DC_SIO_ROMDATA6 0x00000040 +#define DC_SIO_ROMDATA7 0x00000080 +#define DC_SIO_EESEL 0x00000800 +#define DC_SIO_ROMSEL 0x00001000 +#define DC_SIO_ROMCTL_WRITE 0x00002000 +#define DC_SIO_ROMCTL_READ 0x00004000 +#define DC_SIO_MII_CLK 0x00010000 /* MDIO clock */ +#define DC_SIO_MII_DATAOUT 0x00020000 /* MDIO data out */ +#define DC_SIO_MII_DIR 0x00040000 /* MDIO dir */ +#define DC_SIO_MII_DATAIN 0x00080000 /* MDIO data in */ + +#define DC_EECMD_WRITE 0x140 +#define DC_EECMD_READ 0x180 +#define DC_EECMD_ERASE 0x1c0 -#define DC_EE_NODEADDR_OFFSET 0x70 -#define DC_EE_NODEADDR 10 +#define DC_EE_NODEADDR_OFFSET 0x70 +#define DC_EE_NODEADDR 10 /* * General purpose timer register */ -#define DC_TIMER_VALUE 0x0000FFFF -#define DC_TIMER_CONTINUOUS 0x00010000 +#define DC_TIMER_VALUE 0x0000FFFF +#define DC_TIMER_CONTINUOUS 0x00010000 /* * 10baseT status register */ -#define DC_TSTAT_MIIACT 0x00000001 /* MII port activity */ -#define DC_TSTAT_LS100 0x00000002 /* link status of 100baseTX */ -#define DC_TSTAT_LS10 0x00000004 /* link status of 10baseT */ -#define DC_TSTAT_AUTOPOLARITY 0x00000008 -#define DC_TSTAT_AUIACT 0x00000100 /* AUI activity */ -#define DC_TSTAT_10BTACT 0x00000200 /* 10baseT activity */ -#define DC_TSTAT_NSN 0x00000400 /* non-stable FLPs detected */ -#define DC_TSTAT_REMFAULT 0x00000800 -#define DC_TSTAT_ANEGSTAT 0x00007000 -#define DC_TSTAT_LP_CAN_NWAY 0x00008000 /* link partner supports NWAY */ -#define DC_TSTAT_LPCODEWORD 0xFFFF0000 /* link partner's code word */ - -#define DC_ASTAT_DISABLE 0x00000000 -#define DC_ASTAT_TXDISABLE 0x00001000 -#define DC_ASTAT_ABDETECT 0x00002000 -#define DC_ASTAT_ACKDETECT 0x00003000 -#define DC_ASTAT_CMPACKDETECT 0x00004000 -#define DC_ASTAT_AUTONEGCMP 0x00005000 -#define DC_ASTAT_LINKCHECK 0x00006000 +#define DC_TSTAT_MIIACT 0x00000001 /* MII port activity */ +#define DC_TSTAT_LS100 0x00000002 /* link status of 100baseTX */ +#define DC_TSTAT_LS10 0x00000004 /* link status of 10baseT */ +#define DC_TSTAT_AUTOPOLARITY 0x00000008 +#define DC_TSTAT_AUIACT 0x00000100 /* AUI activity */ +#define DC_TSTAT_10BTACT 0x00000200 /* 10baseT activity */ +#define DC_TSTAT_NSN 0x00000400 /* non-stable FLPs detected */ +#define DC_TSTAT_REMFAULT 0x00000800 +#define DC_TSTAT_ANEGSTAT 0x00007000 +#define DC_TSTAT_LP_CAN_NWAY 0x00008000 /* link partner supports NWAY */ +#define DC_TSTAT_LPCODEWORD 0xFFFF0000 /* link partner's code word */ + +#define DC_ASTAT_DISABLE 0x00000000 +#define DC_ASTAT_TXDISABLE 0x00001000 +#define DC_ASTAT_ABDETECT 0x00002000 +#define DC_ASTAT_ACKDETECT 0x00003000 +#define DC_ASTAT_CMPACKDETECT 0x00004000 +#define DC_ASTAT_AUTONEGCMP 0x00005000 +#define DC_ASTAT_LINKCHECK 0x00006000 /* * PHY reset register */ -#define DC_SIA_RESET 0x00000001 -#define DC_SIA_AUI 0x00000008 /* AUI or 10baseT */ +#define DC_SIA_RESET 0x00000001 +#define DC_SIA_AUI 0x00000008 /* AUI or 10baseT */ /* * 10baseT control register */ -#define DC_TCTL_ENCODER_ENB 0x00000001 -#define DC_TCTL_LOOPBACK 0x00000002 -#define DC_TCTL_DRIVER_ENB 0x00000004 -#define DC_TCTL_LNKPULSE_ENB 0x00000008 -#define DC_TCTL_HALFDUPLEX 0x00000040 -#define DC_TCTL_AUTONEGENBL 0x00000080 -#define DC_TCTL_RX_SQUELCH 0x00000100 -#define DC_TCTL_COLL_SQUELCH 0x00000200 -#define DC_TCTL_COLL_DETECT 0x00000400 -#define DC_TCTL_SQE_ENB 0x00000800 -#define DC_TCTL_LINKTEST 0x00001000 -#define DC_TCTL_AUTOPOLARITY 0x00002000 -#define DC_TCTL_SET_POL_PLUS 0x00004000 -#define DC_TCTL_AUTOSENSE 0x00008000 /* 10bt/AUI autosense */ -#define DC_TCTL_100BTXHALF 0x00010000 -#define DC_TCTL_100BTXFULL 0x00020000 -#define DC_TCTL_100BT4 0x00040000 +#define DC_TCTL_ENCODER_ENB 0x00000001 +#define DC_TCTL_LOOPBACK 0x00000002 +#define DC_TCTL_DRIVER_ENB 0x00000004 +#define DC_TCTL_LNKPULSE_ENB 0x00000008 +#define DC_TCTL_HALFDUPLEX 0x00000040 +#define DC_TCTL_AUTONEGENBL 0x00000080 +#define DC_TCTL_RX_SQUELCH 0x00000100 +#define DC_TCTL_COLL_SQUELCH 0x00000200 +#define DC_TCTL_COLL_DETECT 0x00000400 +#define DC_TCTL_SQE_ENB 0x00000800 +#define DC_TCTL_LINKTEST 0x00001000 +#define DC_TCTL_AUTOPOLARITY 0x00002000 +#define DC_TCTL_SET_POL_PLUS 0x00004000 +#define DC_TCTL_AUTOSENSE 0x00008000 /* 10bt/AUI autosense */ +#define DC_TCTL_100BTXHALF 0x00010000 +#define DC_TCTL_100BTXFULL 0x00020000 +#define DC_TCTL_100BT4 0x00040000 /* * Watchdog timer register */ -#define DC_WDOG_JABBERDIS 0x00000001 -#define DC_WDOG_HOSTUNJAB 0x00000002 -#define DC_WDOG_JABBERCLK 0x00000004 -#define DC_WDOG_RXWDOGDIS 0x00000010 -#define DC_WDOG_RXWDOGCLK 0x00000020 -#define DC_WDOG_MUSTBEZERO 0x00000100 -#define DC_WDOG_AUIBNC 0x00100000 -#define DC_WDOG_ACTIVITY 0x00200000 -#define DC_WDOG_RX_MATCH 0x00400000 -#define DC_WDOG_LINK 0x00800000 -#define DC_WDOG_CTLWREN 0x08000000 +#define DC_WDOG_JABBERDIS 0x00000001 +#define DC_WDOG_HOSTUNJAB 0x00000002 +#define DC_WDOG_JABBERCLK 0x00000004 +#define DC_WDOG_RXWDOGDIS 0x00000010 +#define DC_WDOG_RXWDOGCLK 0x00000020 +#define DC_WDOG_MUSTBEZERO 0x00000100 +#define DC_WDOG_AUIBNC 0x00100000 +#define DC_WDOG_ACTIVITY 0x00200000 +#define DC_WDOG_RX_MATCH 0x00400000 +#define DC_WDOG_LINK 0x00800000 +#define DC_WDOG_CTLWREN 0x08000000 /* * SIA and General Purpose Port register (X3201) */ -#define DC_SIAGP_RXMATCH 0x40000000 -#define DC_SIAGP_INT1 0x20000000 -#define DC_SIAGP_INT0 0x10000000 -#define DC_SIAGP_WRITE_EN 0x08000000 -#define DC_SIAGP_RXMATCH_EN 0x04000000 -#define DC_SIAGP_INT1_EN 0x02000000 -#define DC_SIAGP_INT0_EN 0x01000000 -#define DC_SIAGP_LED3 0x00800000 -#define DC_SIAGP_LED2 0x00400000 -#define DC_SIAGP_LED1 0x00200000 -#define DC_SIAGP_LED0 0x00100000 -#define DC_SIAGP_MD_GP3_OUTPUT 0x00080000 -#define DC_SIAGP_MD_GP2_OUTPUT 0x00040000 -#define DC_SIAGP_MD_GP1_OUTPUT 0x00020000 -#define DC_SIAGP_MD_GP0_OUTPUT 0x00010000 +#define DC_SIAGP_RXMATCH 0x40000000 +#define DC_SIAGP_INT1 0x20000000 +#define DC_SIAGP_INT0 0x10000000 +#define DC_SIAGP_WRITE_EN 0x08000000 +#define DC_SIAGP_RXMATCH_EN 0x04000000 +#define DC_SIAGP_INT1_EN 0x02000000 +#define DC_SIAGP_INT0_EN 0x01000000 +#define DC_SIAGP_LED3 0x00800000 +#define DC_SIAGP_LED2 0x00400000 +#define DC_SIAGP_LED1 0x00200000 +#define DC_SIAGP_LED0 0x00100000 +#define DC_SIAGP_MD_GP3_OUTPUT 0x00080000 +#define DC_SIAGP_MD_GP2_OUTPUT 0x00040000 +#define DC_SIAGP_MD_GP1_OUTPUT 0x00020000 +#define DC_SIAGP_MD_GP0_OUTPUT 0x00010000 /* * Size of a setup frame. */ -#define DC_SFRAME_LEN 192 +#define DC_SFRAME_LEN 192 /* * 21x4x TX/RX list structure. */ struct dc_desc { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 23:09:09 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DB3321065673; Sun, 27 Mar 2011 23:09:09 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C75288FC15; Sun, 27 Mar 2011 23:09:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RN995N072410; Sun, 27 Mar 2011 23:09:09 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RN99bP072407; Sun, 27 Mar 2011 23:09:09 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272309.p2RN99bP072407@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 23:09:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220077 - stable/7/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 23:09:10 -0000 Author: yongari Date: Sun Mar 27 23:09:09 2011 New Revision: 220077 URL: http://svn.freebsd.org/changeset/base/220077 Log: MFC r218834-218835: r218834: Consistently use a tab character instead of space after #define. No functional changes. r218835: s/u_intXX_t/uintXX_t/g Modified: stable/7/sys/dev/dc/if_dc.c stable/7/sys/dev/dc/if_dcreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 23:08:01 2011 (r220076) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 23:09:09 2011 (r220077) @@ -127,7 +127,7 @@ __FBSDID("$FreeBSD$"); #include #include -#define DC_USEIOSPACE +#define DC_USEIOSPACE #include @@ -261,16 +261,16 @@ static void dc_dma_map_addr(void *, bus_ static void dc_delay(struct dc_softc *); static void dc_eeprom_idle(struct dc_softc *); static void dc_eeprom_putbyte(struct dc_softc *, int); -static void dc_eeprom_getword(struct dc_softc *, int, u_int16_t *); -static void dc_eeprom_getword_pnic(struct dc_softc *, int, u_int16_t *); -static void dc_eeprom_getword_xircom(struct dc_softc *, int, u_int16_t *); +static void dc_eeprom_getword(struct dc_softc *, int, uint16_t *); +static void dc_eeprom_getword_pnic(struct dc_softc *, int, uint16_t *); +static void dc_eeprom_getword_xircom(struct dc_softc *, int, uint16_t *); static void dc_eeprom_width(struct dc_softc *); static void dc_read_eeprom(struct dc_softc *, caddr_t, int, int, int); static void dc_mii_writebit(struct dc_softc *, int); static int dc_mii_readbit(struct dc_softc *); static void dc_mii_sync(struct dc_softc *); -static void dc_mii_send(struct dc_softc *, u_int32_t, int); +static void dc_mii_send(struct dc_softc *, uint32_t, int); static int dc_mii_readreg(struct dc_softc *, struct dc_mii_frame *); static int dc_mii_writereg(struct dc_softc *, struct dc_mii_frame *); static int dc_miibus_readreg(device_t, int, int); @@ -301,11 +301,11 @@ static void dc_apply_fixup(struct dc_sof static int dc_check_multiport(struct dc_softc *); #ifdef DC_USEIOSPACE -#define DC_RES SYS_RES_IOPORT -#define DC_RID DC_PCI_CFBIO +#define DC_RES SYS_RES_IOPORT +#define DC_RID DC_PCI_CFBIO #else -#define DC_RES SYS_RES_MEMORY -#define DC_RID DC_PCI_CFBMA +#define DC_RES SYS_RES_MEMORY +#define DC_RID DC_PCI_CFBMA #endif static device_method_t dc_methods[] = { @@ -342,14 +342,14 @@ DRIVER_MODULE(dc, cardbus, dc_driver, dc DRIVER_MODULE(dc, pci, dc_driver, dc_devclass, 0, 0); DRIVER_MODULE(miibus, dc, miibus_driver, miibus_devclass, 0, 0); -#define DC_SETBIT(sc, reg, x) \ +#define DC_SETBIT(sc, reg, x) \ CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) | (x)) -#define DC_CLRBIT(sc, reg, x) \ +#define DC_CLRBIT(sc, reg, x) \ CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) & ~(x)) -#define SIO_SET(x) DC_SETBIT(sc, DC_SIO, (x)) -#define SIO_CLR(x) DC_CLRBIT(sc, DC_SIO, (x)) +#define SIO_SET(x) DC_SETBIT(sc, DC_SIO, (x)) +#define SIO_CLR(x) DC_CLRBIT(sc, DC_SIO, (x)) static void dc_delay(struct dc_softc *sc) @@ -496,10 +496,10 @@ dc_eeprom_putbyte(struct dc_softc *sc, i * the EEPROM. */ static void -dc_eeprom_getword_pnic(struct dc_softc *sc, int addr, u_int16_t *dest) +dc_eeprom_getword_pnic(struct dc_softc *sc, int addr, uint16_t *dest) { int i; - u_int32_t r; + uint32_t r; CSR_WRITE_4(sc, DC_PN_SIOCTL, DC_PN_EEOPCODE_READ | addr); @@ -507,7 +507,7 @@ dc_eeprom_getword_pnic(struct dc_softc * DELAY(1); r = CSR_READ_4(sc, DC_SIO); if (!(r & DC_PN_SIOCTL_BUSY)) { - *dest = (u_int16_t)(r & 0xFFFF); + *dest = (uint16_t)(r & 0xFFFF); return; } } @@ -519,17 +519,17 @@ dc_eeprom_getword_pnic(struct dc_softc * * the EEPROM, too. */ static void -dc_eeprom_getword_xircom(struct dc_softc *sc, int addr, u_int16_t *dest) +dc_eeprom_getword_xircom(struct dc_softc *sc, int addr, uint16_t *dest) { SIO_SET(DC_SIO_ROMSEL | DC_SIO_ROMCTL_READ); addr *= 2; CSR_WRITE_4(sc, DC_ROM, addr | 0x160); - *dest = (u_int16_t)CSR_READ_4(sc, DC_SIO) & 0xff; + *dest = (uint16_t)CSR_READ_4(sc, DC_SIO) & 0xff; addr += 1; CSR_WRITE_4(sc, DC_ROM, addr | 0x160); - *dest |= ((u_int16_t)CSR_READ_4(sc, DC_SIO) & 0xff) << 8; + *dest |= ((uint16_t)CSR_READ_4(sc, DC_SIO) & 0xff) << 8; SIO_CLR(DC_SIO_ROMSEL | DC_SIO_ROMCTL_READ); } @@ -538,10 +538,10 @@ dc_eeprom_getword_xircom(struct dc_softc * Read a word of data stored in the EEPROM at address 'addr.' */ static void -dc_eeprom_getword(struct dc_softc *sc, int addr, u_int16_t *dest) +dc_eeprom_getword(struct dc_softc *sc, int addr, uint16_t *dest) { int i; - u_int16_t word = 0; + uint16_t word = 0; /* Force EEPROM to idle state. */ dc_eeprom_idle(sc); @@ -587,7 +587,7 @@ static void dc_read_eeprom(struct dc_softc *sc, caddr_t dest, int off, int cnt, int be) { int i; - u_int16_t word = 0, *ptr; + uint16_t word = 0, *ptr; for (i = 0; i < cnt; i++) { if (DC_IS_PNIC(sc)) @@ -596,7 +596,7 @@ dc_read_eeprom(struct dc_softc *sc, cadd dc_eeprom_getword_xircom(sc, off + i, &word); else dc_eeprom_getword(sc, off + i, &word); - ptr = (u_int16_t *)(dest + (i * 2)); + ptr = (uint16_t *)(dest + (i * 2)); if (be) *ptr = be16toh(word); else @@ -681,7 +681,7 @@ dc_mii_sync(struct dc_softc *sc) * Clock a series of bits through the MII. */ static void -dc_mii_send(struct dc_softc *sc, u_int32_t bits, int cnt) +dc_mii_send(struct dc_softc *sc, uint32_t bits, int cnt) { int i; @@ -1017,9 +1017,9 @@ dc_miibus_mediainit(device_t dev) ifmedia_add(ifm, IFM_ETHER | IFM_HPNA_1, 0, NULL); } -#define DC_BITS_512 9 -#define DC_BITS_128 7 -#define DC_BITS_64 6 +#define DC_BITS_512 9 +#define DC_BITS_128 7 +#define DC_BITS_64 6 static uint32_t dc_mchash_le(struct dc_softc *sc, const uint8_t *addr) @@ -1083,7 +1083,7 @@ dc_setfilt_21143(struct dc_softc *sc) { uint16_t eaddr[(ETHER_ADDR_LEN+1)/2]; struct dc_desc *sframe; - u_int32_t h, *sp; + uint32_t h, *sp; struct ifmultiaddr *ifma; struct ifnet *ifp; int i; @@ -1157,7 +1157,7 @@ dc_setfilt_admtek(struct dc_softc *sc) struct ifnet *ifp; struct ifmultiaddr *ifma; int h = 0; - u_int32_t hashes[2] = { 0, 0 }; + uint32_t hashes[2] = { 0, 0 }; ifp = sc->dc_ifp; @@ -1218,7 +1218,7 @@ dc_setfilt_asix(struct dc_softc *sc) struct ifnet *ifp; struct ifmultiaddr *ifma; int h = 0; - u_int32_t hashes[2] = { 0, 0 }; + uint32_t hashes[2] = { 0, 0 }; ifp = sc->dc_ifp; @@ -1288,7 +1288,7 @@ dc_setfilt_xircom(struct dc_softc *sc) struct ifnet *ifp; struct ifmultiaddr *ifma; struct dc_desc *sframe; - u_int32_t h, *sp; + uint32_t h, *sp; int i; ifp = sc->dc_ifp; @@ -1380,7 +1380,7 @@ static void dc_setcfg(struct dc_softc *sc, int media) { int i, restart = 0, watchdogreg; - u_int32_t isr; + uint32_t isr; if (IFM_SUBTYPE(media) == IFM_NONE) return; @@ -1564,8 +1564,8 @@ static const struct dc_type * dc_devtype(device_t dev) { const struct dc_type *t; - u_int32_t devid; - u_int8_t rev; + uint32_t devid; + uint8_t rev; t = dc_devs; devid = pci_get_devid(dev); @@ -1608,9 +1608,9 @@ static void dc_apply_fixup(struct dc_softc *sc, int media) { struct dc_mediainfo *m; - u_int8_t *p; + uint8_t *p; int i; - u_int32_t reg; + uint32_t reg; m = sc->dc_mi; @@ -1669,11 +1669,11 @@ dc_decode_leaf_sia(struct dc_softc *sc, if (l->dc_sia_code & DC_SIA_CODE_EXT) { m->dc_gp_len = 2; m->dc_gp_ptr = - (u_int8_t *)&l->dc_un.dc_sia_ext.dc_sia_gpio_ctl; + (uint8_t *)&l->dc_un.dc_sia_ext.dc_sia_gpio_ctl; } else { m->dc_gp_len = 2; m->dc_gp_ptr = - (u_int8_t *)&l->dc_un.dc_sia_noext.dc_sia_gpio_ctl; + (uint8_t *)&l->dc_un.dc_sia_noext.dc_sia_gpio_ctl; } m->dc_next = sc->dc_mi; @@ -1700,7 +1700,7 @@ dc_decode_leaf_sym(struct dc_softc *sc, m->dc_media = IFM_100_TX | IFM_FDX; m->dc_gp_len = 2; - m->dc_gp_ptr = (u_int8_t *)&l->dc_sym_gpio_ctl; + m->dc_gp_ptr = (uint8_t *)&l->dc_sym_gpio_ctl; m->dc_next = sc->dc_mi; sc->dc_mi = m; @@ -1713,7 +1713,7 @@ static int dc_decode_leaf_mii(struct dc_softc *sc, struct dc_eblock_mii *l) { struct dc_mediainfo *m; - u_int8_t *p; + uint8_t *p; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); if (m == NULL) { @@ -1724,7 +1724,7 @@ dc_decode_leaf_mii(struct dc_softc *sc, m->dc_media = IFM_AUTO; m->dc_gp_len = l->dc_gpr_len; - p = (u_int8_t *)l; + p = (uint8_t *)l; p += sizeof(struct dc_eblock_mii); m->dc_gp_ptr = p; p += 2 * l->dc_gpr_len; @@ -2032,13 +2032,13 @@ static int dc_attach(device_t dev) { uint32_t eaddr[(ETHER_ADDR_LEN+3)/4]; - u_int32_t command; + uint32_t command; struct dc_softc *sc; struct ifnet *ifp; struct dc_mediainfo *m; - u_int32_t reg, revision; + uint32_t reg, revision; int error, mac_offset, phy, rid, tmp; - u_int8_t *mac; + uint8_t *mac; sc = device_get_softc(dev); sc->dc_dev = dev; @@ -2716,7 +2716,7 @@ dc_newbuf(struct dc_softc *sc, int i) * the time. */ -#define DC_WHOLEFRAME (DC_RXSTAT_FIRSTFRAG | DC_RXSTAT_LASTFRAG) +#define DC_WHOLEFRAME (DC_RXSTAT_FIRSTFRAG | DC_RXSTAT_LASTFRAG) static void dc_pnic_rx_bug_war(struct dc_softc *sc, int idx) { @@ -2725,7 +2725,7 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, struct mbuf *m = NULL; unsigned char *ptr; int i, total_len; - u_int32_t rxstat = 0; + uint32_t rxstat = 0; i = sc->dc_pnic_rx_bug_save; cur_rx = &sc->dc_ldata.dc_rx_list[idx]; @@ -2836,7 +2836,7 @@ dc_rxeof(struct dc_softc *sc) struct ifnet *ifp; struct dc_desc *cur_rx; int i, total_len; - u_int32_t rxstat; + uint32_t rxstat; DC_LOCK_ASSERT(sc); @@ -2954,7 +2954,7 @@ dc_txeof(struct dc_softc *sc) struct dc_desc *cur_tx; struct ifnet *ifp; int idx, setup; - u_int32_t ctl, txstat; + uint32_t ctl, txstat; if (sc->dc_cdata.dc_tx_cnt == 0) return; @@ -3063,7 +3063,7 @@ dc_tick(void *xsc) struct dc_softc *sc; struct mii_data *mii; struct ifnet *ifp; - u_int32_t r; + uint32_t r; sc = xsc; DC_LOCK_ASSERT(sc); @@ -3140,7 +3140,7 @@ dc_tick(void *xsc) static void dc_tx_underrun(struct dc_softc *sc) { - u_int32_t isr; + uint32_t isr; int i; if (DC_IS_DAVICOM(sc)) { @@ -3209,7 +3209,7 @@ dc_poll(struct ifnet *ifp, enum poll_cmd dc_start_locked(ifp); if (cmd == POLL_AND_CHECK_STATUS) { /* also check status register */ - u_int32_t status; + uint32_t status; status = CSR_READ_4(sc, DC_ISR); status &= (DC_ISR_RX_WATDOGTIMEO | DC_ISR_RX_NOBUF | @@ -3223,7 +3223,7 @@ dc_poll(struct ifnet *ifp, enum poll_cmd CSR_WRITE_4(sc, DC_ISR, status); if (status & (DC_ISR_RX_WATDOGTIMEO | DC_ISR_RX_NOBUF)) { - u_int32_t r = CSR_READ_4(sc, DC_FRAMESDISCARDED); + uint32_t r = CSR_READ_4(sc, DC_FRAMESDISCARDED); ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff); if (dc_rx_resync(sc)) @@ -3251,7 +3251,7 @@ dc_intr(void *arg) { struct dc_softc *sc; struct ifnet *ifp; - u_int32_t r, status; + uint32_t r, status; int curpkts, n; sc = arg; @@ -3913,7 +3913,7 @@ dc_stop(struct dc_softc *sc) struct dc_list_data *ld; struct dc_chain_data *cd; int i; - u_int32_t ctl; + uint32_t ctl; DC_LOCK_ASSERT(sc); Modified: stable/7/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 23:08:01 2011 (r220076) +++ stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 23:09:09 2011 (r220077) @@ -36,23 +36,23 @@ * 21143 and clone common register definitions. */ -#define DC_BUSCTL 0x00 /* bus control */ -#define DC_TXSTART 0x08 /* tx start demand */ -#define DC_RXSTART 0x10 /* rx start demand */ -#define DC_RXADDR 0x18 /* rx descriptor list start addr */ -#define DC_TXADDR 0x20 /* tx descriptor list start addr */ -#define DC_ISR 0x28 /* interrupt status register */ -#define DC_NETCFG 0x30 /* network config register */ -#define DC_IMR 0x38 /* interrupt mask */ -#define DC_FRAMESDISCARDED 0x40 /* # of discarded frames */ -#define DC_SIO 0x48 /* MII and ROM/EEPROM access */ -#define DC_ROM 0x50 /* ROM programming address */ -#define DC_TIMER 0x58 /* general timer */ -#define DC_10BTSTAT 0x60 /* SIA status */ -#define DC_SIARESET 0x68 /* SIA connectivity */ -#define DC_10BTCTRL 0x70 /* SIA transmit and receive */ -#define DC_WATCHDOG 0x78 /* SIA and general purpose port */ -#define DC_SIAGP 0x78 /* SIA and general purpose port (X3201) */ +#define DC_BUSCTL 0x00 /* bus control */ +#define DC_TXSTART 0x08 /* tx start demand */ +#define DC_RXSTART 0x10 /* rx start demand */ +#define DC_RXADDR 0x18 /* rx descriptor list start addr */ +#define DC_TXADDR 0x20 /* tx descriptor list start addr */ +#define DC_ISR 0x28 /* interrupt status register */ +#define DC_NETCFG 0x30 /* network config register */ +#define DC_IMR 0x38 /* interrupt mask */ +#define DC_FRAMESDISCARDED 0x40 /* # of discarded frames */ +#define DC_SIO 0x48 /* MII and ROM/EEPROM access */ +#define DC_ROM 0x50 /* ROM programming address */ +#define DC_TIMER 0x58 /* general timer */ +#define DC_10BTSTAT 0x60 /* SIA status */ +#define DC_SIARESET 0x68 /* SIA connectivity */ +#define DC_10BTCTRL 0x70 /* SIA transmit and receive */ +#define DC_WATCHDOG 0x78 /* SIA and general purpose port */ +#define DC_SIAGP 0x78 /* SIA and general purpose port (X3201) */ /* * There are two general 'types' of MX chips that we need to be @@ -64,427 +64,427 @@ * 'magic' numbers we write to CSR16. The PNIC II falls into the * 98713A/98715/98715A/98725 category. */ -#define DC_TYPE_98713 0x1 -#define DC_TYPE_98713A 0x2 -#define DC_TYPE_987x5 0x3 +#define DC_TYPE_98713 0x1 +#define DC_TYPE_98713A 0x2 +#define DC_TYPE_987x5 0x3 /* Other type of supported chips. */ -#define DC_TYPE_21143 0x4 /* Intel 21143 */ -#define DC_TYPE_ASIX 0x5 /* ASIX AX88140A/AX88141 */ -#define DC_TYPE_AL981 0x6 /* ADMtek AL981 Comet */ -#define DC_TYPE_AN983 0x7 /* ADMtek AN983 Centaur */ -#define DC_TYPE_DM9102 0x8 /* Davicom DM9102 */ -#define DC_TYPE_PNICII 0x9 /* 82c115 PNIC II */ -#define DC_TYPE_PNIC 0xA /* 82c168/82c169 PNIC I */ +#define DC_TYPE_21143 0x4 /* Intel 21143 */ +#define DC_TYPE_ASIX 0x5 /* ASIX AX88140A/AX88141 */ +#define DC_TYPE_AL981 0x6 /* ADMtek AL981 Comet */ +#define DC_TYPE_AN983 0x7 /* ADMtek AN983 Centaur */ +#define DC_TYPE_DM9102 0x8 /* Davicom DM9102 */ +#define DC_TYPE_PNICII 0x9 /* 82c115 PNIC II */ +#define DC_TYPE_PNIC 0xA /* 82c168/82c169 PNIC I */ #define DC_TYPE_XIRCOM 0xB /* Xircom X3201 */ -#define DC_TYPE_CONEXANT 0xC /* Conexant LANfinity RS7112 */ +#define DC_TYPE_CONEXANT 0xC /* Conexant LANfinity RS7112 */ -#define DC_IS_MACRONIX(x) \ +#define DC_IS_MACRONIX(x) \ (x->dc_type == DC_TYPE_98713 || \ x->dc_type == DC_TYPE_98713A || \ x->dc_type == DC_TYPE_987x5) -#define DC_IS_ADMTEK(x) \ +#define DC_IS_ADMTEK(x) \ (x->dc_type == DC_TYPE_AL981 || \ x->dc_type == DC_TYPE_AN983) -#define DC_IS_INTEL(x) (x->dc_type == DC_TYPE_21143) -#define DC_IS_ASIX(x) (x->dc_type == DC_TYPE_ASIX) -#define DC_IS_COMET(x) (x->dc_type == DC_TYPE_AL981) -#define DC_IS_CENTAUR(x) (x->dc_type == DC_TYPE_AN983) -#define DC_IS_DAVICOM(x) (x->dc_type == DC_TYPE_DM9102) -#define DC_IS_PNICII(x) (x->dc_type == DC_TYPE_PNICII) -#define DC_IS_PNIC(x) (x->dc_type == DC_TYPE_PNIC) +#define DC_IS_INTEL(x) (x->dc_type == DC_TYPE_21143) +#define DC_IS_ASIX(x) (x->dc_type == DC_TYPE_ASIX) +#define DC_IS_COMET(x) (x->dc_type == DC_TYPE_AL981) +#define DC_IS_CENTAUR(x) (x->dc_type == DC_TYPE_AN983) +#define DC_IS_DAVICOM(x) (x->dc_type == DC_TYPE_DM9102) +#define DC_IS_PNICII(x) (x->dc_type == DC_TYPE_PNICII) +#define DC_IS_PNIC(x) (x->dc_type == DC_TYPE_PNIC) #define DC_IS_XIRCOM(x) (x->dc_type == DC_TYPE_XIRCOM) -#define DC_IS_CONEXANT(x) (x->dc_type == DC_TYPE_CONEXANT) +#define DC_IS_CONEXANT(x) (x->dc_type == DC_TYPE_CONEXANT) /* MII/symbol mode port types */ -#define DC_PMODE_MII 0x1 -#define DC_PMODE_SYM 0x2 -#define DC_PMODE_SIA 0x3 +#define DC_PMODE_MII 0x1 +#define DC_PMODE_SYM 0x2 +#define DC_PMODE_SIA 0x3 /* * Bus control bits. */ -#define DC_BUSCTL_RESET 0x00000001 -#define DC_BUSCTL_ARBITRATION 0x00000002 -#define DC_BUSCTL_SKIPLEN 0x0000007C -#define DC_BUSCTL_BUF_BIGENDIAN 0x00000080 -#define DC_BUSCTL_BURSTLEN 0x00003F00 -#define DC_BUSCTL_CACHEALIGN 0x0000C000 -#define DC_BUSCTL_TXPOLL 0x000E0000 -#define DC_BUSCTL_DBO 0x00100000 -#define DC_BUSCTL_MRME 0x00200000 -#define DC_BUSCTL_MRLE 0x00800000 -#define DC_BUSCTL_MWIE 0x01000000 -#define DC_BUSCTL_ONNOW_ENB 0x04000000 - -#define DC_SKIPLEN_1LONG 0x00000004 -#define DC_SKIPLEN_2LONG 0x00000008 -#define DC_SKIPLEN_3LONG 0x00000010 -#define DC_SKIPLEN_4LONG 0x00000020 -#define DC_SKIPLEN_5LONG 0x00000040 - -#define DC_CACHEALIGN_NONE 0x00000000 -#define DC_CACHEALIGN_8LONG 0x00004000 -#define DC_CACHEALIGN_16LONG 0x00008000 -#define DC_CACHEALIGN_32LONG 0x0000C000 - -#define DC_BURSTLEN_USECA 0x00000000 -#define DC_BURSTLEN_1LONG 0x00000100 -#define DC_BURSTLEN_2LONG 0x00000200 -#define DC_BURSTLEN_4LONG 0x00000400 -#define DC_BURSTLEN_8LONG 0x00000800 -#define DC_BURSTLEN_16LONG 0x00001000 -#define DC_BURSTLEN_32LONG 0x00002000 - -#define DC_TXPOLL_OFF 0x00000000 -#define DC_TXPOLL_1 0x00020000 -#define DC_TXPOLL_2 0x00040000 -#define DC_TXPOLL_3 0x00060000 -#define DC_TXPOLL_4 0x00080000 -#define DC_TXPOLL_5 0x000A0000 -#define DC_TXPOLL_6 0x000C0000 -#define DC_TXPOLL_7 0x000E0000 +#define DC_BUSCTL_RESET 0x00000001 +#define DC_BUSCTL_ARBITRATION 0x00000002 +#define DC_BUSCTL_SKIPLEN 0x0000007C +#define DC_BUSCTL_BUF_BIGENDIAN 0x00000080 +#define DC_BUSCTL_BURSTLEN 0x00003F00 +#define DC_BUSCTL_CACHEALIGN 0x0000C000 +#define DC_BUSCTL_TXPOLL 0x000E0000 +#define DC_BUSCTL_DBO 0x00100000 +#define DC_BUSCTL_MRME 0x00200000 +#define DC_BUSCTL_MRLE 0x00800000 +#define DC_BUSCTL_MWIE 0x01000000 +#define DC_BUSCTL_ONNOW_ENB 0x04000000 + +#define DC_SKIPLEN_1LONG 0x00000004 +#define DC_SKIPLEN_2LONG 0x00000008 +#define DC_SKIPLEN_3LONG 0x00000010 +#define DC_SKIPLEN_4LONG 0x00000020 +#define DC_SKIPLEN_5LONG 0x00000040 + +#define DC_CACHEALIGN_NONE 0x00000000 +#define DC_CACHEALIGN_8LONG 0x00004000 +#define DC_CACHEALIGN_16LONG 0x00008000 +#define DC_CACHEALIGN_32LONG 0x0000C000 + +#define DC_BURSTLEN_USECA 0x00000000 +#define DC_BURSTLEN_1LONG 0x00000100 +#define DC_BURSTLEN_2LONG 0x00000200 +#define DC_BURSTLEN_4LONG 0x00000400 +#define DC_BURSTLEN_8LONG 0x00000800 +#define DC_BURSTLEN_16LONG 0x00001000 +#define DC_BURSTLEN_32LONG 0x00002000 + +#define DC_TXPOLL_OFF 0x00000000 +#define DC_TXPOLL_1 0x00020000 +#define DC_TXPOLL_2 0x00040000 +#define DC_TXPOLL_3 0x00060000 +#define DC_TXPOLL_4 0x00080000 +#define DC_TXPOLL_5 0x000A0000 +#define DC_TXPOLL_6 0x000C0000 +#define DC_TXPOLL_7 0x000E0000 /* * Interrupt status bits. */ -#define DC_ISR_TX_OK 0x00000001 -#define DC_ISR_TX_IDLE 0x00000002 -#define DC_ISR_TX_NOBUF 0x00000004 -#define DC_ISR_TX_JABBERTIMEO 0x00000008 -#define DC_ISR_LINKGOOD 0x00000010 -#define DC_ISR_TX_UNDERRUN 0x00000020 -#define DC_ISR_RX_OK 0x00000040 -#define DC_ISR_RX_NOBUF 0x00000080 -#define DC_ISR_RX_READ 0x00000100 -#define DC_ISR_RX_WATDOGTIMEO 0x00000200 -#define DC_ISR_TX_EARLY 0x00000400 -#define DC_ISR_TIMER_EXPIRED 0x00000800 -#define DC_ISR_LINKFAIL 0x00001000 -#define DC_ISR_BUS_ERR 0x00002000 -#define DC_ISR_RX_EARLY 0x00004000 -#define DC_ISR_ABNORMAL 0x00008000 -#define DC_ISR_NORMAL 0x00010000 -#define DC_ISR_RX_STATE 0x000E0000 -#define DC_ISR_TX_STATE 0x00700000 -#define DC_ISR_BUSERRTYPE 0x03800000 -#define DC_ISR_100MBPSLINK 0x08000000 -#define DC_ISR_MAGICKPACK 0x10000000 - -#define DC_RXSTATE_STOPPED 0x00000000 /* 000 - Stopped */ -#define DC_RXSTATE_FETCH 0x00020000 /* 001 - Fetching descriptor */ -#define DC_RXSTATE_ENDCHECK 0x00040000 /* 010 - check for rx end */ -#define DC_RXSTATE_WAIT 0x00060000 /* 011 - waiting for packet */ -#define DC_RXSTATE_SUSPEND 0x00080000 /* 100 - suspend rx */ -#define DC_RXSTATE_CLOSE 0x000A0000 /* 101 - close tx desc */ -#define DC_RXSTATE_FLUSH 0x000C0000 /* 110 - flush from FIFO */ -#define DC_RXSTATE_DEQUEUE 0x000E0000 /* 111 - dequeue from FIFO */ +#define DC_ISR_TX_OK 0x00000001 +#define DC_ISR_TX_IDLE 0x00000002 +#define DC_ISR_TX_NOBUF 0x00000004 +#define DC_ISR_TX_JABBERTIMEO 0x00000008 +#define DC_ISR_LINKGOOD 0x00000010 +#define DC_ISR_TX_UNDERRUN 0x00000020 +#define DC_ISR_RX_OK 0x00000040 +#define DC_ISR_RX_NOBUF 0x00000080 +#define DC_ISR_RX_READ 0x00000100 +#define DC_ISR_RX_WATDOGTIMEO 0x00000200 +#define DC_ISR_TX_EARLY 0x00000400 +#define DC_ISR_TIMER_EXPIRED 0x00000800 +#define DC_ISR_LINKFAIL 0x00001000 +#define DC_ISR_BUS_ERR 0x00002000 +#define DC_ISR_RX_EARLY 0x00004000 +#define DC_ISR_ABNORMAL 0x00008000 +#define DC_ISR_NORMAL 0x00010000 +#define DC_ISR_RX_STATE 0x000E0000 +#define DC_ISR_TX_STATE 0x00700000 +#define DC_ISR_BUSERRTYPE 0x03800000 +#define DC_ISR_100MBPSLINK 0x08000000 +#define DC_ISR_MAGICKPACK 0x10000000 + +#define DC_RXSTATE_STOPPED 0x00000000 /* 000 - Stopped */ +#define DC_RXSTATE_FETCH 0x00020000 /* 001 - Fetching descriptor */ +#define DC_RXSTATE_ENDCHECK 0x00040000 /* 010 - check for rx end */ +#define DC_RXSTATE_WAIT 0x00060000 /* 011 - waiting for packet */ +#define DC_RXSTATE_SUSPEND 0x00080000 /* 100 - suspend rx */ +#define DC_RXSTATE_CLOSE 0x000A0000 /* 101 - close tx desc */ +#define DC_RXSTATE_FLUSH 0x000C0000 /* 110 - flush from FIFO */ +#define DC_RXSTATE_DEQUEUE 0x000E0000 /* 111 - dequeue from FIFO */ #define DC_HAS_BROKEN_RXSTATE(x) \ (DC_IS_CENTAUR(x) || DC_IS_CONEXANT(x) || (DC_IS_DAVICOM(x) && \ pci_get_revid((x)->dc_dev) >= DC_REVISION_DM9102A)) -#define DC_TXSTATE_RESET 0x00000000 /* 000 - reset */ -#define DC_TXSTATE_FETCH 0x00100000 /* 001 - fetching descriptor */ -#define DC_TXSTATE_WAITEND 0x00200000 /* 010 - wait for tx end */ -#define DC_TXSTATE_READING 0x00300000 /* 011 - read and enqueue */ -#define DC_TXSTATE_RSVD 0x00400000 /* 100 - reserved */ -#define DC_TXSTATE_SETUP 0x00500000 /* 101 - setup packet */ -#define DC_TXSTATE_SUSPEND 0x00600000 /* 110 - suspend tx */ -#define DC_TXSTATE_CLOSE 0x00700000 /* 111 - close tx desc */ +#define DC_TXSTATE_RESET 0x00000000 /* 000 - reset */ +#define DC_TXSTATE_FETCH 0x00100000 /* 001 - fetching descriptor */ +#define DC_TXSTATE_WAITEND 0x00200000 /* 010 - wait for tx end */ +#define DC_TXSTATE_READING 0x00300000 /* 011 - read and enqueue */ +#define DC_TXSTATE_RSVD 0x00400000 /* 100 - reserved */ +#define DC_TXSTATE_SETUP 0x00500000 /* 101 - setup packet */ +#define DC_TXSTATE_SUSPEND 0x00600000 /* 110 - suspend tx */ +#define DC_TXSTATE_CLOSE 0x00700000 /* 111 - close tx desc */ /* * Network config bits. */ -#define DC_NETCFG_RX_HASHPERF 0x00000001 -#define DC_NETCFG_RX_ON 0x00000002 -#define DC_NETCFG_RX_HASHONLY 0x00000004 -#define DC_NETCFG_RX_BADFRAMES 0x00000008 -#define DC_NETCFG_RX_INVFILT 0x00000010 -#define DC_NETCFG_BACKOFFCNT 0x00000020 -#define DC_NETCFG_RX_PROMISC 0x00000040 -#define DC_NETCFG_RX_ALLMULTI 0x00000080 -#define DC_NETCFG_FULLDUPLEX 0x00000200 -#define DC_NETCFG_LOOPBACK 0x00000C00 -#define DC_NETCFG_FORCECOLL 0x00001000 -#define DC_NETCFG_TX_ON 0x00002000 -#define DC_NETCFG_TX_THRESH 0x0000C000 -#define DC_NETCFG_TX_BACKOFF 0x00020000 -#define DC_NETCFG_PORTSEL 0x00040000 /* 0 == 10, 1 == 100 */ -#define DC_NETCFG_HEARTBEAT 0x00080000 -#define DC_NETCFG_STORENFWD 0x00200000 -#define DC_NETCFG_SPEEDSEL 0x00400000 /* 1 == 10, 0 == 100 */ -#define DC_NETCFG_PCS 0x00800000 -#define DC_NETCFG_SCRAMBLER 0x01000000 -#define DC_NETCFG_NO_RXCRC 0x02000000 -#define DC_NETCFG_RX_ALL 0x40000000 -#define DC_NETCFG_CAPEFFECT 0x80000000 - -#define DC_OPMODE_NORM 0x00000000 -#define DC_OPMODE_INTLOOP 0x00000400 -#define DC_OPMODE_EXTLOOP 0x00000800 +#define DC_NETCFG_RX_HASHPERF 0x00000001 +#define DC_NETCFG_RX_ON 0x00000002 +#define DC_NETCFG_RX_HASHONLY 0x00000004 +#define DC_NETCFG_RX_BADFRAMES 0x00000008 +#define DC_NETCFG_RX_INVFILT 0x00000010 +#define DC_NETCFG_BACKOFFCNT 0x00000020 +#define DC_NETCFG_RX_PROMISC 0x00000040 +#define DC_NETCFG_RX_ALLMULTI 0x00000080 +#define DC_NETCFG_FULLDUPLEX 0x00000200 +#define DC_NETCFG_LOOPBACK 0x00000C00 +#define DC_NETCFG_FORCECOLL 0x00001000 +#define DC_NETCFG_TX_ON 0x00002000 +#define DC_NETCFG_TX_THRESH 0x0000C000 +#define DC_NETCFG_TX_BACKOFF 0x00020000 +#define DC_NETCFG_PORTSEL 0x00040000 /* 0 == 10, 1 == 100 */ +#define DC_NETCFG_HEARTBEAT 0x00080000 +#define DC_NETCFG_STORENFWD 0x00200000 +#define DC_NETCFG_SPEEDSEL 0x00400000 /* 1 == 10, 0 == 100 */ +#define DC_NETCFG_PCS 0x00800000 +#define DC_NETCFG_SCRAMBLER 0x01000000 +#define DC_NETCFG_NO_RXCRC 0x02000000 +#define DC_NETCFG_RX_ALL 0x40000000 +#define DC_NETCFG_CAPEFFECT 0x80000000 + +#define DC_OPMODE_NORM 0x00000000 +#define DC_OPMODE_INTLOOP 0x00000400 +#define DC_OPMODE_EXTLOOP 0x00000800 #if 0 -#define DC_TXTHRESH_72BYTES 0x00000000 -#define DC_TXTHRESH_96BYTES 0x00004000 -#define DC_TXTHRESH_128BYTES 0x00008000 -#define DC_TXTHRESH_160BYTES 0x0000C000 +#define DC_TXTHRESH_72BYTES 0x00000000 +#define DC_TXTHRESH_96BYTES 0x00004000 +#define DC_TXTHRESH_128BYTES 0x00008000 +#define DC_TXTHRESH_160BYTES 0x0000C000 #endif -#define DC_TXTHRESH_MIN 0x00000000 -#define DC_TXTHRESH_INC 0x00004000 -#define DC_TXTHRESH_MAX 0x0000C000 +#define DC_TXTHRESH_MIN 0x00000000 +#define DC_TXTHRESH_INC 0x00004000 +#define DC_TXTHRESH_MAX 0x0000C000 /* * Interrupt mask bits. */ -#define DC_IMR_TX_OK 0x00000001 -#define DC_IMR_TX_IDLE 0x00000002 -#define DC_IMR_TX_NOBUF 0x00000004 -#define DC_IMR_TX_JABBERTIMEO 0x00000008 -#define DC_IMR_LINKGOOD 0x00000010 -#define DC_IMR_TX_UNDERRUN 0x00000020 -#define DC_IMR_RX_OK 0x00000040 -#define DC_IMR_RX_NOBUF 0x00000080 -#define DC_IMR_RX_READ 0x00000100 -#define DC_IMR_RX_WATDOGTIMEO 0x00000200 -#define DC_IMR_TX_EARLY 0x00000400 -#define DC_IMR_TIMER_EXPIRED 0x00000800 -#define DC_IMR_LINKFAIL 0x00001000 -#define DC_IMR_BUS_ERR 0x00002000 -#define DC_IMR_RX_EARLY 0x00004000 -#define DC_IMR_ABNORMAL 0x00008000 -#define DC_IMR_NORMAL 0x00010000 -#define DC_IMR_100MBPSLINK 0x08000000 -#define DC_IMR_MAGICKPACK 0x10000000 +#define DC_IMR_TX_OK 0x00000001 +#define DC_IMR_TX_IDLE 0x00000002 +#define DC_IMR_TX_NOBUF 0x00000004 +#define DC_IMR_TX_JABBERTIMEO 0x00000008 +#define DC_IMR_LINKGOOD 0x00000010 +#define DC_IMR_TX_UNDERRUN 0x00000020 +#define DC_IMR_RX_OK 0x00000040 +#define DC_IMR_RX_NOBUF 0x00000080 +#define DC_IMR_RX_READ 0x00000100 +#define DC_IMR_RX_WATDOGTIMEO 0x00000200 +#define DC_IMR_TX_EARLY 0x00000400 +#define DC_IMR_TIMER_EXPIRED 0x00000800 +#define DC_IMR_LINKFAIL 0x00001000 +#define DC_IMR_BUS_ERR 0x00002000 +#define DC_IMR_RX_EARLY 0x00004000 +#define DC_IMR_ABNORMAL 0x00008000 +#define DC_IMR_NORMAL 0x00010000 +#define DC_IMR_100MBPSLINK 0x08000000 +#define DC_IMR_MAGICKPACK 0x10000000 -#define DC_INTRS \ +#define DC_INTRS \ (DC_IMR_RX_OK|DC_IMR_TX_OK|DC_IMR_RX_NOBUF|DC_IMR_RX_WATDOGTIMEO|\ DC_IMR_TX_NOBUF|DC_IMR_TX_UNDERRUN|DC_IMR_BUS_ERR| \ DC_IMR_ABNORMAL|DC_IMR_NORMAL/*|DC_IMR_TX_EARLY*/) /* * Serial I/O (EEPROM/ROM) bits. */ -#define DC_SIO_EE_CS 0x00000001 /* EEPROM chip select */ -#define DC_SIO_EE_CLK 0x00000002 /* EEPROM clock */ -#define DC_SIO_EE_DATAIN 0x00000004 /* EEPROM data output */ -#define DC_SIO_EE_DATAOUT 0x00000008 /* EEPROM data input */ -#define DC_SIO_ROMDATA4 0x00000010 -#define DC_SIO_ROMDATA5 0x00000020 -#define DC_SIO_ROMDATA6 0x00000040 -#define DC_SIO_ROMDATA7 0x00000080 -#define DC_SIO_EESEL 0x00000800 -#define DC_SIO_ROMSEL 0x00001000 -#define DC_SIO_ROMCTL_WRITE 0x00002000 -#define DC_SIO_ROMCTL_READ 0x00004000 -#define DC_SIO_MII_CLK 0x00010000 /* MDIO clock */ -#define DC_SIO_MII_DATAOUT 0x00020000 /* MDIO data out */ -#define DC_SIO_MII_DIR 0x00040000 /* MDIO dir */ -#define DC_SIO_MII_DATAIN 0x00080000 /* MDIO data in */ - -#define DC_EECMD_WRITE 0x140 -#define DC_EECMD_READ 0x180 -#define DC_EECMD_ERASE 0x1c0 +#define DC_SIO_EE_CS 0x00000001 /* EEPROM chip select */ +#define DC_SIO_EE_CLK 0x00000002 /* EEPROM clock */ +#define DC_SIO_EE_DATAIN 0x00000004 /* EEPROM data output */ +#define DC_SIO_EE_DATAOUT 0x00000008 /* EEPROM data input */ +#define DC_SIO_ROMDATA4 0x00000010 +#define DC_SIO_ROMDATA5 0x00000020 +#define DC_SIO_ROMDATA6 0x00000040 +#define DC_SIO_ROMDATA7 0x00000080 +#define DC_SIO_EESEL 0x00000800 +#define DC_SIO_ROMSEL 0x00001000 +#define DC_SIO_ROMCTL_WRITE 0x00002000 +#define DC_SIO_ROMCTL_READ 0x00004000 +#define DC_SIO_MII_CLK 0x00010000 /* MDIO clock */ +#define DC_SIO_MII_DATAOUT 0x00020000 /* MDIO data out */ +#define DC_SIO_MII_DIR 0x00040000 /* MDIO dir */ +#define DC_SIO_MII_DATAIN 0x00080000 /* MDIO data in */ + +#define DC_EECMD_WRITE 0x140 +#define DC_EECMD_READ 0x180 +#define DC_EECMD_ERASE 0x1c0 -#define DC_EE_NODEADDR_OFFSET 0x70 -#define DC_EE_NODEADDR 10 +#define DC_EE_NODEADDR_OFFSET 0x70 +#define DC_EE_NODEADDR 10 /* * General purpose timer register */ -#define DC_TIMER_VALUE 0x0000FFFF -#define DC_TIMER_CONTINUOUS 0x00010000 +#define DC_TIMER_VALUE 0x0000FFFF +#define DC_TIMER_CONTINUOUS 0x00010000 /* * 10baseT status register */ -#define DC_TSTAT_MIIACT 0x00000001 /* MII port activity */ -#define DC_TSTAT_LS100 0x00000002 /* link status of 100baseTX */ -#define DC_TSTAT_LS10 0x00000004 /* link status of 10baseT */ -#define DC_TSTAT_AUTOPOLARITY 0x00000008 -#define DC_TSTAT_AUIACT 0x00000100 /* AUI activity */ -#define DC_TSTAT_10BTACT 0x00000200 /* 10baseT activity */ -#define DC_TSTAT_NSN 0x00000400 /* non-stable FLPs detected */ -#define DC_TSTAT_REMFAULT 0x00000800 -#define DC_TSTAT_ANEGSTAT 0x00007000 -#define DC_TSTAT_LP_CAN_NWAY 0x00008000 /* link partner supports NWAY */ -#define DC_TSTAT_LPCODEWORD 0xFFFF0000 /* link partner's code word */ - -#define DC_ASTAT_DISABLE 0x00000000 -#define DC_ASTAT_TXDISABLE 0x00001000 -#define DC_ASTAT_ABDETECT 0x00002000 -#define DC_ASTAT_ACKDETECT 0x00003000 -#define DC_ASTAT_CMPACKDETECT 0x00004000 -#define DC_ASTAT_AUTONEGCMP 0x00005000 -#define DC_ASTAT_LINKCHECK 0x00006000 +#define DC_TSTAT_MIIACT 0x00000001 /* MII port activity */ +#define DC_TSTAT_LS100 0x00000002 /* link status of 100baseTX */ +#define DC_TSTAT_LS10 0x00000004 /* link status of 10baseT */ +#define DC_TSTAT_AUTOPOLARITY 0x00000008 +#define DC_TSTAT_AUIACT 0x00000100 /* AUI activity */ +#define DC_TSTAT_10BTACT 0x00000200 /* 10baseT activity */ +#define DC_TSTAT_NSN 0x00000400 /* non-stable FLPs detected */ +#define DC_TSTAT_REMFAULT 0x00000800 +#define DC_TSTAT_ANEGSTAT 0x00007000 +#define DC_TSTAT_LP_CAN_NWAY 0x00008000 /* link partner supports NWAY */ +#define DC_TSTAT_LPCODEWORD 0xFFFF0000 /* link partner's code word */ + +#define DC_ASTAT_DISABLE 0x00000000 +#define DC_ASTAT_TXDISABLE 0x00001000 +#define DC_ASTAT_ABDETECT 0x00002000 +#define DC_ASTAT_ACKDETECT 0x00003000 +#define DC_ASTAT_CMPACKDETECT 0x00004000 +#define DC_ASTAT_AUTONEGCMP 0x00005000 +#define DC_ASTAT_LINKCHECK 0x00006000 /* * PHY reset register */ -#define DC_SIA_RESET 0x00000001 -#define DC_SIA_AUI 0x00000008 /* AUI or 10baseT */ +#define DC_SIA_RESET 0x00000001 +#define DC_SIA_AUI 0x00000008 /* AUI or 10baseT */ /* * 10baseT control register */ -#define DC_TCTL_ENCODER_ENB 0x00000001 -#define DC_TCTL_LOOPBACK 0x00000002 -#define DC_TCTL_DRIVER_ENB 0x00000004 -#define DC_TCTL_LNKPULSE_ENB 0x00000008 -#define DC_TCTL_HALFDUPLEX 0x00000040 -#define DC_TCTL_AUTONEGENBL 0x00000080 -#define DC_TCTL_RX_SQUELCH 0x00000100 -#define DC_TCTL_COLL_SQUELCH 0x00000200 -#define DC_TCTL_COLL_DETECT 0x00000400 -#define DC_TCTL_SQE_ENB 0x00000800 -#define DC_TCTL_LINKTEST 0x00001000 -#define DC_TCTL_AUTOPOLARITY 0x00002000 -#define DC_TCTL_SET_POL_PLUS 0x00004000 -#define DC_TCTL_AUTOSENSE 0x00008000 /* 10bt/AUI autosense */ -#define DC_TCTL_100BTXHALF 0x00010000 -#define DC_TCTL_100BTXFULL 0x00020000 -#define DC_TCTL_100BT4 0x00040000 +#define DC_TCTL_ENCODER_ENB 0x00000001 +#define DC_TCTL_LOOPBACK 0x00000002 +#define DC_TCTL_DRIVER_ENB 0x00000004 +#define DC_TCTL_LNKPULSE_ENB 0x00000008 +#define DC_TCTL_HALFDUPLEX 0x00000040 +#define DC_TCTL_AUTONEGENBL 0x00000080 +#define DC_TCTL_RX_SQUELCH 0x00000100 +#define DC_TCTL_COLL_SQUELCH 0x00000200 +#define DC_TCTL_COLL_DETECT 0x00000400 +#define DC_TCTL_SQE_ENB 0x00000800 +#define DC_TCTL_LINKTEST 0x00001000 +#define DC_TCTL_AUTOPOLARITY 0x00002000 +#define DC_TCTL_SET_POL_PLUS 0x00004000 +#define DC_TCTL_AUTOSENSE 0x00008000 /* 10bt/AUI autosense */ +#define DC_TCTL_100BTXHALF 0x00010000 +#define DC_TCTL_100BTXFULL 0x00020000 +#define DC_TCTL_100BT4 0x00040000 /* * Watchdog timer register */ -#define DC_WDOG_JABBERDIS 0x00000001 -#define DC_WDOG_HOSTUNJAB 0x00000002 -#define DC_WDOG_JABBERCLK 0x00000004 -#define DC_WDOG_RXWDOGDIS 0x00000010 -#define DC_WDOG_RXWDOGCLK 0x00000020 -#define DC_WDOG_MUSTBEZERO 0x00000100 -#define DC_WDOG_AUIBNC 0x00100000 -#define DC_WDOG_ACTIVITY 0x00200000 -#define DC_WDOG_RX_MATCH 0x00400000 -#define DC_WDOG_LINK 0x00800000 -#define DC_WDOG_CTLWREN 0x08000000 +#define DC_WDOG_JABBERDIS 0x00000001 +#define DC_WDOG_HOSTUNJAB 0x00000002 +#define DC_WDOG_JABBERCLK 0x00000004 +#define DC_WDOG_RXWDOGDIS 0x00000010 +#define DC_WDOG_RXWDOGCLK 0x00000020 +#define DC_WDOG_MUSTBEZERO 0x00000100 +#define DC_WDOG_AUIBNC 0x00100000 +#define DC_WDOG_ACTIVITY 0x00200000 +#define DC_WDOG_RX_MATCH 0x00400000 +#define DC_WDOG_LINK 0x00800000 +#define DC_WDOG_CTLWREN 0x08000000 /* * SIA and General Purpose Port register (X3201) */ -#define DC_SIAGP_RXMATCH 0x40000000 -#define DC_SIAGP_INT1 0x20000000 -#define DC_SIAGP_INT0 0x10000000 -#define DC_SIAGP_WRITE_EN 0x08000000 -#define DC_SIAGP_RXMATCH_EN 0x04000000 -#define DC_SIAGP_INT1_EN 0x02000000 -#define DC_SIAGP_INT0_EN 0x01000000 -#define DC_SIAGP_LED3 0x00800000 -#define DC_SIAGP_LED2 0x00400000 -#define DC_SIAGP_LED1 0x00200000 -#define DC_SIAGP_LED0 0x00100000 -#define DC_SIAGP_MD_GP3_OUTPUT 0x00080000 -#define DC_SIAGP_MD_GP2_OUTPUT 0x00040000 -#define DC_SIAGP_MD_GP1_OUTPUT 0x00020000 -#define DC_SIAGP_MD_GP0_OUTPUT 0x00010000 +#define DC_SIAGP_RXMATCH 0x40000000 +#define DC_SIAGP_INT1 0x20000000 +#define DC_SIAGP_INT0 0x10000000 +#define DC_SIAGP_WRITE_EN 0x08000000 +#define DC_SIAGP_RXMATCH_EN 0x04000000 +#define DC_SIAGP_INT1_EN 0x02000000 +#define DC_SIAGP_INT0_EN 0x01000000 +#define DC_SIAGP_LED3 0x00800000 +#define DC_SIAGP_LED2 0x00400000 +#define DC_SIAGP_LED1 0x00200000 +#define DC_SIAGP_LED0 0x00100000 +#define DC_SIAGP_MD_GP3_OUTPUT 0x00080000 +#define DC_SIAGP_MD_GP2_OUTPUT 0x00040000 +#define DC_SIAGP_MD_GP1_OUTPUT 0x00020000 +#define DC_SIAGP_MD_GP0_OUTPUT 0x00010000 /* * Size of a setup frame. */ -#define DC_SFRAME_LEN 192 +#define DC_SFRAME_LEN 192 /* * 21x4x TX/RX list structure. */ struct dc_desc { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 23:13:02 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 94BE2106566C; Sun, 27 Mar 2011 23:13:02 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 81AD98FC14; Sun, 27 Mar 2011 23:13:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RND2du072575; Sun, 27 Mar 2011 23:13:02 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RND2sg072573; Sun, 27 Mar 2011 23:13:02 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272313.p2RND2sg072573@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 23:13:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220078 - stable/8/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 23:13:02 -0000 Author: yongari Date: Sun Mar 27 23:13:02 2011 New Revision: 220078 URL: http://svn.freebsd.org/changeset/base/220078 Log: MFC r219407: Rearrange dc_tx_underrun() a bit to correctly set TX FIFO threshold value. Controllers that always require "store and forward" mode( Davicom and PNIC 82C168) have no way to recover from TX underrun except completely reinitializing hardware. Previously only Davicom was reinitialized and the TX FIFO threshold was changed not to use "store and forward" mode after reinitialization since the default FIFO threshold value was 0. This effectively disabled Davicom controller's "store and forward" mode once it encountered TX underruns. In theory, this can cause watchodg timeouts. Intel 21143 controller requires TX MAC should be idle before changing TX FIFO threshold. So driver tried to disable TX MAC and checked whether it saw the idle state of TX MAC. Driver should perform full hardware reinitialization on failing to enter to idle state and it should not touch TX MAC again once it performed full reinitialization. While I'm here remove resetting TX FIFO threshold to 0 when interface is put into down state. If driver ever encountered TX underrun, it's likely to trigger TX underrun again whenever interface is brought to up again. Keeping old/learned TX FIFO threshold value shall reduce the chance of seeing TX underrns in next run. Modified: stable/8/sys/dev/dc/if_dc.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 23:09:09 2011 (r220077) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 23:13:02 2011 (r220078) @@ -3142,50 +3142,57 @@ dc_tick(void *xsc) static void dc_tx_underrun(struct dc_softc *sc) { - uint32_t isr; - int i; + uint32_t netcfg, isr; + int i, reinit; - if (DC_IS_DAVICOM(sc)) { - sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - dc_init_locked(sc); - } - - if (DC_IS_INTEL(sc)) { - /* - * The real 21143 requires that the transmitter be idle - * in order to change the transmit threshold or store - * and forward state. - */ - DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); - - for (i = 0; i < DC_TIMEOUT; i++) { - isr = CSR_READ_4(sc, DC_ISR); - if (isr & DC_ISR_TX_IDLE) - break; - DELAY(10); - } - if (i == DC_TIMEOUT) { - device_printf(sc->dc_dev, - "%s: failed to force tx to idle state\n", - __func__); - sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - dc_init_locked(sc); + reinit = 0; + netcfg = CSR_READ_4(sc, DC_NETCFG); + device_printf(sc->dc_dev, "TX underrun -- "); + if ((sc->dc_flags & DC_TX_STORENFWD) == 0) { + if (sc->dc_txthresh + DC_TXTHRESH_INC > DC_TXTHRESH_MAX) { + printf("using store and forward mode\n"); + netcfg |= DC_NETCFG_STORENFWD; + } else { + printf("increasing TX threshold\n"); + sc->dc_txthresh += DC_TXTHRESH_INC; + netcfg &= ~DC_NETCFG_TX_THRESH; + netcfg |= sc->dc_txthresh; + } + + if (DC_IS_INTEL(sc)) { + /* + * The real 21143 requires that the transmitter be idle + * in order to change the transmit threshold or store + * and forward state. + */ + CSR_WRITE_4(sc, DC_NETCFG, netcfg & ~DC_NETCFG_TX_ON); + + for (i = 0; i < DC_TIMEOUT; i++) { + isr = CSR_READ_4(sc, DC_ISR); + if (isr & DC_ISR_TX_IDLE) + break; + DELAY(10); + } + if (i == DC_TIMEOUT) { + device_printf(sc->dc_dev, + "%s: failed to force tx to idle state\n", + __func__); + reinit++; + } } + } else { + printf("resetting\n"); + reinit++; } - device_printf(sc->dc_dev, "TX underrun -- "); - sc->dc_txthresh += DC_TXTHRESH_INC; - if (sc->dc_txthresh > DC_TXTHRESH_MAX) { - printf("using store and forward mode\n"); - DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_STORENFWD); + if (reinit == 0) { + CSR_WRITE_4(sc, DC_NETCFG, netcfg); + if (DC_IS_INTEL(sc)) + CSR_WRITE_4(sc, DC_NETCFG, netcfg | DC_NETCFG_TX_ON); } else { - printf("increasing TX threshold\n"); - DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_TX_THRESH); - DC_SETBIT(sc, DC_NETCFG, sc->dc_txthresh); + sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + dc_init_locked(sc); } - - if (DC_IS_INTEL(sc)) - DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); } #ifdef DEVICE_POLLING @@ -3825,7 +3832,6 @@ dc_ioctl(struct ifnet *ifp, u_long comma if (need_setfilt) dc_setfilt(sc); } else { - sc->dc_txthresh = 0; ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 23:14:02 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A4B281065676; Sun, 27 Mar 2011 23:14:02 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 91C348FC19; Sun, 27 Mar 2011 23:14:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RNE2XF072628; Sun, 27 Mar 2011 23:14:02 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RNE22p072626; Sun, 27 Mar 2011 23:14:02 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272314.p2RNE22p072626@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 23:14:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220079 - stable/7/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 23:14:02 -0000 Author: yongari Date: Sun Mar 27 23:14:02 2011 New Revision: 220079 URL: http://svn.freebsd.org/changeset/base/220079 Log: MFC r219407: Rearrange dc_tx_underrun() a bit to correctly set TX FIFO threshold value. Controllers that always require "store and forward" mode( Davicom and PNIC 82C168) have no way to recover from TX underrun except completely reinitializing hardware. Previously only Davicom was reinitialized and the TX FIFO threshold was changed not to use "store and forward" mode after reinitialization since the default FIFO threshold value was 0. This effectively disabled Davicom controller's "store and forward" mode once it encountered TX underruns. In theory, this can cause watchodg timeouts. Intel 21143 controller requires TX MAC should be idle before changing TX FIFO threshold. So driver tried to disable TX MAC and checked whether it saw the idle state of TX MAC. Driver should perform full hardware reinitialization on failing to enter to idle state and it should not touch TX MAC again once it performed full reinitialization. While I'm here remove resetting TX FIFO threshold to 0 when interface is put into down state. If driver ever encountered TX underrun, it's likely to trigger TX underrun again whenever interface is brought to up again. Keeping old/learned TX FIFO threshold value shall reduce the chance of seeing TX underrns in next run. Modified: stable/7/sys/dev/dc/if_dc.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 23:13:02 2011 (r220078) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 23:14:02 2011 (r220079) @@ -3140,50 +3140,57 @@ dc_tick(void *xsc) static void dc_tx_underrun(struct dc_softc *sc) { - uint32_t isr; - int i; + uint32_t netcfg, isr; + int i, reinit; - if (DC_IS_DAVICOM(sc)) { - sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - dc_init_locked(sc); - } - - if (DC_IS_INTEL(sc)) { - /* - * The real 21143 requires that the transmitter be idle - * in order to change the transmit threshold or store - * and forward state. - */ - DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); - - for (i = 0; i < DC_TIMEOUT; i++) { - isr = CSR_READ_4(sc, DC_ISR); - if (isr & DC_ISR_TX_IDLE) - break; - DELAY(10); - } - if (i == DC_TIMEOUT) { - device_printf(sc->dc_dev, - "%s: failed to force tx to idle state\n", - __func__); - sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - dc_init_locked(sc); + reinit = 0; + netcfg = CSR_READ_4(sc, DC_NETCFG); + device_printf(sc->dc_dev, "TX underrun -- "); + if ((sc->dc_flags & DC_TX_STORENFWD) == 0) { + if (sc->dc_txthresh + DC_TXTHRESH_INC > DC_TXTHRESH_MAX) { + printf("using store and forward mode\n"); + netcfg |= DC_NETCFG_STORENFWD; + } else { + printf("increasing TX threshold\n"); + sc->dc_txthresh += DC_TXTHRESH_INC; + netcfg &= ~DC_NETCFG_TX_THRESH; + netcfg |= sc->dc_txthresh; + } + + if (DC_IS_INTEL(sc)) { + /* + * The real 21143 requires that the transmitter be idle + * in order to change the transmit threshold or store + * and forward state. + */ + CSR_WRITE_4(sc, DC_NETCFG, netcfg & ~DC_NETCFG_TX_ON); + + for (i = 0; i < DC_TIMEOUT; i++) { + isr = CSR_READ_4(sc, DC_ISR); + if (isr & DC_ISR_TX_IDLE) + break; + DELAY(10); + } + if (i == DC_TIMEOUT) { + device_printf(sc->dc_dev, + "%s: failed to force tx to idle state\n", + __func__); + reinit++; + } } + } else { + printf("resetting\n"); + reinit++; } - device_printf(sc->dc_dev, "TX underrun -- "); - sc->dc_txthresh += DC_TXTHRESH_INC; - if (sc->dc_txthresh > DC_TXTHRESH_MAX) { - printf("using store and forward mode\n"); - DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_STORENFWD); + if (reinit == 0) { + CSR_WRITE_4(sc, DC_NETCFG, netcfg); + if (DC_IS_INTEL(sc)) + CSR_WRITE_4(sc, DC_NETCFG, netcfg | DC_NETCFG_TX_ON); } else { - printf("increasing TX threshold\n"); - DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_TX_THRESH); - DC_SETBIT(sc, DC_NETCFG, sc->dc_txthresh); + sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + dc_init_locked(sc); } - - if (DC_IS_INTEL(sc)) - DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); } #ifdef DEVICE_POLLING @@ -3821,7 +3828,6 @@ dc_ioctl(struct ifnet *ifp, u_long comma if (need_setfilt) dc_setfilt(sc); } else { - sc->dc_txthresh = 0; ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 23:43:32 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B5367106564A; Sun, 27 Mar 2011 23:43:32 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 668D68FC08; Sun, 27 Mar 2011 23:43:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RNhWV3073214; Sun, 27 Mar 2011 23:43:32 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RNhWAS073210; Sun, 27 Mar 2011 23:43:32 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201103272343.p2RNhWAS073210@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 27 Mar 2011 23:43:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220080 - head/usr.sbin/bsdinstall/scripts X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 23:43:32 -0000 Author: nwhitehorn Date: Sun Mar 27 23:43:32 2011 New Revision: 220080 URL: http://svn.freebsd.org/changeset/base/220080 Log: Add mirror selection for FTP installs. To support TBEMD installs (e.g. powerpc64), this looks in a slightly different default path than now, specifying both $MACHINE and $MACHINE_ARCH: MIRROR/pub/FreeBSD/releases/`uname -p`/`uname -m`/`uname -r` How to handle TBEMD properly probably merits some more discussion, but, since no such 9.0-CURRENT distfiles exist at the moment, all existing mirrors presently fail anyway. Added: head/usr.sbin/bsdinstall/scripts/mirrorselect (contents, props changed) Modified: head/usr.sbin/bsdinstall/scripts/Makefile head/usr.sbin/bsdinstall/scripts/auto Modified: head/usr.sbin/bsdinstall/scripts/Makefile ============================================================================== --- head/usr.sbin/bsdinstall/scripts/Makefile Sun Mar 27 23:14:02 2011 (r220079) +++ head/usr.sbin/bsdinstall/scripts/Makefile Sun Mar 27 23:43:32 2011 (r220080) @@ -1,7 +1,7 @@ # $FreeBSD$ -SCRIPTS= auto adduser checksum config hostname jail keymap mount netconfig \ - rootpass services time umount wlanconfig +SCRIPTS= auto adduser checksum config hostname jail keymap mirrorselect \ + mount netconfig rootpass services time umount wlanconfig BINDIR= /usr/libexec/bsdinstall NO_MAN= true Modified: head/usr.sbin/bsdinstall/scripts/auto ============================================================================== --- head/usr.sbin/bsdinstall/scripts/auto Sun Mar 27 23:14:02 2011 (r220079) +++ head/usr.sbin/bsdinstall/scripts/auto Sun Mar 27 23:43:32 2011 (r220080) @@ -35,6 +35,7 @@ error() { if [ $? -ne 0 ]; then exit else + test -n $DISTDIR_IS_UNIONFS && umount -f $BSDINSTALL_DISTDIR test -f $PATH_FSTAB && bsdinstall umount exec $0 fi @@ -72,13 +73,23 @@ for dist in $DISTRIBUTIONS; do FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" fi done +FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space -if [ ! -z "$FETCH_DISTRIBUTIONS" -a ! -z $BSDINSTALL_CONFIGCURRENT ]; then +if [ -n "$FETCH_DISTRIBUTIONS" -a -n "$BSDINSTALL_CONFIGCURRENT" ]; then dialog --backtitle "FreeBSD Installer" --title "Network Installation" --msgbox "No installation files were found on the boot volume. The next few screens will allow you to configure networking so that they can be downloaded from the Internet." 0 0 bsdinstall netconfig || error NETCONFIG_DONE=yes fi +if [ -n "$FETCH_DISTRIBUTIONS" -a -z "$BSDINSTALL_DISTSITE" ]; then + exec 3>&1 + BSDINSTALL_DISTSITE=`bsdinstall mirrorselect 2>&1 1>&3` + MIRROR_BUTTON=$? + exec 3>&- + test $MIRROR_BUTTON -eq 0 || error + export BSDINSTALL_DISTSITE +fi + rm $PATH_FSTAB touch $PATH_FSTAB @@ -114,7 +125,11 @@ if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS" # Try to use any existing distfiles - [ -d $BSDINSTALL_DISTDIR -a "$FETCH_DISTRIBUTIONS" != "$ALL_DISTRIBUTIONS" ] && mount_unionfs "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR" + if [ -d $BSDINSTALL_DISTDIR -a "$FETCH_DISTRIBUTIONS" != \ + "$ALL_DISTRIBUTIONS" ]; then + DISTDIR_IS_UNIONFS=1 + mount_unionfs "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR" + fi # Otherwise, fetch everything if [ $? -ne 0 ]; then @@ -126,6 +141,8 @@ if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then export DISTRIBUTIONS="$ALL_DISTRIBUTIONS" fi +error + bsdinstall checksum || error bsdinstall distextract || error bsdinstall rootpass || error Added: head/usr.sbin/bsdinstall/scripts/mirrorselect ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/bsdinstall/scripts/mirrorselect Sun Mar 27 23:43:32 2011 (r220080) @@ -0,0 +1,214 @@ +#!/bin/sh +#- +# Copyright (c) 2011 Nathan Whitehorn +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ + +: ${DIALOG_OK=0} +: ${DIALOG_CANCEL=1} +: ${DIALOG_HELP=2} +: ${DIALOG_EXTRA=3} +: ${DIALOG_ITEM_HELP=4} +: ${DIALOG_ESC=255} + +exec 3>&1 +MIRROR=`dialog --backtitle "FreeBSD Installer" \ + --title "Mirror Selection" --extra-button --extra-label "Other" \ + --menu "Please select the site closest to you or \"other\" if you'd like to specify a different choice. Also note that not every site listed here carries more than the base distribution kits. Only Primary sites are guaranteed to carry the full range of possible distributions. Select a site that's close!" \ + 0 0 0 \ + ftp://ftp.freebsd.org "Main Site"\ + ftp://snapshots.jp.freebsd.org "Snapshots Server Japan"\ + ftp://snapshots.se.freebsd.org "Snapshots Server Sweden"\ + ftp://ftp.freebsd.org "IPv6 Main Site"\ + ftp://ftp3.ie.freebsd.org "IPv6 Ireland"\ + ftp://ftp.il.freebsd.org "IPv6 Israel"\ + ftp://ftp2.jp.freebsd.org "IPv6 Japan"\ + ftp://ftp4.us.freebsd.org "IPv6 USA"\ + ftp://ftp2.tr.freebsd.org "IPv6 Turkey"\ + ftp://ftp1.freebsd.org "Primary"\ + ftp://ftp2.freebsd.org "Primary #2"\ + ftp://ftp3.freebsd.org "Primary #3"\ + ftp://ftp4.freebsd.org "Primary #4"\ + ftp://ftp5.freebsd.org "Primary #5"\ + ftp://ftp6.freebsd.org "Primary #6"\ + ftp://ftp7.freebsd.org "Primary #7"\ + ftp://ftp8.freebsd.org "Primary #8"\ + ftp://ftp9.freebsd.org "Primary #9"\ + ftp://ftp10.freebsd.org "Primary #10"\ + ftp://ftp11.freebsd.org "Primary #11"\ + ftp://ftp12.freebsd.org "Primary #12"\ + ftp://ftp13.freebsd.org "Primary #13"\ + ftp://ftp14.freebsd.org "Primary #14"\ + ftp://ftp.ar.freebsd.org "Argentina"\ + ftp://ftp.au.freebsd.org "Australia"\ + ftp://ftp2.au.freebsd.org "Australia #2"\ + ftp://ftp3.au.freebsd.org "Australia #3"\ + ftp://ftp.at.freebsd.org "Austria"\ + ftp://ftp2.at.freebsd.org "Austria #2"\ + ftp://ftp.br.freebsd.org "Brazil"\ + ftp://ftp2.br.freebsd.org "Brazil #2"\ + ftp://ftp3.br.freebsd.org "Brazil #3"\ + ftp://ftp4.br.freebsd.org "Brazil #4"\ + ftp://ftp5.br.freebsd.org "Brazil #5"\ + ftp://ftp6.br.freebsd.org "Brazil #6"\ + ftp://ftp7.br.freebsd.org "Brazil #7"\ + ftp://ftp.ca.freebsd.org "Canada"\ + ftp://ftp.cn.freebsd.org "China"\ + ftp://ftp2.cn.freebsd.org "China #2"\ + ftp://ftp.hr.freebsd.org "Croatia"\ + ftp://ftp.cz.freebsd.org "Czech Republic"\ + ftp://ftp.dk.freebsd.org "Denmark"\ + ftp://ftp2.dk.freebsd.org "Denmark #2"\ + ftp://ftp.ee.freebsd.org "Estonia"\ + ftp://ftp.fi.freebsd.org "Finland"\ + ftp://ftp.fr.freebsd.org "France"\ + ftp://ftp2.fr.freebsd.org "France #2"\ + ftp://ftp3.fr.freebsd.org "France #3"\ + ftp://ftp5.fr.freebsd.org "France #5"\ + ftp://ftp6.fr.freebsd.org "France #6"\ + ftp://ftp8.fr.freebsd.org "France #8"\ + ftp://ftp.de.freebsd.org "Germany"\ + ftp://ftp2.de.freebsd.org "Germany #2"\ + ftp://ftp3.de.freebsd.org "Germany #3"\ + ftp://ftp4.de.freebsd.org "Germany #4"\ + ftp://ftp5.de.freebsd.org "Germany #5"\ + ftp://ftp6.de.freebsd.org "Germany #6"\ + ftp://ftp7.de.freebsd.org "Germany #7"\ + ftp://ftp8.de.freebsd.org "Germany #8"\ + ftp://ftp.gr.freebsd.org "Greece"\ + ftp://ftp2.gr.freebsd.org "Greece #2"\ + ftp://ftp.hu.freebsd.org "Hungary"\ + ftp://ftp.is.freebsd.org "Iceland"\ + ftp://ftp.ie.freebsd.org "Ireland"\ + ftp://ftp2.ie.freebsd.org "Ireland #2"\ + ftp://ftp3.ie.freebsd.org "Ireland #3"\ + ftp://ftp.il.freebsd.org "Israel"\ + ftp://ftp.it.freebsd.org "Italy"\ + ftp://ftp.jp.freebsd.org "Japan"\ + ftp://ftp2.jp.freebsd.org "Japan #2"\ + ftp://ftp3.jp.freebsd.org "Japan #3"\ + ftp://ftp4.jp.freebsd.org "Japan #4"\ + ftp://ftp5.jp.freebsd.org "Japan #5"\ + ftp://ftp6.jp.freebsd.org "Japan #6"\ + ftp://ftp7.jp.freebsd.org "Japan #7"\ + ftp://ftp8.jp.freebsd.org "Japan #8"\ + ftp://ftp9.jp.freebsd.org "Japan #9"\ + ftp://ftp.kr.freebsd.org "Korea"\ + ftp://ftp2.kr.freebsd.org "Korea #2"\ + ftp://ftp.lt.freebsd.org "Lithuania"\ + ftp://ftp.nl.freebsd.org "Netherlands"\ + ftp://ftp2.nl.freebsd.org "Netherlands #2"\ + ftp://ftp.no.freebsd.org "Norway"\ + ftp://ftp3.no.freebsd.org "Norway #3"\ + ftp://ftp.pl.freebsd.org "Poland"\ + ftp://ftp2.pl.freebsd.org "Poland #2"\ + ftp://ftp5.pl.freebsd.org "Poland #5"\ + ftp://ftp.pt.freebsd.org "Portugal"\ + ftp://ftp2.pt.freebsd.org "Portugal #2"\ + ftp://ftp4.pt.freebsd.org "Portugal #4"\ + ftp://ftp.ro.freebsd.org "Romania"\ + ftp://ftp.ru.freebsd.org "Russia"\ + ftp://ftp2.ru.freebsd.org "Russia #2"\ + ftp://ftp3.ru.freebsd.org "Russia #3"\ + ftp://ftp4.ru.freebsd.org "Russia #4"\ + ftp://ftp.sg.freebsd.org "Singapore"\ + ftp://ftp.sk.freebsd.org "Slovak Republic"\ + ftp://ftp.si.freebsd.org "Slovenia"\ + ftp://ftp2.si.freebsd.org "Slovenia #2"\ + ftp://ftp.za.freebsd.org "South Africa"\ + ftp://ftp2.za.freebsd.org "South Africa #2"\ + ftp://ftp3.za.freebsd.org "South Africa #3"\ + ftp://ftp4.za.freebsd.org "South Africa #4"\ + ftp://ftp.es.freebsd.org "Spain"\ + ftp://ftp2.es.freebsd.org "Spain #2"\ + ftp://ftp3.es.freebsd.org "Spain #3"\ + ftp://ftp.se.freebsd.org "Sweden"\ + ftp://ftp2.se.freebsd.org "Sweden #2"\ + ftp://ftp3.se.freebsd.org "Sweden #3"\ + ftp://ftp4.se.freebsd.org "Sweden #4"\ + ftp://ftp5.se.freebsd.org "Sweden #5"\ + ftp://ftp.ch.freebsd.org "Switzerland"\ + ftp://ftp2.ch.freebsd.org "Switzerland #2"\ + ftp://ftp.tw.freebsd.org "Taiwan"\ + ftp://ftp2.tw.freebsd.org "Taiwan #2"\ + ftp://ftp3.tw.freebsd.org "Taiwan #3"\ + ftp://ftp4.tw.freebsd.org "Taiwan #4"\ + ftp://ftp6.tw.freebsd.org "Taiwan #6"\ + ftp://ftp11.tw.freebsd.org "Taiwan #11"\ + ftp://ftp.tr.freebsd.org "Turkey"\ + ftp://ftp2.tr.freebsd.org "Turkey #2"\ + ftp://ftp.uk.freebsd.org "UK"\ + ftp://ftp2.uk.freebsd.org "UK #2"\ + ftp://ftp3.uk.freebsd.org "UK #3"\ + ftp://ftp4.uk.freebsd.org "UK #4"\ + ftp://ftp5.uk.freebsd.org "UK #5"\ + ftp://ftp6.uk.freebsd.org "UK #6"\ + ftp://ftp.ua.freebsd.org "Ukraine"\ + ftp://ftp2.ua.freebsd.org "Ukraine #2"\ + ftp://ftp5.ua.freebsd.org "Ukraine #5"\ + ftp://ftp6.ua.freebsd.org "Ukraine #6"\ + ftp://ftp7.ua.freebsd.org "Ukraine #7"\ + ftp://ftp8.ua.freebsd.org "Ukraine #8"\ + ftp://ftp1.us.freebsd.org "USA #1"\ + ftp://ftp2.us.freebsd.org "USA #2"\ + ftp://ftp3.us.freebsd.org "USA #3"\ + ftp://ftp4.us.freebsd.org "USA #4"\ + ftp://ftp5.us.freebsd.org "USA #5"\ + ftp://ftp6.us.freebsd.org "USA #6"\ + ftp://ftp7.us.freebsd.org "USA #7"\ + ftp://ftp8.us.freebsd.org "USA #8"\ + ftp://ftp9.us.freebsd.org "USA #9"\ + ftp://ftp10.us.freebsd.org "USA #10"\ + ftp://ftp11.us.freebsd.org "USA #11"\ + ftp://ftp12.us.freebsd.org "USA #12"\ + ftp://ftp13.us.freebsd.org "USA #13"\ + ftp://ftp14.us.freebsd.org "USA #14"\ + ftp://ftp15.us.freebsd.org "USA #15"\ + 2>&1 1>&3` +MIRROR_BUTTON=$? +exec 3>&- + +BSDINSTALL_DISTSITE="$MIRROR/pub/FreeBSD/releases/`uname -p`/`uname -m`/`uname -r`" + +case $MIRROR_BUTTON in +$DIALOG_CANCEL) + exit 1 + ;; +$DIALOG_OK) + ;; +$DIALOG_EXTRA) + exec 3>&1 + BSDINSTALL_DISTSITE=`dialog --backtitle "FreeBSD Installer" \ + --title "Mirror Selection" \ + --inputbox "Please enter the URL to an alternate FreeBSD mirror:" \ + 0 0 "$BSDINSTALL_DISTSITE" 2>&1 1>&3` + MIRROR_BUTTON=$? + exec 3>&- + test $MIRROR_BUTTON -eq 0 || exec $0 $@ + ;; +esac + +export BSDINSTALL_DISTSITE +echo $BSDINSTALL_DISTSITE >&2 From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 23:46:12 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D3488106564A; Sun, 27 Mar 2011 23:46:12 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A613F8FC13; Sun, 27 Mar 2011 23:46:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RNkCAc073324; Sun, 27 Mar 2011 23:46:12 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RNkCIQ073322; Sun, 27 Mar 2011 23:46:12 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201103272346.p2RNkCIQ073322@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 27 Mar 2011 23:46:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220081 - head/release X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 23:46:12 -0000 Author: nwhitehorn Date: Sun Mar 27 23:46:12 2011 New Revision: 220081 URL: http://svn.freebsd.org/changeset/base/220081 Log: Add infrastructure for generation of boot-only ISO images. These have a reduced world, though still reasonably complete for fixit purposes. Modified: head/release/Makefile Modified: head/release/Makefile ============================================================================== --- head/release/Makefile Sun Mar 27 23:43:32 2011 (r220080) +++ head/release/Makefile Sun Mar 27 23:46:12 2011 (r220081) @@ -122,13 +122,38 @@ system: packagesystem ln -s /tmp/bsdinstall_etc/resolv.conf ${.OBJDIR}/release/etc/resolv.conf echo sendmail_enable=\"NONE\" > ${.OBJDIR}/release/etc/rc.conf echo hostid_enable=\"NO\" >> ${.OBJDIR}/release/etc/rc.conf - touch ${.OBJDIR}/release/etc/fstab cp ${.CURDIR}/rc.local ${.OBJDIR}/release/etc touch ${.OBJDIR}/${.TARGET} +bootonly: packagesystem +# Install system + mkdir ${.OBJDIR}/bootonly + cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \ + DESTDIR=${.OBJDIR}/bootonly WITHOUT_AMD=1 WITHOUT_AT=1 \ + WITHOUT_BIND_DNSSEC=1 WITHOUT_BIND_ETC=1 WITHOUT_BIND_MTREE=1 \ + WITHOUT_BIND_NAMED=1 WITHOUT_GAMES=1 WITHOUT_GROFF=1 \ + WITHOUT_INSTALLLIB=1 WITHOUT_LIB32=1 WITHOUT_MAIL=1 \ + WITHOUT_NCP=1 WITHOUT_TOOLCHAIN=1 WITHOUT_RESCUE=1 WITHOUT_DICT=1 + -rm ${.OBJDIR}/bootonly/boot/kernel/*.symbols +# Copy manifest only (no distfiles) to get checksums + mkdir ${.OBJDIR}/bootonly/usr/freebsd-dist + cp ${.OBJDIR}/MANIFEST ${.OBJDIR}/bootonly/usr/freebsd-dist +# Copy documentation, if generated +.if !defined(NODOC) + cp ${.OBJDIR}/reldoc/* ${.OBJDIR}/bootonly +.endif +# Set up installation environment + ln -s /tmp/bsdinstall_etc/resolv.conf ${.OBJDIR}/bootonly/etc/resolv.conf + echo sendmail_enable=\"NONE\" > ${.OBJDIR}/bootonly/etc/rc.conf + echo hostid_enable=\"NO\" >> ${.OBJDIR}/bootonly/etc/rc.conf + cp ${.CURDIR}/rc.local ${.OBJDIR}/bootonly/etc + release.iso: system sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.OBJDIR}/release.iso ${.OBJDIR}/release +bootonly.iso: bootonly + sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.OBJDIR}/bootonly.iso ${.OBJDIR}/bootonly + memstick: system sh ${.CURDIR}/${TARGET}/make-memstick.sh ${.OBJDIR}/release ${.OBJDIR}/memstick @@ -136,7 +161,7 @@ packagesystem: base.txz kernel.txz ${EXT sh ${.CURDIR}/scripts/make-manifest.sh ${.OBJDIR}/*.txz > ${.OBJDIR}/MANIFEST touch ${.OBJDIR}/${.TARGET} -cdrom: release.iso +cdrom: release.iso bootonly.iso ftp: packagesystem rm -rf ${.OBJDIR}/ftp mkdir ${.OBJDIR}/ftp From owner-svn-src-all@FreeBSD.ORG Sun Mar 27 23:46:53 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 52616106566B; Sun, 27 Mar 2011 23:46:53 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3FD6F8FC13; Sun, 27 Mar 2011 23:46:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RNkrWV073371; Sun, 27 Mar 2011 23:46:53 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RNkrmF073369; Sun, 27 Mar 2011 23:46:53 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201103272346.p2RNkrmF073369@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 27 Mar 2011 23:46:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220082 - head/release X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 23:46:53 -0000 Author: nwhitehorn Date: Sun Mar 27 23:46:52 2011 New Revision: 220082 URL: http://svn.freebsd.org/changeset/base/220082 Log: Copy all generated ISO images into the release area. Modified: head/release/generate-release.sh Modified: head/release/generate-release.sh ============================================================================== --- head/release/generate-release.sh Sun Mar 27 23:46:12 2011 (r220081) +++ head/release/generate-release.sh Sun Mar 27 23:46:52 2011 (r220082) @@ -62,5 +62,5 @@ fi chroot $2 /bin/sh -c "cd /usr/src && make $MAKE_FLAGS buildworld buildkernel" || exit 1 chroot $2 /bin/sh -c "cd /usr/src/release && make release" || exit 1 mkdir $2/R -cp -pRP $2/usr/obj/usr/src/release/release.iso $2/usr/obj/usr/src/release/memstick $2/usr/obj/usr/src/release/ftp $2/R +cp -pRP $2/usr/obj/usr/src/release/*.iso $2/usr/obj/usr/src/release/memstick $2/usr/obj/usr/src/release/ftp $2/R From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 00:13:42 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 566361065674; Mon, 28 Mar 2011 00:13:42 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 37DC98FC0C; Mon, 28 Mar 2011 00:13:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S0Dg9v073954; Mon, 28 Mar 2011 00:13:42 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S0DgkO073952; Mon, 28 Mar 2011 00:13:42 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103280013.p2S0DgkO073952@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 28 Mar 2011 00:13:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220083 - stable/8/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 00:13:42 -0000 Author: yongari Date: Mon Mar 28 00:13:41 2011 New Revision: 220083 URL: http://svn.freebsd.org/changeset/base/220083 Log: MFC r219701: Remove too expensive bus_dmamap_sync(9) call in dc_rx_resync(). With this change, driver may not notice updated descriptor status change when bounce buffers are active. However, rxeof() in next run will handle the synchronization. Change dc_rxeof() a bit to return the number of processed frames in RX descriptor ring. Previously it returned the number of frames that were successfully passed to upper stack which in turn means it ignored frames that were discarded due to errors. The number of processed frames in RX descriptor ring is used to detect whether driver is out of sync with controller's current descriptor pointer. Returning number of processed frames reduces unnecessary (probably wrong) re-synchronization. Reviewed by: marius Modified: stable/8/sys/dev/dc/if_dc.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 23:46:52 2011 (r220082) +++ stable/8/sys/dev/dc/if_dc.c Mon Mar 28 00:13:41 2011 (r220083) @@ -2790,8 +2790,6 @@ dc_rx_resync(struct dc_softc *sc) pos = sc->dc_cdata.dc_rx_prod; for (i = 0; i < DC_RX_LIST_CNT; i++) { - bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, - BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); cur_rx = &sc->dc_ldata.dc_rx_list[pos]; if (!(le32toh(cur_rx->dc_status) & DC_RXSTAT_OWN)) break; @@ -2862,6 +2860,7 @@ dc_rxeof(struct dc_softc *sc) bus_dmamap_sync(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i], BUS_DMASYNC_POSTREAD); total_len = DC_RXBYTES(rxstat); + rx_npkts++; if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) { if ((rxstat & DC_WHOLEFRAME) != DC_WHOLEFRAME) { @@ -2939,7 +2938,6 @@ dc_rxeof(struct dc_softc *sc) DC_UNLOCK(sc); (*ifp->if_input)(ifp, m); DC_LOCK(sc); - rx_npkts++; } sc->dc_cdata.dc_rx_prod = i; @@ -3263,7 +3261,7 @@ dc_intr(void *arg) struct dc_softc *sc; struct ifnet *ifp; uint32_t r, status; - int curpkts, n; + int n; sc = arg; @@ -3293,9 +3291,7 @@ dc_intr(void *arg) CSR_WRITE_4(sc, DC_ISR, status); if (status & DC_ISR_RX_OK) { - curpkts = ifp->if_ipackets; - dc_rxeof(sc); - if (curpkts == ifp->if_ipackets) { + if (dc_rxeof(sc) == 0) { while (dc_rx_resync(sc)) dc_rxeof(sc); } @@ -3319,9 +3315,7 @@ dc_intr(void *arg) || (status & DC_ISR_RX_NOBUF)) { r = CSR_READ_4(sc, DC_FRAMESDISCARDED); ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff); - curpkts = ifp->if_ipackets; - dc_rxeof(sc); - if (curpkts == ifp->if_ipackets) { + if (dc_rxeof(sc) == 0) { while (dc_rx_resync(sc)) dc_rxeof(sc); } From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 00:14:46 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1233) id E21D2106566B; Mon, 28 Mar 2011 00:14:46 +0000 (UTC) Date: Mon, 28 Mar 2011 00:14:46 +0000 From: Alexander Best To: Nathan Whitehorn Message-ID: <20110328001446.GA74922@freebsd.org> References: <201103272346.p2RNkrmF073369@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201103272346.p2RNkrmF073369@svn.freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220082 - head/release X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 00:14:47 -0000 On Sun Mar 27 11, Nathan Whitehorn wrote: > Author: nwhitehorn > Date: Sun Mar 27 23:46:52 2011 > New Revision: 220082 > URL: http://svn.freebsd.org/changeset/base/220082 > > Log: > Copy all generated ISO images into the release area. s/cp -pRP/cp -a/ ? > > Modified: > head/release/generate-release.sh > > Modified: head/release/generate-release.sh > ============================================================================== > --- head/release/generate-release.sh Sun Mar 27 23:46:12 2011 (r220081) > +++ head/release/generate-release.sh Sun Mar 27 23:46:52 2011 (r220082) > @@ -62,5 +62,5 @@ fi > chroot $2 /bin/sh -c "cd /usr/src && make $MAKE_FLAGS buildworld buildkernel" || exit 1 > chroot $2 /bin/sh -c "cd /usr/src/release && make release" || exit 1 > mkdir $2/R > -cp -pRP $2/usr/obj/usr/src/release/release.iso $2/usr/obj/usr/src/release/memstick $2/usr/obj/usr/src/release/ftp $2/R > +cp -pRP $2/usr/obj/usr/src/release/*.iso $2/usr/obj/usr/src/release/memstick $2/usr/obj/usr/src/release/ftp $2/R > -- a13x From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 00:14:56 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 988B61065672; Mon, 28 Mar 2011 00:14:56 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 84A708FC12; Mon, 28 Mar 2011 00:14:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S0Eu2u074010; Mon, 28 Mar 2011 00:14:56 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S0Eu5w074008; Mon, 28 Mar 2011 00:14:56 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103280014.p2S0Eu5w074008@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 28 Mar 2011 00:14:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220084 - stable/7/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 00:14:56 -0000 Author: yongari Date: Mon Mar 28 00:14:56 2011 New Revision: 220084 URL: http://svn.freebsd.org/changeset/base/220084 Log: MFC r219701: Remove too expensive bus_dmamap_sync(9) call in dc_rx_resync(). With this change, driver may not notice updated descriptor status change when bounce buffers are active. However, rxeof() in next run will handle the synchronization. Change dc_rxeof() a bit to return the number of processed frames in RX descriptor ring. Previously it returned the number of frames that were successfully passed to upper stack which in turn means it ignored frames that were discarded due to errors. The number of processed frames in RX descriptor ring is used to detect whether driver is out of sync with controller's current descriptor pointer. Returning number of processed frames reduces unnecessary (probably wrong) re-synchronization. Reviewed by: marius Modified: stable/7/sys/dev/dc/if_dc.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Mon Mar 28 00:13:41 2011 (r220083) +++ stable/7/sys/dev/dc/if_dc.c Mon Mar 28 00:14:56 2011 (r220084) @@ -238,7 +238,7 @@ static int dc_newbuf(struct dc_softc *, static int dc_encap(struct dc_softc *, struct mbuf **); static void dc_pnic_rx_bug_war(struct dc_softc *, int); static int dc_rx_resync(struct dc_softc *); -static void dc_rxeof(struct dc_softc *); +static int dc_rxeof(struct dc_softc *); static void dc_txeof(struct dc_softc *); static void dc_tick(void *); static void dc_tx_underrun(struct dc_softc *); @@ -2791,8 +2791,6 @@ dc_rx_resync(struct dc_softc *sc) pos = sc->dc_cdata.dc_rx_prod; for (i = 0; i < DC_RX_LIST_CNT; i++) { - bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, - BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); cur_rx = &sc->dc_ldata.dc_rx_list[pos]; if (!(le32toh(cur_rx->dc_status) & DC_RXSTAT_OWN)) break; @@ -2829,18 +2827,19 @@ dc_discard_rxbuf(struct dc_softc *sc, in * A frame has been uploaded: pass the resulting mbuf chain up to * the higher level protocols. */ -static void +static int dc_rxeof(struct dc_softc *sc) { struct mbuf *m; struct ifnet *ifp; struct dc_desc *cur_rx; - int i, total_len; + int i, total_len, rx_npkts; uint32_t rxstat; DC_LOCK_ASSERT(sc); ifp = sc->dc_ifp; + rx_npkts = 0; bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); @@ -2862,6 +2861,7 @@ dc_rxeof(struct dc_softc *sc) bus_dmamap_sync(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i], BUS_DMASYNC_POSTREAD); total_len = DC_RXBYTES(rxstat); + rx_npkts++; if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) { if ((rxstat & DC_WHOLEFRAME) != DC_WHOLEFRAME) { @@ -2896,7 +2896,7 @@ dc_rxeof(struct dc_softc *sc) else { ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); - return; + return (rx_npkts); } } } @@ -2942,6 +2942,7 @@ dc_rxeof(struct dc_softc *sc) } sc->dc_cdata.dc_rx_prod = i; + return (rx_npkts); } /* @@ -3259,7 +3260,7 @@ dc_intr(void *arg) struct dc_softc *sc; struct ifnet *ifp; uint32_t r, status; - int curpkts, n; + int n; sc = arg; @@ -3289,9 +3290,7 @@ dc_intr(void *arg) CSR_WRITE_4(sc, DC_ISR, status); if (status & DC_ISR_RX_OK) { - curpkts = ifp->if_ipackets; - dc_rxeof(sc); - if (curpkts == ifp->if_ipackets) { + if (dc_rxeof(sc) == 0) { while (dc_rx_resync(sc)) dc_rxeof(sc); } @@ -3315,9 +3314,7 @@ dc_intr(void *arg) || (status & DC_ISR_RX_NOBUF)) { r = CSR_READ_4(sc, DC_FRAMESDISCARDED); ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff); - curpkts = ifp->if_ipackets; - dc_rxeof(sc); - if (curpkts == ifp->if_ipackets) { + if (dc_rxeof(sc) == 0) { while (dc_rx_resync(sc)) dc_rxeof(sc); } From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 00:18:02 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F0763106564A; Mon, 28 Mar 2011 00:18:02 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DCC688FC0A; Mon, 28 Mar 2011 00:18:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S0I2cv074135; Mon, 28 Mar 2011 00:18:02 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S0I2J8074133; Mon, 28 Mar 2011 00:18:02 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103280018.p2S0I2J8074133@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 28 Mar 2011 00:18:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220085 - stable/8/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 00:18:03 -0000 Author: yongari Date: Mon Mar 28 00:18:02 2011 New Revision: 220085 URL: http://svn.freebsd.org/changeset/base/220085 Log: MFC r201449: Fix CardBus spelling. Modified: stable/8/sys/dev/dc/if_dc.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Mon Mar 28 00:14:56 2011 (r220084) +++ stable/8/sys/dev/dc/if_dc.c Mon Mar 28 00:18:02 2011 (r220085) @@ -44,8 +44,8 @@ __FBSDID("$FreeBSD$"); * ASIX Electronics AX88141 (www.asix.com.tw) * ADMtek AL981 (www.admtek.com.tw) * ADMtek AN983 (www.admtek.com.tw) - * ADMtek cardbus AN985 (www.admtek.com.tw) - * Netgear FA511 (www.netgear.com) Appears to be rebadged ADMTek cardbus AN985 + * ADMtek CardBus AN985 (www.admtek.com.tw) + * Netgear FA511 (www.netgear.com) Appears to be rebadged ADMTek CardBus AN985 * Davicom DM9100, DM9102, DM9102A (www.davicom8.com) * Accton EN1217 (www.accton.com) * Xircom X3201 (www.xircom.com) @@ -165,7 +165,7 @@ static const struct dc_type dc_devs[] = { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN983), 0, "ADMtek AN983 10/100BaseTX" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN985), 0, - "ADMtek AN985 cardBus 10/100BaseTX or clone" }, + "ADMtek AN985 CardBus 10/100BaseTX or clone" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_ADM9511), 0, "ADMtek ADM9511 10/100BaseTX" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_ADM9513), 0, From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 00:19:01 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 72187106566B; Mon, 28 Mar 2011 00:19:01 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5E69A8FC19; Mon, 28 Mar 2011 00:19:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S0J1rE074185; Mon, 28 Mar 2011 00:19:01 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S0J1aR074183; Mon, 28 Mar 2011 00:19:01 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103280019.p2S0J1aR074183@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 28 Mar 2011 00:19:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220086 - stable/7/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 00:19:01 -0000 Author: yongari Date: Mon Mar 28 00:19:01 2011 New Revision: 220086 URL: http://svn.freebsd.org/changeset/base/220086 Log: MFC r201449: Fix CardBus spelling. Modified: stable/7/sys/dev/dc/if_dc.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Mon Mar 28 00:18:02 2011 (r220085) +++ stable/7/sys/dev/dc/if_dc.c Mon Mar 28 00:19:01 2011 (r220086) @@ -44,8 +44,8 @@ __FBSDID("$FreeBSD$"); * ASIX Electronics AX88141 (www.asix.com.tw) * ADMtek AL981 (www.admtek.com.tw) * ADMtek AN983 (www.admtek.com.tw) - * ADMtek cardbus AN985 (www.admtek.com.tw) - * Netgear FA511 (www.netgear.com) Appears to be rebadged ADMTek cardbus AN985 + * ADMtek CardBus AN985 (www.admtek.com.tw) + * Netgear FA511 (www.netgear.com) Appears to be rebadged ADMTek CardBus AN985 * Davicom DM9100, DM9102, DM9102A (www.davicom8.com) * Accton EN1217 (www.accton.com) * Xircom X3201 (www.xircom.com) @@ -165,7 +165,7 @@ static const struct dc_type dc_devs[] = { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN983), 0, "ADMtek AN983 10/100BaseTX" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN985), 0, - "ADMtek AN985 cardBus 10/100BaseTX or clone" }, + "ADMtek AN985 CardBus 10/100BaseTX or clone" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_ADM9511), 0, "ADMtek ADM9511 10/100BaseTX" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_ADM9513), 0, From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 01:24:21 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7F8E41065672; Mon, 28 Mar 2011 01:24:21 +0000 (UTC) (envelope-from kevlo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 335B58FC0C; Mon, 28 Mar 2011 01:24:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S1OLnI075546; Mon, 28 Mar 2011 01:24:21 GMT (envelope-from kevlo@svn.freebsd.org) Received: (from kevlo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S1OLnm075544; Mon, 28 Mar 2011 01:24:21 GMT (envelope-from kevlo@svn.freebsd.org) Message-Id: <201103280124.p2S1OLnm075544@svn.freebsd.org> From: Kevin Lo Date: Mon, 28 Mar 2011 01:24:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220087 - stable/8/sys/dev/usb/wlan X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 01:24:21 -0000 Author: kevlo Date: Mon Mar 28 01:24:20 2011 New Revision: 220087 URL: http://svn.freebsd.org/changeset/base/220087 Log: MFC r219982: Fix panic while associating access point. While here, add the SMC SMCWUSB-G Modified: stable/8/sys/dev/usb/wlan/if_zyd.c Modified: stable/8/sys/dev/usb/wlan/if_zyd.c ============================================================================== --- stable/8/sys/dev/usb/wlan/if_zyd.c Mon Mar 28 00:19:01 2011 (r220086) +++ stable/8/sys/dev/usb/wlan/if_zyd.c Mon Mar 28 01:24:20 2011 (r220087) @@ -229,6 +229,7 @@ static const struct usb_device_id zyd_de ZYD_ZD1211_DEV(ZYXEL, ZYAIRG220), ZYD_ZD1211_DEV(ZYXEL, G200V2), /* ZYD_ZD1211B */ + ZYD_ZD1211B_DEV(ACCTON, SMCWUSBG_NF), ZYD_ZD1211B_DEV(ACCTON, SMCWUSBG), ZYD_ZD1211B_DEV(ACCTON, ZD1211B), ZYD_ZD1211B_DEV(ASUS, A9T_WIFI), @@ -510,9 +511,6 @@ zyd_tx_free(struct zyd_tx_data *data, in m_freem(data->m); data->m = NULL; - if (txerr == 0) - ieee80211_ratectl_tx_complete(data->ni->ni_vap, - data->ni, IEEE80211_RATECTL_TX_SUCCESS, NULL, NULL); ieee80211_free_node(data->ni); data->ni = NULL; } From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 02:37:06 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 16008106564A; Mon, 28 Mar 2011 02:37:06 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 019D98FC08; Mon, 28 Mar 2011 02:37:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S2b5mk077040; Mon, 28 Mar 2011 02:37:05 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S2b5Vt077038; Mon, 28 Mar 2011 02:37:05 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201103280237.p2S2b5Vt077038@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 28 Mar 2011 02:37:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220088 - head/usr.sbin/bsdinstall/scripts X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 02:37:06 -0000 Author: nwhitehorn Date: Mon Mar 28 02:37:05 2011 New Revision: 220088 URL: http://svn.freebsd.org/changeset/base/220088 Log: Improve error handling. Modified: head/usr.sbin/bsdinstall/scripts/auto Modified: head/usr.sbin/bsdinstall/scripts/auto ============================================================================== --- head/usr.sbin/bsdinstall/scripts/auto Mon Mar 28 01:24:20 2011 (r220087) +++ head/usr.sbin/bsdinstall/scripts/auto Mon Mar 28 02:37:05 2011 (r220088) @@ -29,14 +29,14 @@ echo "Begun Installation at $(date)" > $BSDINSTALL_LOG error() { + test -n "$DISTDIR_IS_UNIONFS" && umount -f $BSDINSTALL_DISTDIR + test -f $PATH_FSTAB && bsdinstall umount dialog --backtitle "FreeBSD Installer" --title "Abort" \ --no-label "Exit" --yes-label "Restart" --yesno \ "An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0 if [ $? -ne 0 ]; then exit else - test -n $DISTDIR_IS_UNIONFS && umount -f $BSDINSTALL_DISTDIR - test -f $PATH_FSTAB && bsdinstall umount exec $0 fi } @@ -81,7 +81,7 @@ if [ -n "$FETCH_DISTRIBUTIONS" -a -n "$B NETCONFIG_DONE=yes fi -if [ -n "$FETCH_DISTRIBUTIONS" -a -z "$BSDINSTALL_DISTSITE" ]; then +if [ -n "$FETCH_DISTRIBUTIONS" ]; then exec 3>&1 BSDINSTALL_DISTSITE=`bsdinstall mirrorselect 2>&1 1>&3` MIRROR_BUTTON=$? @@ -125,8 +125,7 @@ if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS" # Try to use any existing distfiles - if [ -d $BSDINSTALL_DISTDIR -a "$FETCH_DISTRIBUTIONS" != \ - "$ALL_DISTRIBUTIONS" ]; then + if [ -d $BSDINSTALL_DISTDIR ]; then DISTDIR_IS_UNIONFS=1 mount_unionfs "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR" fi From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 04:29:51 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1293810656AC; Mon, 28 Mar 2011 04:29:51 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F2FFE8FC08; Mon, 28 Mar 2011 04:29:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S4Toqc080812; Mon, 28 Mar 2011 04:29:50 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S4To9v080810; Mon, 28 Mar 2011 04:29:50 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201103280429.p2S4To9v080810@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 28 Mar 2011 04:29:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220089 - head/usr.sbin/bsdinstall/scripts X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 04:29:51 -0000 Author: nwhitehorn Date: Mon Mar 28 04:29:50 2011 New Revision: 220089 URL: http://svn.freebsd.org/changeset/base/220089 Log: Committing while tired is never a good idea. Remove an unconditional error exit left over from debugging. Modified: head/usr.sbin/bsdinstall/scripts/auto Modified: head/usr.sbin/bsdinstall/scripts/auto ============================================================================== --- head/usr.sbin/bsdinstall/scripts/auto Mon Mar 28 02:37:05 2011 (r220088) +++ head/usr.sbin/bsdinstall/scripts/auto Mon Mar 28 04:29:50 2011 (r220089) @@ -140,8 +140,6 @@ if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then export DISTRIBUTIONS="$ALL_DISTRIBUTIONS" fi -error - bsdinstall checksum || error bsdinstall distextract || error bsdinstall rootpass || error From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 06:35:18 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 58F5D106564A; Mon, 28 Mar 2011 06:35:18 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2E9868FC14; Mon, 28 Mar 2011 06:35:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S6ZIQC083632; Mon, 28 Mar 2011 06:35:18 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S6ZIev083629; Mon, 28 Mar 2011 06:35:18 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201103280635.p2S6ZIev083629@svn.freebsd.org> From: Alan Cox Date: Mon, 28 Mar 2011 06:35:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220090 - in head/sys: amd64/amd64 conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 06:35:18 -0000 Author: alc Date: Mon Mar 28 06:35:17 2011 New Revision: 220090 URL: http://svn.freebsd.org/changeset/base/220090 Log: The new binutils has correctly redefined MAXPAGESIZE on amd64 as 0x200000 instead of 0x100000. As a side effect, an amd64 kernel now loads at physical address 0x200000 instead of 0x100000. This is probably for the best because it avoids the use of a 2MB page mapping for the first 1MB of the kernel that also spans the fixed MTRRs. However, getmemsize() still thinks that the kernel loads at 0x100000, and so the physical memory between 0x100000 and 0x200000 is lost. Fix this problem by replacing the hard-wired constant in getmemsize() by a symbol "kernphys" that is defined by the linker script. In collaboration with: kib Modified: head/sys/amd64/amd64/machdep.c head/sys/conf/ldscript.amd64 Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Mon Mar 28 04:29:50 2011 (r220089) +++ head/sys/amd64/amd64/machdep.c Mon Mar 28 06:35:17 2011 (r220090) @@ -156,6 +156,11 @@ static void get_fpcontext(struct thread static int set_fpcontext(struct thread *td, const mcontext_t *mcp); SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); +/* + * The file "conf/ldscript.amd64" defines the symbol "kernphys". Its value is + * the physical address at which the kernel is loaded. + */ +extern char kernphys[]; #ifdef DDB extern vm_offset_t ksym_start, ksym_end; #endif @@ -1417,7 +1422,7 @@ getmemsize(caddr_t kmdp, u_int64_t first /* * block out kernel memory as not available. */ - if (pa >= 0x100000 && pa < first) + if (pa >= (vm_paddr_t)kernphys && pa < first) goto do_dump_avail; /* Modified: head/sys/conf/ldscript.amd64 ============================================================================== --- head/sys/conf/ldscript.amd64 Mon Mar 28 04:29:50 2011 (r220089) +++ head/sys/conf/ldscript.amd64 Mon Mar 28 06:35:17 2011 (r220090) @@ -6,7 +6,8 @@ SEARCH_DIR("/usr/lib"); SECTIONS { /* Read-only sections, merged into text segment: */ - . = kernbase + CONSTANT (MAXPAGESIZE) + SIZEOF_HEADERS; + kernphys = CONSTANT (MAXPAGESIZE); + . = kernbase + kernphys + SIZEOF_HEADERS; .interp : { *(.interp) } .hash : { *(.hash) } .gnu.hash : { *(.gnu.hash) } From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 07:00:41 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 805B7106564A; Mon, 28 Mar 2011 07:00:41 +0000 (UTC) (envelope-from mr@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 70F2E8FC1E; Mon, 28 Mar 2011 07:00:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S70f3F084252; Mon, 28 Mar 2011 07:00:41 GMT (envelope-from mr@svn.freebsd.org) Received: (from mr@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S70fsr084250; Mon, 28 Mar 2011 07:00:41 GMT (envelope-from mr@svn.freebsd.org) Message-Id: <201103280700.p2S70fsr084250@svn.freebsd.org> From: Michael Reifenberger Date: Mon, 28 Mar 2011 07:00:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220091 - head/tools/tools/nanobsd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 07:00:41 -0000 Author: mr Date: Mon Mar 28 07:00:41 2011 New Revision: 220091 URL: http://svn.freebsd.org/changeset/base/220091 Log: Use ${NANO_WORLDDIR}/var/empty as copy source since it has no schg flag set. Copying over /var/empty's schg flag had unpleasant side effects (schg flag on /etc and /cfg) during nanobsd boot before. Modified: head/tools/tools/nanobsd/nanobsd.sh Modified: head/tools/tools/nanobsd/nanobsd.sh ============================================================================== --- head/tools/tools/nanobsd/nanobsd.sh Mon Mar 28 06:35:17 2011 (r220090) +++ head/tools/tools/nanobsd/nanobsd.sh Mon Mar 28 07:00:41 2011 (r220091) @@ -413,8 +413,8 @@ populate_slice ( ) ( dir=$2 mnt=$3 lbl=$4 - test -z $2 && dir=/var/empty - test -d $dir || dir=/var/empty + test -z $2 && dir=${NANO_WORLDDIR}/var/empty + test -d $dir || dir=${NANO_WORLDDIR}/var/empty echo "Creating ${dev} with ${dir} (mounting on ${mnt})" newfs_part $dev $mnt $lbl cd ${dir} From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 08:22:14 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1634C106566B; Mon, 28 Mar 2011 08:22:14 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DF5AA8FC1C; Mon, 28 Mar 2011 08:22:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S8MDwa086451; Mon, 28 Mar 2011 08:22:13 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S8MDKe086449; Mon, 28 Mar 2011 08:22:13 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103280822.p2S8MDKe086449@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 28 Mar 2011 08:22:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220092 - stable/8/sys/compat/freebsd32 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 08:22:14 -0000 Author: kib Date: Mon Mar 28 08:22:13 2011 New Revision: 220092 URL: http://svn.freebsd.org/changeset/base/220092 Log: MFC r219986: Fix file leakage in the freebsd32_ioctl routines. Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c ============================================================================== --- stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Mon Mar 28 07:00:41 2011 (r220091) +++ stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Mon Mar 28 08:22:13 2011 (r220092) @@ -70,7 +70,6 @@ freebsd32_ioctl_md(struct thread *td, st panic("%s: where is my ioctl data??", __func__); if (uap->com & IOC_IN) { if ((error = copyin(uap->data, &md32, sizeof(md32)))) { - fdrop(fp, td); return (error); } CP(md32, mdv, md_version); @@ -121,7 +120,6 @@ freebsd32_ioctl_md(struct thread *td, st CP(mdv, md32, md_fwsectors); error = copyout(&md32, uap->data, sizeof(md32)); } - fdrop(fp, td); return error; } @@ -144,7 +142,6 @@ freebsd32_ioctl_ioc_toc_header(struct th CP(toch32, toch, ending_track); error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&toch, td->td_ucred, td); - fdrop(fp, td); return (error); } @@ -175,7 +172,6 @@ freebsd32_ioctl_ioc_read_toc(struct thre PTROUT_CP(toce, toce32, data); error = copyout(&toce32, uap->data, sizeof(toce32)); } - fdrop(fp, td); return error; } @@ -192,7 +188,6 @@ freebsd32_ioctl_fiodgname(struct thread CP(fgn32, fgn, len); PTRIN_CP(fgn32, fgn, buf); error = fo_ioctl(fp, FIODGNAME, (caddr_t)&fgn, td->td_ucred, td); - fdrop(fp, td); return (error); } @@ -219,16 +214,20 @@ freebsd32_ioctl(struct thread *td, struc case MDIOCDETACH_32: /* FALLTHROUGH */ case MDIOCQUERY_32: /* FALLTHROUGH */ case MDIOCLIST_32: - return freebsd32_ioctl_md(td, uap, fp); + error = freebsd32_ioctl_md(td, uap, fp); + break; case CDIOREADTOCENTRYS_32: - return freebsd32_ioctl_ioc_read_toc(td, uap, fp); + error = freebsd32_ioctl_ioc_read_toc(td, uap, fp); + break; case CDIOREADTOCHEADER_32: - return freebsd32_ioctl_ioc_toc_header(td, uap, fp); + error = freebsd32_ioctl_ioc_toc_header(td, uap, fp); + break; case FIODGNAME_32: - return freebsd32_ioctl_fiodgname(td, uap, fp); + error = freebsd32_ioctl_fiodgname(td, uap, fp); + break; default: fdrop(fp, td); @@ -237,4 +236,7 @@ freebsd32_ioctl(struct thread *td, struc PTRIN_CP(*uap, ap, data); return ioctl(td, &ap); } + + fdrop(fp, td); + return error; } From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 08:23:46 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 55AB5106566C; Mon, 28 Mar 2011 08:23:46 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 452038FC13; Mon, 28 Mar 2011 08:23:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S8NkAv086537; Mon, 28 Mar 2011 08:23:46 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S8NkVD086535; Mon, 28 Mar 2011 08:23:46 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103280823.p2S8NkVD086535@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 28 Mar 2011 08:23:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220093 - stable/8/sys/compat/freebsd32 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 08:23:46 -0000 Author: kib Date: Mon Mar 28 08:23:45 2011 New Revision: 220093 URL: http://svn.freebsd.org/changeset/base/220093 Log: MFC r219987: Remove unneccessary panics. Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c ============================================================================== --- stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Mon Mar 28 08:22:13 2011 (r220092) +++ stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Mon Mar 28 08:23:45 2011 (r220093) @@ -66,8 +66,6 @@ freebsd32_ioctl_md(struct thread *td, st u_long com = 0; int error; - if (uap->data == NULL) - panic("%s: where is my ioctl data??", __func__); if (uap->com & IOC_IN) { if ((error = copyin(uap->data, &md32, sizeof(md32)))) { return (error); @@ -132,9 +130,6 @@ freebsd32_ioctl_ioc_toc_header(struct th struct ioc_toc_header32 toch32; int error; - if (uap->data == NULL) - panic("%s: where is my ioctl data??", __func__); - if ((error = copyin(uap->data, &toch32, sizeof(toch32)))) return (error); CP(toch32, toch, len); @@ -154,9 +149,6 @@ freebsd32_ioctl_ioc_read_toc(struct thre struct ioc_read_toc_entry32 toce32; int error; - if (uap->data == NULL) - panic("%s: where is my ioctl data??", __func__); - if ((error = copyin(uap->data, &toce32, sizeof(toce32)))) return (error); CP(toce32, toce, address_format); From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 08:37:48 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 899DD106566C; Mon, 28 Mar 2011 08:37:48 +0000 (UTC) (envelope-from martymac@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 792018FC16; Mon, 28 Mar 2011 08:37:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S8bmoA086890; Mon, 28 Mar 2011 08:37:48 GMT (envelope-from martymac@svn.freebsd.org) Received: (from martymac@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S8bm1V086888; Mon, 28 Mar 2011 08:37:48 GMT (envelope-from martymac@svn.freebsd.org) Message-Id: <201103280837.p2S8bm1V086888@svn.freebsd.org> From: Ganael LAPLANCHE Date: Mon, 28 Mar 2011 08:37:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220094 - head/usr.bin/calendar/calendars X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 08:37:48 -0000 Author: martymac (ports committer) Date: Mon Mar 28 08:37:48 2011 New Revision: 220094 URL: http://svn.freebsd.org/changeset/base/220094 Log: Add myself Modified: head/usr.bin/calendar/calendars/calendar.freebsd Modified: head/usr.bin/calendar/calendars/calendar.freebsd ============================================================================== --- head/usr.bin/calendar/calendars/calendar.freebsd Mon Mar 28 08:23:45 2011 (r220093) +++ head/usr.bin/calendar/calendars/calendar.freebsd Mon Mar 28 08:37:48 2011 (r220094) @@ -320,6 +320,7 @@ 12/03 Diane Bruce born in Ottawa, Ontario, Canada, 1952 12/05 Ivan Voras born in Slavonski Brod, Croatia, 1981 12/06 Stefan Farfeleder born in Wien, Austria, 1980 +12/11 Ganael Laplanche born in Reims, France, 1980 12/15 James FitzGibbon born in Amersham, Buckinghamshire, United Kingdom, 1974 12/15 Timur I. Bakeyev born in Kazan, Republic of Tatarstan, USSR, 1974 12/18 Chris Timmons born in Ellensburg, Washington, United States, 1964 From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 09:05:43 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8DD821065670; Mon, 28 Mar 2011 09:05:43 +0000 (UTC) (envelope-from martymac@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7CE958FC1D; Mon, 28 Mar 2011 09:05:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S95h6g087572; Mon, 28 Mar 2011 09:05:43 GMT (envelope-from martymac@svn.freebsd.org) Received: (from martymac@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S95hgw087570; Mon, 28 Mar 2011 09:05:43 GMT (envelope-from martymac@svn.freebsd.org) Message-Id: <201103280905.p2S95hgw087570@svn.freebsd.org> From: Ganael LAPLANCHE Date: Mon, 28 Mar 2011 09:05:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220095 - head/share/misc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 09:05:43 -0000 Author: martymac (ports committer) Date: Mon Mar 28 09:05:43 2011 New Revision: 220095 URL: http://svn.freebsd.org/changeset/base/220095 Log: Add myself to committers-ports.dot Modified: head/share/misc/committers-ports.dot Modified: head/share/misc/committers-ports.dot ============================================================================== --- head/share/misc/committers-ports.dot Mon Mar 28 08:37:48 2011 (r220094) +++ head/share/misc/committers-ports.dot Mon Mar 28 09:05:43 2011 (r220095) @@ -127,6 +127,7 @@ makc [label="Max Brazhnikov\nmakc@FreeBS mandree [label="Matthias Andree\nmandree@FreeBSD.org\n2009/11/18"] marcus [label="Joe Marcus Clarke\nmarcus@FreeBSD.org\n2002/04/05"] markus [label="Markus Brueffer\nmarkus@FreeBSD.org\n2004/02/21"] +martymac [label="Ganael Laplanche\nmartymac@FreeBSD.org\n2010/09/24"] mat [label="Mathieu Arnold\nmat@FreeBSD.org\n2003/08/15"] mezz [label="Jeremy Messenger\nmezz@FreeBSD.org\n2004/04/30"] miwi [label="Martin Wilke\nmiwi@FreeBSD.org\n2006/06/04"] From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 09:11:00 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1BF04106564A; Mon, 28 Mar 2011 09:11:00 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0ABB98FC15; Mon, 28 Mar 2011 09:11:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S9AxSp087728; Mon, 28 Mar 2011 09:10:59 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S9Ax4u087726; Mon, 28 Mar 2011 09:10:59 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103280910.p2S9Ax4u087726@svn.freebsd.org> From: Adrian Chadd Date: Mon, 28 Mar 2011 09:10:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220096 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 09:11:00 -0000 Author: adrian Date: Mon Mar 28 09:10:59 2011 New Revision: 220096 URL: http://svn.freebsd.org/changeset/base/220096 Log: The previous commit didn't completely rename this to what it should be. Modified: head/sys/mips/atheros/ar71xx_machdep.c Modified: head/sys/mips/atheros/ar71xx_machdep.c ============================================================================== --- head/sys/mips/atheros/ar71xx_machdep.c Mon Mar 28 09:05:43 2011 (r220095) +++ head/sys/mips/atheros/ar71xx_machdep.c Mon Mar 28 09:10:59 2011 (r220096) @@ -217,7 +217,7 @@ platform_start(__register_t a0 __unused, * but in fact there's 32mb. */ #if defined(AR71XX_REALMEM) - realmem = btoc(MIPS_REALMEM); + realmem = btoc(AR71XX_REALMEM); #endif /* phys_avail regions are in bytes */ From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 11:08:59 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2C84C1065676; Mon, 28 Mar 2011 11:08:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 195188FC2A; Mon, 28 Mar 2011 11:08:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SB8w47092607; Mon, 28 Mar 2011 11:08:58 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SB8w9w092605; Mon, 28 Mar 2011 11:08:58 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201103281108.p2SB8w9w092605@svn.freebsd.org> From: Alexander Motin Date: Mon, 28 Mar 2011 11:08:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220097 - head/sys/dev/mvs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 11:08:59 -0000 Author: mav Date: Mon Mar 28 11:08:58 2011 New Revision: 220097 URL: http://svn.freebsd.org/changeset/base/220097 Log: Update mvs(4) driver to work over FDT's simplebus(4) bus. Modified: head/sys/dev/mvs/mvs_soc.c Modified: head/sys/dev/mvs/mvs_soc.c ============================================================================== --- head/sys/dev/mvs/mvs_soc.c Mon Mar 28 09:10:59 2011 (r220096) +++ head/sys/dev/mvs/mvs_soc.c Mon Mar 28 11:08:58 2011 (r220097) @@ -43,6 +43,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include "mvs.h" /* local prototypes */ @@ -73,6 +75,9 @@ mvs_probe(device_t dev) int i; uint32_t devid, revid; + if (!ofw_bus_is_compatible(dev, "mrvl,sata")) + return (ENXIO); + soc_id(&devid, &revid); for (i = 0; mvs_ids[i].id != 0; i++) { if (mvs_ids[i].id == devid && @@ -440,10 +445,10 @@ static device_method_t mvs_methods[] = { { 0, 0 } }; static driver_t mvs_driver = { - "sata", + "mvs", mvs_methods, sizeof(struct mvs_controller) }; -DRIVER_MODULE(sata, mbus, mvs_driver, mvs_devclass, 0, 0); -MODULE_VERSION(sata, 1); - +DRIVER_MODULE(mvs, simplebus, mvs_driver, mvs_devclass, 0, 0); +MODULE_VERSION(mvs, 1); +MODULE_DEPEND(mvs, cam, 1, 1, 1); From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 11:48:49 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6E1E71065680; Mon, 28 Mar 2011 11:48:49 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5C4AE8FC0A; Mon, 28 Mar 2011 11:48:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SBmni4093479; Mon, 28 Mar 2011 11:48:49 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SBmnNq093477; Mon, 28 Mar 2011 11:48:49 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103281148.p2SBmnNq093477@svn.freebsd.org> From: Adrian Chadd Date: Mon, 28 Mar 2011 11:48:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220098 - head/sys/dev/ath X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 11:48:49 -0000 Author: adrian Date: Mon Mar 28 11:48:49 2011 New Revision: 220098 URL: http://svn.freebsd.org/changeset/base/220098 Log: Add in HT protection but disable it by default. I'll clear how it's supposed to work with Bernhard and then look at enabling this in the correct situations. But this -does- enable HT RTS protection (using the appropriate legacy rates) if this bit of code is enabled. Modified: head/sys/dev/ath/if_ath_tx.c Modified: head/sys/dev/ath/if_ath_tx.c ============================================================================== --- head/sys/dev/ath/if_ath_tx.c Mon Mar 28 11:08:58 2011 (r220097) +++ head/sys/dev/ath/if_ath_tx.c Mon Mar 28 11:48:49 2011 (r220098) @@ -702,6 +702,24 @@ ath_tx_start(struct ath_softc *sc, struc sc->sc_stats.ast_tx_protect++; } +#if 0 + /* + * If 11n protection is enabled and it's a HT frame, + * enable RTS. + * + * XXX ic_htprotmode or ic_curhtprotmode? + * XXX should it_htprotmode only matter if ic_curhtprotmode + * XXX indicates it's not a HT pure environment? + */ + if ((ic->ic_htprotmode == IEEE80211_PROT_RTSCTS) && + rt->info[rix].phy == IEEE80211_T_HT && + (flags & HAL_TXDESC_NOACK) == 0) { + cix = rt->info[sc->sc_protrix].controlRate; + flags |= HAL_TXDESC_RTSENA; + sc->sc_stats.ast_tx_htprotect++; + } +#endif + /* * Calculate duration. This logically belongs in the 802.11 * layer but it lacks sufficient information to calculate it. From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 12:39:48 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A1ABA1065672; Mon, 28 Mar 2011 12:39:48 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8EE398FC1F; Mon, 28 Mar 2011 12:39:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SCdmd6094651; Mon, 28 Mar 2011 12:39:48 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SCdm46094649; Mon, 28 Mar 2011 12:39:48 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103281239.p2SCdm46094649@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 28 Mar 2011 12:39:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220099 - head/sys/ufs/ffs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 12:39:48 -0000 Author: kib Date: Mon Mar 28 12:39:48 2011 New Revision: 220099 URL: http://svn.freebsd.org/changeset/base/220099 Log: Fix the softdep_request_cleanup() function definition for !SOFTUPDATES case. Submitted by: Aleksandr Rybalko Modified: head/sys/ufs/ffs/ffs_softdep.c Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Mon Mar 28 11:48:49 2011 (r220098) +++ head/sys/ufs/ffs/ffs_softdep.c Mon Mar 28 12:39:48 2011 (r220099) @@ -514,9 +514,10 @@ softdep_releasefile(ip) } int -softdep_request_cleanup(fs, vp) +softdep_request_cleanup(fs, vp, resource) struct fs *fs; struct vnode *vp; + int resource; { return (0); From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 12:48:33 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A5559106566B; Mon, 28 Mar 2011 12:48:33 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 918798FC0A; Mon, 28 Mar 2011 12:48:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SCmXf8094858; Mon, 28 Mar 2011 12:48:33 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SCmX2m094854; Mon, 28 Mar 2011 12:48:33 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103281248.p2SCmX2m094854@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 28 Mar 2011 12:48:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220100 - in head/sys: dev/ksyms kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 12:48:33 -0000 Author: kib Date: Mon Mar 28 12:48:33 2011 New Revision: 220100 URL: http://svn.freebsd.org/changeset/base/220100 Log: Promote ksyms_map() and ksyms_unmap() to general facility copyout_map() and copyout_unmap() interfaces. Submitted by: John Wehle , nox MFC after: 2 weeks Modified: head/sys/dev/ksyms/ksyms.c head/sys/kern/subr_uio.c head/sys/sys/uio.h Modified: head/sys/dev/ksyms/ksyms.c ============================================================================== --- head/sys/dev/ksyms/ksyms.c Mon Mar 28 12:39:48 2011 (r220099) +++ head/sys/dev/ksyms/ksyms.c Mon Mar 28 12:48:33 2011 (r220100) @@ -360,53 +360,6 @@ ksyms_snapshot(struct tsizes *ts, vm_off return (error); } -/* - * Map some anonymous memory in user space of size sz, rounded up to the page - * boundary. - */ -static int -ksyms_map(struct thread *td, vm_offset_t *addr, size_t sz) -{ - struct vmspace *vms = td->td_proc->p_vmspace; - int error; - vm_size_t size; - - - /* - * Map somewhere after heap in process memory. - */ - PROC_LOCK(td->td_proc); - *addr = round_page((vm_offset_t)vms->vm_daddr + - lim_max(td->td_proc, RLIMIT_DATA)); - PROC_UNLOCK(td->td_proc); - - /* round size up to page boundry */ - size = (vm_size_t) round_page(sz); - - error = vm_mmap(&vms->vm_map, addr, size, PROT_READ | PROT_WRITE, - VM_PROT_ALL, MAP_PRIVATE | MAP_ANON, OBJT_DEFAULT, NULL, 0); - - return (error); -} - -/* - * Unmap memory in user space. - */ -static int -ksyms_unmap(struct thread *td, vm_offset_t addr, size_t sz) -{ - vm_map_t map; - vm_size_t size; - - map = &td->td_proc->p_vmspace->vm_map; - size = (vm_size_t) round_page(sz); - - if (!vm_map_remove(map, addr, addr + size)) - return (EINVAL); - - return (0); -} - static void ksyms_cdevpriv_dtr(void *data) { @@ -475,7 +428,7 @@ ksyms_open(struct cdev *dev, int flags, total_elf_sz = sizeof(struct ksyms_hdr) + ts.ts_symsz + ts.ts_strsz; - error = ksyms_map(td, &(sc->sc_uaddr), + error = copyout_map(td, &(sc->sc_uaddr), (vm_size_t) total_elf_sz); if (error) break; @@ -488,7 +441,7 @@ ksyms_open(struct cdev *dev, int flags, } /* Snapshot failed, unmap the memory and try again */ - (void) ksyms_unmap(td, sc->sc_uaddr, sc->sc_usize); + (void) copyout_unmap(td, sc->sc_uaddr, sc->sc_usize); } failed: @@ -624,7 +577,7 @@ ksyms_close(struct cdev *dev, int flags return (error); /* Unmap the buffer from the process address space. */ - error = ksyms_unmap(td, sc->sc_uaddr, sc->sc_usize); + error = copyout_unmap(td, sc->sc_uaddr, sc->sc_usize); devfs_clear_cdevpriv(); Modified: head/sys/kern/subr_uio.c ============================================================================== --- head/sys/kern/subr_uio.c Mon Mar 28 12:39:48 2011 (r220099) +++ head/sys/kern/subr_uio.c Mon Mar 28 12:48:33 2011 (r220100) @@ -44,13 +44,16 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include #include #include #include #include +#include #include #include #ifdef ZERO_COPY_SOCKETS @@ -457,3 +460,49 @@ cloneuio(struct uio *uiop) bcopy(uiop->uio_iov, uio->uio_iov, iovlen); return (uio); } + +/* + * Map some anonymous memory in user space of size sz, rounded up to the page + * boundary. + */ +int +copyout_map(struct thread *td, vm_offset_t *addr, size_t sz) +{ + struct vmspace *vms = td->td_proc->p_vmspace; + int error; + vm_size_t size; + + /* + * Map somewhere after heap in process memory. + */ + PROC_LOCK(td->td_proc); + *addr = round_page((vm_offset_t)vms->vm_daddr + + lim_max(td->td_proc, RLIMIT_DATA)); + PROC_UNLOCK(td->td_proc); + + /* round size up to page boundry */ + size = (vm_size_t) round_page(sz); + + error = vm_mmap(&vms->vm_map, addr, size, PROT_READ | PROT_WRITE, + VM_PROT_ALL, MAP_PRIVATE | MAP_ANON, OBJT_DEFAULT, NULL, 0); + + return (error); +} + +/* + * Unmap memory in user space. + */ +int +copyout_unmap(struct thread *td, vm_offset_t addr, size_t sz) +{ + vm_map_t map; + vm_size_t size; + + map = &td->td_proc->p_vmspace->vm_map; + size = (vm_size_t) round_page(sz); + + if (!vm_map_remove(map, addr, addr + size)) + return (EINVAL); + + return (0); +} Modified: head/sys/sys/uio.h ============================================================================== --- head/sys/sys/uio.h Mon Mar 28 12:39:48 2011 (r220099) +++ head/sys/sys/uio.h Mon Mar 28 12:48:33 2011 (r220100) @@ -94,6 +94,8 @@ int copyiniov(struct iovec *iovp, u_int int copyinstrfrom(const void * __restrict src, void * __restrict dst, size_t len, size_t * __restrict copied, int seg); int copyinuio(struct iovec *iovp, u_int iovcnt, struct uio **uiop); +int copyout_map(struct thread *td, vm_offset_t *addr, size_t sz); +int copyout_unmap(struct thread *td, vm_offset_t addr, size_t sz); int uiomove(void *cp, int n, struct uio *uio); int uiomove_frombuf(void *buf, int buflen, struct uio *uio); int uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, int n, From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 13:21:26 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C7C37106564A; Mon, 28 Mar 2011 13:21:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B34128FC16; Mon, 28 Mar 2011 13:21:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SDLQwN095548; Mon, 28 Mar 2011 13:21:26 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SDLQSt095546; Mon, 28 Mar 2011 13:21:26 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103281321.p2SDLQSt095546@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 28 Mar 2011 13:21:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220101 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 13:21:26 -0000 Author: kib Date: Mon Mar 28 13:21:26 2011 New Revision: 220101 URL: http://svn.freebsd.org/changeset/base/220101 Log: Handle zero length in copyout_unmap(). Submitted by: John Wehle MFC after: 2 weeks Modified: head/sys/kern/subr_uio.c Modified: head/sys/kern/subr_uio.c ============================================================================== --- head/sys/kern/subr_uio.c Mon Mar 28 12:48:33 2011 (r220100) +++ head/sys/kern/subr_uio.c Mon Mar 28 13:21:26 2011 (r220101) @@ -498,6 +498,9 @@ copyout_unmap(struct thread *td, vm_offs vm_map_t map; vm_size_t size; + if (sz == 0) + return (0); + map = &td->td_proc->p_vmspace->vm_map; size = (vm_size_t) round_page(sz); From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 13:28:23 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 60462106566C; Mon, 28 Mar 2011 13:28:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4B3BA8FC0A; Mon, 28 Mar 2011 13:28:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SDSNLe095738; Mon, 28 Mar 2011 13:28:23 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SDSNdC095736; Mon, 28 Mar 2011 13:28:23 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103281328.p2SDSNdC095736@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 28 Mar 2011 13:28:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220102 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 13:28:23 -0000 Author: kib Date: Mon Mar 28 13:28:23 2011 New Revision: 220102 URL: http://svn.freebsd.org/changeset/base/220102 Log: Trim white spaces, adjust style. MFC after: 2 weeks Modified: head/sys/kern/subr_uio.c Modified: head/sys/kern/subr_uio.c ============================================================================== --- head/sys/kern/subr_uio.c Mon Mar 28 13:21:26 2011 (r220101) +++ head/sys/kern/subr_uio.c Mon Mar 28 13:28:23 2011 (r220102) @@ -468,24 +468,26 @@ cloneuio(struct uio *uiop) int copyout_map(struct thread *td, vm_offset_t *addr, size_t sz) { - struct vmspace *vms = td->td_proc->p_vmspace; + struct vmspace *vms; int error; vm_size_t size; - - /* + + vms = td->td_proc->p_vmspace; + + /* * Map somewhere after heap in process memory. */ PROC_LOCK(td->td_proc); - *addr = round_page((vm_offset_t)vms->vm_daddr + + *addr = round_page((vm_offset_t)vms->vm_daddr + lim_max(td->td_proc, RLIMIT_DATA)); PROC_UNLOCK(td->td_proc); /* round size up to page boundry */ - size = (vm_size_t) round_page(sz); - - error = vm_mmap(&vms->vm_map, addr, size, PROT_READ | PROT_WRITE, + size = (vm_size_t)round_page(sz); + + error = vm_mmap(&vms->vm_map, addr, size, PROT_READ | PROT_WRITE, VM_PROT_ALL, MAP_PRIVATE | MAP_ANON, OBJT_DEFAULT, NULL, 0); - + return (error); } @@ -497,12 +499,12 @@ copyout_unmap(struct thread *td, vm_offs { vm_map_t map; vm_size_t size; - + if (sz == 0) return (0); map = &td->td_proc->p_vmspace->vm_map; - size = (vm_size_t) round_page(sz); + size = (vm_size_t)round_page(sz); if (!vm_map_remove(map, addr, addr + size)) return (EINVAL); From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 16:58:48 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B5A251065676; Mon, 28 Mar 2011 16:58:48 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A68858FC13; Mon, 28 Mar 2011 16:58:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SGwmJR000487; Mon, 28 Mar 2011 16:58:48 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SGwmOv000485; Mon, 28 Mar 2011 16:58:48 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103281658.p2SGwmOv000485@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 28 Mar 2011 16:58:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220103 - head/sys/dev/fxp X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 16:58:48 -0000 Author: yongari Date: Mon Mar 28 16:58:48 2011 New Revision: 220103 URL: http://svn.freebsd.org/changeset/base/220103 Log: Normally fxp(4) does not receive bad frames but promiscuous mode makes controller to receive bad frames and i82557 will also receive bad frames since fxp(4) have to receive VLAN oversized frames. If fxp(4) encounter DMA overrun error, the received frame size would be 0 so the actual frame size after checksum field extraction the length would be negative(-2). Due to signed/unsigned comparison used in driver, frame length check did not work for DMA overrun frames. Correct this by casting it to int. While I'm here explicitly check DMA overrun error and discard the frame regardless of result of received frame length check. Reported by: n_hibma Tested by: n_hibma MFC after: 1 week Modified: head/sys/dev/fxp/if_fxp.c Modified: head/sys/dev/fxp/if_fxp.c ============================================================================== --- head/sys/dev/fxp/if_fxp.c Mon Mar 28 13:28:23 2011 (r220102) +++ head/sys/dev/fxp/if_fxp.c Mon Mar 28 16:58:48 2011 (r220103) @@ -1941,11 +1941,11 @@ fxp_intr_body(struct fxp_softc *sc, stru /* Adjust for appended checksum bytes. */ total_len -= 2; } - if (total_len < sizeof(struct ether_header) || + if (total_len < (int)sizeof(struct ether_header) || total_len > (MCLBYTES - RFA_ALIGNMENT_FUDGE - sc->rfa_size) || status & (FXP_RFA_STATUS_CRC | - FXP_RFA_STATUS_ALIGN)) { + FXP_RFA_STATUS_ALIGN | FXP_RFA_STATUS_OVERRUN)) { m_freem(m); fxp_add_rfabuf(sc, rxp); continue; From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 17:41:10 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7BC501065677; Mon, 28 Mar 2011 17:41:10 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 683098FC1A; Mon, 28 Mar 2011 17:41:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SHfAR3001563; Mon, 28 Mar 2011 17:41:10 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SHfAFu001547; Mon, 28 Mar 2011 17:41:10 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103281741.p2SHfAFu001547@svn.freebsd.org> From: Mikolaj Golub Date: Mon, 28 Mar 2011 17:41:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220104 - in stable/8: etc etc/mail etc/rc.d sbin/hastctl sbin/hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 17:41:10 -0000 Author: trociny Date: Mon Mar 28 17:41:10 2011 New Revision: 220104 URL: http://svn.freebsd.org/changeset/base/220104 Log: MFC r217729, r217730, r217731, r217732, r217737, r217784, r217958, r217961, r217962, r217964, r217965, r217966, r217967, r217969, r218040, r218041, r218042, r218043, r218044, r218045, r218048, r218049, r218119, r218132, r218138, r218139, r218147, r218148, r218158, r218185, r218191, r218192, r218193, r218194, r218201, r218214, r218215, r218217, r218218, r218370, r218373, r218374, r218375, r218376, r218464, r218465, r218474, r219082: r217729 (pjd): - On primary worker reload, update hr_exec field. - Update comment. r217730 (pjd): Use int16 for error. r217731 (pjd): Use more consistent function name with the others (pjdlogv_prefix_set() instead of pjdlog_prefix_setv()). r217732 (pjd): Add nv_assert() which allows to assert that the given name exists. r217737 (pjd): Add missing logs. r217784 (pjd): Don't open configuration file from worker process. Handle SIGHUP in the master process only and pass changes to the worker processes over control socket. This removes access to global namespace in preparation for capsicum sandboxing. r217958 (pjd): Remove __dead2 from pjdlog_verify() prototype, it does return sometimes. r217961 (pjd): - Remove obvious NOTREACHED comment after abort() call. - Remove redundant newline at the end of the file. r217962 (pjd): Add LOG_NDELAY flag to openlog(3) - we want descriptor to be immediately open so there are no surprises once we start chrooting or using capsicum. r217964 (pjd): Use pjd copyright for 2011 work. r217965 (pjd): Add functions to initialize/finalize pjdlog. This allows to open/close log file at will. r217966 (pjd): Extend pjdlog_verify() to support the following additional macros: PJDLOG_RVERIFY() - always check expression and on false log the given message and exit. PJDLOG_RASSERT() - check expression when NDEBUG is not defined and on false log given message and exit. PJDLOG_ABORT() - log the given message and exit. r217967 (pjd): Close the control socket before exiting, so it will be unlinked. r217969 (pjd): Remember created control connection so on fork(2) we can close it in child. r218040 (pjd): Initialize all global variables on pjdlog_init(). r218041 (pjd): Add function to close all unneeded descriptors after fork(2). r218042 (pjd): Add comments to places where we treat errors as ciritical, but it is possible to handle them more gracefully. r218043 (pjd): Close all unneeded descriptors after fork(2). r218044 (pjd): Add function to assert that the only descriptors we have open are the ones we expect to be open. Also assert that they point at expected type. Because openlog(3) API is unable to tell us descriptor number it is using, we have to close syslog socket, remember assert message in local buffer and if we fail on assertion, reopen syslog socket and log the message. r218045 (pjd): Use newly added descriptors_assert() function to ensure only expected descriptors are open. r218046 (pjd), r218047 (pjd), r218119 (maxim): Add 'hast' user and 'hast' group that will be used by hastd (and maybe hastctl) to drop privileges. r218048 (pjd): Implement function that drops privileges by: - chrooting to /var/empty (user hast home directory), - setting groups to 'hast' (user hast primary group), - setting real group id, effective group id and saved group id to 'hast', - setting real user id, effective user id and saved user id to 'hast'. At the end verify that those operations where successfull. r218049 (pjd): Drop privileges in worker processes. Accepting connections and handshaking in secondary is still done before dropping privileges. It should be implemented by only accepting connections in privileged main process and passing connection descriptors to the worker, but is not implemented yet. r218132 (pjd): Rename pjdlog_verify() to pjdlog_abort() as it better describes what the the function does and mark it with __dead2. r218138 (pjd): - Use pjdlog for assertions and aborts as this will log assert/abort message to syslog if we run in background. - Asserts in proto.c that method we want to call is implemented and remove dummy methods from protocols implementation that are only there to abort the program with nice message. r218139 (pjd): Implement two new functions for sending descriptor and receving descriptor over UNIX domain sockets and socket pairs. This is in preparation for capsicum. r218147 (pjd), r218148 (pjd): Fix build on ia64. r218158 (pjd): Do not set socket send and receive buffer. It will be auto-tuned. Confirmed by: rwatson r218185 (pjd): Be prepared that hp_client or hp_server might be NULL now. r218191 (pjd): Move protocol allocation and deallocation to separate functions. r218192 (pjd), r218201 (bz): Allow to specify connection timeout by the caller. r218193 (pjd): Add proto_connect_wait() to wait for connection to finish. If timeout argument to proto_connect() is -1, then the caller needs to use this new function to wait for connection. This change is in preparation for capsicum, where sandboxed worker wants to ask main process to connect in worker's behalf and pass descriptor to the worker. Because we don't want the main process to wait for the connection, it will start async connection and pass descriptor to the worker who will be responsible for waiting for the connection to finish. r218194 (pjd): - Rename proto_descriptor_{send,recv}() functions to proto_connection_{send,recv} and change them to return proto_conn structure. We don't operate directly on descriptors, but on proto_conns. - Add wrap method to wrap descriptor with proto_conn. - Remove methods to send and receive descriptors and implement this functionality as additional argument to send and receive methods. r218214 (pjd): Let the caller log info about successful privilege drop. We don't want to log this in hastctl. r218215 (pjd): Drop privileges after connecting to hastd, but before sending or receiving anything. r218217 (pjd): Add missing locking after moving keepalive_send() to remote send thread in r214692. r218218 (pjd): Setup another socketpair between parent and child, so that primary sandboxed worker can ask the main privileged process to connect in worker's behalf and then we can migrate descriptor using this socketpair to worker. This is not really needed now, but will be needed once we start to use capsicum for sandboxing. r218370 (pjd): Close more descriptors that can be open if the worker process for the given resource is already running. Submitted by: Mikolaj Golub r218373 (pjd): Open syslog when logging sysconf(3) failure. Reported by: Mikolaj Golub r218374 (pjd): Treat fstat(2) failure (different than EBADF) as fatal error. Reported by: Mikolaj Golub r218375 (pjd): Add (void) cast before snprintf(3)s for which we are not interested in return values. r218376 (pjd): Now that we break the loop on fstat(2) failure we no longer need to satisfy gcc's imperfections. r218464 (pjd): Unlink UNIX domain socket file only if: 1. The descriptor is the one we are listening on (not the one when we connect as a client and not the one which is created on accept(2)). 2. Descriptor was created by us (PID matches with the PID stored on bind(2)). Reported by: Mikolaj Golub r218465 (pjd): Explicitly include as suggested by getpid(2) and don't rely on including what's needed. r218474 (pjd): When we decide to unlink socket file, sun_path must be set. If it is set, but there is problem unlinking the file, log a warning. r219082 (pjd): Recognize 'reload' command, as hastd can be reloaded with the SIGHUP signal. Approved by: pjd (mentor) Modified: stable/8/etc/ftpusers stable/8/etc/group stable/8/etc/mail/aliases stable/8/etc/master.passwd stable/8/etc/rc.d/hastd stable/8/sbin/hastctl/hastctl.c stable/8/sbin/hastd/control.c stable/8/sbin/hastd/control.h stable/8/sbin/hastd/hast.h stable/8/sbin/hastd/hastd.c stable/8/sbin/hastd/hastd.h stable/8/sbin/hastd/nv.c stable/8/sbin/hastd/nv.h stable/8/sbin/hastd/pjdlog.c stable/8/sbin/hastd/pjdlog.h stable/8/sbin/hastd/primary.c stable/8/sbin/hastd/proto.c stable/8/sbin/hastd/proto.h stable/8/sbin/hastd/proto_common.c stable/8/sbin/hastd/proto_impl.h stable/8/sbin/hastd/proto_socketpair.c stable/8/sbin/hastd/proto_tcp4.c stable/8/sbin/hastd/proto_uds.c stable/8/sbin/hastd/secondary.c stable/8/sbin/hastd/subr.c stable/8/sbin/hastd/subr.h Directory Properties: stable/8/etc/ (props changed) stable/8/sbin/hastctl/ (props changed) stable/8/sbin/hastd/ (props changed) Modified: stable/8/etc/ftpusers ============================================================================== --- stable/8/etc/ftpusers Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/etc/ftpusers Mon Mar 28 17:41:10 2011 (r220104) @@ -20,6 +20,7 @@ _dhcp uucp pop www +hast nobody mailnull smmsp Modified: stable/8/etc/group ============================================================================== --- stable/8/etc/group Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/etc/group Mon Mar 28 17:41:10 2011 (r220104) @@ -27,5 +27,6 @@ dialer:*:68: network:*:69: audit:*:77: www:*:80: +hast:*:845: nogroup:*:65533: nobody:*:65534: Modified: stable/8/etc/mail/aliases ============================================================================== --- stable/8/etc/mail/aliases Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/etc/mail/aliases Mon Mar 28 17:41:10 2011 (r220104) @@ -30,6 +30,7 @@ bin: root bind: root daemon: root games: root +hast: root kmem: root mailnull: postmaster man: root Modified: stable/8/etc/master.passwd ============================================================================== --- stable/8/etc/master.passwd Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/etc/master.passwd Mon Mar 28 17:41:10 2011 (r220104) @@ -20,4 +20,5 @@ _dhcp:*:65:65::0:0:dhcp programs:/var/em uucp:*:66:66::0:0:UUCP pseudo-user:/var/spool/uucppublic:/usr/local/libexec/uucp/uucico pop:*:68:6::0:0:Post Office Owner:/nonexistent:/usr/sbin/nologin www:*:80:80::0:0:World Wide Web Owner:/nonexistent:/usr/sbin/nologin +hast:*:845:845::0:0:HAST unprivileged user:/var/empty:/usr/sbin/nologin nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/usr/sbin/nologin Modified: stable/8/etc/rc.d/hastd ============================================================================== --- stable/8/etc/rc.d/hastd Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/etc/rc.d/hastd Mon Mar 28 17:41:10 2011 (r220104) @@ -18,6 +18,7 @@ hastctl="/sbin/hastctl" required_files="/etc/hast.conf" stop_precmd="hastd_stop_precmd" required_modules="geom_gate:g_gate" +extra_commands="reload" hastd_stop_precmd() { Modified: stable/8/sbin/hastctl/hastctl.c ============================================================================== --- stable/8/sbin/hastctl/hastctl.c Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastctl/hastctl.c Mon Mar 28 17:41:10 2011 (r220104) @@ -430,6 +430,7 @@ main(int argc, char *argv[]) break; } + pjdlog_init(PJDLOG_MODE_STD); pjdlog_debug_set(debug); cfg = yy_config_parse(cfgpath, true); @@ -486,10 +487,15 @@ main(int argc, char *argv[]) cfg->hc_controladdr); } /* ...and connect to hastd. */ - if (proto_connect(controlconn) < 0) { + if (proto_connect(controlconn, HAST_TIMEOUT) < 0) { pjdlog_exit(EX_OSERR, "Unable to connect to hastd via %s", cfg->hc_controladdr); } + + if (drop_privs() != 0) + exit(EX_CONFIG); + pjdlog_debug(1, "Privileges successfully dropped."); + /* Send the command to the server... */ if (hast_proto_send(NULL, controlconn, nv, NULL, 0) < 0) { pjdlog_exit(EX_UNAVAILABLE, Modified: stable/8/sbin/hastd/control.c ============================================================================== --- stable/8/sbin/hastd/control.c Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/control.c Mon Mar 28 17:41:10 2011 (r220104) @@ -62,6 +62,10 @@ child_cleanup(struct hast_resource *res) proto_close(res->hr_event); res->hr_event = NULL; } + if (res->hr_conn != NULL) { + proto_close(res->hr_conn); + res->hr_conn = NULL; + } res->hr_workerpid = 0; } @@ -159,12 +163,13 @@ control_status_worker(struct hast_resour nv_add_uint8(cnvout, HASTCTL_STATUS, "cmd"); error = nv_error(cnvout); if (error != 0) { - /* LOG */ + pjdlog_common(LOG_ERR, 0, error, + "Unable to prepare control header"); goto end; } if (hast_proto_send(res, res->hr_ctrl, cnvout, NULL, 0) < 0) { error = errno; - /* LOG */ + pjdlog_errno(LOG_ERR, "Unable to send control header"); goto end; } @@ -173,17 +178,17 @@ control_status_worker(struct hast_resour */ if (hast_proto_recv_hdr(res->hr_ctrl, &cnvin) < 0) { error = errno; - /* LOG */ + pjdlog_errno(LOG_ERR, "Unable to receive control header"); goto end; } - error = nv_get_int64(cnvin, "error"); + error = nv_get_int16(cnvin, "error"); if (error != 0) goto end; if ((str = nv_get_string(cnvin, "status")) == NULL) { error = ENOENT; - /* LOG */ + pjdlog_errno(LOG_ERR, "Field 'status' is missing."); goto end; } nv_add_string(nvout, str, "status%u", no); @@ -277,6 +282,7 @@ control_handle(struct hastd_config *cfg) return; } + cfg->hc_controlin = conn; nvin = nvout = NULL; role = HAST_ROLE_UNDEF; @@ -383,6 +389,7 @@ close: if (nvout != NULL) nv_free(nvout); proto_close(conn); + cfg->hc_controlin = NULL; } /* @@ -410,7 +417,6 @@ ctrl_thread(void *arg) nv_free(nvin); continue; } - nv_free(nvin); nvout = nv_alloc(); switch (cmd) { case HASTCTL_STATUS: @@ -432,11 +438,23 @@ ctrl_thread(void *arg) nv_add_uint32(nvout, (uint32_t)0, "keepdirty"); nv_add_uint64(nvout, (uint64_t)0, "dirty"); } + nv_add_int16(nvout, 0, "error"); + break; + case HASTCTL_RELOAD: + /* + * When parent receives SIGHUP and discovers that + * something related to us has changes, it sends reload + * message to us. + */ + assert(res->hr_role == HAST_ROLE_PRIMARY); + primary_config_reload(res, nvin); + nv_add_int16(nvout, 0, "error"); break; default: nv_add_int16(nvout, EINVAL, "error"); break; } + nv_free(nvin); if (nv_error(nvout) != 0) { pjdlog_error("Unable to create answer on control message."); nv_free(nvout); Modified: stable/8/sbin/hastd/control.h ============================================================================== --- stable/8/sbin/hastd/control.h Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/control.h Mon Mar 28 17:41:10 2011 (r220104) @@ -34,6 +34,7 @@ #define HASTCTL_SET_ROLE 1 #define HASTCTL_STATUS 2 +#define HASTCTL_RELOAD 3 struct hastd_config; struct hast_resource; Modified: stable/8/sbin/hastd/hast.h ============================================================================== --- stable/8/sbin/hastd/hast.h Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/hast.h Mon Mar 28 17:41:10 2011 (r220104) @@ -81,6 +81,7 @@ #define HIO_FLUSH 4 #define HIO_KEEPALIVE 5 +#define HAST_USER "hast" #define HAST_TIMEOUT 5 #define HAST_CONFIG "/etc/hast.conf" #define HAST_CONTROL "/var/run/hastctl" @@ -101,6 +102,8 @@ struct hastd_config { char hc_controladdr[HAST_ADDRSIZE]; /* Protocol-specific data. */ struct proto_conn *hc_controlconn; + /* Incoming control connection. */ + struct proto_conn *hc_controlin; /* Address to listen on. */ char hc_listenaddr[HAST_ADDRSIZE]; /* Protocol-specific data. */ @@ -179,10 +182,12 @@ struct hast_resource { int hr_previous_role; /* PID of child worker process. 0 - no child. */ pid_t hr_workerpid; - /* Control connection between parent and child. */ + /* Control commands from parent to child. */ struct proto_conn *hr_ctrl; /* Events from child to parent. */ struct proto_conn *hr_event; + /* Connection requests from child to parent. */ + struct proto_conn *hr_conn; /* Activemap structure. */ struct activemap *hr_amp; Modified: stable/8/sbin/hastd/hastd.c ============================================================================== --- stable/8/sbin/hastd/hastd.c Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/hastd.c Mon Mar 28 17:41:10 2011 (r220104) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2009-2010 The FreeBSD Foundation - * Copyright (c) 2010 Pawel Jakub Dawidek + * Copyright (c) 2010-2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -34,9 +34,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include -#include #include #include #include @@ -93,6 +93,194 @@ g_gate_load(void) } } +void +descriptors_cleanup(struct hast_resource *res) +{ + struct hast_resource *tres; + + TAILQ_FOREACH(tres, &cfg->hc_resources, hr_next) { + if (tres == res) { + PJDLOG_VERIFY(res->hr_role == HAST_ROLE_SECONDARY || + (res->hr_remotein == NULL && + res->hr_remoteout == NULL)); + continue; + } + if (tres->hr_remotein != NULL) + proto_close(tres->hr_remotein); + if (tres->hr_remoteout != NULL) + proto_close(tres->hr_remoteout); + if (tres->hr_ctrl != NULL) + proto_close(tres->hr_ctrl); + if (tres->hr_event != NULL) + proto_close(tres->hr_event); + if (tres->hr_conn != NULL) + proto_close(tres->hr_conn); + } + if (cfg->hc_controlin != NULL) + proto_close(cfg->hc_controlin); + proto_close(cfg->hc_controlconn); + proto_close(cfg->hc_listenconn); + (void)pidfile_close(pfh); + hook_fini(); + pjdlog_fini(); +} + +static const char * +dtype2str(mode_t mode) +{ + + if (S_ISBLK(mode)) + return ("block device"); + else if (S_ISCHR(mode)) + return ("character device"); + else if (S_ISDIR(mode)) + return ("directory"); + else if (S_ISFIFO(mode)) + return ("pipe or FIFO"); + else if (S_ISLNK(mode)) + return ("symbolic link"); + else if (S_ISREG(mode)) + return ("regular file"); + else if (S_ISSOCK(mode)) + return ("socket"); + else if (S_ISWHT(mode)) + return ("whiteout"); + else + return ("unknown"); +} + +void +descriptors_assert(const struct hast_resource *res, int pjdlogmode) +{ + char msg[256]; + struct stat sb; + long maxfd; + bool isopen; + mode_t mode; + int fd; + + /* + * At this point descriptor to syslog socket is closed, so if we want + * to log assertion message, we have to first store it in 'msg' local + * buffer and then open syslog socket and log it. + */ + msg[0] = '\0'; + + maxfd = sysconf(_SC_OPEN_MAX); + if (maxfd < 0) { + pjdlog_init(pjdlogmode); + pjdlog_prefix_set("[%s] (%s) ", res->hr_name, + role2str(res->hr_role)); + pjdlog_errno(LOG_WARNING, "sysconf(_SC_OPEN_MAX) failed"); + pjdlog_fini(); + maxfd = 16384; + } + for (fd = 0; fd <= maxfd; fd++) { + if (fstat(fd, &sb) == 0) { + isopen = true; + mode = sb.st_mode; + } else if (errno == EBADF) { + isopen = false; + mode = 0; + } else { + (void)snprintf(msg, sizeof(msg), + "Unable to fstat descriptor %d: %s", fd, + strerror(errno)); + break; + } + if (fd == STDIN_FILENO || fd == STDOUT_FILENO || + fd == STDERR_FILENO) { + if (!isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (%s) is closed, but should be open.", + fd, (fd == STDIN_FILENO ? "stdin" : + (fd == STDOUT_FILENO ? "stdout" : "stderr"))); + break; + } + } else if (fd == proto_descriptor(res->hr_event)) { + if (!isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (event) is closed, but should be open.", + fd); + break; + } + if (!S_ISSOCK(mode)) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (event) is %s, but should be %s.", + fd, dtype2str(mode), dtype2str(S_IFSOCK)); + break; + } + } else if (fd == proto_descriptor(res->hr_ctrl)) { + if (!isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (ctrl) is closed, but should be open.", + fd); + break; + } + if (!S_ISSOCK(mode)) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (ctrl) is %s, but should be %s.", + fd, dtype2str(mode), dtype2str(S_IFSOCK)); + break; + } + } else if (fd == proto_descriptor(res->hr_conn)) { + if (!isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (conn) is closed, but should be open.", + fd); + break; + } + if (!S_ISSOCK(mode)) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (conn) is %s, but should be %s.", + fd, dtype2str(mode), dtype2str(S_IFSOCK)); + break; + } + } else if (res->hr_role == HAST_ROLE_SECONDARY && + fd == proto_descriptor(res->hr_remotein)) { + if (!isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (remote in) is closed, but should be open.", + fd); + break; + } + if (!S_ISSOCK(mode)) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (remote in) is %s, but should be %s.", + fd, dtype2str(mode), dtype2str(S_IFSOCK)); + break; + } + } else if (res->hr_role == HAST_ROLE_SECONDARY && + fd == proto_descriptor(res->hr_remoteout)) { + if (!isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (remote out) is closed, but should be open.", + fd); + break; + } + if (!S_ISSOCK(mode)) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (remote out) is %s, but should be %s.", + fd, dtype2str(mode), dtype2str(S_IFSOCK)); + break; + } + } else { + if (isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d is open (%s), but should be closed.", + fd, dtype2str(mode)); + break; + } + } + } + if (msg[0] != '\0') { + pjdlog_init(pjdlogmode); + pjdlog_prefix_set("[%s] (%s) ", res->hr_name, + role2str(res->hr_role)); + PJDLOG_ABORT("%s", msg); + } +} + static void child_exit_log(unsigned int pid, int status) { @@ -161,7 +349,7 @@ resource_needs_restart(const struct hast const struct hast_resource *res1) { - assert(strcmp(res0->hr_name, res1->hr_name) == 0); + PJDLOG_ASSERT(strcmp(res0->hr_name, res1->hr_name) == 0); if (strcmp(res0->hr_provname, res1->hr_provname) != 0) return (true); @@ -186,9 +374,9 @@ resource_needs_reload(const struct hast_ const struct hast_resource *res1) { - assert(strcmp(res0->hr_name, res1->hr_name) == 0); - assert(strcmp(res0->hr_provname, res1->hr_provname) == 0); - assert(strcmp(res0->hr_localpath, res1->hr_localpath) == 0); + PJDLOG_ASSERT(strcmp(res0->hr_name, res1->hr_name) == 0); + PJDLOG_ASSERT(strcmp(res0->hr_provname, res1->hr_provname) == 0); + PJDLOG_ASSERT(strcmp(res0->hr_localpath, res1->hr_localpath) == 0); if (res0->hr_role != HAST_ROLE_PRIMARY) return (false); @@ -205,6 +393,45 @@ resource_needs_reload(const struct hast_ } static void +resource_reload(const struct hast_resource *res) +{ + struct nv *nvin, *nvout; + int error; + + PJDLOG_ASSERT(res->hr_role == HAST_ROLE_PRIMARY); + + nvout = nv_alloc(); + nv_add_uint8(nvout, HASTCTL_RELOAD, "cmd"); + nv_add_string(nvout, res->hr_remoteaddr, "remoteaddr"); + nv_add_int32(nvout, (int32_t)res->hr_replication, "replication"); + nv_add_int32(nvout, (int32_t)res->hr_timeout, "timeout"); + nv_add_string(nvout, res->hr_exec, "exec"); + if (nv_error(nvout) != 0) { + nv_free(nvout); + pjdlog_error("Unable to allocate header for reload message."); + return; + } + if (hast_proto_send(res, res->hr_ctrl, nvout, NULL, 0) < 0) { + pjdlog_errno(LOG_ERR, "Unable to send reload message"); + nv_free(nvout); + return; + } + nv_free(nvout); + + /* Receive response. */ + if (hast_proto_recv_hdr(res->hr_ctrl, &nvin) < 0) { + pjdlog_errno(LOG_ERR, "Unable to receive reload reply"); + return; + } + error = nv_get_int16(nvin, "error"); + nv_free(nvin); + if (error != 0) { + pjdlog_common(LOG_ERR, 0, error, "Reload failed"); + return; + } +} + +static void hastd_reload(void) { struct hastd_config *newcfg; @@ -306,8 +533,9 @@ hastd_reload(void) * recreating it. * * We do just reload (send SIGHUP to worker process) if we act as - * PRIMARY, but only remote address, replication mode and timeout - * has changed. For those, there is no need to restart worker process. + * PRIMARY, but only if remote address, replication mode, timeout or + * execution path has changed. For those, there is no need to restart + * worker process. * If PRIMARY receives SIGHUP, it will reconnect if remote address or * replication mode has changed or simply set new timeout if only * timeout has changed. @@ -317,7 +545,7 @@ hastd_reload(void) if (strcmp(cres->hr_name, nres->hr_name) == 0) break; } - assert(cres != NULL); + PJDLOG_ASSERT(cres != NULL); if (resource_needs_restart(cres, nres)) { pjdlog_info("Resource %s configuration was modified, restarting it.", cres->hr_name); @@ -335,13 +563,10 @@ hastd_reload(void) sizeof(cres->hr_remoteaddr)); cres->hr_replication = nres->hr_replication; cres->hr_timeout = nres->hr_timeout; - if (cres->hr_workerpid != 0) { - if (kill(cres->hr_workerpid, SIGHUP) < 0) { - pjdlog_errno(LOG_WARNING, - "Unable to send SIGHUP to worker process %u", - (unsigned int)cres->hr_workerpid); - } - } + strlcpy(cres->hr_exec, nres->hr_exec, + sizeof(cres->hr_exec)); + if (cres->hr_workerpid != 0) + resource_reload(cres); } } @@ -496,10 +721,10 @@ listen_accept(void) * we have to cancel those and accept the new connection. */ if (token == NULL) { - assert(res->hr_remoteout == NULL); + PJDLOG_ASSERT(res->hr_remoteout == NULL); pjdlog_debug(1, "Initial connection from %s.", raddr); if (res->hr_workerpid != 0) { - assert(res->hr_remotein == NULL); + PJDLOG_ASSERT(res->hr_remotein == NULL); pjdlog_debug(1, "Worker process exists (pid=%u), stopping it.", (unsigned int)res->hr_workerpid); @@ -599,6 +824,41 @@ close: } static void +connection_migrate(struct hast_resource *res) +{ + struct proto_conn *conn; + int16_t val = 0; + + if (proto_recv(res->hr_conn, &val, sizeof(val)) < 0) { + pjdlog_errno(LOG_WARNING, + "Unable to receive connection command"); + return; + } + if (proto_client(res->hr_remoteaddr, &conn) < 0) { + val = errno; + pjdlog_errno(LOG_WARNING, + "Unable to create outgoing connection to %s", + res->hr_remoteaddr); + goto out; + } + if (proto_connect(conn, -1) < 0) { + val = errno; + pjdlog_errno(LOG_WARNING, "Unable to connect to %s", + res->hr_remoteaddr); + proto_close(conn); + goto out; + } + val = 0; +out: + if (proto_send(res->hr_conn, &val, sizeof(val)) < 0) { + pjdlog_errno(LOG_WARNING, + "Unable to send reply to connection request"); + } + if (val == 0 && proto_connection_send(res->hr_conn, conn) < 0) + pjdlog_errno(LOG_WARNING, "Unable to send connection"); +} + +static void main_loop(void) { struct hast_resource *res; @@ -629,6 +889,7 @@ main_loop(void) case SIGTERM: sigexit_received = true; terminate_workers(); + proto_close(cfg->hc_controlconn); exit(EX_OK); break; case SIGCHLD: @@ -638,29 +899,37 @@ main_loop(void) hastd_reload(); break; default: - assert(!"invalid condition"); + PJDLOG_ABORT("Unexpected signal (%d).", signo); } } /* Setup descriptors for select(2). */ FD_ZERO(&rfds); maxfd = fd = proto_descriptor(cfg->hc_controlconn); - assert(fd >= 0); + PJDLOG_ASSERT(fd >= 0); FD_SET(fd, &rfds); fd = proto_descriptor(cfg->hc_listenconn); - assert(fd >= 0); + PJDLOG_ASSERT(fd >= 0); FD_SET(fd, &rfds); maxfd = fd > maxfd ? fd : maxfd; TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { if (res->hr_event == NULL) continue; + PJDLOG_ASSERT(res->hr_conn != NULL); fd = proto_descriptor(res->hr_event); - assert(fd >= 0); + PJDLOG_ASSERT(fd >= 0); FD_SET(fd, &rfds); maxfd = fd > maxfd ? fd : maxfd; + if (res->hr_role == HAST_ROLE_PRIMARY) { + /* Only primary workers asks for connections. */ + fd = proto_descriptor(res->hr_conn); + PJDLOG_ASSERT(fd >= 0); + FD_SET(fd, &rfds); + maxfd = fd > maxfd ? fd : maxfd; + } } - assert(maxfd + 1 <= (int)FD_SETSIZE); + PJDLOG_ASSERT(maxfd + 1 <= (int)FD_SETSIZE); ret = select(maxfd + 1, &rfds, NULL, NULL, &seltimeout); if (ret == 0) hook_check(); @@ -678,12 +947,20 @@ main_loop(void) TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { if (res->hr_event == NULL) continue; + PJDLOG_ASSERT(res->hr_conn != NULL); if (FD_ISSET(proto_descriptor(res->hr_event), &rfds)) { if (event_recv(res) == 0) continue; /* The worker process exited? */ proto_close(res->hr_event); res->hr_event = NULL; + proto_close(res->hr_conn); + res->hr_conn = NULL; + continue; + } + if (res->hr_role == HAST_ROLE_PRIMARY && + FD_ISSET(proto_descriptor(res->hr_conn), &rfds)) { + connection_migrate(res); } } } @@ -735,6 +1012,7 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; + pjdlog_init(PJDLOG_MODE_STD); pjdlog_debug_set(debuglevel); g_gate_load(); @@ -751,7 +1029,7 @@ main(int argc, char *argv[]) } cfg = yy_config_parse(cfgpath, true); - assert(cfg != NULL); + PJDLOG_ASSERT(cfg != NULL); /* * Restore default actions for interesting signals in case parent Modified: stable/8/sbin/hastd/hastd.h ============================================================================== --- stable/8/sbin/hastd/hastd.h Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/hastd.h Mon Mar 28 17:41:10 2011 (r220104) @@ -43,7 +43,12 @@ extern const char *cfgpath; extern bool sigexit_received; extern struct pidfh *pfh; +void descriptors_cleanup(struct hast_resource *res); +void descriptors_assert(const struct hast_resource *res, int pjdlogmode); + void hastd_primary(struct hast_resource *res); void hastd_secondary(struct hast_resource *res, struct nv *nvin); +void primary_config_reload(struct hast_resource *res, struct nv *nv); + #endif /* !_HASTD_H_ */ Modified: stable/8/sbin/hastd/nv.c ============================================================================== --- stable/8/sbin/hastd/nv.c Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/nv.c Mon Mar 28 17:41:10 2011 (r220104) @@ -563,11 +563,10 @@ nv_get_string(struct nv *nv, const char return (str); } -bool -nv_exists(struct nv *nv, const char *namefmt, ...) +static bool +nv_vexists(struct nv *nv, const char *namefmt, va_list nameap) { struct nvhdr *nvh; - va_list nameap; int snverror, serrno; if (nv == NULL) @@ -576,9 +575,7 @@ nv_exists(struct nv *nv, const char *nam serrno = errno; snverror = nv->nv_error; - va_start(nameap, namefmt); nvh = nv_find(nv, NV_TYPE_NONE, namefmt, nameap); - va_end(nameap); errno = serrno; nv->nv_error = snverror; @@ -586,6 +583,29 @@ nv_exists(struct nv *nv, const char *nam return (nvh != NULL); } +bool +nv_exists(struct nv *nv, const char *namefmt, ...) +{ + va_list nameap; + bool ret; + + va_start(nameap, namefmt); + ret = nv_vexists(nv, namefmt, nameap); + va_end(nameap); + + return (ret); +} + +void +nv_assert(struct nv *nv, const char *namefmt, ...) +{ + va_list nameap; + + va_start(nameap, namefmt); + assert(nv_vexists(nv, namefmt, nameap)); + va_end(nameap); +} + /* * Dump content of the nv structure. */ Modified: stable/8/sbin/hastd/nv.h ============================================================================== --- stable/8/sbin/hastd/nv.h Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/nv.h Mon Mar 28 17:41:10 2011 (r220104) @@ -127,6 +127,7 @@ const char *nv_get_string(struct nv *nv, __printflike(2, 3); bool nv_exists(struct nv *nv, const char *namefmt, ...) __printflike(2, 3); +void nv_assert(struct nv *nv, const char *namefmt, ...) __printflike(2, 3); void nv_dump(struct nv *nv); #endif /* !_NV_H_ */ Modified: stable/8/sbin/hastd/pjdlog.c ============================================================================== --- stable/8/sbin/hastd/pjdlog.c Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/pjdlog.c Mon Mar 28 17:41:10 2011 (r220104) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2009-2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -33,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -40,10 +42,38 @@ __FBSDID("$FreeBSD$"); #include "pjdlog.h" -static int pjdlog_mode = PJDLOG_MODE_STD; -static int pjdlog_debug_level = 0; +static bool pjdlog_initialized = false; +static int pjdlog_mode, pjdlog_debug_level; static char pjdlog_prefix[128]; +void +pjdlog_init(int mode) +{ + + assert(!pjdlog_initialized); + assert(mode == PJDLOG_MODE_STD || mode == PJDLOG_MODE_SYSLOG); + + if (mode == PJDLOG_MODE_SYSLOG) + openlog(NULL, LOG_PID | LOG_NDELAY, LOG_DAEMON); + pjdlog_mode = mode; + pjdlog_debug_level = 0; + bzero(pjdlog_prefix, sizeof(pjdlog_prefix)); + + pjdlog_initialized = true; +} + +void +pjdlog_fini(void) +{ + + assert(pjdlog_initialized); + + if (pjdlog_mode == PJDLOG_MODE_SYSLOG) + closelog(); + + pjdlog_initialized = false; +} + /* * Configure where the logs should go. * By default they are send to stdout/stderr, but after going into background @@ -54,12 +84,18 @@ void pjdlog_mode_set(int mode) { + assert(pjdlog_initialized); assert(mode == PJDLOG_MODE_STD || mode == PJDLOG_MODE_SYSLOG); - pjdlog_mode = mode; + if (pjdlog_mode == mode) + return; if (mode == PJDLOG_MODE_SYSLOG) - openlog(NULL, LOG_PID, LOG_DAEMON); + openlog(NULL, LOG_PID | LOG_NDELAY, LOG_DAEMON); + else /* if (mode == PJDLOG_MODE_STD) */ + closelog(); + + pjdlog_mode = mode; } /* @@ -69,6 +105,8 @@ int pjdlog_mode_get(void) { + assert(pjdlog_initialized); + return (pjdlog_mode); } @@ -80,6 +118,7 @@ void pjdlog_debug_set(int level) { + assert(pjdlog_initialized); assert(level >= 0); pjdlog_debug_level = level; @@ -92,6 +131,8 @@ int pjdlog_debug_get(void) { + assert(pjdlog_initialized); + return (pjdlog_debug_level); } @@ -104,8 +145,10 @@ pjdlog_prefix_set(const char *fmt, ...) { va_list ap; + assert(pjdlog_initialized); + va_start(ap, fmt); - pjdlog_prefix_setv(fmt, ap); + pjdlogv_prefix_set(fmt, ap); va_end(ap); } @@ -114,9 +157,10 @@ pjdlog_prefix_set(const char *fmt, ...) * Setting prefix to NULL will remove it. */ void -pjdlog_prefix_setv(const char *fmt, va_list ap) +pjdlogv_prefix_set(const char *fmt, va_list ap) { + assert(pjdlog_initialized); assert(fmt != NULL); vsnprintf(pjdlog_prefix, sizeof(pjdlog_prefix), fmt, ap); @@ -159,6 +203,8 @@ pjdlog_common(int loglevel, int debuglev { va_list ap; + assert(pjdlog_initialized); + va_start(ap, fmt); pjdlogv_common(loglevel, debuglevel, error, fmt, ap); va_end(ap); @@ -173,6 +219,7 @@ pjdlogv_common(int loglevel, int debugle va_list ap) { + assert(pjdlog_initialized); assert(loglevel == LOG_EMERG || loglevel == LOG_ALERT || loglevel == LOG_CRIT || loglevel == LOG_ERR || loglevel == LOG_WARNING || loglevel == LOG_NOTICE || @@ -249,6 +296,8 @@ void pjdlogv(int loglevel, const char *fmt, va_list ap) { + assert(pjdlog_initialized); + /* LOG_DEBUG is invalid here, pjdlogv?_debug() should be used. */ assert(loglevel == LOG_EMERG || loglevel == LOG_ALERT || loglevel == LOG_CRIT || loglevel == LOG_ERR || @@ -266,6 +315,8 @@ pjdlog(int loglevel, const char *fmt, .. { va_list ap; + assert(pjdlog_initialized); + va_start(ap, fmt); pjdlogv(loglevel, fmt, ap); va_end(ap); @@ -278,6 +329,8 @@ void pjdlogv_debug(int debuglevel, const char *fmt, va_list ap) { + assert(pjdlog_initialized); + pjdlogv_common(LOG_DEBUG, debuglevel, -1, fmt, ap); } @@ -289,6 +342,8 @@ pjdlog_debug(int debuglevel, const char { va_list ap; + assert(pjdlog_initialized); + va_start(ap, fmt); pjdlogv_debug(debuglevel, fmt, ap); va_end(ap); @@ -301,6 +356,8 @@ void pjdlogv_errno(int loglevel, const char *fmt, va_list ap) { + assert(pjdlog_initialized); + pjdlogv_common(loglevel, 0, errno, fmt, ap); } @@ -312,6 +369,8 @@ pjdlog_errno(int loglevel, const char *f { va_list ap; + assert(pjdlog_initialized); + va_start(ap, fmt); pjdlogv_errno(loglevel, fmt, ap); va_end(ap); @@ -324,6 +383,8 @@ void pjdlogv_exit(int exitcode, const char *fmt, va_list ap) { + assert(pjdlog_initialized); + pjdlogv_errno(LOG_ERR, fmt, ap); exit(exitcode); /* NOTREACHED */ @@ -337,6 +398,8 @@ pjdlog_exit(int exitcode, const char *fm { va_list ap; + assert(pjdlog_initialized); + va_start(ap, fmt); pjdlogv_exit(exitcode, fmt, ap); /* NOTREACHED */ @@ -350,6 +413,8 @@ void pjdlogv_exitx(int exitcode, const char *fmt, va_list ap) { + assert(pjdlog_initialized); + pjdlogv(LOG_ERR, fmt, ap); exit(exitcode); /* NOTREACHED */ @@ -363,6 +428,8 @@ pjdlog_exitx(int exitcode, const char *f { va_list ap; + assert(pjdlog_initialized); + va_start(ap, fmt); pjdlogv_exitx(exitcode, fmt, ap); /* NOTREACHED */ @@ -370,21 +437,42 @@ pjdlog_exitx(int exitcode, const char *f *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 19:03:57 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 08A05106564A; Mon, 28 Mar 2011 19:03:57 +0000 (UTC) (envelope-from weongyo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ED0AA8FC0C; Mon, 28 Mar 2011 19:03:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJ3ucY003531; Mon, 28 Mar 2011 19:03:56 GMT (envelope-from weongyo@svn.freebsd.org) Received: (from weongyo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJ3uht003529; Mon, 28 Mar 2011 19:03:56 GMT (envelope-from weongyo@svn.freebsd.org) Message-Id: <201103281903.p2SJ3uht003529@svn.freebsd.org> From: Weongyo Jeong Date: Mon, 28 Mar 2011 19:03:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220105 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 19:03:57 -0000 Author: weongyo Date: Mon Mar 28 19:03:56 2011 New Revision: 220105 URL: http://svn.freebsd.org/changeset/base/220105 Log: Covers values if (BYTES_THIS_ACK(tp, th) / tp->t_maxseg) value is from 2.0 to 3.0. Reviewed by: lstewart Modified: head/sys/netinet/tcp_sack.c Modified: head/sys/netinet/tcp_sack.c ============================================================================== --- head/sys/netinet/tcp_sack.c Mon Mar 28 17:41:10 2011 (r220104) +++ head/sys/netinet/tcp_sack.c Mon Mar 28 19:03:56 2011 (r220105) @@ -577,7 +577,7 @@ tcp_sack_partialack(struct tcpcb *tp, st tcp_timer_activate(tp, TT_REXMT, 0); tp->t_rtttime = 0; /* Send one or 2 segments based on how much new data was acked. */ - if ((BYTES_THIS_ACK(tp, th) / tp->t_maxseg) > 2) + if ((BYTES_THIS_ACK(tp, th) / tp->t_maxseg) >= 2) num_segs = 2; tp->snd_cwnd = (tp->sackhint.sack_bytes_rexmit + (tp->snd_nxt - tp->sack_newdata) + num_segs * tp->t_maxseg); From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 19:08:53 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9719F106564A; Mon, 28 Mar 2011 19:08:53 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 873028FC17; Mon, 28 Mar 2011 19:08:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJ8rhw003683; Mon, 28 Mar 2011 19:08:53 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJ8rdR003681; Mon, 28 Mar 2011 19:08:53 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103281908.p2SJ8rdR003681@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 28 Mar 2011 19:08:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220106 - head/sys/dev/dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 19:08:53 -0000 Author: yongari Date: Mon Mar 28 19:08:53 2011 New Revision: 220106 URL: http://svn.freebsd.org/changeset/base/220106 Log: Revise r220046 by introducing dc_netcfg_wait() which waits the end of active DMA cycle. dc_setcfg() also has to wait until the DMA engine is stopped so using a common function to handle the job is better than duplicating the code. No objection from: marius Modified: head/sys/dev/dc/if_dc.c Modified: head/sys/dev/dc/if_dc.c ============================================================================== --- head/sys/dev/dc/if_dc.c Mon Mar 28 19:03:56 2011 (r220105) +++ head/sys/dev/dc/if_dc.c Mon Mar 28 19:08:53 2011 (r220106) @@ -279,6 +279,7 @@ static void dc_miibus_statchg(device_t); static void dc_miibus_mediainit(device_t); static void dc_setcfg(struct dc_softc *, int); +static void dc_netcfg_wait(struct dc_softc *); static uint32_t dc_mchash_le(struct dc_softc *, const uint8_t *); static uint32_t dc_mchash_be(const uint8_t *); static void dc_setfilt_21143(struct dc_softc *); @@ -1370,6 +1371,32 @@ dc_setfilt(struct dc_softc *sc) dc_setfilt_xircom(sc); } +static void +dc_netcfg_wait(struct dc_softc *sc) +{ + uint32_t isr; + int i; + + for (i = 0; i < DC_TIMEOUT; i++) { + isr = CSR_READ_4(sc, DC_ISR); + if (isr & DC_ISR_TX_IDLE && + ((isr & DC_ISR_RX_STATE) == DC_RXSTATE_STOPPED || + (isr & DC_ISR_RX_STATE) == DC_RXSTATE_WAIT)) + break; + DELAY(10); + } + if (i == DC_TIMEOUT) { + if (!(isr & DC_ISR_TX_IDLE) && !DC_IS_ASIX(sc)) + device_printf(sc->dc_dev, + "%s: failed to force tx to idle state\n", __func__); + if (!((isr & DC_ISR_RX_STATE) == DC_RXSTATE_STOPPED || + (isr & DC_ISR_RX_STATE) == DC_RXSTATE_WAIT) && + !DC_HAS_BROKEN_RXSTATE(sc)) + device_printf(sc->dc_dev, + "%s: failed to force rx to idle state\n", __func__); + } +} + /* * In order to fiddle with the 'full-duplex' and '100Mbps' bits in * the netconfig register, we first have to put the transmit and/or @@ -1378,8 +1405,7 @@ dc_setfilt(struct dc_softc *sc) static void dc_setcfg(struct dc_softc *sc, int media) { - int i, restart = 0, watchdogreg; - uint32_t isr; + int restart = 0, watchdogreg; if (IFM_SUBTYPE(media) == IFM_NONE) return; @@ -1387,28 +1413,7 @@ dc_setcfg(struct dc_softc *sc, int media if (CSR_READ_4(sc, DC_NETCFG) & (DC_NETCFG_TX_ON | DC_NETCFG_RX_ON)) { restart = 1; DC_CLRBIT(sc, DC_NETCFG, (DC_NETCFG_TX_ON | DC_NETCFG_RX_ON)); - - for (i = 0; i < DC_TIMEOUT; i++) { - isr = CSR_READ_4(sc, DC_ISR); - if (isr & DC_ISR_TX_IDLE && - ((isr & DC_ISR_RX_STATE) == DC_RXSTATE_STOPPED || - (isr & DC_ISR_RX_STATE) == DC_RXSTATE_WAIT)) - break; - DELAY(10); - } - - if (i == DC_TIMEOUT) { - if (!(isr & DC_ISR_TX_IDLE) && !DC_IS_ASIX(sc)) - device_printf(sc->dc_dev, - "%s: failed to force tx to idle state\n", - __func__); - if (!((isr & DC_ISR_RX_STATE) == DC_RXSTATE_STOPPED || - (isr & DC_ISR_RX_STATE) == DC_RXSTATE_WAIT) && - !DC_HAS_BROKEN_RXSTATE(sc)) - device_printf(sc->dc_dev, - "%s: failed to force rx to idle state\n", - __func__); - } + dc_netcfg_wait(sc); } if (IFM_SUBTYPE(media) == IFM_100_TX) { @@ -3917,7 +3922,7 @@ dc_stop(struct dc_softc *sc) struct dc_list_data *ld; struct dc_chain_data *cd; int i; - uint32_t ctl, isr; + uint32_t ctl, netcfg; DC_LOCK_ASSERT(sc); @@ -3928,38 +3933,21 @@ dc_stop(struct dc_softc *sc) callout_stop(&sc->dc_stat_ch); callout_stop(&sc->dc_wdog_ch); sc->dc_wdog_timer = 0; + sc->dc_link = 0; ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); - DC_CLRBIT(sc, DC_NETCFG, (DC_NETCFG_RX_ON | DC_NETCFG_TX_ON)); - - for (i = 0; i < DC_TIMEOUT; i++) { - isr = CSR_READ_4(sc, DC_ISR); - if ((isr & DC_ISR_TX_IDLE || - (isr & DC_ISR_TX_STATE) == DC_TXSTATE_RESET) && - (isr & DC_ISR_RX_STATE) == DC_RXSTATE_STOPPED) - break; - DELAY(10); - } - - if (i == DC_TIMEOUT) { - if (!((isr & DC_ISR_TX_IDLE) || - (isr & DC_ISR_TX_STATE) == DC_TXSTATE_RESET) && - !DC_IS_ASIX(sc) && !DC_IS_DAVICOM(sc)) - device_printf(sc->dc_dev, - "%s: failed to force tx to idle state\n", - __func__); - if (!((isr & DC_ISR_RX_STATE) == DC_RXSTATE_STOPPED) && - !DC_HAS_BROKEN_RXSTATE(sc)) - device_printf(sc->dc_dev, - "%s: failed to force rx to idle state\n", - __func__); - } - + netcfg = CSR_READ_4(sc, DC_NETCFG); + if (netcfg & (DC_NETCFG_RX_ON | DC_NETCFG_TX_ON)) + CSR_WRITE_4(sc, DC_NETCFG, + netcfg & ~(DC_NETCFG_RX_ON | DC_NETCFG_TX_ON)); CSR_WRITE_4(sc, DC_IMR, 0x00000000); + /* Wait the completion of TX/RX SM. */ + if (netcfg & (DC_NETCFG_RX_ON | DC_NETCFG_TX_ON)) + dc_netcfg_wait(sc); + CSR_WRITE_4(sc, DC_TXADDR, 0x00000000); CSR_WRITE_4(sc, DC_RXADDR, 0x00000000); - sc->dc_link = 0; /* * Free data in the RX lists. From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 19:22:56 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 16E14106564A; Mon, 28 Mar 2011 19:22:56 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 058F58FC0A; Mon, 28 Mar 2011 19:22:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJMt7t004131; Mon, 28 Mar 2011 19:22:55 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJMtva004130; Mon, 28 Mar 2011 19:22:55 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103281922.p2SJMtva004130@svn.freebsd.org> From: Doug Barton Date: Mon, 28 Mar 2011 19:22:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220107 - in stable/8/etc: periodic/daily periodic/security periodic/weekly rc.d X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 19:22:56 -0000 Author: dougb Date: Mon Mar 28 19:22:55 2011 New Revision: 220107 URL: http://svn.freebsd.org/changeset/base/220107 Log: MFC r219587, r220017, r220048 Adjust svn:executable properties Modified: Directory Properties: stable/8/etc/ (props changed) stable/8/etc/periodic/daily/404.status-zfs (props changed) stable/8/etc/periodic/daily/405.status-ata-raid (props changed) stable/8/etc/periodic/daily/406.status-gmirror (props changed) stable/8/etc/periodic/daily/407.status-graid3 (props changed) stable/8/etc/periodic/daily/408.status-gstripe (props changed) stable/8/etc/periodic/daily/409.status-gconcat (props changed) stable/8/etc/periodic/daily/480.status-ntpd (props changed) stable/8/etc/periodic/security/410.logincheck (props changed) stable/8/etc/periodic/security/460.chkportsum (props changed) stable/8/etc/periodic/security/510.ipfdenied (props changed) stable/8/etc/periodic/security/520.pfdenied (props changed) stable/8/etc/periodic/security/610.ipf6denied (props changed) stable/8/etc/periodic/weekly/340.noid (props changed) stable/8/etc/rc.d/Makefile (props changed) stable/8/etc/rc.d/hastd (props changed) From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 19:27:46 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6F7EF1065676; Mon, 28 Mar 2011 19:27:46 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5E6BA8FC14; Mon, 28 Mar 2011 19:27:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJRkru004359; Mon, 28 Mar 2011 19:27:46 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJRka9004358; Mon, 28 Mar 2011 19:27:46 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103281927.p2SJRka9004358@svn.freebsd.org> From: Doug Barton Date: Mon, 28 Mar 2011 19:27:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220109 - in stable/7/etc: periodic/daily periodic/security periodic/weekly rc.d X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 19:27:46 -0000 Author: dougb Date: Mon Mar 28 19:27:46 2011 New Revision: 220109 URL: http://svn.freebsd.org/changeset/base/220109 Log: MFC r219587, r220017, r220048 Adjust svn:executable properties Modified: Directory Properties: stable/7/etc/ (props changed) stable/7/etc/periodic/daily/404.status-zfs (props changed) stable/7/etc/periodic/daily/405.status-ata-raid (props changed) stable/7/etc/periodic/daily/406.status-gmirror (props changed) stable/7/etc/periodic/daily/407.status-graid3 (props changed) stable/7/etc/periodic/daily/408.status-gstripe (props changed) stable/7/etc/periodic/daily/409.status-gconcat (props changed) stable/7/etc/periodic/daily/480.status-ntpd (props changed) stable/7/etc/periodic/security/410.logincheck (props changed) stable/7/etc/periodic/security/510.ipfdenied (props changed) stable/7/etc/periodic/security/520.pfdenied (props changed) stable/7/etc/periodic/security/610.ipf6denied (props changed) stable/7/etc/periodic/weekly/340.noid (props changed) stable/7/etc/rc.d/Makefile (props changed) From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 19:29:30 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AC34D1065675; Mon, 28 Mar 2011 19:29:30 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9B4DF8FC1E; Mon, 28 Mar 2011 19:29:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJTUAp004432; Mon, 28 Mar 2011 19:29:30 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJTUN6004431; Mon, 28 Mar 2011 19:29:30 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103281929.p2SJTUN6004431@svn.freebsd.org> From: Doug Barton Date: Mon, 28 Mar 2011 19:29:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220110 - stable/7/etc/rc.d X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 19:29:30 -0000 Author: dougb Date: Mon Mar 28 19:29:30 2011 New Revision: 220110 URL: http://svn.freebsd.org/changeset/base/220110 Log: Direct commit to update svn:executable property on remaining scripts Modified: Directory Properties: stable/7/etc/rc.d/FILESYSTEMS (props changed) stable/7/etc/rc.d/NETWORKING (props changed) stable/7/etc/rc.d/abi (props changed) stable/7/etc/rc.d/addswap (props changed) stable/7/etc/rc.d/adjkerntz (props changed) stable/7/etc/rc.d/apm (props changed) stable/7/etc/rc.d/archdep (props changed) stable/7/etc/rc.d/atm1 (props changed) stable/7/etc/rc.d/atm2 (props changed) stable/7/etc/rc.d/atm3 (props changed) stable/7/etc/rc.d/auditd (props changed) stable/7/etc/rc.d/auto_linklocal (props changed) stable/7/etc/rc.d/bgfsck (props changed) stable/7/etc/rc.d/bluetooth (props changed) stable/7/etc/rc.d/bridge (props changed) stable/7/etc/rc.d/bsnmpd (props changed) stable/7/etc/rc.d/bthidd (props changed) stable/7/etc/rc.d/cleanvar (props changed) stable/7/etc/rc.d/ddb (props changed) stable/7/etc/rc.d/devd (props changed) stable/7/etc/rc.d/devfs (props changed) stable/7/etc/rc.d/dumpon (props changed) stable/7/etc/rc.d/early.sh (props changed) stable/7/etc/rc.d/encswap (props changed) stable/7/etc/rc.d/ftp-proxy (props changed) stable/7/etc/rc.d/ftpd (props changed) stable/7/etc/rc.d/gbde (props changed) stable/7/etc/rc.d/geli (props changed) stable/7/etc/rc.d/geli2 (props changed) stable/7/etc/rc.d/hcsecd (props changed) stable/7/etc/rc.d/hostapd (props changed) stable/7/etc/rc.d/hostid (props changed) stable/7/etc/rc.d/hostname (props changed) stable/7/etc/rc.d/idmapd (props changed) stable/7/etc/rc.d/initrandom (props changed) stable/7/etc/rc.d/ip6addrctl (props changed) stable/7/etc/rc.d/ip6fw (props changed) stable/7/etc/rc.d/ipfw (props changed) stable/7/etc/rc.d/ipxrouted (props changed) stable/7/etc/rc.d/isdnd (props changed) stable/7/etc/rc.d/jail (props changed) stable/7/etc/rc.d/kadmind (props changed) stable/7/etc/rc.d/kerberos (props changed) stable/7/etc/rc.d/keyserv (props changed) stable/7/etc/rc.d/kldxref (props changed) stable/7/etc/rc.d/kpasswdd (props changed) stable/7/etc/rc.d/localpkg (props changed) stable/7/etc/rc.d/lockd (props changed) stable/7/etc/rc.d/mdconfig (props changed) stable/7/etc/rc.d/mdconfig2 (props changed) stable/7/etc/rc.d/mixer (props changed) stable/7/etc/rc.d/mountlate (props changed) stable/7/etc/rc.d/moused (props changed) stable/7/etc/rc.d/mroute6d (props changed) stable/7/etc/rc.d/msgs (props changed) stable/7/etc/rc.d/natd (props changed) stable/7/etc/rc.d/netif (props changed) stable/7/etc/rc.d/netoptions (props changed) stable/7/etc/rc.d/network_ipv6 (props changed) stable/7/etc/rc.d/nfsclient (props changed) stable/7/etc/rc.d/nfsserver (props changed) stable/7/etc/rc.d/nisdomain (props changed) stable/7/etc/rc.d/nscd (props changed) stable/7/etc/rc.d/nsswitch (props changed) stable/7/etc/rc.d/othermta (props changed) stable/7/etc/rc.d/pf (props changed) stable/7/etc/rc.d/pflog (props changed) stable/7/etc/rc.d/pfsync (props changed) stable/7/etc/rc.d/power_profile (props changed) stable/7/etc/rc.d/powerd (props changed) stable/7/etc/rc.d/ppp (props changed) stable/7/etc/rc.d/pppoed (props changed) stable/7/etc/rc.d/random (props changed) stable/7/etc/rc.d/resolv (props changed) stable/7/etc/rc.d/rfcomm_pppd_server (props changed) stable/7/etc/rc.d/routing (props changed) stable/7/etc/rc.d/sdpd (props changed) stable/7/etc/rc.d/serial (props changed) stable/7/etc/rc.d/sppp (props changed) stable/7/etc/rc.d/statd (props changed) stable/7/etc/rc.d/static_arp (props changed) stable/7/etc/rc.d/syscons (props changed) stable/7/etc/rc.d/sysctl (props changed) stable/7/etc/rc.d/tmp (props changed) stable/7/etc/rc.d/ugidfw (props changed) stable/7/etc/rc.d/var (props changed) stable/7/etc/rc.d/watchdogd (props changed) stable/7/etc/rc.d/wpa_supplicant (props changed) stable/7/etc/rc.d/ypset (props changed) stable/7/etc/rc.d/ypupdated (props changed) stable/7/etc/rc.d/ypxfrd (props changed) stable/7/etc/rc.d/zfs (props changed) From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 19:32:16 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 577911065672; Mon, 28 Mar 2011 19:32:16 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 471508FC08; Mon, 28 Mar 2011 19:32:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJWGZs004574; Mon, 28 Mar 2011 19:32:16 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJWGL6004572; Mon, 28 Mar 2011 19:32:16 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103281932.p2SJWGL6004572@svn.freebsd.org> From: Doug Barton Date: Mon, 28 Mar 2011 19:32:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220111 - stable/8/usr.sbin/newsyslog X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 19:32:16 -0000 Author: dougb Date: Mon Mar 28 19:32:16 2011 New Revision: 220111 URL: http://svn.freebsd.org/changeset/base/220111 Log: MFC r220015: An EXAMPLE for Modified: stable/8/usr.sbin/newsyslog/newsyslog.conf.5 Directory Properties: stable/8/usr.sbin/newsyslog/ (props changed) Modified: stable/8/usr.sbin/newsyslog/newsyslog.conf.5 ============================================================================== --- stable/8/usr.sbin/newsyslog/newsyslog.conf.5 Mon Mar 28 19:29:30 2011 (r220110) +++ stable/8/usr.sbin/newsyslog/newsyslog.conf.5 Mon Mar 28 19:32:16 2011 (r220111) @@ -21,7 +21,7 @@ .\" the suitability of this software for any purpose. It is .\" provided "as is" without express or implied warranty. .\" -.Dd January 31, 2011 +.Dd February 25, 2011 .Dt NEWSYSLOG.CONF 5 .Os .Sh NAME @@ -349,6 +349,11 @@ If this field is not present, then a .Dv SIGHUP signal will be sent. .El +.Sh EXAMPLES +The following is an example of the +.Dq Aq Li include +entry: +.Dl " /etc/newsyslog-local.conf" .Sh SEE ALSO .Xr bzip2 1 , .Xr gzip 1 , From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 19:39:54 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 360121065676; Mon, 28 Mar 2011 19:39:54 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 24C628FC20; Mon, 28 Mar 2011 19:39:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJdsX2004854; Mon, 28 Mar 2011 19:39:54 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJdrEC004849; Mon, 28 Mar 2011 19:39:53 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103281939.p2SJdrEC004849@svn.freebsd.org> From: Doug Barton Date: Mon, 28 Mar 2011 19:39:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220112 - in stable/8/etc: defaults periodic/daily periodic/security X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 19:39:54 -0000 Author: dougb Date: Mon Mar 28 19:39:53 2011 New Revision: 220112 URL: http://svn.freebsd.org/changeset/base/220112 Log: MFC r220020: Add a daily period script to back up /var/db/pkg MFC r220049: Hook the 220.backup-pkgdb script I added to the build unconditionally Hook up 610.ipf6denied based on MK_IPFILTER as 510.ipfdenied is now Added: stable/8/etc/periodic/daily/220.backup-pkgdb - copied unchanged from r220020, head/etc/periodic/daily/220.backup-pkgdb Modified: stable/8/etc/defaults/periodic.conf stable/8/etc/periodic/daily/Makefile stable/8/etc/periodic/security/Makefile Directory Properties: stable/8/etc/ (props changed) Modified: stable/8/etc/defaults/periodic.conf ============================================================================== --- stable/8/etc/defaults/periodic.conf Mon Mar 28 19:32:16 2011 (r220111) +++ stable/8/etc/defaults/periodic.conf Mon Mar 28 19:39:53 2011 (r220112) @@ -74,6 +74,10 @@ daily_backup_passwd_enable="YES" # Bac # 210.backup-aliases daily_backup_aliases_enable="YES" # Backup mail aliases +# 220.backup-pkgdb +daily_backup_pkgdb_enable="YES" # Backup /var/db/pkg +daily_backup_pkgdb_dir="/var/backups" + # 300.calendar daily_calendar_enable="NO" # Run calendar -a Copied: stable/8/etc/periodic/daily/220.backup-pkgdb (from r220020, head/etc/periodic/daily/220.backup-pkgdb) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/etc/periodic/daily/220.backup-pkgdb Mon Mar 28 19:39:53 2011 (r220112, copy of r220020, head/etc/periodic/daily/220.backup-pkgdb) @@ -0,0 +1,50 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# If there is a global system configuration file, suck it in. +# +if [ -r /etc/defaults/periodic.conf ] +then + . /etc/defaults/periodic.conf + source_periodic_confs +fi + +rc=0 + +case "$daily_backup_pkgdb_enable" in + [Yy][Ee][Ss]) + bak="${daily_backup_pkgdb_dir:-/var/backups}" + bak_file="${bak}/pkgdb.bak.tbz" + + pkg_dbdir=`make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2>/dev/null` + + if [ ! -d "$bak" ] + then + install -d -o root -g wheel -m 750 $bak || { + echo '$daily_backup_pkgdb_enable is enabled but' \ + "$daily_backup_pkgdb_dbdir doesn't exist" ; + exit 2 ; } + fi + + echo '' + echo 'Backing up package db directory:' + + new_bak_file=`mktemp ${bak_file}-XXXXX` + + if tar -cjf "${new_bak_file}" "$pkg_dbdir"; then + chmod 644 "${new_bak_file}" + + if [ -e "${bak_file}.2" -a -e "${bak_file}" ]; then + unlink "${bak_file}.2" + mv "${bak_file}" "${bak_file}.2" + fi + [ -e "${bak_file}" ] && mv "${bak_file}" "${bak_file}.2" + mv "${new_bak_file}" "${bak_file}" + else + rc=3 + fi ;; +esac + +exit $rc Modified: stable/8/etc/periodic/daily/Makefile ============================================================================== --- stable/8/etc/periodic/daily/Makefile Mon Mar 28 19:32:16 2011 (r220111) +++ stable/8/etc/periodic/daily/Makefile Mon Mar 28 19:39:53 2011 (r220112) @@ -6,6 +6,7 @@ FILES= 100.clean-disks \ 110.clean-tmps \ 120.clean-preserve \ 200.backup-passwd \ + 220.backup-pkgdb \ 330.news \ 400.status-disks \ 405.status-ata-raid \ Modified: stable/8/etc/periodic/security/Makefile ============================================================================== --- stable/8/etc/periodic/security/Makefile Mon Mar 28 19:32:16 2011 (r220111) +++ stable/8/etc/periodic/security/Makefile Mon Mar 28 19:39:53 2011 (r220112) @@ -17,6 +17,7 @@ FILES= 100.chksetuid \ .if ${MK_IPFILTER} != "no" FILES+= 510.ipfdenied +FILES+= 610.ipf6denied .endif .if ${MK_IPFW} != "no" From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 19:42:21 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8CF60106566C; Mon, 28 Mar 2011 19:42:21 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7BBEB8FC14; Mon, 28 Mar 2011 19:42:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJgLk1004981; Mon, 28 Mar 2011 19:42:21 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJgLeK004976; Mon, 28 Mar 2011 19:42:21 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103281942.p2SJgLeK004976@svn.freebsd.org> From: Doug Barton Date: Mon, 28 Mar 2011 19:42:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220113 - in stable/7/etc: defaults periodic/daily periodic/security X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 19:42:21 -0000 Author: dougb Date: Mon Mar 28 19:42:21 2011 New Revision: 220113 URL: http://svn.freebsd.org/changeset/base/220113 Log: MFC r220020: Add a daily period script to back up /var/db/pkg MFC r220049: Hook the 220.backup-pkgdb script I added to the build unconditionally Hook up 610.ipf6denied based on MK_IPFILTER as 510.ipfdenied is now Added: stable/7/etc/periodic/daily/220.backup-pkgdb - copied unchanged from r220020, head/etc/periodic/daily/220.backup-pkgdb Modified: stable/7/etc/defaults/periodic.conf stable/7/etc/periodic/daily/Makefile stable/7/etc/periodic/security/Makefile Directory Properties: stable/7/etc/ (props changed) Modified: stable/7/etc/defaults/periodic.conf ============================================================================== --- stable/7/etc/defaults/periodic.conf Mon Mar 28 19:39:53 2011 (r220112) +++ stable/7/etc/defaults/periodic.conf Mon Mar 28 19:42:21 2011 (r220113) @@ -74,6 +74,10 @@ daily_backup_passwd_enable="YES" # Bac # 210.backup-aliases daily_backup_aliases_enable="YES" # Backup mail aliases +# 220.backup-pkgdb +daily_backup_pkgdb_enable="YES" # Backup /var/db/pkg +daily_backup_pkgdb_dir="/var/backups" + # 300.calendar daily_calendar_enable="NO" # Run calendar -a Copied: stable/7/etc/periodic/daily/220.backup-pkgdb (from r220020, head/etc/periodic/daily/220.backup-pkgdb) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/etc/periodic/daily/220.backup-pkgdb Mon Mar 28 19:42:21 2011 (r220113, copy of r220020, head/etc/periodic/daily/220.backup-pkgdb) @@ -0,0 +1,50 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# If there is a global system configuration file, suck it in. +# +if [ -r /etc/defaults/periodic.conf ] +then + . /etc/defaults/periodic.conf + source_periodic_confs +fi + +rc=0 + +case "$daily_backup_pkgdb_enable" in + [Yy][Ee][Ss]) + bak="${daily_backup_pkgdb_dir:-/var/backups}" + bak_file="${bak}/pkgdb.bak.tbz" + + pkg_dbdir=`make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2>/dev/null` + + if [ ! -d "$bak" ] + then + install -d -o root -g wheel -m 750 $bak || { + echo '$daily_backup_pkgdb_enable is enabled but' \ + "$daily_backup_pkgdb_dbdir doesn't exist" ; + exit 2 ; } + fi + + echo '' + echo 'Backing up package db directory:' + + new_bak_file=`mktemp ${bak_file}-XXXXX` + + if tar -cjf "${new_bak_file}" "$pkg_dbdir"; then + chmod 644 "${new_bak_file}" + + if [ -e "${bak_file}.2" -a -e "${bak_file}" ]; then + unlink "${bak_file}.2" + mv "${bak_file}" "${bak_file}.2" + fi + [ -e "${bak_file}" ] && mv "${bak_file}" "${bak_file}.2" + mv "${new_bak_file}" "${bak_file}" + else + rc=3 + fi ;; +esac + +exit $rc Modified: stable/7/etc/periodic/daily/Makefile ============================================================================== --- stable/7/etc/periodic/daily/Makefile Mon Mar 28 19:39:53 2011 (r220112) +++ stable/7/etc/periodic/daily/Makefile Mon Mar 28 19:42:21 2011 (r220113) @@ -6,6 +6,7 @@ FILES= 100.clean-disks \ 110.clean-tmps \ 120.clean-preserve \ 200.backup-passwd \ + 220.backup-pkgdb \ 330.news \ 400.status-disks \ 404.status-zfs \ Modified: stable/7/etc/periodic/security/Makefile ============================================================================== --- stable/7/etc/periodic/security/Makefile Mon Mar 28 19:39:53 2011 (r220112) +++ stable/7/etc/periodic/security/Makefile Mon Mar 28 19:42:21 2011 (r220113) @@ -16,6 +16,7 @@ FILES= 100.chksetuid \ .if ${MK_IPFILTER} != "no" FILES+= 510.ipfdenied +FILES+= 610.ipf6denied .endif .if ${MK_IPFW} != "no" From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 19:44:55 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 34D6D106566B; Mon, 28 Mar 2011 19:44:55 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 252D88FC1A; Mon, 28 Mar 2011 19:44:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJitOe005094; Mon, 28 Mar 2011 19:44:55 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJitvv005092; Mon, 28 Mar 2011 19:44:55 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103281944.p2SJitvv005092@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 28 Mar 2011 19:44:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220114 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 19:44:55 -0000 Author: kib Date: Mon Mar 28 19:44:54 2011 New Revision: 220114 URL: http://svn.freebsd.org/changeset/base/220114 Log: Fix the check for vm_map_remove() error. Pointed out by: alc MFC after: 2 weeks Modified: head/sys/kern/subr_uio.c Modified: head/sys/kern/subr_uio.c ============================================================================== --- head/sys/kern/subr_uio.c Mon Mar 28 19:42:21 2011 (r220113) +++ head/sys/kern/subr_uio.c Mon Mar 28 19:44:54 2011 (r220114) @@ -506,7 +506,7 @@ copyout_unmap(struct thread *td, vm_offs map = &td->td_proc->p_vmspace->vm_map; size = (vm_size_t)round_page(sz); - if (!vm_map_remove(map, addr, addr + size)) + if (vm_map_remove(map, addr, addr + size) != KERN_SUCCESS) return (EINVAL); return (0); From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 22:50:03 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F40CD106564A; Mon, 28 Mar 2011 22:50:02 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D94488FC0C; Mon, 28 Mar 2011 22:50:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SMo2B9009071; Mon, 28 Mar 2011 22:50:02 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SMo2HI009069; Mon, 28 Mar 2011 22:50:02 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201103282250.p2SMo2HI009069@svn.freebsd.org> From: Jilles Tjoelker Date: Mon, 28 Mar 2011 22:50:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220115 - stable/8/lib/libc/string X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 22:50:03 -0000 Author: jilles Date: Mon Mar 28 22:50:02 2011 New Revision: 220115 URL: http://svn.freebsd.org/changeset/base/220115 Log: MFC r219803: index(3): Mention that index/rindex are deprecated and not specified by POSIX.1-2008. Modified: stable/8/lib/libc/string/index.3 Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) Modified: stable/8/lib/libc/string/index.3 ============================================================================== --- stable/8/lib/libc/string/index.3 Mon Mar 28 19:44:54 2011 (r220114) +++ stable/8/lib/libc/string/index.3 Mon Mar 28 22:50:02 2011 (r220115) @@ -30,7 +30,7 @@ .\" @(#)index.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd March 20, 2011 .Dt INDEX 3 .Os .Sh NAME @@ -45,6 +45,17 @@ .Ft "char *" .Fn rindex "const char *s" "int c" .Sh DESCRIPTION +.Bf -symbolic +The +.Fn index +and +.Fn rindex +functions have been deprecated in favor of +.Xr strchr 3 +and +.Xr strrchr 3 . +.Ef +.Pp The .Fn index function @@ -100,3 +111,5 @@ before they were moved to for .St -p1003.1-2001 compliance. +The functions are not specified by +.St -p1003.1-2008 . From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 23:08:19 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 484941065670; Mon, 28 Mar 2011 23:08:19 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 356558FC16; Mon, 28 Mar 2011 23:08:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SN8Jwn009535; Mon, 28 Mar 2011 23:08:19 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SN8JWX009532; Mon, 28 Mar 2011 23:08:19 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <201103282308.p2SN8JWX009532@svn.freebsd.org> From: Maksim Yevmenkin Date: Mon, 28 Mar 2011 23:08:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220116 - head/usr.sbin/bluetooth/l2ping X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 23:08:19 -0000 Author: emax Date: Mon Mar 28 23:08:18 2011 New Revision: 220116 URL: http://svn.freebsd.org/changeset/base/220116 Log: Do not use word 'flood' as it not entirely correct. Use better 'no delay' description. While here, replace atoi(3) with strtol(3). Submitted by: arundel MFC after: 1 week Modified: head/usr.sbin/bluetooth/l2ping/l2ping.8 head/usr.sbin/bluetooth/l2ping/l2ping.c Modified: head/usr.sbin/bluetooth/l2ping/l2ping.8 ============================================================================== --- head/usr.sbin/bluetooth/l2ping/l2ping.8 Mon Mar 28 22:50:02 2011 (r220115) +++ head/usr.sbin/bluetooth/l2ping/l2ping.8 Mon Mar 28 23:08:18 2011 (r220116) @@ -25,7 +25,7 @@ .\" $Id: l2ping.8,v 1.3 2003/05/21 01:00:19 max Exp $ .\" $FreeBSD$ .\" -.Dd June 14, 2002 +.Dd March 29, 2011 .Dt L2PING 8 .Os .Sh NAME @@ -36,7 +36,7 @@ .Op Fl fhn .Fl a Ar remote .Op Fl c Ar count -.Op Fl i Ar delay +.Op Fl i Ar wait .Op Fl S Ar source .Op Fl s Ar size .Sh DESCRIPTION @@ -63,8 +63,7 @@ If this option is not specified, .Nm will operate until interrupted. .It Fl f -.Dq Flood -ping, i.e., no delay between packets. +Don't wait between sending each packet. .It Fl h Display usage message and exit. .It Fl i Ar wait @@ -109,7 +108,7 @@ Some implementations may not like large .Xr ng_l2cap 4 , .Xr l2control 8 .Sh AUTHORS -.An Maksim Yevmenkin Aq m_evmenkin@yahoo.com +.An Maksim Yevmenkin Aq emax@FreeBSD.org .Sh BUGS Could collect more statistic. Could check for duplicated, corrupted and lost packets. Modified: head/usr.sbin/bluetooth/l2ping/l2ping.c ============================================================================== --- head/usr.sbin/bluetooth/l2ping/l2ping.c Mon Mar 28 22:50:02 2011 (r220115) +++ head/usr.sbin/bluetooth/l2ping/l2ping.c Mon Mar 28 23:08:18 2011 (r220116) @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -60,11 +61,11 @@ int main(int argc, char *argv[]) { bdaddr_t src, dst; - struct hostent *he = NULL; - uint8_t *echo_data = NULL; + struct hostent *he; + uint8_t *echo_data; struct sockaddr_l2cap sa; int32_t n, s, count, wait, flood, echo_size, numeric; - char *rname = NULL; + char *endp, *rname; /* Set defaults */ memcpy(&src, NG_HCI_BDADDR_ANY, sizeof(src)); @@ -100,8 +101,8 @@ main(int argc, char *argv[]) break; case 'c': - count = atoi(optarg); - if (count <= 0) + count = strtol(optarg, &endp, 10); + if (count <= 0 || *endp != '\0') usage(); break; @@ -110,8 +111,8 @@ main(int argc, char *argv[]) break; case 'i': - wait = atoi(optarg); - if (wait <= 0) + wait = strtol(optarg, &endp, 10); + if (wait <= 0 || *endp != '\0') usage(); break; @@ -129,9 +130,10 @@ main(int argc, char *argv[]) break; case 's': - echo_size = atoi(optarg); - if (echo_size < sizeof(int32_t) || - echo_size > NG_L2CAP_MAX_ECHO_SIZE) + echo_size = strtol(optarg, &endp, 10); + if (echo_size < sizeof(int32_t) || + echo_size > NG_L2CAP_MAX_ECHO_SIZE || + *endp != '\0') usage(); break; @@ -272,12 +274,12 @@ tv2msec(struct timeval const *tvp) static void usage(void) { - fprintf(stderr, "Usage: l2ping -a bd_addr " \ - "[-S bd_addr -c count -i wait -n -s size -h]\n"); + fprintf(stderr, "Usage: l2ping [-fhn] -a remote " \ + "[-c count] [-i wait] [-S source] [-s size]\n"); fprintf(stderr, "Where:\n"); fprintf(stderr, " -a remote Specify remote device to ping\n"); fprintf(stderr, " -c count Number of packets to send\n"); - fprintf(stderr, " -f No delay (sort of flood)\n"); + fprintf(stderr, " -f No delay between packets\n"); fprintf(stderr, " -h Display this message\n"); fprintf(stderr, " -i wait Delay between packets (sec)\n"); fprintf(stderr, " -n Numeric output only\n"); From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 23:12:38 2011 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id D0B9A1065672; Mon, 28 Mar 2011 23:12:38 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from 65-241-43-5.globalsuite.net (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id EBA1014DF0A; Mon, 28 Mar 2011 23:12:37 +0000 (UTC) Message-ID: <4D9115E5.3040008@FreeBSD.org> Date: Mon, 28 Mar 2011 16:12:37 -0700 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.15) Gecko/20110319 Thunderbird/3.1.9 MIME-Version: 1.0 To: Warner Losh References: <201103271657.p2RGvs2m063692@svn.freebsd.org> <4D8F7257.50207@FreeBSD.org> In-Reply-To: X-Enigmail-Version: 1.1.2 OpenPGP: id=1A1ABC84 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Josh Paetzel , svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, kib@FreeBSD.org Subject: Re: svn commit: r220059 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 23:12:38 -0000 On 03/27/2011 15:29, Warner Losh wrote: > > On Mar 27, 2011, at 11:22 AM, Doug Barton wrote: > >> On 03/27/2011 09:57, Josh Paetzel wrote: >>> Replace "$?" = "0" with $? -eq 0 in tests >> >> Excellent! > > Most of the time I've found that moving the command up to the if makes the code clearer too. At jobs I've had in the past when I've written code similar to what we have here, it almost always got flagged... In general I agree with you. I did take a look at the specific cases where the -eq 0 changes were made and IMO it's about 50/50 whether that would actually be an optimization, or if leaving it as is makes the code more readable. I chose to go with "focus on the positive." :) Doug -- Nothin' ever doesn't change, but nothin' changes much. -- OK Go Breadth of IT experience, and depth of knowledge in the DNS. Yours for the right price. :) http://SupersetSolutions.com/ From owner-svn-src-all@FreeBSD.ORG Mon Mar 28 23:22:55 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id 8E1361065679; Mon, 28 Mar 2011 23:22:55 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from 65-241-43-5.globalsuite.net (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id ADF461A43D2; Mon, 28 Mar 2011 23:22:20 +0000 (UTC) Message-ID: <4D91182C.601@FreeBSD.org> Date: Mon, 28 Mar 2011 16:22:20 -0700 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.15) Gecko/20110319 Thunderbird/3.1.9 MIME-Version: 1.0 To: Jeff Roberson References: <4D840BD0.4030306@freebsd.org> <201103200000.p2K00pue003373@chez.mckusick.com> <20110320162212.GI1606@alchemy.franken.de> <4D8662B0.8000705@FreeBSD.org> In-Reply-To: X-Enigmail-Version: 1.1.2 OpenPGP: id=1A1ABC84 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Tue, 29 Mar 2011 01:45:36 +0000 Cc: src-committers@freebsd.org, kvedulv@kvedulv.de, Jeff Roberson , Kirk McKusick , Gavin Atkinson , Nathan Whitehorn , Marius Strobl , svn-src-head@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r219667 - head/usr.sbin/bsdinstall/partedit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 23:22:55 -0000 On 03/21/2011 00:33, Jeff Roberson wrote: > On Sun, 20 Mar 2011, Doug Barton wrote: > >> On 03/20/2011 09:22, Marius Strobl wrote: >> >>> I fear it's still a bit premature for enable SU+J by default. Rather >>> recently I was told about a SU+J filesystems lost after a panic >>> that happend after snapshotting it (report CC'ed, maybe he can >>> provide some more details) and I'm pretty sure I've seen the problem >>> described in PR 149022 also after the potential fix mentioned in its >>> feedback. >> >> +1 >> >> I tried enabling SU+J on my /var (after backing up of course) and >> after a panic random files were missing entirely. Not the last updates >> to those files, the whole file, and many of them had not been written >> to in days/weeks/months. >> > > So you're saying the directory entry was missing? I'm saying that the file wasn't visible to 'ls /var/db/pkg/foo/'. I didn't debug it past determining that the files were missing. > Can you tell me how big the directory was? Most of the damage was in /var/db/pkg/, so the individual directories that were missing files were small, no more than 10 files each. I imagine there was probably other damaged scattered throughout /var, but once I learned how many files were missing I just nuked it and restored from backup. > Number of files? I stopped counting around 20 or so. > Approximate directory size when > you consider file names? When you fsck'd were inodes recovered and > linked into lost and found? No. > What was the actual path? To the lost files? The ones that I actually noticed missing were all /var/db/pkg/*/+CONTENTS. There were probably a lot of other files missing, but those were noticeable because the ports tree was throwing errors, and a missing +CONTENTS file can't be recovered from without re-installing the port. > I'm trying to wrap my head around how this would be possible and where > the error could be and whether it could be caused by SUJ. It never happened before enabling SUJ, happened shortly after I did, and has never happened since I disabled it. It's probably worth reiterating that the damage happened after an actual panic, as opposed to during "regular" operation. > The number of > interactions with disk writes are minimal. Corruption if it occurs would > most likely be caused by a bad journal recovery. Unlikely in this case, since the damage was not confined to recently-written files. hth, Doug PS, my primary concern was that we not enable this by default until it can be demonstrated to be more robust. However Nathan has already enabled it in the new installer, so now perhaps it would be fitting to send a message to -current letting people know that the plan is to have it on by default in 9.0, and asking people to resume more rigorous testing. -- Nothin' ever doesn't change, but nothin' changes much. -- OK Go Breadth of IT experience, and depth of knowledge in the DNS. Yours for the right price. :) http://SupersetSolutions.com/ From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 06:42:53 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 65FDA106564A; Tue, 29 Mar 2011 06:42:52 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 555638FC14; Tue, 29 Mar 2011 06:42:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2T6gqiJ019643; Tue, 29 Mar 2011 06:42:52 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2T6gqve019641; Tue, 29 Mar 2011 06:42:52 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201103290642.p2T6gqve019641@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Tue, 29 Mar 2011 06:42:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220124 - head/sys/modules/ipfw X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 06:42:53 -0000 Author: ae Date: Tue Mar 29 06:42:52 2011 New Revision: 220124 URL: http://svn.freebsd.org/changeset/base/220124 Log: Do not build ip_fw_nat.c for ipfw.ko. It can be build as separate module. MFC after: 1 week Modified: head/sys/modules/ipfw/Makefile Modified: head/sys/modules/ipfw/Makefile ============================================================================== --- head/sys/modules/ipfw/Makefile Tue Mar 29 05:58:09 2011 (r220123) +++ head/sys/modules/ipfw/Makefile Tue Mar 29 06:42:52 2011 (r220124) @@ -6,7 +6,7 @@ KMOD= ipfw SRCS= ip_fw2.c ip_fw_pfil.c -SRCS+= ip_fw_dynamic.c ip_fw_log.c ip_fw_nat.c +SRCS+= ip_fw_dynamic.c ip_fw_log.c SRCS+= ip_fw_sockopt.c ip_fw_table.c SRCS+= opt_inet6.h opt_ipsec.h From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 11:54:22 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E252A106564A; Tue, 29 Mar 2011 11:54:22 +0000 (UTC) (envelope-from ru@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D05CF8FC0C; Tue, 29 Mar 2011 11:54:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TBsMCm027526; Tue, 29 Mar 2011 11:54:22 GMT (envelope-from ru@svn.freebsd.org) Received: (from ru@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TBsMiG027524; Tue, 29 Mar 2011 11:54:22 GMT (envelope-from ru@svn.freebsd.org) Message-Id: <201103291154.p2TBsMiG027524@svn.freebsd.org> From: Ruslan Ermilov Date: Tue, 29 Mar 2011 11:54:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220125 - stable/8/usr.bin/netstat X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 11:54:23 -0000 Author: ru Date: Tue Mar 29 11:54:22 2011 New Revision: 220125 URL: http://svn.freebsd.org/changeset/base/220125 Log: MFC r220041: Fixed sockets display somewhat (-L, -T, -x, -Lx, with and without -A). (I didn't try to fix negative TCP timers with -x.) Also, fixed a mismerge of -T option in r216964 -- it erroneously added headers for TCP timers to -x. Modified: stable/8/usr.bin/netstat/inet.c Directory Properties: stable/8/usr.bin/netstat/ (props changed) Modified: stable/8/usr.bin/netstat/inet.c ============================================================================== --- stable/8/usr.bin/netstat/inet.c Tue Mar 29 06:42:52 2011 (r220124) +++ stable/8/usr.bin/netstat/inet.c Tue Mar 29 11:54:22 2011 (r220125) @@ -404,43 +404,44 @@ protopr(u_long off, const char *name, in "Current listen queue sizes (qlen/incqlen/maxqlen)"); putchar('\n'); if (Aflag) - printf("%-8.8s ", "Tcpcb"); + printf("%-*s ", 2 * (int)sizeof(void *), "Tcpcb"); if (Lflag) - printf("%-5.5s %-14.14s %-22.22s\n", + printf((Aflag && !Wflag) ? + "%-5.5s %-14.14s %-18.18s" : + "%-5.5s %-14.14s %-22.22s", "Proto", "Listen", "Local Address"); - if (Tflag) + else if (Tflag) printf((Aflag && !Wflag) ? - "%-5.5s %-6.6s %-6.6s %-6.6s %-18.18s %s\n" : - "%-5.5s %-6.6s %-6.6s %-6.6s %-22.22s %s\n", + "%-5.5s %-6.6s %-6.6s %-6.6s %-18.18s %s" : + "%-5.5s %-6.6s %-6.6s %-6.6s %-22.22s %s", "Proto", "Rexmit", "OOORcv", "0-win", "Local Address", "Foreign Address"); + else { + printf((Aflag && !Wflag) ? + "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s" : + "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s", + "Proto", "Recv-Q", "Send-Q", + "Local Address", "Foreign Address"); + if (!xflag) + printf(" (state)"); + } if (xflag) { - printf("%-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s ", + printf(" %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s", "R-MBUF", "S-MBUF", "R-CLUS", "S-CLUS", "R-HIWA", "S-HIWA", "R-LOWA", "S-LOWA", "R-BCNT", "S-BCNT", "R-BMAX", "S-BMAX"); - printf("%7.7s %7.7s %7.7s %7.7s %7.7s %7.7s\n", - "rexmt", "persist", "keep", - "2msl", "delack", "rcvtime"); - } - if (!xflag && !Tflag) { - printf((Aflag && !Wflag) ? - "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s" : - "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s", - "Proto", "Recv-Q", "Send-Q", - "Local Address", "Foreign Address"); - printf("(state)\n"); } + putchar('\n'); first = 0; } if (Lflag && so->so_qlimit == 0) continue; if (Aflag) { if (istcp) - printf("%8lx ", (u_long)inp->inp_ppcb); + printf("%*lx ", 2 * (int)sizeof(void *), (u_long)inp->inp_ppcb); else - printf("%8lx ", (u_long)so->so_pcb); + printf("%*lx ", 2 * (int)sizeof(void *), (u_long)so->so_pcb); } #ifdef INET6 if ((inp->inp_vflag & INP_IPV6) != 0) @@ -521,23 +522,13 @@ protopr(u_long off, const char *name, in #endif /* INET6 */ } if (xflag) { - if (Lflag) - printf("%21s %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u ", - " ", - so->so_rcv.sb_mcnt, so->so_snd.sb_mcnt, - so->so_rcv.sb_ccnt, so->so_snd.sb_ccnt, - so->so_rcv.sb_hiwat, so->so_snd.sb_hiwat, - so->so_rcv.sb_lowat, so->so_snd.sb_lowat, - so->so_rcv.sb_mbcnt, so->so_snd.sb_mbcnt, - so->so_rcv.sb_mbmax, so->so_snd.sb_mbmax); - else - printf("%6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u ", - so->so_rcv.sb_mcnt, so->so_snd.sb_mcnt, - so->so_rcv.sb_ccnt, so->so_snd.sb_ccnt, - so->so_rcv.sb_hiwat, so->so_snd.sb_hiwat, - so->so_rcv.sb_lowat, so->so_snd.sb_lowat, - so->so_rcv.sb_mbcnt, so->so_snd.sb_mbcnt, - so->so_rcv.sb_mbmax, so->so_snd.sb_mbmax); + printf("%6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u", + so->so_rcv.sb_mcnt, so->so_snd.sb_mcnt, + so->so_rcv.sb_ccnt, so->so_snd.sb_ccnt, + so->so_rcv.sb_hiwat, so->so_snd.sb_hiwat, + so->so_rcv.sb_lowat, so->so_snd.sb_lowat, + so->so_rcv.sb_mbcnt, so->so_snd.sb_mbcnt, + so->so_rcv.sb_mbmax, so->so_snd.sb_mbmax); } if (istcp && !Lflag && !xflag && !Tflag) { if (tp->t_state < 0 || tp->t_state >= TCP_NSTATES) From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 12:38:13 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AE6B1106566C; Tue, 29 Mar 2011 12:38:13 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9DE9D8FC16; Tue, 29 Mar 2011 12:38:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TCcDPS028657; Tue, 29 Mar 2011 12:38:13 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TCcDDB028655; Tue, 29 Mar 2011 12:38:13 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201103291238.p2TCcDDB028655@svn.freebsd.org> From: John Baldwin Date: Tue, 29 Mar 2011 12:38:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220126 - head/sys/isa X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 12:38:13 -0000 Author: jhb Date: Tue Mar 29 12:38:13 2011 New Revision: 220126 URL: http://svn.freebsd.org/changeset/base/220126 Log: - Enable an extra debugging bootverbose printf when probing ISA PNP cards listing each card as it is found on non-PC98 (PC98 already had this). - Increase the length of the DELAY() used before timing out while reading PNP resource data. Tested by: Steven Nikkel steven_nikkel ertyu org MFC after: 1 week Modified: head/sys/isa/pnp.c Modified: head/sys/isa/pnp.c ============================================================================== --- head/sys/isa/pnp.c Tue Mar 29 11:54:22 2011 (r220125) +++ head/sys/isa/pnp.c Tue Mar 29 12:38:13 2011 (r220126) @@ -209,7 +209,7 @@ pnp_get_resource_info(u_char *buffer, in for (j = 0; j < 100; j++) { if ((inb((pnp_rd_port << 2) | 0x3)) & 0x1) break; - DELAY(1); + DELAY(10); } if (j == 100) { printf("PnP device failed to report resource data\n"); @@ -743,10 +743,10 @@ pnp_isolation_protocol(device_t parent) printf("A Normal-ISA-PnP card (%s).\n", pnp_eisaformat(id.vendor_id)); } +#endif if (bootverbose) printf("Reading PnP configuration for %s.\n", pnp_eisaformat(id.vendor_id)); -#endif error = pnp_read_resources(&resources, &space, &len); if (error) break; From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 15:59:07 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC0A01065670; Tue, 29 Mar 2011 15:59:07 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A05218FC13; Tue, 29 Mar 2011 15:59:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TFx7sE033270; Tue, 29 Mar 2011 15:59:07 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TFx7Iv033266; Tue, 29 Mar 2011 15:59:07 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103291559.p2TFx7Iv033266@svn.freebsd.org> From: Adrian Chadd Date: Tue, 29 Mar 2011 15:59:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220132 - head/sys/dev/ath X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 15:59:07 -0000 Author: adrian Date: Tue Mar 29 15:59:07 2011 New Revision: 220132 URL: http://svn.freebsd.org/changeset/base/220132 Log: According to ath9k recv.c, one shouldn't be doing self-linked descriptors in the RX path when doing 11n and block-ack'ed frames. Apparently, the MAC will loop over that self-linked descriptor and treat it as "good enough" for (incorrectly!) ACKing the frames in the block-ack. Until I figure out how to work around this issue in the future, this counter will tell me if packet RX processing ever gets to the point where it's touching the self-linked descriptor. If there's ever enough packets to get to that point, BA's will be invalid and likely very unhappy. Modified: head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_ath_sysctl.c head/sys/dev/ath/if_athioctl.h Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Tue Mar 29 15:36:43 2011 (r220131) +++ head/sys/dev/ath/if_ath.c Tue Mar 29 15:59:07 2011 (r220132) @@ -3338,6 +3338,7 @@ ath_rx_proc(void *arg, int npending) ds = bf->bf_desc; if (ds->ds_link == bf->bf_daddr) { /* NB: never process the self-linked entry at the end */ + sc->sc_stats.ast_rx_hitqueueend++; break; } /* XXX sync descriptor memory */ Modified: head/sys/dev/ath/if_ath_sysctl.c ============================================================================== --- head/sys/dev/ath/if_ath_sysctl.c Tue Mar 29 15:36:43 2011 (r220131) +++ head/sys/dev/ath/if_ath_sysctl.c Tue Mar 29 15:59:07 2011 (r220132) @@ -703,6 +703,8 @@ ath_sysctl_stats_attach(struct ath_softc &sc->sc_stats.ast_rx_hi_rx_chain, 0, ""); SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_htprotect", CTLFLAG_RD, &sc->sc_stats.ast_tx_htprotect, 0, "HT tx frames with protection"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_hitqueueend", CTLFLAG_RD, + &sc->sc_stats.ast_rx_hitqueueend, 0, "RX hit queue end"); /* Attach the RX phy error array */ ath_sysctl_stats_attach_rxphyerr(sc, child); Modified: head/sys/dev/ath/if_athioctl.h ============================================================================== --- head/sys/dev/ath/if_athioctl.h Tue Mar 29 15:36:43 2011 (r220131) +++ head/sys/dev/ath/if_athioctl.h Tue Mar 29 15:59:07 2011 (r220132) @@ -128,7 +128,8 @@ struct ath_stats { u_int32_t ast_rx_decrypt_busy_err; u_int32_t ast_rx_hi_rx_chain; u_int32_t ast_tx_htprotect; /* HT tx frames with protection */ - u_int32_t ast_pad[3]; + u_int32_t ast_rx_hitqueueend; + u_int32_t ast_pad[2]; }; #define SIOCGATHSTATS _IOWR('i', 137, struct ifreq) From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 17:47:25 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DF2171065672; Tue, 29 Mar 2011 17:47:25 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CB2E38FC08; Tue, 29 Mar 2011 17:47:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2THlPwr035889; Tue, 29 Mar 2011 17:47:25 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2THlPDa035877; Tue, 29 Mar 2011 17:47:25 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103291747.p2THlPDa035877@svn.freebsd.org> From: Edward Tomasz Napierala Date: Tue, 29 Mar 2011 17:47:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220137 - in head: . sys/amd64/conf sys/conf sys/kern sys/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 17:47:26 -0000 Author: trasz Date: Tue Mar 29 17:47:25 2011 New Revision: 220137 URL: http://svn.freebsd.org/changeset/base/220137 Log: Add racct. It's an API to keep per-process, per-jail, per-loginclass and per-loginclass resource accounting information, to be used by the new resource limits code. It's connected to the build, but the code that actually calls the new functions will come later. Sponsored by: The FreeBSD Foundation Reviewed by: kib (earlier version) Added: head/kern_racct.c (contents, props changed) head/sys/kern/kern_racct.c (contents, props changed) head/sys/sys/racct.h (contents, props changed) Modified: head/sys/amd64/conf/GENERIC head/sys/conf/NOTES head/sys/conf/files head/sys/conf/options head/sys/kern/init_main.c head/sys/kern/kern_exit.c head/sys/kern/kern_fork.c head/sys/kern/kern_jail.c head/sys/kern/kern_loginclass.c head/sys/kern/kern_resource.c head/sys/sys/jail.h head/sys/sys/kernel.h head/sys/sys/loginclass.h head/sys/sys/proc.h head/sys/sys/resourcevar.h Added: head/kern_racct.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/kern_racct.c Tue Mar 29 17:47:25 2011 (r220137) @@ -0,0 +1,842 @@ +/*- + * Copyright (c) 2010 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Edward Tomasz Napierala under sponsorship + * from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_kdtrace.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef RCTL +#include +#endif + +#ifdef RACCT + +FEATURE(racct, "Resource Accounting"); + +static struct mtx racct_lock; +MTX_SYSINIT(racct_lock, &racct_lock, "racct lock", MTX_DEF); + +static uma_zone_t racct_zone; + +static void racct_sub_racct(struct racct *dest, const struct racct *src); +static void racct_sub_cred_locked(struct ucred *cred, int resource, + uint64_t amount); +static void racct_add_cred_locked(struct ucred *cred, int resource, + uint64_t amount); + +SDT_PROVIDER_DEFINE(racct); +SDT_PROBE_DEFINE3(racct, kernel, rusage, add, add, "struct proc *", "int", + "uint64_t"); +SDT_PROBE_DEFINE3(racct, kernel, rusage, add_failure, add-failure, + "struct proc *", "int", "uint64_t"); +SDT_PROBE_DEFINE3(racct, kernel, rusage, add_cred, add-cred, "struct ucred *", + "int", "uint64_t"); +SDT_PROBE_DEFINE3(racct, kernel, rusage, add_force, add-force, "struct proc *", + "int", "uint64_t"); +SDT_PROBE_DEFINE3(racct, kernel, rusage, set, set, "struct proc *", "int", + "uint64_t"); +SDT_PROBE_DEFINE3(racct, kernel, rusage, set_failure, set-failure, + "struct proc *", "int", "uint64_t"); +SDT_PROBE_DEFINE3(racct, kernel, rusage, sub, sub, "struct proc *", "int", + "uint64_t"); +SDT_PROBE_DEFINE3(racct, kernel, rusage, sub_cred, sub-cred, "struct ucred *", + "int", "uint64_t"); +SDT_PROBE_DEFINE1(racct, kernel, racct, create, create, "struct racct *"); +SDT_PROBE_DEFINE1(racct, kernel, racct, destroy, destroy, "struct racct *"); +SDT_PROBE_DEFINE2(racct, kernel, racct, join, join, "struct racct *", + "struct racct *"); +SDT_PROBE_DEFINE2(racct, kernel, racct, join_failure, join-failure, + "struct racct *", "struct racct *"); +SDT_PROBE_DEFINE2(racct, kernel, racct, leave, leave, "struct racct *", + "struct racct *"); + +int racct_types[] = { + [RACCT_CPU] = + RACCT_IN_THOUSANDS, + [RACCT_FSIZE] = + RACCT_RECLAIMABLE | RACCT_INHERITABLE | RACCT_DENIABLE, + [RACCT_DATA] = + RACCT_RECLAIMABLE | RACCT_INHERITABLE | RACCT_DENIABLE, + [RACCT_STACK] = + RACCT_RECLAIMABLE | RACCT_INHERITABLE | RACCT_DENIABLE, + [RACCT_CORE] = + RACCT_DENIABLE, + [RACCT_RSS] = + RACCT_RECLAIMABLE, + [RACCT_MEMLOCK] = + RACCT_RECLAIMABLE | RACCT_DENIABLE, + [RACCT_NPROC] = + RACCT_RECLAIMABLE | RACCT_DENIABLE, + [RACCT_NOFILE] = + RACCT_RECLAIMABLE | RACCT_INHERITABLE | RACCT_DENIABLE, + [RACCT_SBSIZE] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_VMEM] = + RACCT_RECLAIMABLE | RACCT_INHERITABLE | RACCT_DENIABLE, + [RACCT_NPTS] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_SWAP] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_NTHR] = + RACCT_RECLAIMABLE | RACCT_DENIABLE, + [RACCT_MSGQQUEUED] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_MSGQSIZE] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_NMSGQ] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_NSEM] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_NSEMOP] = + RACCT_RECLAIMABLE | RACCT_INHERITABLE | RACCT_DENIABLE, + [RACCT_NSHM] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_SHMSIZE] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_WALLCLOCK] = + RACCT_IN_THOUSANDS }; + +static void +racct_add_racct(struct racct *dest, const struct racct *src) +{ + int i; + + mtx_assert(&racct_lock, MA_OWNED); + + /* + * Update resource usage in dest. + */ + for (i = 0; i <= RACCT_MAX; i++) { + KASSERT(dest->r_resources[i] >= 0, + ("racct propagation meltdown: dest < 0")); + KASSERT(src->r_resources[i] >= 0, + ("racct propagation meltdown: src < 0")); + dest->r_resources[i] += src->r_resources[i]; + } +} + +static void +racct_sub_racct(struct racct *dest, const struct racct *src) +{ + int i; + + mtx_assert(&racct_lock, MA_OWNED); + + /* + * Update resource usage in dest. + */ + for (i = 0; i <= RACCT_MAX; i++) { + if (!racct_is_sloppy(i) && + !racct_is_dampened(i)) { + KASSERT(dest->r_resources[i] >= 0, + ("racct propagation meltdown: dest < 0")); + KASSERT(src->r_resources[i] >= 0, + ("racct propagation meltdown: src < 0")); + KASSERT(src->r_resources[i] <= dest->r_resources[i], + ("racct propagation meltdown: src > dest")); + } + if (racct_is_reclaimable(i)) { + dest->r_resources[i] -= src->r_resources[i]; + if (dest->r_resources[i] < 0) { + KASSERT(racct_is_sloppy(i) || + racct_is_dampened(i), + ("racct_sub_racct: usage < 0")); + dest->r_resources[i] = 0; + } + } + } +} + +void +racct_create(struct racct **racctp) +{ + + SDT_PROBE(racct, kernel, racct, create, racctp, 0, 0, 0, 0); + + KASSERT(*racctp == NULL, ("racct already allocated")); + + *racctp = uma_zalloc(racct_zone, M_WAITOK | M_ZERO); +} + +static void +racct_destroy_locked(struct racct **racctp) +{ + int i; + struct racct *racct; + + SDT_PROBE(racct, kernel, racct, destroy, racctp, 0, 0, 0, 0); + + mtx_assert(&racct_lock, MA_OWNED); + KASSERT(racctp != NULL, ("NULL racctp")); + KASSERT(*racctp != NULL, ("NULL racct")); + + racct = *racctp; + + for (i = 0; i <= RACCT_MAX; i++) { + if (racct_is_sloppy(i)) + continue; + if (!racct_is_reclaimable(i)) + continue; + if (racct_is_dampened(i)) + continue; + KASSERT(racct->r_resources[i] == 0, + ("destroying non-empty racct: " + "%ju allocated for resource %d\n", + racct->r_resources[i], i)); + } + uma_zfree(racct_zone, racct); + *racctp = NULL; +} + +void +racct_destroy(struct racct **racct) +{ + + mtx_lock(&racct_lock); + racct_destroy_locked(racct); + mtx_unlock(&racct_lock); +} + +/* + * Increase consumption of 'resource' by 'amount' for 'racct' + * and all its parents. Differently from other cases, 'amount' here + * may be less than zero. + */ +static void +racct_alloc_resource(struct racct *racct, int resource, + uint64_t amount) +{ + + mtx_assert(&racct_lock, MA_OWNED); + KASSERT(racct != NULL, ("NULL racct")); + + racct->r_resources[resource] += amount; + if (racct->r_resources[resource] < 0) { + KASSERT(racct_is_sloppy(resource) || + racct_is_dampened(resource), + ("racct_alloc_resource: usage < 0")); + racct->r_resources[resource] = 0; + } +} + +/* + * Increase allocation of 'resource' by 'amount' for process 'p'. + * Return 0 if it's below limits, or errno, if it's not. + */ +int +racct_add(struct proc *p, int resource, uint64_t amount) +{ +#ifdef RCTL + int error; +#endif + + if (p->p_flag & P_SYSTEM) + return (0); + + SDT_PROBE(racct, kernel, rusage, add, p, resource, amount, 0, 0); + + /* + * We need proc lock to dereference p->p_ucred. + */ + PROC_LOCK_ASSERT(p, MA_OWNED); + KASSERT(amount >= 0, ("racct_add: invalid amount for resource %d: %ju", + resource, amount)); + + mtx_lock(&racct_lock); +#ifdef RCTL + error = rctl_enforce(p, resource, amount); + if (error && racct_is_deniable(resource)) { + SDT_PROBE(racct, kernel, rusage, add_failure, p, resource, + amount, 0, 0); + mtx_unlock(&racct_lock); + return (error); + } +#endif + racct_alloc_resource(p->p_racct, resource, amount); + racct_add_cred_locked(p->p_ucred, resource, amount); + mtx_unlock(&racct_lock); + + return (0); +} + +static void +racct_add_cred_locked(struct ucred *cred, int resource, uint64_t amount) +{ + struct prison *pr; + + SDT_PROBE(racct, kernel, rusage, add_cred, cred, resource, amount, + 0, 0); + + KASSERT(amount >= 0, + ("racct_add_cred: invalid amount for resource %d: %ju", + resource, amount)); + + racct_alloc_resource(cred->cr_ruidinfo->ui_racct, resource, amount); + for (pr = cred->cr_prison; pr != NULL; pr = pr->pr_parent) + racct_alloc_resource(pr->pr_racct, resource, amount); + racct_alloc_resource(cred->cr_loginclass->lc_racct, resource, amount); +} + +/* + * Increase allocation of 'resource' by 'amount' for credential 'cred'. + * Doesn't check for limits and never fails. + * + * XXX: Shouldn't this ever return an error? + */ +void +racct_add_cred(struct ucred *cred, int resource, uint64_t amount) +{ + + mtx_lock(&racct_lock); + racct_add_cred_locked(cred, resource, amount); + mtx_unlock(&racct_lock); +} + +/* + * Increase allocation of 'resource' by 'amount' for process 'p'. + * Doesn't check for limits and never fails. + */ +void +racct_add_force(struct proc *p, int resource, uint64_t amount) +{ + + if (p->p_flag & P_SYSTEM) + return; + + SDT_PROBE(racct, kernel, rusage, add_force, p, resource, amount, 0, 0); + + /* + * We need proc lock to dereference p->p_ucred. + */ + PROC_LOCK_ASSERT(p, MA_OWNED); + KASSERT(amount >= 0, + ("racct_add_force: invalid amount for resource %d: %ju", + resource, amount)); + + mtx_lock(&racct_lock); + racct_alloc_resource(p->p_racct, resource, amount); + mtx_unlock(&racct_lock); + racct_add_cred(p->p_ucred, resource, amount); +} + +static int +racct_set_locked(struct proc *p, int resource, uint64_t amount) +{ + int64_t diff; +#ifdef RCTL + int error; +#endif + + if (p->p_flag & P_SYSTEM) + return (0); + + SDT_PROBE(racct, kernel, rusage, set, p, resource, amount, 0, 0); + + /* + * We need proc lock to dereference p->p_ucred. + */ + PROC_LOCK_ASSERT(p, MA_OWNED); + KASSERT(amount >= 0, ("racct_set: invalid amount for resource %d: %ju", + resource, amount)); + + diff = amount - p->p_racct->r_resources[resource]; +#ifdef notyet + KASSERT(diff >= 0 || racct_is_reclaimable(resource), + ("racct_set: usage of non-reclaimable resource %d dropping", + resource)); +#endif +#ifdef RCTL + if (diff > 0) { + error = rctl_enforce(p, resource, diff); + if (error && racct_is_deniable(resource)) { + SDT_PROBE(racct, kernel, rusage, set_failure, p, + resource, amount, 0, 0); + return (error); + } + } +#endif + racct_alloc_resource(p->p_racct, resource, diff); + if (diff > 0) + racct_add_cred_locked(p->p_ucred, resource, diff); + else if (diff < 0) + racct_sub_cred_locked(p->p_ucred, resource, -diff); + + return (0); +} + +/* + * Set allocation of 'resource' to 'amount' for process 'p'. + * Return 0 if it's below limits, or errno, if it's not. + * + * Note that decreasing the allocation always returns 0, + * even if it's above the limit. + */ +int +racct_set(struct proc *p, int resource, uint64_t amount) +{ + int error; + + mtx_lock(&racct_lock); + error = racct_set_locked(p, resource, amount); + mtx_unlock(&racct_lock); + return (error); +} + +void +racct_set_force(struct proc *p, int resource, uint64_t amount) +{ + int64_t diff; + + if (p->p_flag & P_SYSTEM) + return; + + SDT_PROBE(racct, kernel, rusage, set, p, resource, amount, 0, 0); + + /* + * We need proc lock to dereference p->p_ucred. + */ + PROC_LOCK_ASSERT(p, MA_OWNED); + KASSERT(amount >= 0, + ("racct_set_force: invalid amount for resource %d: %ju", + resource, amount)); + + mtx_lock(&racct_lock); + diff = amount - p->p_racct->r_resources[resource]; + racct_alloc_resource(p->p_racct, resource, diff); + if (diff > 0) + racct_add_cred_locked(p->p_ucred, resource, diff); + else if (diff < 0) + racct_sub_cred_locked(p->p_ucred, resource, -diff); + mtx_unlock(&racct_lock); +} + +/* + * Returns amount of 'resource' the process 'p' can keep allocated. + * Allocating more than that would be denied, unless the resource + * is marked undeniable. Amount of already allocated resource does + * not matter. + */ +uint64_t +racct_get_limit(struct proc *p, int resource) +{ + +#ifdef RCTL + return (rctl_get_limit(p, resource)); +#else + return (UINT64_MAX); +#endif +} + +/* + * Returns amount of 'resource' the process 'p' can keep allocated. + * Allocating more than that would be denied, unless the resource + * is marked undeniable. Amount of already allocated resource does + * matter. + */ +uint64_t +racct_get_available(struct proc *p, int resource) +{ + +#ifdef RCTL + return (rctl_get_available(p, resource)); +#else + return (UINT64_MAX); +#endif +} + +/* + * Decrease allocation of 'resource' by 'amount' for process 'p'. + */ +void +racct_sub(struct proc *p, int resource, uint64_t amount) +{ + + if (p->p_flag & P_SYSTEM) + return; + + SDT_PROBE(racct, kernel, rusage, sub, p, resource, amount, 0, 0); + + /* + * We need proc lock to dereference p->p_ucred. + */ + PROC_LOCK_ASSERT(p, MA_OWNED); + KASSERT(amount >= 0, ("racct_sub: invalid amount for resource %d: %ju", + resource, amount)); + KASSERT(racct_is_reclaimable(resource), + ("racct_sub: called for non-reclaimable resource %d", resource)); + + mtx_lock(&racct_lock); + KASSERT(amount <= p->p_racct->r_resources[resource], + ("racct_sub: freeing %ju of resource %d, which is more " + "than allocated %jd for %s (pid %d)", amount, resource, + (intmax_t)p->p_racct->r_resources[resource], p->p_comm, p->p_pid)); + + racct_alloc_resource(p->p_racct, resource, -amount); + racct_sub_cred_locked(p->p_ucred, resource, amount); + mtx_unlock(&racct_lock); +} + +static void +racct_sub_cred_locked(struct ucred *cred, int resource, uint64_t amount) +{ + struct prison *pr; + + SDT_PROBE(racct, kernel, rusage, sub_cred, cred, resource, amount, + 0, 0); + + KASSERT(amount >= 0, + ("racct_sub_cred: invalid amount for resource %d: %ju", + resource, amount)); +#ifdef notyet + KASSERT(racct_is_reclaimable(resource), + ("racct_sub_cred: called for non-reclaimable resource %d", + resource)); +#endif + + racct_alloc_resource(cred->cr_ruidinfo->ui_racct, resource, -amount); + for (pr = cred->cr_prison; pr != NULL; pr = pr->pr_parent) + racct_alloc_resource(pr->pr_racct, resource, -amount); + racct_alloc_resource(cred->cr_loginclass->lc_racct, resource, -amount); +} + +/* + * Decrease allocation of 'resource' by 'amount' for credential 'cred'. + */ +void +racct_sub_cred(struct ucred *cred, int resource, uint64_t amount) +{ + + mtx_lock(&racct_lock); + racct_sub_cred_locked(cred, resource, amount); + mtx_unlock(&racct_lock); +} + +/* + * Inherit resource usage information from the parent process. + */ +int +racct_proc_fork(struct proc *parent, struct proc *child) +{ + int i, error = 0; + + /* + * Create racct for the child process. + */ + racct_create(&child->p_racct); + + /* + * No resource accounting for kernel processes. + */ + if (child->p_flag & P_SYSTEM) + return (0); + + PROC_LOCK(parent); + PROC_LOCK(child); + mtx_lock(&racct_lock); + + /* + * Inherit resource usage. + */ + for (i = 0; i <= RACCT_MAX; i++) { + if (parent->p_racct->r_resources[i] == 0 || + !racct_is_inheritable(i)) + continue; + + error = racct_set_locked(child, i, + parent->p_racct->r_resources[i]); + if (error != 0) { + /* + * XXX: The only purpose of these two lines is + * to prevent from tripping checks in racct_destroy(). + */ + for (i = 0; i <= RACCT_MAX; i++) + racct_set_locked(child, i, 0); + goto out; + } + } + +#ifdef RCTL + error = rctl_proc_fork(parent, child); + if (error != 0) { + /* + * XXX: The only purpose of these two lines is to prevent from + * tripping checks in racct_destroy(). + */ + for (i = 0; i <= RACCT_MAX; i++) + racct_set_locked(child, i, 0); + } +#endif + +out: + if (error != 0) + racct_destroy_locked(&child->p_racct); + mtx_unlock(&racct_lock); + PROC_UNLOCK(child); + PROC_UNLOCK(parent); + + return (error); +} + +void +racct_proc_exit(struct proc *p) +{ + uint64_t runtime; + + PROC_LOCK(p); + /* + * We don't need to calculate rux, proc_reap() has already done this. + */ + runtime = cputick2usec(p->p_rux.rux_runtime); +#ifdef notyet + KASSERT(runtime >= p->p_prev_runtime, ("runtime < p_prev_runtime")); +#else + if (runtime < p->p_prev_runtime) + runtime = p->p_prev_runtime; +#endif + racct_set(p, RACCT_CPU, runtime); + + /* + * XXX: Free this some other way. + */ + racct_set(p, RACCT_FSIZE, 0); + racct_set(p, RACCT_NPTS, 0); + racct_set(p, RACCT_NTHR, 0); + racct_set(p, RACCT_RSS, 0); + PROC_UNLOCK(p); + +#ifdef RCTL + rctl_racct_release(p->p_racct); +#endif + racct_destroy(&p->p_racct); +} + +/* + * Called after credentials change, to move resource utilisation + * between raccts. + */ +void +racct_proc_ucred_changed(struct proc *p, struct ucred *oldcred, + struct ucred *newcred) +{ + struct uidinfo *olduip, *newuip; + struct loginclass *oldlc, *newlc; + struct prison *oldpr, *newpr, *pr; + + PROC_LOCK_ASSERT(p, MA_NOTOWNED); + + newuip = newcred->cr_ruidinfo; + olduip = oldcred->cr_ruidinfo; + newlc = newcred->cr_loginclass; + oldlc = oldcred->cr_loginclass; + newpr = newcred->cr_prison; + oldpr = oldcred->cr_prison; + + mtx_lock(&racct_lock); + if (newuip != olduip) { + racct_sub_racct(olduip->ui_racct, p->p_racct); + racct_add_racct(newuip->ui_racct, p->p_racct); + } + if (newlc != oldlc) { + racct_sub_racct(oldlc->lc_racct, p->p_racct); + racct_add_racct(newlc->lc_racct, p->p_racct); + } + if (newpr != oldpr) { + for (pr = oldpr; pr != NULL; pr = pr->pr_parent) + racct_sub_racct(pr->pr_racct, p->p_racct); + for (pr = newpr; pr != NULL; pr = pr->pr_parent) + racct_add_racct(pr->pr_racct, p->p_racct); + } + mtx_unlock(&racct_lock); + +#ifdef RCTL + rctl_proc_ucred_changed(p, newcred); +#endif +} + +static void +racctd(void) +{ + struct thread *td; + struct proc *p; + struct timeval wallclock; + uint64_t runtime; + + for (;;) { + sx_slock(&allproc_lock); + + FOREACH_PROC_IN_SYSTEM(p) { + if (p->p_state != PRS_NORMAL) + continue; + if (p->p_flag & P_SYSTEM) + continue; + + microuptime(&wallclock); + timevalsub(&wallclock, &p->p_stats->p_start); + PROC_LOCK(p); + PROC_SLOCK(p); + FOREACH_THREAD_IN_PROC(p, td) { + ruxagg(p, td); + thread_lock(td); + thread_unlock(td); + } + runtime = cputick2usec(p->p_rux.rux_runtime); + PROC_SUNLOCK(p); +#ifdef notyet + KASSERT(runtime >= p->p_prev_runtime, + ("runtime < p_prev_runtime")); +#else + if (runtime < p->p_prev_runtime) + runtime = p->p_prev_runtime; +#endif + p->p_prev_runtime = runtime; + mtx_lock(&racct_lock); + racct_set_locked(p, RACCT_CPU, runtime); + racct_set_locked(p, RACCT_WALLCLOCK, + wallclock.tv_sec * 1000000 + wallclock.tv_usec); + mtx_unlock(&racct_lock); + PROC_UNLOCK(p); + } + sx_sunlock(&allproc_lock); + pause("-", hz); + } +} + +static struct kproc_desc racctd_kp = { + "racctd", + racctd, + NULL +}; +SYSINIT(racctd, SI_SUB_RACCTD, SI_ORDER_FIRST, kproc_start, &racctd_kp); + +static void +racct_init(void) +{ + + racct_zone = uma_zcreate("racct", sizeof(struct racct), + NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); + /* + * XXX: Move this somewhere. + */ + racct_create(&prison0.pr_racct); +} +SYSINIT(racct, SI_SUB_RACCT, SI_ORDER_FIRST, racct_init, NULL); + +#else /* !RACCT */ + +int +racct_add(struct proc *p, int resource, uint64_t amount) +{ + + return (0); +} + +void +racct_add_cred(struct ucred *cred, int resource, uint64_t amount) +{ +} + +void +racct_add_force(struct proc *p, int resource, uint64_t amount) +{ + + return (0); +} + +int +racct_set(struct proc *p, int resource, uint64_t amount) +{ + + return (0); +} + +void +racct_sub(struct proc *p, int resource, uint64_t amount) +{ +} + +void +racct_sub_cred(struct ucred *cred, int resource, uint64_t amount) +{ +} + +uint64_t +racct_get_limit(struct proc *p, int resource) +{ + + return (UINT64_MAX); +} + +void +racct_create(struct racct **racctp) +{ +} + +void +racct_destroy(struct racct **racctp) +{ +} + +int +racct_proc_fork(struct proc *parent, struct proc *child) +{ + + return (0); +} + +void +racct_proc_exit(struct proc *p) +{ +} + +#endif /* !RACCT */ Modified: head/sys/amd64/conf/GENERIC ============================================================================== --- head/sys/amd64/conf/GENERIC Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/amd64/conf/GENERIC Tue Mar 29 17:47:25 2011 (r220137) @@ -65,6 +65,8 @@ options MAC # TrustedBSD MAC Framewor #options KDTRACE_HOOKS # Kernel DTrace hooks options INCLUDE_CONFIG_FILE # Include this file in kernel +options RACCT + # Debugging for use in -current options KDB # Enable kernel debugger support. options DDB # Support DDB. Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/conf/NOTES Tue Mar 29 17:47:25 2011 (r220137) @@ -2930,6 +2930,9 @@ options AAC_DEBUG # Debugging levels: # 2 - extremely noisy, emit trace # items in loops, etc. +# Resource Accounting +options RACCT + # Yet more undocumented options for linting. # BKTR_ALLOC_PAGES has no effect except to cause warnings, and # BROOKTREE_ALLOC_PAGES hasn't actually been superseded by it, since the Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/conf/files Tue Mar 29 17:47:25 2011 (r220137) @@ -2225,6 +2225,7 @@ kern/kern_poll.c optional device_pollin kern/kern_priv.c standard kern/kern_proc.c standard kern/kern_prot.c standard +kern/kern_racct.c standard kern/kern_resource.c standard kern/kern_rmlock.c standard kern/kern_rwlock.c standard Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/conf/options Tue Mar 29 17:47:25 2011 (r220137) @@ -873,6 +873,9 @@ SDP_DEBUG opt_ofed.h IPOIB_DEBUG opt_ofed.h IPOIB_CM opt_ofed.h +# Resource Accounting +RACCT opt_global.h + # At least one of the AR71XX ubiquiti boards has a Redboot configuration # that "lies" about the amount of RAM it has. Until a cleaner method is # defined, this option will suffice in overriding what Redboot says. Modified: head/sys/kern/init_main.c ============================================================================== --- head/sys/kern/init_main.c Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/kern/init_main.c Tue Mar 29 17:47:25 2011 (r220137) @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -526,6 +527,9 @@ proc0_init(void *dummy __unused) p->p_limit->pl_rlimit[RLIMIT_MEMLOCK].rlim_max = pageablemem; p->p_cpulimit = RLIM_INFINITY; + /* Initialize resource accounting structures. */ + racct_create(&p->p_racct); + p->p_stats = pstats_alloc(); /* Allocate a prototype map so we have something to fork. */ Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/kern/kern_exit.c Tue Mar 29 17:47:25 2011 (r220137) @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -741,6 +742,11 @@ proc_reap(struct thread *td, struct proc (void)chgproccnt(p->p_ucred->cr_ruidinfo, -1, 0); /* + * Destroy resource accounting information associated with the process. + */ + racct_proc_exit(p); + + /* * Free credentials, arguments, and sigacts. */ crfree(p->p_ucred); Modified: head/sys/kern/kern_fork.c ============================================================================== --- head/sys/kern/kern_fork.c Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/kern/kern_fork.c Tue Mar 29 17:47:25 2011 (r220137) @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -783,6 +784,21 @@ fork1(struct thread *td, int flags, int knlist_init_mtx(&newproc->p_klist, &newproc->p_mtx); STAILQ_INIT(&newproc->p_ktr); + /* + * XXX: This is ugly; when we copy resource usage, we need to bump + * per-cred resource counters. + */ + newproc->p_ucred = p1->p_ucred; + + /* + * Initialize resource accounting for the child process. + */ + error = racct_proc_fork(p1, newproc); + if (error != 0) { + error = EAGAIN; + goto fail1; + } + /* We have to lock the process tree while we look for a pid. */ sx_slock(&proctree_lock); @@ -827,6 +843,7 @@ fork1(struct thread *td, int flags, int error = EAGAIN; fail: + racct_proc_exit(newproc); sx_sunlock(&proctree_lock); if (ppsratecheck(&lastfail, &curfail, 1)) printf("maxproc limit exceeded by uid %i, please see tuning(7) and login.conf(5).\n", Modified: head/sys/kern/kern_jail.c ============================================================================== --- head/sys/kern/kern_jail.c Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/kern/kern_jail.c Tue Mar 29 17:47:25 2011 (r220137) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1195,6 +1196,7 @@ kern_jail_set(struct thread *td, struct root = mypr->pr_root; vref(root); } + racct_create(&pr->pr_racct); strlcpy(pr->pr_hostuuid, DEFAULT_HOSTUUID, HOSTUUIDLEN); pr->pr_flags |= PR_HOST; #if defined(INET) || defined(INET6) @@ -2295,6 +2297,9 @@ do_jail_attach(struct thread *td, struct newcred->cr_prison = pr; p->p_ucred = newcred; PROC_UNLOCK(p); +#ifdef RACCT + racct_proc_ucred_changed(p, oldcred, newcred); +#endif crfree(oldcred); prison_deref(ppr, PD_DEREF | PD_DEUREF); return (0); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 17:52:45 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 964A6106566C; Tue, 29 Mar 2011 17:52:45 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 69C3B8FC21; Tue, 29 Mar 2011 17:52:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2THqjXx036030; Tue, 29 Mar 2011 17:52:45 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2THqjeF036028; Tue, 29 Mar 2011 17:52:45 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103291752.p2THqjeF036028@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 29 Mar 2011 17:52:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220138 - stable/8/lib/libc/stdio X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 17:52:45 -0000 Author: trociny Date: Tue Mar 29 17:52:45 2011 New Revision: 220138 URL: http://svn.freebsd.org/changeset/base/220138 Log: MFC r219342, r219346: r219342 (pjd): Fix various issues in how %#T is handled: - If precision is 0, don't print period followed by no digits. - If precision is 0 stop printing units as soon as possible (eg. if we have three years and five days and precision is 0 print only 3y5d). - If precision is not 0, print all units (eg. 3y0d0h0m0s.00). r219346 (pjd): Because we call __printf_out() with a on-stack buffer, also call __printf_flush() so we are sure it won't be referenced after we return. Approved by: kib (co-mentor), pjd (mentor) Modified: stable/8/lib/libc/stdio/xprintf_time.c Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) Modified: stable/8/lib/libc/stdio/xprintf_time.c ============================================================================== --- stable/8/lib/libc/stdio/xprintf_time.c Tue Mar 29 17:47:25 2011 (r220137) +++ stable/8/lib/libc/stdio/xprintf_time.c Tue Mar 29 17:52:45 2011 (r220138) @@ -62,7 +62,7 @@ __printf_render_time(struct __printf_io struct timespec *ts; time_t *tp; intmax_t t, tx; - int i, prec, nsec; + int i, prec, nsec, ret; prec = 0; if (pi->is_long) { @@ -79,6 +79,12 @@ __printf_render_time(struct __printf_io tp = *((time_t **)arg[0]); t = *tp; } + if (pi->is_long || pi->is_long_double) { + if (pi->prec >= 0) + prec = pi->prec; + if (prec == 0) + nsec = 0; + } p = buf; if (pi->alt) { @@ -87,29 +93,29 @@ __printf_render_time(struct __printf_io p += sprintf(p, "%jdy", t / YEAR); t %= YEAR; } - if (t >= DAY && t != 0) { + if (tx >= DAY && (t != 0 || prec != 0)) { p += sprintf(p, "%jdd", t / DAY); t %= DAY; } - if (t >= HOUR && t != 0) { + if (tx >= HOUR && (t != 0 || prec != 0)) { p += sprintf(p, "%jdh", t / HOUR); t %= HOUR; } - if (t >= MINUTE && t != 0) { + if (tx >= MINUTE && (t != 0 || prec != 0)) { p += sprintf(p, "%jdm", t / MINUTE); t %= MINUTE; } - if (t != 0 || tx == 0) + if (t != 0 || tx == 0 || prec != 0) p += sprintf(p, "%jds", t); } else { p += sprintf(p, "%jd", (intmax_t)t); } - if (pi->is_long || pi->is_long_double) { - if (pi->prec >= 0) - prec = pi->prec; + if (prec != 0) { for (i = prec; i < 9; i++) nsec /= 10; p += sprintf(p, ".%.*d", prec, nsec); } - return(__printf_out(io, pi, buf, p - buf)); + ret = __printf_out(io, pi, buf, p - buf); + __printf_flush(io); + return (ret); } From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 17:55:16 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F3071065672; Tue, 29 Mar 2011 17:55:16 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2CA508FC15; Tue, 29 Mar 2011 17:55:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2THtGiC036130; Tue, 29 Mar 2011 17:55:16 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2THtGcr036128; Tue, 29 Mar 2011 17:55:16 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103291755.p2THtGcr036128@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 29 Mar 2011 17:55:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220139 - stable/8/lib/libutil X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 17:55:16 -0000 Author: trociny Date: Tue Mar 29 17:55:15 2011 New Revision: 220139 URL: http://svn.freebsd.org/changeset/base/220139 Log: MFC r200035, r219344: Bring in missing headers and primitive type declarations into to make it work when included by itself. r200035 (ed): Make work when included by itself. There are several reasons why it didn't work: - It was missing for __BEGIN_DECLS. - It uses various primitive types that were not declared. r219344 (pjd): expand_number() needs uint64_t, declare it here if not already declared. Approved by: kib (co-mentor), pjd (mentor) Modified: stable/8/lib/libutil/libutil.h Directory Properties: stable/8/lib/libutil/ (props changed) Modified: stable/8/lib/libutil/libutil.h ============================================================================== --- stable/8/lib/libutil/libutil.h Tue Mar 29 17:52:45 2011 (r220138) +++ stable/8/lib/libutil/libutil.h Tue Mar 29 17:55:15 2011 (r220139) @@ -39,6 +39,39 @@ #ifndef _LIBUTIL_H_ #define _LIBUTIL_H_ +#include +#include + +#ifndef _GID_T_DECLARED +typedef __gid_t gid_t; +#define _GID_T_DECLARED +#endif + +#ifndef _INT64_T_DECLARED +typedef __int64_t int64_t; +#define _INT64_T_DECLARED +#endif + +#ifndef _UINT64_T_DECLARED +typedef __uint64_t uint64_t; +#define _UINT64_T_DECLARED +#endif + +#ifndef _PID_T_DECLARED +typedef __pid_t pid_t; +#define _PID_T_DECLARED +#endif + +#ifndef _SIZE_T_DECLARED +typedef __size_t size_t; +#define _SIZE_T_DECLARED +#endif + +#ifndef _UID_T_DECLARED +typedef __uid_t uid_t; +#define _UID_T_DECLARED +#endif + #define PROPERTY_MAX_NAME 64 #define PROPERTY_MAX_VALUE 512 From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 17:57:40 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 83CDD1065674; Tue, 29 Mar 2011 17:57:40 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 718A98FC12; Tue, 29 Mar 2011 17:57:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2THveUl036208; Tue, 29 Mar 2011 17:57:40 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2THveVn036206; Tue, 29 Mar 2011 17:57:40 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103291757.p2THveVn036206@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 29 Mar 2011 17:57:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220140 - stable/8/include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 17:57:40 -0000 Author: trociny Date: Tue Mar 29 17:57:40 2011 New Revision: 220140 URL: http://svn.freebsd.org/changeset/base/220140 Log: MFC r219343: r219343 (pjd): Include stdio.h, so we can include printf.h in any order, as it needs FILE. Approved by: kib (co-mentor), pjd (mentor) Modified: stable/8/include/printf.h Directory Properties: stable/8/include/ (props changed) Modified: stable/8/include/printf.h ============================================================================== --- stable/8/include/printf.h Tue Mar 29 17:55:15 2011 (r220139) +++ stable/8/include/printf.h Tue Mar 29 17:57:40 2011 (r220140) @@ -29,6 +29,7 @@ #ifndef _PRINTF_H_ #define _PRINTF_H_ +#include #include /* From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 17:59:30 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 98853106566B; Tue, 29 Mar 2011 17:59:30 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 865138FC13; Tue, 29 Mar 2011 17:59:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2THxUiV036276; Tue, 29 Mar 2011 17:59:30 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2THxU9g036274; Tue, 29 Mar 2011 17:59:30 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103291759.p2THxU9g036274@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 29 Mar 2011 17:59:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220141 - stable/8/share/mk X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 17:59:30 -0000 Author: trociny Date: Tue Mar 29 17:59:30 2011 New Revision: 220141 URL: http://svn.freebsd.org/changeset/base/220141 Log: MFC r219368: r219368 (pjd): To be able to use printf extensions we need to turn off gcc format checking. Following the convention of NO_WERROR and NO_WCAST_ALIGN add NO_WFORMAT, which, when defined in Makefile, turns off compile-time format checking (by adding -Wno-format), but still allows to use high WARNS level. Approved by: kib (co-mentor), pjd (mentor) Modified: stable/8/share/mk/bsd.sys.mk Directory Properties: stable/8/share/mk/ (props changed) Modified: stable/8/share/mk/bsd.sys.mk ============================================================================== --- stable/8/share/mk/bsd.sys.mk Tue Mar 29 17:57:40 2011 (r220140) +++ stable/8/share/mk/bsd.sys.mk Tue Mar 29 17:59:30 2011 (r220141) @@ -69,6 +69,9 @@ CWARNFLAGS += -Werror . endif . endif . endif +. if defined(NO_WFORMAT) +CWARNFLAGS += -Wno-format +. endif .endif .if defined(IGNORE_PRAGMA) From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 18:01:05 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1DFFF106566B; Tue, 29 Mar 2011 18:01:05 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id E71508FC1A; Tue, 29 Mar 2011 18:01:04 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 8651F46B09; Tue, 29 Mar 2011 14:01:04 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 07B6B8A01B; Tue, 29 Mar 2011 14:01:04 -0400 (EDT) From: John Baldwin To: Randall Stewart Date: Tue, 29 Mar 2011 14:01:03 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> In-Reply-To: <201101191907.p0JJ7GMp086060@svn.freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201103291401.03565.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Tue, 29 Mar 2011 14:01:04 -0400 (EDT) Cc: svn-src-head@freebsd.org, deischen@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r217592 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 18:01:05 -0000 On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: > Author: rrs > Date: Wed Jan 19 19:07:16 2011 > New Revision: 217592 > URL: http://svn.freebsd.org/changeset/base/217592 > > Log: > Fix a bug where Multicast packets sent from a > udp endpoint may end up echoing back to the sender > even with OUT joining the multi-cast group. > > Reviewed by: gnn, bms, bz? > Obtained from: deischen (with help from) > > Modified: > head/sys/netinet/udp_usrreq.c > > Modified: head/sys/netinet/udp_usrreq.c > ============================================================================== > --- head/sys/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 (r217591) > +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 (r217592) > @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) > * and source-specific multicast. [RFC3678] > */ > imo = inp->inp_moptions; > - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && > - imo != NULL) { > + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { > struct sockaddr_in group; > int blocked; > - > + if(imo == NULL) { > + INP_RUNLOCK(inp); > + continue; > + } > bzero(&group, sizeof(struct sockaddr_in)); > group.sin_len = sizeof(struct sockaddr_in); > group.sin_family = AF_INET; So it turns out that this is a feature, not a bug, and is how multicast has always worked. Specifically, if you bind a UDP socket with a wildcard address, it should receive all traffic for the bound port, unicast or multicast. When you join a group, you have switched the socket into a mode where it now has a whitelist of acceptable multicast groups, but if a socket has no joined groups, it should receive all multicast traffic, not none. This change breaks that. I did not find this behavior intuitive at first, but it does seem to be required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for example: 3. Overview of APIs There are a number of different APIs described in this document that are appropriate for a number of different application types and IP versions. Before providing detailed descriptions, this section provides a "taxonomy" with a brief description of each. There are two categories of source-filter APIs, both of which are designed to allow multicast receiver applications to designate the unicast address(es) of sender(s) along with the multicast group (destination address) to receive. o Basic (Delta-based): Some applications desire the simplicity of a delta-based API in which each function call specifies a single source address which should be added to or removed from the existing filter for a given multicast group address on which to listen. Such applications typically fall into either of two categories: + Any-Source Multicast: By default, all sources are accepted. Individual sources may be turned off and back on as needed over time. This is also known as "exclude" mode, since the source filter contains a list of excluded sources. + Source-Specific Multicast: Only sources in a given list are allowed. The list may change over time. This is also known as "include" mode, since the source filter contains a list of included sources. This API would be used, for example, by "single-source" applications such as audio/video broadcasting. It would also be used for logical multi-source sessions where each source independently allocates its own Source-Specific Multicast group address. ..... 4.1.1. IPv4 Any-Source Multicast API The following socket options are defined in for applications in the Any-Source Multicast category: Socket option Argument type IP_ADD_MEMBERSHIP struct ip_mreq IP_BLOCK_SOURCE struct ip_mreq_source IP_UNBLOCK_SOURCE struct ip_mreq_source IP_DROP_MEMBERSHIP struct ip_mreq IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on most operating systems, and are used to join and leave an any-source group. IP_BLOCK_SOURCE can be used to block data from a given source to a given group (e.g., if the user "mutes" that source), and IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then "unmutes" the source). As to why the packets loop back to the receiver, I believe that is a separate issue on the output side, not the receive side. -- John Baldwin From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 18:16:50 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 08184106564A; Tue, 29 Mar 2011 18:16:50 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EAA978FC1F; Tue, 29 Mar 2011 18:16:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TIGnTa036908; Tue, 29 Mar 2011 18:16:49 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TIGnru036906; Tue, 29 Mar 2011 18:16:49 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103291816.p2TIGnru036906@svn.freebsd.org> From: Edward Tomasz Napierala Date: Tue, 29 Mar 2011 18:16:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220143 - head/sys/amd64/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 18:16:50 -0000 Author: trasz Date: Tue Mar 29 18:16:49 2011 New Revision: 220143 URL: http://svn.freebsd.org/changeset/base/220143 Log: Revert part of r220137, committed by mistake - RACCT is _not_ supposed to be enabled in GENERIC. Modified: head/sys/amd64/conf/GENERIC Modified: head/sys/amd64/conf/GENERIC ============================================================================== --- head/sys/amd64/conf/GENERIC Tue Mar 29 18:07:19 2011 (r220142) +++ head/sys/amd64/conf/GENERIC Tue Mar 29 18:16:49 2011 (r220143) @@ -65,8 +65,6 @@ options MAC # TrustedBSD MAC Framewor #options KDTRACE_HOOKS # Kernel DTrace hooks options INCLUDE_CONFIG_FILE # Include this file in kernel -options RACCT - # Debugging for use in -current options KDB # Enable kernel debugger support. options DDB # Support DDB. From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 18:44:08 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 60FE7106566B; Tue, 29 Mar 2011 18:44:08 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 35D458FC0C; Tue, 29 Mar 2011 18:44:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TIi84S037667; Tue, 29 Mar 2011 18:44:08 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TIi8oN037666; Tue, 29 Mar 2011 18:44:08 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103291844.p2TIi8oN037666@svn.freebsd.org> From: Edward Tomasz Napierala Date: Tue, 29 Mar 2011 18:44:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220145 - head X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 18:44:08 -0000 Author: trasz Date: Tue Mar 29 18:44:07 2011 New Revision: 220145 URL: http://svn.freebsd.org/changeset/base/220145 Log: Revert file added in a wrong place by mistake. D'oh. Deleted: head/kern_racct.c From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 19:19:11 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F3D4F106564A; Tue, 29 Mar 2011 19:19:10 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C84F78FC0A; Tue, 29 Mar 2011 19:19:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TJJAHW038498; Tue, 29 Mar 2011 19:19:10 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TJJA0W038496; Tue, 29 Mar 2011 19:19:10 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103291919.p2TJJA0W038496@svn.freebsd.org> From: Edward Tomasz Napierala Date: Tue, 29 Mar 2011 19:19:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220146 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 19:19:11 -0000 Author: trasz Date: Tue Mar 29 19:19:10 2011 New Revision: 220146 URL: http://svn.freebsd.org/changeset/base/220146 Log: Remove pointless (always true) KASSERTs. Submitted by: pjd Modified: head/sys/kern/kern_racct.c Modified: head/sys/kern/kern_racct.c ============================================================================== --- head/sys/kern/kern_racct.c Tue Mar 29 18:44:07 2011 (r220145) +++ head/sys/kern/kern_racct.c Tue Mar 29 19:19:10 2011 (r220146) @@ -285,8 +285,6 @@ racct_add(struct proc *p, int resource, * We need proc lock to dereference p->p_ucred. */ PROC_LOCK_ASSERT(p, MA_OWNED); - KASSERT(amount >= 0, ("racct_add: invalid amount for resource %d: %ju", - resource, amount)); mtx_lock(&racct_lock); #ifdef RCTL @@ -313,10 +311,6 @@ racct_add_cred_locked(struct ucred *cred SDT_PROBE(racct, kernel, rusage, add_cred, cred, resource, amount, 0, 0); - KASSERT(amount >= 0, - ("racct_add_cred: invalid amount for resource %d: %ju", - resource, amount)); - racct_alloc_resource(cred->cr_ruidinfo->ui_racct, resource, amount); for (pr = cred->cr_prison; pr != NULL; pr = pr->pr_parent) racct_alloc_resource(pr->pr_racct, resource, amount); @@ -355,9 +349,6 @@ racct_add_force(struct proc *p, int reso * We need proc lock to dereference p->p_ucred. */ PROC_LOCK_ASSERT(p, MA_OWNED); - KASSERT(amount >= 0, - ("racct_add_force: invalid amount for resource %d: %ju", - resource, amount)); mtx_lock(&racct_lock); racct_alloc_resource(p->p_racct, resource, amount); @@ -382,8 +373,6 @@ racct_set_locked(struct proc *p, int res * We need proc lock to dereference p->p_ucred. */ PROC_LOCK_ASSERT(p, MA_OWNED); - KASSERT(amount >= 0, ("racct_set: invalid amount for resource %d: %ju", - resource, amount)); diff = amount - p->p_racct->r_resources[resource]; #ifdef notyet @@ -442,9 +431,6 @@ racct_set_force(struct proc *p, int reso * We need proc lock to dereference p->p_ucred. */ PROC_LOCK_ASSERT(p, MA_OWNED); - KASSERT(amount >= 0, - ("racct_set_force: invalid amount for resource %d: %ju", - resource, amount)); mtx_lock(&racct_lock); diff = amount - p->p_racct->r_resources[resource]; @@ -506,8 +492,6 @@ racct_sub(struct proc *p, int resource, * We need proc lock to dereference p->p_ucred. */ PROC_LOCK_ASSERT(p, MA_OWNED); - KASSERT(amount >= 0, ("racct_sub: invalid amount for resource %d: %ju", - resource, amount)); KASSERT(racct_is_reclaimable(resource), ("racct_sub: called for non-reclaimable resource %d", resource)); @@ -530,9 +514,6 @@ racct_sub_cred_locked(struct ucred *cred SDT_PROBE(racct, kernel, rusage, sub_cred, cred, resource, amount, 0, 0); - KASSERT(amount >= 0, - ("racct_sub_cred: invalid amount for resource %d: %ju", - resource, amount)); #ifdef notyet KASSERT(racct_is_reclaimable(resource), ("racct_sub_cred: called for non-reclaimable resource %d", From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 19:48:04 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC5971065675; Tue, 29 Mar 2011 19:48:03 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BBF778FC08; Tue, 29 Mar 2011 19:48:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TJm3ZK039129; Tue, 29 Mar 2011 19:48:03 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TJm3Z2039126; Tue, 29 Mar 2011 19:48:03 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201103291948.p2TJm3Z2039126@svn.freebsd.org> From: Marius Strobl Date: Tue, 29 Mar 2011 19:48:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220147 - head/sys/sparc64/pci X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 19:48:04 -0000 Author: marius Date: Tue Mar 29 19:48:03 2011 New Revision: 220147 URL: http://svn.freebsd.org/changeset/base/220147 Log: Allocate memory for a DMA method table only in case we need to override the iommu(4) provided one, i.e. in case of Hummingbird and Sabre bridges, otherwise just use the iommu(4) one. This also fixes a bug introduced in r220039 which caused an empty DMA method table to be used for the second of a pair of Psycho bridges. Modified: head/sys/sparc64/pci/psycho.c head/sys/sparc64/pci/psychovar.h Modified: head/sys/sparc64/pci/psycho.c ============================================================================== --- head/sys/sparc64/pci/psycho.c Tue Mar 29 19:19:10 2011 (r220146) +++ head/sys/sparc64/pci/psycho.c Tue Mar 29 19:48:03 2011 (r220147) @@ -529,21 +529,29 @@ psycho_attach(device_t dev) * * For the moment, 32KB should be more than enough. */ - memcpy(&sc->sc_dma_methods, &iommu_dma_methods, - sizeof(sc->sc_dma_methods)); - sc->sc_is = malloc(sizeof(struct iommu_state), M_DEVBUF, - M_NOWAIT | M_ZERO); + sc->sc_is = malloc(sizeof(*sc->sc_is), M_DEVBUF, M_NOWAIT | + M_ZERO); if (sc->sc_is == NULL) - panic("%s: malloc iommu_state failed", __func__); + panic("%s: could not malloc IOMMU state", __func__); sc->sc_is->is_flags = IOMMU_PRESERVE_PROM; if (sc->sc_mode == PSYCHO_MODE_SABRE) { - sc->sc_dma_methods.dm_dmamap_sync = + sc->sc_dma_methods = + malloc(sizeof(*sc->sc_dma_methods), M_DEVBUF, + M_NOWAIT); + if (sc->sc_dma_methods == NULL) + panic("%s: could not malloc DMA methods", + __func__); + memcpy(sc->sc_dma_methods, &iommu_dma_methods, + sizeof(*sc->sc_dma_methods)); + sc->sc_dma_methods->dm_dmamap_sync = sabre_dmamap_sync; sc->sc_is->is_pmaxaddr = IOMMU_MAXADDR(SABRE_IOMMU_BITS); - } else + } else { + sc->sc_dma_methods = &iommu_dma_methods; sc->sc_is->is_pmaxaddr = IOMMU_MAXADDR(PSYCHO_IOMMU_BITS); + } sc->sc_is->is_sb[0] = sc->sc_is->is_sb[1] = 0; if (OF_getproplen(node, "no-streaming-cache") < 0) sc->sc_is->is_sb[0] = sc->sc_pcictl + PCR_STRBUF; @@ -551,6 +559,7 @@ psycho_attach(device_t dev) psycho_iommu_init(sc, 3, dvmabase); } else { /* Just copy IOMMU state, config tag and address. */ + sc->sc_dma_methods = &iommu_dma_methods; sc->sc_is = osc->sc_is; if (OF_getproplen(node, "no-streaming-cache") < 0) sc->sc_is->is_sb[1] = sc->sc_pcictl + PCR_STRBUF; @@ -567,7 +576,7 @@ psycho_attach(device_t dev) panic("%s: bus_dma_tag_create failed", __func__); /* Customize the tag. */ sc->sc_pci_dmat->dt_cookie = sc->sc_is; - sc->sc_pci_dmat->dt_mt = &sc->sc_dma_methods; + sc->sc_pci_dmat->dt_mt = sc->sc_dma_methods; i = OF_getprop(node, "bus-range", (void *)prop_array, sizeof(prop_array)); Modified: head/sys/sparc64/pci/psychovar.h ============================================================================== --- head/sys/sparc64/pci/psychovar.h Tue Mar 29 19:19:10 2011 (r220146) +++ head/sys/sparc64/pci/psychovar.h Tue Mar 29 19:48:03 2011 (r220147) @@ -36,7 +36,7 @@ * per pair of psychos. */ struct psycho_softc { - struct bus_dma_methods sc_dma_methods; + struct bus_dma_methods *sc_dma_methods; device_t sc_dev; From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 20:53:53 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F31C31065670; Tue, 29 Mar 2011 20:53:52 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DC1C48FC14; Tue, 29 Mar 2011 20:53:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TKrqFX040672; Tue, 29 Mar 2011 20:53:52 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TKrpP5040638; Tue, 29 Mar 2011 20:53:51 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201103292053.p2TKrpP5040638@svn.freebsd.org> From: Martin Matuska Date: Tue, 29 Mar 2011 20:53:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220150 - in head: contrib/gcc contrib/gcc/config/mips contrib/gcc/config/rs6000 contrib/gcc/config/s390 contrib/gcc/cp contrib/gcc/doc contrib/libstdc++ contrib/libstdc++/include/std c... X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 20:53:53 -0000 Author: mm Date: Tue Mar 29 20:53:51 2011 New Revision: 220150 URL: http://svn.freebsd.org/changeset/base/220150 Log: Upgrade of base gcc and libstdc++ to the last GPLv2-licensed revision (rev. 127959 of gcc-4_2-branch). Resolved GCC bugs: c++: 17763, 29365, 30535, 30917, 31337, 31941, 32108, 32112, 32346, 32898, 32992 debug: 32610, 32914 libstdc++: 33084, 33128 middle-end: 32563 rtl-optimization: 33148 tree-optimization: 25413, 32723 target: 32218 Tested by: pointyhat (miwi) Obtained from: gcc (gcc-4_2-branch up to rev. 127959) PR: gnu/153298, gnu/153959, gnu/154385 MFC after: 1 month Modified: head/contrib/gcc/BASE-VER head/contrib/gcc/ChangeLog head/contrib/gcc/DATESTAMP head/contrib/gcc/DEV-PHASE head/contrib/gcc/config/mips/predicates.md head/contrib/gcc/config/rs6000/rs6000.c head/contrib/gcc/config/s390/s390.md head/contrib/gcc/cp/ChangeLog head/contrib/gcc/cp/call.c head/contrib/gcc/cp/cp-tree.h head/contrib/gcc/cp/cxx-pretty-print.c head/contrib/gcc/cp/decl.c head/contrib/gcc/cp/decl2.c head/contrib/gcc/cp/error.c head/contrib/gcc/cp/lex.c head/contrib/gcc/cp/name-lookup.c head/contrib/gcc/cp/pt.c head/contrib/gcc/cp/semantics.c head/contrib/gcc/cp/typeck.c head/contrib/gcc/doc/contrib.texi head/contrib/gcc/dwarf2out.c head/contrib/gcc/expr.c head/contrib/gcc/fold-const.c head/contrib/gcc/gimplify.c head/contrib/gcc/reload1.c head/contrib/gcc/simplify-rtx.c head/contrib/gcc/target-def.h head/contrib/gcc/target.h head/contrib/gcc/targhooks.c head/contrib/gcc/targhooks.h head/contrib/gcc/tree-if-conv.c head/contrib/gcc/tree-ssa-structalias.c head/contrib/gcc/tree-vect-analyze.c head/contrib/gcc/tree-vect-patterns.c head/contrib/gcc/tree.c head/contrib/gcc/tree.h head/contrib/libstdc++/ChangeLog head/contrib/libstdc++/include/std/std_valarray.h head/contrib/libstdc++/include/tr1/random head/sys/sys/param.h Directory Properties: head/contrib/gcc/ (props changed) head/contrib/libstdc++/ (props changed) Modified: head/contrib/gcc/BASE-VER ============================================================================== --- head/contrib/gcc/BASE-VER Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/BASE-VER Tue Mar 29 20:53:51 2011 (r220150) @@ -1 +1 @@ -4.2.1 +4.2.2 Modified: head/contrib/gcc/ChangeLog ============================================================================== --- head/contrib/gcc/ChangeLog Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/ChangeLog Tue Mar 29 20:53:51 2011 (r220150) @@ -1,3 +1,121 @@ +2007-08-31 Jakub Jelinek + + PR rtl-optimization/33148 + * simplify-rtx.c (simplify_unary_operation_1): Only optimize + (neg (lt X 0)) if X has scalar int mode. + + PR debug/32914 + * dwarf2out.c (rtl_for_decl_init): If vector decl has CONSTRUCTOR + initializer, use build_vector_from_ctor if possible to create + VECTOR_CST out of it. If vector initializer is not VECTOR_CST + even after this, return NULL. + +2007-08-27 Jason Merrill + + PR c++/31337 + * gimplify.c (gimplify_modify_expr): Discard the assignment of + zero-sized types after calling gimplify_modify_expr_rhs. + +2007-08-24 Jakub Jelinek + + PR debug/32610 + * dwarf2out.c (gen_decl_die): Don't call + gen_tagged_type_instantiation_die if decl doesn't have tagged type. + +2007-08-24 Richard Guenther + + * expr.c (get_inner_reference): Remove unused variable. + +2007-08-24 Richard Guenther + + * expr.c (get_inner_reference): Do computation of bitoffset + from offset in a way we can detect overflow reliably. + +2007-08-22 Richard Guenther + + PR middle-end/32563 + * tree.c (host_integerp): Treat sizetype as signed as it is + sign-extended. + +2007-08-20 Adam Nemet + + * config/mips/predicates.md (const_call_insn_operand): Invoke + SYMBOL_REF_LONG_CALL_P only on SYMBOL_REFs. + +2007-08-17 Chen liqin + + * config/score/score.md : Update pattern tablejump. + * config/score/score.c : Update score_initialize_trampoline + function. + * config/score/score.h (TRAMPOLINE_TEMPLATE): Added macro. + (TRAMPOLINE_INSNS, TRAMPOLINE_SIZE) Update macro. + * doc/contrib.texi: Add my entry. + +2007-08-02 Andreas Krebbel + + * config/s390/s390.md ("*xordi3_cconly"): Change xr to xg. + +2007-08-01 Andreas Krebbel + + * config/s390/s390.md (TF in GPR splitter): Change operand_subword + parameter to TFmode. + +2007-07-30 Mark Mitchell + + * BASE-VER: Bump. + * DEV-PHASE: Mark as prerelease. + +2007-07-25 Steve Ellcey + + PR target/32218 + * tree-vect-patterns.c (vect_pattern_recog_1): Check for valid type. + +2007-07-25 Dorit Nuzman + Devang Patel + + PR tree-optimization/25413 + * targhooks.c (default_builtin_vector_alignment_reachable): New. + * targhooks.h (default_builtin_vector_alignment_reachable): New. + * tree.h (contains_packed_reference): New. + * expr.c (contains_packed_reference): New. + * tree-vect-analyze.c (vector_alignment_reachable_p): New. + (vect_enhance_data_refs_alignment): Call + vector_alignment_reachable_p. + * target.h (vector_alignment_reachable): New builtin. + * target-def.h (TARGET_VECTOR_ALIGNMENT_REACHABLE): New. + * config/rs6000/rs6000.c (rs6000_vector_alignment_reachable): New. + (TARGET_VECTOR_ALIGNMENT_REACHABLE): Define. + +2007-07-24 Richard Guenther + + Backport from mainline: + 2007-07-16 Richard Guenther + Uros Bizjak + + * tree-if-conv.c (find_phi_replacement_condition): Unshare "*cond" + before forcing it to gimple operand. + +2007-07-24 Richard Guenther + + PR tree-optimization/32723 + Backport from mainline: + 2007-03-09 Daniel Berlin + + * tree-ssa-structalias.c (shared_bitmap_info_t): New structure. + (shared_bitmap_table): New variable. + (shared_bitmap_hash): New function. + (shared_bitmap_eq): Ditto + (shared_bitmap_lookup): Ditto. + (shared_bitmap_add): Ditto. + (find_what_p_points_to): Rewrite to use shared bitmap hashtable. + (init_alias_vars): Init shared bitmap hashtable. + (delete_points_to_sets): Delete shared bitmap hashtable. + +2007-07-23 Bernd Schmidt + + * reload1.c (choose_reload_regs): Set reload_spill_index for regs + chosen during find_reloads. + 2007-07-19 Release Manager * GCC 4.2.1 released. Modified: head/contrib/gcc/DATESTAMP ============================================================================== --- head/contrib/gcc/DATESTAMP Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/DATESTAMP Tue Mar 29 20:53:51 2011 (r220150) @@ -1 +1 @@ -20070719 +20070831 Modified: head/contrib/gcc/DEV-PHASE ============================================================================== --- head/contrib/gcc/DEV-PHASE Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/DEV-PHASE Tue Mar 29 20:53:51 2011 (r220150) @@ -0,0 +1 @@ +prerelease Modified: head/contrib/gcc/config/mips/predicates.md ============================================================================== --- head/contrib/gcc/config/mips/predicates.md Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/config/mips/predicates.md Tue Mar 29 20:53:51 2011 (r220150) @@ -116,7 +116,9 @@ /* If -mlong-calls, force all calls to use register addressing. Also, if this function has the long_call attribute, we must use register addressing. */ - return !TARGET_LONG_CALLS && !SYMBOL_REF_LONG_CALL_P (op); + return (!TARGET_LONG_CALLS + && !(GET_CODE (op) == SYMBOL_REF + && SYMBOL_REF_LONG_CALL_P (op))); case SYMBOL_GOT_GLOBAL: /* Without explicit relocs, there is no special syntax for Modified: head/contrib/gcc/config/rs6000/rs6000.c ============================================================================== --- head/contrib/gcc/config/rs6000/rs6000.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/config/rs6000/rs6000.c Tue Mar 29 20:53:51 2011 (r220150) @@ -664,6 +664,7 @@ static int rs6000_use_sched_lookahead (v static tree rs6000_builtin_mask_for_load (void); static void def_builtin (int, const char *, tree, int); +static bool rs6000_vector_alignment_reachable (tree, bool); static void rs6000_init_builtins (void); static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx); static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx); @@ -915,6 +916,9 @@ static const char alt_reg_names[][8] = #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load +#undef TARGET_VECTOR_ALIGNMENT_REACHABLE +#define TARGET_VECTOR_ALIGNMENT_REACHABLE rs6000_vector_alignment_reachable + #undef TARGET_INIT_BUILTINS #define TARGET_INIT_BUILTINS rs6000_init_builtins @@ -1584,6 +1588,37 @@ rs6000_builtin_mask_for_load (void) return 0; } + +/* Return true iff, data reference of TYPE can reach vector alignment (16) + after applying N number of iterations. This routine does not determine + how may iterations are required to reach desired alignment. */ + +static bool +rs6000_vector_alignment_reachable (tree type ATTRIBUTE_UNUSED, bool is_packed) +{ + if (is_packed) + return false; + + if (TARGET_32BIT) + { + if (rs6000_alignment_flags == MASK_ALIGN_NATURAL) + return true; + + if (rs6000_alignment_flags == MASK_ALIGN_POWER) + return true; + + return false; + } + else + { + if (TARGET_MACHO) + return false; + + /* Assuming that all other types are naturally aligned. CHECKME! */ + return true; + } +} + /* Handle generic options of the form -mfoo=yes/no. NAME is the option name. VALUE is the option value. Modified: head/contrib/gcc/config/s390/s390.md ============================================================================== --- head/contrib/gcc/config/s390/s390.md Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/config/s390/s390.md Tue Mar 29 20:53:51 2011 (r220150) @@ -1500,7 +1500,7 @@ && !s_operand (operands[1], VOIDmode)" [(set (match_dup 0) (match_dup 1))] { - rtx addr = operand_subword (operands[0], 1, 0, DFmode); + rtx addr = operand_subword (operands[0], 1, 0, TFmode); s390_load_address (addr, XEXP (operands[1], 0)); operands[1] = replace_equiv_address (operands[1], addr); }) @@ -5624,7 +5624,7 @@ "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT" "@ xgr\t%0,%2 - xr\t%0,%2" + xg\t%0,%2" [(set_attr "op_type" "RRE,RXY")]) (define_insn "*xordi3_extimm" Modified: head/contrib/gcc/cp/ChangeLog ============================================================================== --- head/contrib/gcc/cp/ChangeLog Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/ChangeLog Tue Mar 29 20:53:51 2011 (r220150) @@ -1,3 +1,66 @@ +2007-08-24 Jakub Jelinek + + PR c++/31941 + * error.c (resolve_virtual_fun_from_obj_type_ref): Handle + TARGET_VTABLE_USES_DESCRIPTORS targets properly. + + PR c++/32898 + * name-lookup.c (set_decl_namespace): lookup_qualified_name failure + is error_mark_node rather than NULL_TREE. + * pt.c (check_explicit_specialization): Likewise. + +2007-08-22 Jason Merrill + + PR c++/29365 + * pt.c (outermost_tinst_level): New function. + * lex.c (in_main_input_context): New function. + * cp-tree.h: Declare it. + * decl2.c (constrain_class_visibility): Use it to avoid warning + about uses of the anonymous namespace in the main input file. + +2007-08-20 Jakub Jelinek + + PR c++/32992 + * typeck.c (check_return_expr): Don't NRV optimize vars in + anonymous unions. + * decl.c (finish_function): Comment fix. + +2007-08-18 Paolo Carlini + + PR c++/32112 + * error.c (dump_decl): Deal with UNBOUND_CLASS_TEMPLATE. + * cxx-pretty-print.c (pp_cxx_unqualified_id): Likewise. + +2007-08-10 Paolo Carlini + + PR c++/17763 + * error.c (dump_expr): Consistently use the *_cxx_* + variants of the pretty-print functions. + +2007-07-30 Paolo Carlini + + PR c++/32108 + * semantics.c (finish_label_stmt): Reject the __label__ + extension outside function scopes. + +2007-07-28 Simon Martin + Mark Mitchell + + PR c++/30917 + * name-lookup.c (lookup_name_real): Non namespace-scope bindings can be + hidden due to friend declarations in local classes. + +2007-07-27 Mark Mitchell + + PR c++/32346 + * call.c (convert_for_arg_passing): Only widen bitfields to their + declared types if necessary. + +2007-07-24 Paolo Carlini + + PR c++/30535 + * pt.c (unify): Never pass error_mark_node to template_decl_level. + 2007-07-19 Release Manager * GCC 4.2.1 released. Modified: head/contrib/gcc/cp/call.c ============================================================================== --- head/contrib/gcc/cp/call.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/call.c Tue Mar 29 20:53:51 2011 (r220150) @@ -4674,7 +4674,27 @@ type_passed_as (tree type) tree convert_for_arg_passing (tree type, tree val) { - val = convert_bitfield_to_declared_type (val); + tree bitfield_type; + + /* If VAL is a bitfield, then -- since it has already been converted + to TYPE -- it cannot have a precision greater than TYPE. + + If it has a smaller precision, we must widen it here. For + example, passing "int f:3;" to a function expecting an "int" will + not result in any conversion before this point. + + If the precision is the same we must not risk widening. For + example, the COMPONENT_REF for a 32-bit "long long" bitfield will + often have type "int", even though the C++ type for the field is + "long long". If the value is being passed to a function + expecting an "int", then no conversions will be required. But, + if we call convert_bitfield_to_declared_type, the bitfield will + be converted to "long long". */ + bitfield_type = is_bitfield_expr_with_lowered_type (val); + if (bitfield_type + && TYPE_PRECISION (TREE_TYPE (val)) < TYPE_PRECISION (type)) + val = convert_to_integer (TYPE_MAIN_VARIANT (bitfield_type), val); + if (val == error_mark_node) ; /* Pass classes with copy ctors by invisible reference. */ Modified: head/contrib/gcc/cp/cp-tree.h ============================================================================== --- head/contrib/gcc/cp/cp-tree.h Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/cp-tree.h Tue Mar 29 20:53:51 2011 (r220150) @@ -4079,6 +4079,7 @@ extern void yyerror (const char *); extern void yyhook (int); extern bool cxx_init (void); extern void cxx_finish (void); +extern bool in_main_input_context (void); /* in method.c */ extern void init_method (void); @@ -4161,6 +4162,7 @@ extern tree build_non_dependent_args (t extern bool reregister_specialization (tree, tree, tree); extern tree fold_non_dependent_expr (tree); extern bool explicit_class_specialization_p (tree); +extern tree outermost_tinst_level (void); /* in repo.c */ extern void init_repo (void); Modified: head/contrib/gcc/cp/cxx-pretty-print.c ============================================================================== --- head/contrib/gcc/cp/cxx-pretty-print.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/cxx-pretty-print.c Tue Mar 29 20:53:51 2011 (r220150) @@ -204,6 +204,10 @@ pp_cxx_unqualified_id (cxx_pretty_printe pp_cxx_unqualified_id (pp, TEMPLATE_PARM_DECL (t)); break; + case UNBOUND_CLASS_TEMPLATE: + pp_cxx_unqualified_id (pp, TYPE_NAME (t)); + break; + default: pp_unsupported_tree (pp, t); break; Modified: head/contrib/gcc/cp/decl.c ============================================================================== --- head/contrib/gcc/cp/decl.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/decl.c Tue Mar 29 20:53:51 2011 (r220150) @@ -11273,7 +11273,7 @@ finish_function (int flags) gcc_assert (stmts_are_full_exprs_p ()); /* Set up the named return value optimization, if we can. Candidate - variables are selected in check_return_value. */ + variables are selected in check_return_expr. */ if (current_function_return_value) { tree r = current_function_return_value; Modified: head/contrib/gcc/cp/decl2.c ============================================================================== --- head/contrib/gcc/cp/decl2.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/decl2.c Tue Mar 29 20:53:51 2011 (r220150) @@ -1860,9 +1860,12 @@ constrain_class_visibility (tree type) int subvis = type_visibility (ftype); if (subvis == VISIBILITY_ANON) - warning (0, "\ + { + if (!in_main_input_context ()) + warning (0, "\ %qT has a field %qD whose type uses the anonymous namespace", type, t); + } else if (IS_AGGR_TYPE (ftype) && vis < VISIBILITY_HIDDEN && subvis >= VISIBILITY_HIDDEN) @@ -1877,9 +1880,12 @@ constrain_class_visibility (tree type) int subvis = type_visibility (TREE_TYPE (t)); if (subvis == VISIBILITY_ANON) - warning (0, "\ + { + if (!in_main_input_context()) + warning (0, "\ %qT has a base %qT whose type uses the anonymous namespace", type, TREE_TYPE (t)); + } else if (vis < VISIBILITY_HIDDEN && subvis >= VISIBILITY_HIDDEN) warning (OPT_Wattributes, "\ Modified: head/contrib/gcc/cp/error.c ============================================================================== --- head/contrib/gcc/cp/error.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/error.c Tue Mar 29 20:53:51 2011 (r220150) @@ -901,6 +901,10 @@ dump_decl (tree t, int flags) pp_type_id (cxx_pp, t); break; + case UNBOUND_CLASS_TEMPLATE: + dump_type (t, flags); + break; + default: pp_unsupported_tree (cxx_pp, t); /* Fall through to error. */ @@ -1301,10 +1305,14 @@ static tree resolve_virtual_fun_from_obj_type_ref (tree ref) { tree obj_type = TREE_TYPE (OBJ_TYPE_REF_OBJECT (ref)); - int index = tree_low_cst (OBJ_TYPE_REF_TOKEN (ref), 1); + HOST_WIDE_INT index = tree_low_cst (OBJ_TYPE_REF_TOKEN (ref), 1); tree fun = BINFO_VIRTUALS (TYPE_BINFO (TREE_TYPE (obj_type))); - while (index--) + while (index) + { fun = TREE_CHAIN (fun); + index -= (TARGET_VTABLE_USES_DESCRIPTORS + ? TARGET_VTABLE_USES_DESCRIPTORS : 1); + } return BV_FN (fun); } @@ -1420,13 +1428,13 @@ dump_expr (tree t, int flags) if (TREE_CODE (ob) == ADDR_EXPR) { dump_expr (TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS); - pp_dot (cxx_pp); + pp_cxx_dot (cxx_pp); } else if (TREE_CODE (ob) != PARM_DECL || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this")) { dump_expr (ob, flags | TFF_EXPR_IN_PARENS); - pp_arrow (cxx_pp); + pp_cxx_arrow (cxx_pp); } args = TREE_CHAIN (args); } Modified: head/contrib/gcc/cp/lex.c ============================================================================== --- head/contrib/gcc/cp/lex.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/lex.c Tue Mar 29 20:53:51 2011 (r220150) @@ -827,3 +827,18 @@ make_aggr_type (enum tree_code code) return t; } + +/* Returns true if we are currently in the main source file, or in a + template instantiation started from the main source file. */ + +bool +in_main_input_context (void) +{ + tree tl = outermost_tinst_level(); + + if (tl) + return strcmp (main_input_filename, + LOCATION_FILE (TINST_LOCATION (tl))) == 0; + else + return strcmp (main_input_filename, input_filename) == 0; +} Modified: head/contrib/gcc/cp/name-lookup.c ============================================================================== --- head/contrib/gcc/cp/name-lookup.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/name-lookup.c Tue Mar 29 20:53:51 2011 (r220150) @@ -2924,7 +2924,7 @@ set_decl_namespace (tree decl, tree scop /* See whether this has been declared in the namespace. */ old = lookup_qualified_name (scope, DECL_NAME (decl), false, true); - if (!old) + if (old == error_mark_node) /* No old declaration at all. */ goto complain; if (!is_overloaded_fn (decl)) @@ -3996,8 +3996,49 @@ lookup_name_real (tree name, int prefer_ if (binding) { - /* Only namespace-scope bindings can be hidden. */ - gcc_assert (!hidden_name_p (binding)); + if (hidden_name_p (binding)) + { + /* A non namespace-scope binding can only be hidden if + we are in a local class, due to friend declarations. + In particular, consider: + + void f() { + struct A { + friend struct B; + void g() { B* b; } // error: B is hidden + } + struct B {}; + } + + The standard says that "B" is a local class in "f" + (but not nested within "A") -- but that name lookup + for "B" does not find this declaration until it is + declared directly with "f". + + In particular: + + [class.friend] + + If a friend declaration appears in a local class and + the name specified is an unqualified name, a prior + declaration is looked up without considering scopes + that are outside the innermost enclosing non-class + scope. For a friend class declaration, if there is no + prior declaration, the class that is specified + belongs to the innermost enclosing non-class scope, + but if it is subsequently referenced, its name is not + found by name lookup until a matching declaration is + provided in the innermost enclosing nonclass scope. + */ + gcc_assert (current_class_type && + LOCAL_CLASS_P (current_class_type)); + + /* This binding comes from a friend declaration in the local + class. The standard (11.4.8) states that the lookup can + only succeed if there is a non-hidden declaration in the + current scope, which is not the case here. */ + POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE); + } val = binding; break; } Modified: head/contrib/gcc/cp/pt.c ============================================================================== --- head/contrib/gcc/cp/pt.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/pt.c Tue Mar 29 20:53:51 2011 (r220150) @@ -1971,7 +1971,7 @@ check_explicit_specialization (tree decl context. */ fns = lookup_qualified_name (CP_DECL_CONTEXT (decl), dname, false, true); - if (!fns || !is_overloaded_fn (fns)) + if (fns == error_mark_node || !is_overloaded_fn (fns)) { error ("%qD is not a template function", dname); fns = error_mark_node; @@ -5288,6 +5288,15 @@ reopen_tinst_level (tree level) pop_tinst_level (); } +/* Returns the TINST_LEVEL which gives the original instantiation + context. */ + +tree +outermost_tinst_level (void) +{ + return tree_last (current_tinst_level); +} + /* DECL is a friend FUNCTION_DECL or TEMPLATE_DECL. ARGS is the vector of template arguments, as for tsubst. @@ -10453,6 +10462,8 @@ unify (tree tparms, tree targs, tree par case TEMPLATE_TEMPLATE_PARM: case BOUND_TEMPLATE_TEMPLATE_PARM: tparm = TREE_VALUE (TREE_VEC_ELT (tparms, 0)); + if (tparm == error_mark_node) + return 1; if (TEMPLATE_TYPE_LEVEL (parm) != template_decl_level (tparm)) Modified: head/contrib/gcc/cp/semantics.c ============================================================================== --- head/contrib/gcc/cp/semantics.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/semantics.c Tue Mar 29 20:53:51 2011 (r220150) @@ -1320,8 +1320,13 @@ finish_label_stmt (tree name) void finish_label_decl (tree name) { - tree decl = declare_local_label (name); - add_decl_expr (decl); + if (!at_function_scope_p ()) + { + error ("__label__ declarations are only allowed in function scopes"); + return; + } + + add_decl_expr (declare_local_label (name)); } /* When DECL goes out of scope, make sure that CLEANUP is executed. */ Modified: head/contrib/gcc/cp/typeck.c ============================================================================== --- head/contrib/gcc/cp/typeck.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/typeck.c Tue Mar 29 20:53:51 2011 (r220150) @@ -6604,6 +6604,7 @@ check_return_expr (tree retval, bool *no && TREE_CODE (retval) == VAR_DECL && DECL_CONTEXT (retval) == current_function_decl && ! TREE_STATIC (retval) + && ! DECL_ANON_UNION_VAR_P (retval) && (DECL_ALIGN (retval) >= DECL_ALIGN (DECL_RESULT (current_function_decl))) && same_type_p ((TYPE_MAIN_VARIANT Modified: head/contrib/gcc/doc/contrib.texi ============================================================================== --- head/contrib/gcc/doc/contrib.texi Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/doc/contrib.texi Tue Mar 29 20:53:51 2011 (r220150) @@ -514,6 +514,10 @@ patches. Robert Lipe for OpenServer support, new testsuites, testing, etc. @item +Chen Liqin for various S+core related fixes/improvement, and for +maintaining the S+core port. + +@item Weiwen Liu for testing and various bug fixes. @item Modified: head/contrib/gcc/dwarf2out.c ============================================================================== --- head/contrib/gcc/dwarf2out.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/dwarf2out.c Tue Mar 29 20:53:51 2011 (r220150) @@ -10065,6 +10065,43 @@ rtl_for_decl_init (tree init, tree type) else if (initializer_constant_valid_p (init, type) && ! walk_tree (&init, reference_to_unused, NULL, NULL)) { + /* Convert vector CONSTRUCTOR initializers to VECTOR_CST if + possible. */ + if (TREE_CODE (type) == VECTOR_TYPE) + switch (TREE_CODE (init)) + { + case VECTOR_CST: + break; + case CONSTRUCTOR: + if (TREE_CONSTANT (init)) + { + VEC(constructor_elt,gc) *elts = CONSTRUCTOR_ELTS (init); + bool constant_p = true; + tree value; + unsigned HOST_WIDE_INT ix; + + /* Even when ctor is constant, it might contain non-*_CST + elements (e.g. { 1.0/0.0 - 1.0/0.0, 0.0 }) and those don't + belong into VECTOR_CST nodes. */ + FOR_EACH_CONSTRUCTOR_VALUE (elts, ix, value) + if (!CONSTANT_CLASS_P (value)) + { + constant_p = false; + break; + } + + if (constant_p) + { + init = build_vector_from_ctor (type, elts); + break; + } + } + /* FALLTHRU */ + + default: + return NULL; + } + rtl = expand_expr (init, NULL_RTX, VOIDmode, EXPAND_INITIALIZER); /* If expand_expr returns a MEM, it wasn't immediate. */ @@ -13197,7 +13234,8 @@ gen_decl_die (tree decl, dw_die_ref cont was generated within the original definition of an inline function) we have to generate a special (abbreviated) DW_TAG_structure_type, DW_TAG_union_type, or DW_TAG_enumeration_type DIE here. */ - if (TYPE_DECL_IS_STUB (decl) && decl_ultimate_origin (decl) != NULL_TREE) + if (TYPE_DECL_IS_STUB (decl) && decl_ultimate_origin (decl) != NULL_TREE + && is_tagged_type (TREE_TYPE (decl))) { gen_tagged_type_instantiation_die (TREE_TYPE (decl), context_die); break; Modified: head/contrib/gcc/expr.c ============================================================================== --- head/contrib/gcc/expr.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/expr.c Tue Mar 29 20:53:51 2011 (r220150) @@ -5654,7 +5654,6 @@ get_inner_reference (tree exp, HOST_WIDE enum machine_mode mode = VOIDmode; tree offset = size_zero_node; tree bit_offset = bitsize_zero_node; - tree tem; /* First get the mode, signedness, and size. We do this from just the outermost expression. */ @@ -5690,6 +5689,8 @@ get_inner_reference (tree exp, HOST_WIDE *pbitsize = tree_low_cst (size_tree, 1); } + *pmode = mode; + /* Compute cumulative bit-offset for nested component-refs and array-refs, and find the ultimate containing object. */ while (1) @@ -5774,21 +5775,69 @@ get_inner_reference (tree exp, HOST_WIDE done: /* If OFFSET is constant, see if we can return the whole thing as a - constant bit position. Otherwise, split it up. */ - if (host_integerp (offset, 0) - && 0 != (tem = size_binop (MULT_EXPR, - fold_convert (bitsizetype, offset), - bitsize_unit_node)) - && 0 != (tem = size_binop (PLUS_EXPR, tem, bit_offset)) - && host_integerp (tem, 0)) - *pbitpos = tree_low_cst (tem, 0), *poffset = 0; - else - *pbitpos = tree_low_cst (bit_offset, 0), *poffset = offset; + constant bit position. Make sure to handle overflow during + this conversion. */ + if (host_integerp (offset, 0)) + { + double_int tem = double_int_mul (tree_to_double_int (offset), + uhwi_to_double_int (BITS_PER_UNIT)); + tem = double_int_add (tem, tree_to_double_int (bit_offset)); + if (double_int_fits_in_shwi_p (tem)) + { + *pbitpos = double_int_to_shwi (tem); + *poffset = NULL_TREE; + return exp; + } + } + + /* Otherwise, split it up. */ + *pbitpos = tree_low_cst (bit_offset, 0); + *poffset = offset; - *pmode = mode; return exp; } +/* Given an expression EXP that may be a COMPONENT_REF or an ARRAY_REF, + look for whether EXP or any nested component-refs within EXP is marked + as PACKED. */ + +bool +contains_packed_reference (tree exp) +{ + bool packed_p = false; + + while (1) + { + switch (TREE_CODE (exp)) + { + case COMPONENT_REF: + { + tree field = TREE_OPERAND (exp, 1); + packed_p = DECL_PACKED (field) + || TYPE_PACKED (TREE_TYPE (field)) + || TYPE_PACKED (TREE_TYPE (exp)); + if (packed_p) + goto done; + } + break; + + case BIT_FIELD_REF: + case ARRAY_REF: + case ARRAY_RANGE_REF: + case REALPART_EXPR: + case IMAGPART_EXPR: + case VIEW_CONVERT_EXPR: + break; + + default: + goto done; + } + exp = TREE_OPERAND (exp, 0); + } + done: + return packed_p; +} + /* Return a tree of sizetype representing the size, in bytes, of the element of EXP, an ARRAY_REF. */ Modified: head/contrib/gcc/fold-const.c ============================================================================== --- head/contrib/gcc/fold-const.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/fold-const.c Tue Mar 29 20:53:51 2011 (r220150) @@ -9387,6 +9387,7 @@ fold_binary (enum tree_code code, tree t /* ~X | X is -1. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR + && INTEGRAL_TYPE_P (TREE_TYPE (arg1)) && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)) { t1 = build_int_cst (type, -1); @@ -9396,6 +9397,7 @@ fold_binary (enum tree_code code, tree t /* X | ~X is -1. */ if (TREE_CODE (arg1) == BIT_NOT_EXPR + && INTEGRAL_TYPE_P (TREE_TYPE (arg0)) && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) { t1 = build_int_cst (type, -1); @@ -9503,6 +9505,7 @@ fold_binary (enum tree_code code, tree t /* ~X ^ X is -1. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR + && INTEGRAL_TYPE_P (TREE_TYPE (arg1)) && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)) { t1 = build_int_cst (type, -1); @@ -9512,6 +9515,7 @@ fold_binary (enum tree_code code, tree t /* X ^ ~X is -1. */ if (TREE_CODE (arg1) == BIT_NOT_EXPR + && INTEGRAL_TYPE_P (TREE_TYPE (arg0)) && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) { t1 = build_int_cst (type, -1); Modified: head/contrib/gcc/gimplify.c ============================================================================== --- head/contrib/gcc/gimplify.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/gimplify.c Tue Mar 29 20:53:51 2011 (r220150) @@ -3532,8 +3532,16 @@ gimplify_modify_expr (tree *expr_p, tree gcc_assert (TREE_CODE (*expr_p) == MODIFY_EXPR || TREE_CODE (*expr_p) == INIT_EXPR); - /* For zero sized types only gimplify the left hand side and right hand side - as statements and throw away the assignment. */ + /* See if any simplifications can be done based on what the RHS is. */ + ret = gimplify_modify_expr_rhs (expr_p, from_p, to_p, pre_p, post_p, + want_value); + if (ret != GS_UNHANDLED) + return ret; + + /* For zero sized types only gimplify the left hand side and right hand + side as statements and throw away the assignment. Do this after + gimplify_modify_expr_rhs so we handle TARGET_EXPRs of addressable + types properly. */ if (zero_sized_type (TREE_TYPE (*from_p))) { gimplify_stmt (from_p); @@ -3544,12 +3552,6 @@ gimplify_modify_expr (tree *expr_p, tree return GS_ALL_DONE; } - /* See if any simplifications can be done based on what the RHS is. */ - ret = gimplify_modify_expr_rhs (expr_p, from_p, to_p, pre_p, post_p, - want_value); - if (ret != GS_UNHANDLED) - return ret; - /* If the value being copied is of variable width, compute the length of the copy into a WITH_SIZE_EXPR. Note that we need to do this before gimplifying any of the operands so that we can resolve any Modified: head/contrib/gcc/reload1.c ============================================================================== --- head/contrib/gcc/reload1.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/reload1.c Tue Mar 29 20:53:51 2011 (r220150) @@ -5451,7 +5451,14 @@ choose_reload_regs (struct insn_chain *c for (j = 0; j < n_reloads; j++) { reload_order[j] = j; - reload_spill_index[j] = -1; + if (rld[j].reg_rtx != NULL_RTX) + { + gcc_assert (REG_P (rld[j].reg_rtx) + && HARD_REGISTER_P (rld[j].reg_rtx)); + reload_spill_index[j] = REGNO (rld[j].reg_rtx); + } + else + reload_spill_index[j] = -1; if (rld[j].nregs > 1) { Modified: head/contrib/gcc/simplify-rtx.c ============================================================================== --- head/contrib/gcc/simplify-rtx.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/simplify-rtx.c Tue Mar 29 20:53:51 2011 (r220150) @@ -589,7 +589,8 @@ simplify_unary_operation_1 (enum rtx_cod /* (neg (lt x 0)) is (ashiftrt X C) if STORE_FLAG_VALUE is 1. */ /* (neg (lt x 0)) is (lshiftrt X C) if STORE_FLAG_VALUE is -1. */ if (GET_CODE (op) == LT - && XEXP (op, 1) == const0_rtx) + && XEXP (op, 1) == const0_rtx + && SCALAR_INT_MODE_P (GET_MODE (XEXP (op, 0)))) { enum machine_mode inner = GET_MODE (XEXP (op, 0)); int isize = GET_MODE_BITSIZE (inner); Modified: head/contrib/gcc/target-def.h ============================================================================== --- head/contrib/gcc/target-def.h Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/target-def.h Tue Mar 29 20:53:51 2011 (r220150) @@ -337,9 +337,12 @@ Foundation, 51 Franklin Street, Fifth Fl TARGET_SCHED_SET_SCHED_FLAGS} #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD 0 +#define TARGET_VECTOR_ALIGNMENT_REACHABLE \ + default_builtin_vector_alignment_reachable #define TARGET_VECTORIZE \ - {TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD} + {TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD, \ + TARGET_VECTOR_ALIGNMENT_REACHABLE} #define TARGET_DEFAULT_TARGET_FLAGS 0 Modified: head/contrib/gcc/target.h ============================================================================== --- head/contrib/gcc/target.h Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/target.h Tue Mar 29 20:53:51 2011 (r220150) @@ -375,6 +375,10 @@ struct gcc_target by the vectorizer, and return the decl of the target builtin function. */ tree (* builtin_mask_for_load) (void); + + /* Return true if vector alignment is reachable (by peeling N + interations) for the given type. */ + bool (* vector_alignment_reachable) (tree, bool); } vectorize; /* The initial value of target_flags. */ Modified: head/contrib/gcc/targhooks.c ============================================================================== --- head/contrib/gcc/targhooks.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/targhooks.c Tue Mar 29 20:53:51 2011 (r220150) @@ -604,4 +604,20 @@ default_reloc_rw_mask (void) return flag_pic ? 3 : 0; } +bool +default_builtin_vector_alignment_reachable (tree type, bool is_packed) +{ + if (is_packed) + return false; + + /* Assuming that types whose size is > pointer-size are not guaranteed to be + naturally aligned. */ + if (tree_int_cst_compare (TYPE_SIZE (type), bitsize_int (POINTER_SIZE)) > 0) + return false; + + /* Assuming that types whose size is <= pointer-size + are naturally aligned. */ + return true; +} + #include "gt-targhooks.h" Modified: head/contrib/gcc/targhooks.h ============================================================================== --- head/contrib/gcc/targhooks.h Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/targhooks.h Tue Mar 29 20:53:51 2011 (r220150) @@ -57,6 +57,8 @@ extern const char * default_invalid_with extern bool default_narrow_bitfield (void); +extern bool default_builtin_vector_alignment_reachable (tree, bool); + /* These are here, and not in hooks.[ch], because not all users of hooks.h include tm.h, and thus we don't have CUMULATIVE_ARGS. */ Modified: head/contrib/gcc/tree-if-conv.c ============================================================================== --- head/contrib/gcc/tree-if-conv.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/tree-if-conv.c Tue Mar 29 20:53:51 2011 (r220150) @@ -743,7 +743,7 @@ find_phi_replacement_condition (struct l if (TREE_CODE (*cond) == TRUTH_NOT_EXPR) /* We can be smart here and choose inverted condition without switching bbs. */ - *cond = invert_truthvalue (*cond); + *cond = invert_truthvalue (*cond); else /* Select non loop header bb. */ first_edge = second_edge; @@ -762,9 +762,11 @@ find_phi_replacement_condition (struct l /* Create temp. for the condition. Vectorizer prefers to have gimple value as condition. Various targets use different means to communicate - condition in vector compare operation. Using gimple value allows compiler - to emit vector compare and select RTL without exposing compare's result. */ - *cond = force_gimple_operand (*cond, &new_stmts, false, NULL_TREE); + condition in vector compare operation. Using gimple value allows + compiler to emit vector compare and select RTL without exposing + compare's result. */ + *cond = force_gimple_operand (unshare_expr (*cond), &new_stmts, + false, NULL_TREE); if (new_stmts) bsi_insert_before (bsi, new_stmts, BSI_SAME_STMT); if (!is_gimple_reg (*cond) && !is_gimple_condexpr (*cond)) Modified: head/contrib/gcc/tree-ssa-structalias.c ============================================================================== --- head/contrib/gcc/tree-ssa-structalias.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/tree-ssa-structalias.c Tue Mar 29 20:53:51 2011 (r220150) @@ -4350,6 +4350,75 @@ intra_create_variable_infos (void) process_constraint (new_constraint (lhs, rhs)); } +/* Structure used to put solution bitmaps in a hashtable so they can + be shared among variables with the same points-to set. */ + +typedef struct shared_bitmap_info +{ + bitmap pt_vars; + hashval_t hashcode; +} *shared_bitmap_info_t; + +static htab_t shared_bitmap_table; + +/* Hash function for a shared_bitmap_info_t */ + +static hashval_t +shared_bitmap_hash (const void *p) +{ + const shared_bitmap_info_t bi = (shared_bitmap_info_t) p; + return bi->hashcode; +} + +/* Equality function for two shared_bitmap_info_t's. */ + +static int +shared_bitmap_eq (const void *p1, const void *p2) +{ + const shared_bitmap_info_t sbi1 = (shared_bitmap_info_t) p1; + const shared_bitmap_info_t sbi2 = (shared_bitmap_info_t) p2; + return bitmap_equal_p (sbi1->pt_vars, sbi2->pt_vars); +} + +/* Lookup a bitmap in the shared bitmap hashtable, and return an already + existing instance if there is one, NULL otherwise. */ + +static bitmap +shared_bitmap_lookup (bitmap pt_vars) +{ + void **slot; + struct shared_bitmap_info sbi; + + sbi.pt_vars = pt_vars; + sbi.hashcode = bitmap_hash (pt_vars); + + slot = htab_find_slot_with_hash (shared_bitmap_table, &sbi, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Tue Mar 29 20:58:25 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D61C106568A; Tue, 29 Mar 2011 20:58:25 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 877E38FC2B; Tue, 29 Mar 2011 20:58:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TKwPRX040811; Tue, 29 Mar 2011 20:58:25 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TKwPL6040796; Tue, 29 Mar 2011 20:58:25 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103292058.p2TKwPL6040796@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 29 Mar 2011 20:58:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220151 - in stable/8/sbin: hastctl hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 20:58:25 -0000 Author: trociny Date: Tue Mar 29 20:58:25 2011 New Revision: 220151 URL: http://svn.freebsd.org/changeset/base/220151 Log: MFC r219351, r219354, r219369, r219370, r219371, r219372, r219373, r219385, r219482, r219620, r219669, r219721, r219813, r219814, r219815, r219816, r219817, r219818, r219821, r219830, r219831, r219832, r219833, r219837, r219844, r219864, r219873, r219879, r219882, r219884, r219887, r219900: r219351 (pjd): Allow to checksum on-the-wire data using either CRC32 or SHA256. r219354 (pjd): Allow to compress on-the-wire data using two algorithms: - HOLE - it simply turns all-zero blocks into few bytes header; it is extremely fast, so it is turned on by default; it is mostly intended to speed up initial synchronization where we expect many zeros; - LZF - very fast algorithm by Marc Alexander Lehmann, which shows very decent compression ratio and has BSD license. r219369 (pjd): Provides three states for pjdlog_initialized, so we can also tell that this is fist initialization ever. r219370 (pjd), r219385 (pjd): - Turn on printf extentions. - Load support for %T for pritning time. - Add support for %N for printing number in human readable form. - Add support for %S for printing sockaddr structure (currently only AF_INET family is supported, as this is all we need in HAST). - Disable gcc compile-time format checking as this will no longer work. r219371 (pjd): Use %S to print IP address and port number. r219372 (pjd): - Log size of data to synchronize in human readable form (using %N). - Log synchronization time (using %T). - Log synchronization speed in human readable form (using %N). r219373 (pjd): Print some of the numbers in human readable form (using %N). r219482: Make workers inherit debug level from the main process. r219620 (pjd): In command line options allow size to be specified using k/M/G/T suffixes. r219669 (pjd): Remove #include needed for debugging. r219721: For secondary, set 2 * HAST_KEEPALIVE seconds timeout for incoming connection so the worker will exit if it does not receive packets from the primary during this interval. Reported by: Christian Vogt Tested by: Christian Vogt r219813 (pjd): If there is any traffic on one of out descriptors, we were not checking for long running hooks. Fix it by not using select(2) timeout to decide if we want to check hooks or not. r219814 (pjd): When creating connection on behalf of primary worker, set pjdlog prefix to resource name and role, so that any logs related to that can be identified properly. r219815 (pjd): Add snprlcat() and vsnprlcat() - the functions I'm always missing. They work as a combination of snprintf(3) and strlcat(3) - the caller can append a string build based on the given format. r219816 (pjd): Use snprlcat() instead of two strlcat(3)s. r219817 (pjd): Log when we start hooks checking and when we execute a hook. r219818 (pjd), r219821 (pjd): In hast.conf we define the other node's address in 'remote' variable. This way we know how to connect to secondary node when we are primary. The same variable is used by the secondary node - it only accepts connections from the address stored in 'remote' variable. In cluster configurations it is common that each node has its individual IP address and there is one addtional shared IP address which is assigned to primary node. It seems it is possible that if the shared IP address is from the same network as the individual IP address it might be choosen by the kernel as a source address for connection with the secondary node. Such connection will be rejected by secondary, as it doesn't come from primary node individual IP. Add 'source' variable that allows to specify source IP address we want to bind to before connecting to the secondary node. r219821 (pjd): Forgot to commit this as a part of r219818. r219830 (pjd): Detect situation where resource internal identifier differs. This means that both nodes have separately managed resources that don't have the same data. r219831 (pjd): Be pedantic and free nvout before exiting. r219832 (pjd): Increase debug level of "Checking hooks." message. r219833 (pjd): Remove stale comment. Yes, it is valid to set role back to init. r219837 (pjd): Before handling any events on descriptors check signals so we can update our info about worker processes if any of them was terminated in the meantime. This fixes the problem with 'hastctl status' running from a hook called on split-brain: 1. Secondary calls a hooks and terminates. 2. Hook asks for resource status via 'hastctl status'. 3. The main hastd handles the status request by sending it to the secondary worker who is already dead, but because signals weren't checked yet he doesn't know that and we get EPIPE. r219843 (pjd): Fix typo. r219844 (pjd): Initialize localcnt on first write. This fixes assertion when we create resource, set role to primary, do no writes, then sent it to secondary and accept connection from primary. r219864 (pjd): White space cleanups. r219873 (pjd), r219873 (pjd): The proto API is a general purpose API, so don't use 'hast' in structures or function names. It can now be used outside of HAST. r219879: For requests that are sent only to remote component use the error from remote. r219882: After synchronization is complete we should make primary counters be equal to secondary counters: primary_localcnt = secondary_remotecnt primary_remotecnt = secondary_localcnt Previously it was done wrong and split-brain was observed after primary had synchronized up-to-date data from secondary. r219887 (pjd): Add pjd copyright. r219900 (pjd): Don't create socketpair for connection forwarding between parent and secondary. Secondary doesn't need to connect anywhere. Approved by: pjd (mentor) Added: stable/8/sbin/hastd/crc32.c - copied unchanged from r219351, head/sbin/hastd/crc32.c stable/8/sbin/hastd/crc32.h - copied unchanged from r219351, head/sbin/hastd/crc32.h stable/8/sbin/hastd/hast_checksum.c - copied unchanged from r219351, head/sbin/hastd/hast_checksum.c stable/8/sbin/hastd/hast_checksum.h - copied unchanged from r219351, head/sbin/hastd/hast_checksum.h stable/8/sbin/hastd/hast_compression.c - copied unchanged from r219354, head/sbin/hastd/hast_compression.c stable/8/sbin/hastd/hast_compression.h - copied unchanged from r219354, head/sbin/hastd/hast_compression.h stable/8/sbin/hastd/lzf.c - copied unchanged from r219354, head/sbin/hastd/lzf.c stable/8/sbin/hastd/lzf.h - copied unchanged from r219354, head/sbin/hastd/lzf.h Modified: stable/8/sbin/hastctl/Makefile stable/8/sbin/hastctl/hastctl.8 stable/8/sbin/hastctl/hastctl.c stable/8/sbin/hastd/Makefile stable/8/sbin/hastd/activemap.c stable/8/sbin/hastd/control.c stable/8/sbin/hastd/hast.conf.5 stable/8/sbin/hastd/hast.h stable/8/sbin/hastd/hast_proto.c stable/8/sbin/hastd/hastd.8 stable/8/sbin/hastd/hastd.c stable/8/sbin/hastd/hooks.c stable/8/sbin/hastd/parse.y stable/8/sbin/hastd/pjdlog.c stable/8/sbin/hastd/primary.c stable/8/sbin/hastd/proto.c stable/8/sbin/hastd/proto.h stable/8/sbin/hastd/proto_common.c stable/8/sbin/hastd/proto_impl.h stable/8/sbin/hastd/proto_socketpair.c stable/8/sbin/hastd/proto_tcp4.c stable/8/sbin/hastd/proto_uds.c stable/8/sbin/hastd/secondary.c stable/8/sbin/hastd/subr.c stable/8/sbin/hastd/subr.h stable/8/sbin/hastd/token.l Directory Properties: stable/8/sbin/hastctl/ (props changed) stable/8/sbin/hastd/ (props changed) Modified: stable/8/sbin/hastctl/Makefile ============================================================================== --- stable/8/sbin/hastctl/Makefile Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastctl/Makefile Tue Mar 29 20:58:25 2011 (r220151) @@ -6,18 +6,21 @@ PROG= hastctl SRCS= activemap.c +SRCS+= crc32.c SRCS+= ebuf.c -SRCS+= hast_proto.c hastctl.c +SRCS+= hast_checksum.c hast_compression.c hast_proto.c hastctl.c +SRCS+= lzf.c SRCS+= metadata.c SRCS+= nv.c SRCS+= parse.y pjdlog.c -SRCS+= proto.c proto_common.c proto_tcp4.c proto_uds.c +SRCS+= proto.c proto_common.c proto_uds.c SRCS+= token.l SRCS+= subr.c SRCS+= y.tab.h WARNS?= 6 MAN= hastctl.8 +NO_WFORMAT= CFLAGS+=-I${.CURDIR}/../hastd CFLAGS+=-DINET .if ${MK_INET6_SUPPORT} != "no" @@ -26,8 +29,8 @@ CFLAGS+=-DINET6 # This is needed to have WARNS > 1. CFLAGS+=-DYY_NO_UNPUT -DPADD= ${LIBL} -LDADD= -ll +DPADD= ${LIBL} ${LIBUTIL} +LDADD= -ll -lutil .if ${MK_OPENSSL} != "no" DPADD+= ${LIBCRYPTO} LDADD+= -lcrypto Modified: stable/8/sbin/hastctl/hastctl.8 ============================================================================== --- stable/8/sbin/hastctl/hastctl.8 Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastctl/hastctl.8 Tue Mar 29 20:58:25 2011 (r220151) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 1, 2010 +.Dd March 13, 2011 .Dt HASTCTL 8 .Os .Sh NAME @@ -113,6 +113,9 @@ Size of the smaller provider used as bac This option can be omitted if node providers have the same size on both sides. .El +.Pp +If size is suffixed with a k, M, G or T, it is taken as a kilobyte, +megabyte, gigabyte or terabyte measurement respectively. .It Cm role Change role of the given resource. The role can be one of: Modified: stable/8/sbin/hastctl/hastctl.c ============================================================================== --- stable/8/sbin/hastctl/hastctl.c Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastctl/hastctl.c Tue Mar 29 20:58:25 2011 (r220151) @@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include @@ -213,8 +213,10 @@ dump_one(struct hast_resource *res) return (ret); printf("resource: %s\n", res->hr_name); - printf(" datasize: %ju\n", (uintmax_t)res->hr_datasize); - printf(" extentsize: %d\n", res->hr_extentsize); + printf(" datasize: %ju (%NB)\n", (uintmax_t)res->hr_datasize, + (intmax_t)res->hr_datasize); + printf(" extentsize: %d (%NB)\n", res->hr_extentsize, + (intmax_t)res->hr_extentsize); printf(" keepdirty: %d\n", res->hr_keepdirty); printf(" localoff: %ju\n", (uintmax_t)res->hr_localoff); printf(" resuid: %ju\n", (uintmax_t)res->hr_resuid); @@ -321,47 +323,33 @@ control_status(struct nv *nv) nv_get_string(nv, "provname%u", ii)); printf(" localpath: %s\n", nv_get_string(nv, "localpath%u", ii)); - printf(" extentsize: %u\n", - (unsigned int)nv_get_uint32(nv, "extentsize%u", ii)); + printf(" extentsize: %u (%NB)\n", + (unsigned int)nv_get_uint32(nv, "extentsize%u", ii), + (intmax_t)nv_get_uint32(nv, "extentsize%u", ii)); printf(" keepdirty: %u\n", (unsigned int)nv_get_uint32(nv, "keepdirty%u", ii)); printf(" remoteaddr: %s\n", nv_get_string(nv, "remoteaddr%u", ii)); + str = nv_get_string(nv, "sourceaddr%u", ii); + if (str != NULL) + printf(" sourceaddr: %s\n", str); printf(" replication: %s\n", nv_get_string(nv, "replication%u", ii)); str = nv_get_string(nv, "status%u", ii); if (str != NULL) printf(" status: %s\n", str); - printf(" dirty: %ju bytes\n", - (uintmax_t)nv_get_uint64(nv, "dirty%u", ii)); + printf(" dirty: %ju (%NB)\n", + (uintmax_t)nv_get_uint64(nv, "dirty%u", ii), + (intmax_t)nv_get_uint64(nv, "dirty%u", ii)); } return (ret); } -static int -numfromstr(const char *str, intmax_t *nump) -{ - intmax_t num; - char *suffix; - int rerrno; - - rerrno = errno; - errno = 0; - num = strtoimax(str, &suffix, 0); - if (errno == 0 && *suffix != '\0') - errno = EINVAL; - if (errno != 0) - return (-1); - *nump = num; - errno = rerrno; - return (0); -} - int main(int argc, char *argv[]) { struct nv *nv; - intmax_t mediasize, extentsize, keepdirty; + int64_t mediasize, extentsize, keepdirty; int cmd, debug, error, ii; const char *optstr; @@ -403,15 +391,15 @@ main(int argc, char *argv[]) debug++; break; case 'e': - if (numfromstr(optarg, &extentsize) < 0) + if (expand_number(optarg, &extentsize) < 0) err(1, "Invalid extentsize"); break; case 'k': - if (numfromstr(optarg, &keepdirty) < 0) + if (expand_number(optarg, &keepdirty) < 0) err(1, "Invalid keepdirty"); break; case 'm': - if (numfromstr(optarg, &mediasize) < 0) + if (expand_number(optarg, &mediasize) < 0) err(1, "Invalid mediasize"); break; case 'h': @@ -481,7 +469,7 @@ main(int argc, char *argv[]) } /* Setup control connection... */ - if (proto_client(cfg->hc_controladdr, &controlconn) < 0) { + if (proto_client(NULL, cfg->hc_controladdr, &controlconn) < 0) { pjdlog_exit(EX_OSERR, "Unable to setup control connection to %s", cfg->hc_controladdr); Modified: stable/8/sbin/hastd/Makefile ============================================================================== --- stable/8/sbin/hastd/Makefile Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastd/Makefile Tue Mar 29 20:58:25 2011 (r220151) @@ -4,9 +4,10 @@ PROG= hastd SRCS= activemap.c -SRCS+= control.c +SRCS+= control.c crc32.c SRCS+= ebuf.c event.c -SRCS+= hast_proto.c hastd.c hooks.c +SRCS+= hast_checksum.c hast_compression.c hast_proto.c hastd.c hooks.c +SRCS+= lzf.c SRCS+= metadata.c SRCS+= nv.c SRCS+= secondary.c @@ -19,6 +20,8 @@ SRCS+= y.tab.h WARNS?= 6 MAN= hastd.8 hast.conf.5 +NO_WFORMAT= +CFLAGS+=-DPROTO_TCP4_DEFAULT_PORT=8457 CFLAGS+=-I${.CURDIR} CFLAGS+=-DINET .if ${MK_INET6_SUPPORT} != "no" Modified: stable/8/sbin/hastd/activemap.c ============================================================================== --- stable/8/sbin/hastd/activemap.c Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastd/activemap.c Tue Mar 29 20:58:25 2011 (r220151) @@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$"); #define ACTIVEMAP_MAGIC 0xac71e4 struct activemap { int am_magic; /* Magic value. */ - off_t am_mediasize; /* Media size in bytes. */ + off_t am_mediasize; /* Media size in bytes. */ uint32_t am_extentsize; /* Extent size in bytes, must be power of 2. */ uint8_t am_extentshift;/* 2 ^ extentbits == extentsize */ Modified: stable/8/sbin/hastd/control.c ============================================================================== --- stable/8/sbin/hastd/control.c Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastd/control.c Tue Mar 29 20:58:25 2011 (r220151) @@ -43,6 +43,8 @@ __FBSDID("$FreeBSD$"); #include "hast.h" #include "hastd.h" +#include "hast_checksum.h" +#include "hast_compression.h" #include "hast_proto.h" #include "hooks.h" #include "nv.h" @@ -232,6 +234,8 @@ control_status(struct hastd_config *cfg, nv_add_string(nvout, res->hr_provname, "provname%u", no); nv_add_string(nvout, res->hr_localpath, "localpath%u", no); nv_add_string(nvout, res->hr_remoteaddr, "remoteaddr%u", no); + if (res->hr_sourceaddr[0] != '\0') + nv_add_string(nvout, res->hr_sourceaddr, "sourceaddr%u", no); switch (res->hr_replication) { case HAST_REPLICATION_FULLSYNC: nv_add_string(nvout, "fullsync", "replication%u", no); @@ -246,6 +250,10 @@ control_status(struct hastd_config *cfg, nv_add_string(nvout, "unknown", "replication%u", no); break; } + nv_add_string(nvout, checksum_name(res->hr_checksum), + "checksum%u", no); + nv_add_string(nvout, compression_name(res->hr_compression), + "compression%u", no); nv_add_string(nvout, role2str(res->hr_role), "role%u", no); switch (res->hr_role) { @@ -319,7 +327,7 @@ control_handle(struct hastd_config *cfg) if (cmd == HASTCTL_SET_ROLE) { role = nv_get_uint8(nvin, "role"); switch (role) { - case HAST_ROLE_INIT: /* Is that valid to set, hmm? */ + case HAST_ROLE_INIT: case HAST_ROLE_PRIMARY: case HAST_ROLE_SECONDARY: break; Copied: stable/8/sbin/hastd/crc32.c (from r219351, head/sbin/hastd/crc32.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sbin/hastd/crc32.c Tue Mar 29 20:58:25 2011 (r220151, copy of r219351, head/sbin/hastd/crc32.c) @@ -0,0 +1,115 @@ +/*- + * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or + * code or tables extracted from it, as desired without restriction. + */ + +/* + * First, the polynomial itself and its table of feedback terms. The + * polynomial is + * X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 + * + * Note that we take it "backwards" and put the highest-order term in + * the lowest-order bit. The X^32 term is "implied"; the LSB is the + * X^31 term, etc. The X^0 term (usually shown as "+1") results in + * the MSB being 1 + * + * Note that the usual hardware shift register implementation, which + * is what we're using (we're merely optimizing it by doing eight-bit + * chunks at a time) shifts bits into the lowest-order term. In our + * implementation, that means shifting towards the right. Why do we + * do it this way? Because the calculated CRC must be transmitted in + * order from highest-order term to lowest-order term. UARTs transmit + * characters in order from LSB to MSB. By storing the CRC this way + * we hand it to the UART in the order low-byte to high-byte; the UART + * sends each low-bit to hight-bit; and the result is transmission bit + * by bit from highest- to lowest-order term without requiring any bit + * shuffling on our part. Reception works similarly + * + * The feedback terms table consists of 256, 32-bit entries. Notes + * + * The table can be generated at runtime if desired; code to do so + * is shown later. It might not be obvious, but the feedback + * terms simply represent the results of eight shift/xor opera + * tions for all combinations of data and CRC register values + * + * The values must be right-shifted by eight bits by the "updcrc + * logic; the shift must be unsigned (bring in zeroes). On some + * hardware you could probably optimize the shift in assembler by + * using byte-swap instructions + * polynomial $edb88320 + * + * + * CRC32 code derived from work by Gary S. Brown. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include + +uint32_t crc32_tab[] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, + 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, + 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, + 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, + 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, + 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, + 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, + 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, + 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, + 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, + 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, + 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, + 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, + 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, + 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, + 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, + 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, + 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d +}; + +/* + * A function that calculates the CRC-32 based on the table above is + * given below for documentation purposes. An equivalent implementation + * of this function that's actually used in the kernel can be found + * in sys/libkern.h, where it can be inlined. + * + * uint32_t + * crc32(const void *buf, size_t size) + * { + * const uint8_t *p = buf; + * uint32_t crc; + * + * crc = ~0U; + * while (size--) + * crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); + * return crc ^ ~0U; + * } + */ Copied: stable/8/sbin/hastd/crc32.h (from r219351, head/sbin/hastd/crc32.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sbin/hastd/crc32.h Tue Mar 29 20:58:25 2011 (r220151, copy of r219351, head/sbin/hastd/crc32.h) @@ -0,0 +1,28 @@ +/*- + * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or + * code or tables extracted from it, as desired without restriction. + * + * $FreeBSD$ + */ + +#ifndef _CRC32_H_ +#define _CRC32_H_ + +#include /* uint32_t */ +#include /* size_t */ + +extern uint32_t crc32_tab[]; + +static __inline uint32_t +crc32(const void *buf, size_t size) +{ + const uint8_t *p = buf; + uint32_t crc; + + crc = ~0U; + while (size--) + crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); + return (crc ^ ~0U); +} + +#endif /* !_CRC32_H_ */ Modified: stable/8/sbin/hastd/hast.conf.5 ============================================================================== --- stable/8/sbin/hastd/hast.conf.5 Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastd/hast.conf.5 Tue Mar 29 20:58:25 2011 (r220151) @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 The FreeBSD Foundation -.\" Copyright (c) 2010 Pawel Jakub Dawidek +.\" Copyright (c) 2010-2011 Pawel Jakub Dawidek .\" All rights reserved. .\" .\" This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 30, 2010 +.Dd March 20, 2011 .Dt HAST.CONF 5 .Os .Sh NAME @@ -59,6 +59,8 @@ file is following: control listen replication +checksum +compression timeout exec @@ -77,6 +79,8 @@ on { resource { # Resource section replication + checksum + compression name local timeout @@ -89,6 +93,7 @@ resource { local # Required remote + source } on { # Resource-node section @@ -97,6 +102,7 @@ resource { local # Required remote + source } } .Ed @@ -201,6 +207,36 @@ The .Ic async replication mode is currently not implemented. .El +.It Ic checksum Aq algorithm +.Pp +Checksum algorithm should be one of the following: +.Bl -tag -width ".Ic sha256" +.It Ic none +No checksum will be calculated for the data being send over the network. +This is the default setting. +.It Ic crc32 +CRC32 checksum will be calculated. +.It Ic sha256 +SHA256 checksum will be calculated. +.El +.It Ic compression Aq algorithm +.Pp +Compression algorithm should be one of the following: +.Bl -tag -width ".Ic none" +.It Ic none +Data send over the network will not be compressed. +.It Ic hole +Only blocks that contain all zeros will be compressed. +This is very useful for initial synchronization where potentially many blocks +are still all zeros. +There should be no measurable performance overhead when this algorithm is being +used. +This is the default setting. +.It Ic lzf +The LZF algorithm by Marc Alexander Lehmann will be used to compress the data +send over the network. +LZF is very fast, general purpose compression algorithm. +.El .It Ic timeout Aq seconds .Pp Connection timeout in seconds. @@ -303,6 +339,14 @@ A special value of .Va none can be used when the remote address is not yet known (eg. the other node is not set up yet). +.It Ic source Aq addr +.Pp +Local address to bind to before connecting to the remote +.Nm hastd +daemon. +Format is the same as for the +.Ic listen +statement. .El .Sh FILES .Bl -tag -width ".Pa /var/run/hastctl" -compact @@ -333,10 +377,12 @@ resource shared { resource tank { on hasta { local /dev/mirror/tanka + source tcp4://10.0.0.1 remote tcp4://10.0.0.2 } on hastb { local /dev/mirror/tankb + source tcp4://10.0.0.2 remote tcp4://10.0.0.1 } } Modified: stable/8/sbin/hastd/hast.h ============================================================================== --- stable/8/sbin/hastd/hast.h Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastd/hast.h Tue Mar 29 20:58:25 2011 (r220151) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2009-2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -85,7 +86,6 @@ #define HAST_TIMEOUT 5 #define HAST_CONFIG "/etc/hast.conf" #define HAST_CONTROL "/var/run/hastctl" -#define HASTD_PORT 8457 #define HASTD_LISTEN "tcp4://0.0.0.0:8457" #define HASTD_PIDFILE "/var/run/hastd.pid" @@ -97,6 +97,9 @@ #define HAST_ADDRSIZE 1024 #define HAST_TOKEN_SIZE 16 +/* Number of seconds to sleep between reconnect retries or keepalive packets. */ +#define HAST_KEEPALIVE 10 + struct hastd_config { /* Address to communicate with hastctl(8). */ char hc_controladdr[HAST_ADDRSIZE]; @@ -116,6 +119,14 @@ struct hastd_config { #define HAST_REPLICATION_MEMSYNC 1 #define HAST_REPLICATION_ASYNC 2 +#define HAST_COMPRESSION_NONE 0 +#define HAST_COMPRESSION_HOLE 1 +#define HAST_COMPRESSION_LZF 2 + +#define HAST_CHECKSUM_NONE 0 +#define HAST_CHECKSUM_CRC32 1 +#define HAST_CHECKSUM_SHA256 2 + /* * Structure that describes single resource. */ @@ -132,6 +143,10 @@ struct hast_resource { int hr_keepdirty; /* Path to a program to execute on various events. */ char hr_exec[PATH_MAX]; + /* Compression algorithm. */ + int hr_compression; + /* Checksum algorithm. */ + int hr_checksum; /* Path to local component. */ char hr_localpath[PATH_MAX]; @@ -153,6 +168,8 @@ struct hast_resource { /* Address of the remote component. */ char hr_remoteaddr[HAST_ADDRSIZE]; + /* Local address to bind to for outgoing connections. */ + char hr_sourceaddr[HAST_ADDRSIZE]; /* Connection for incoming data. */ struct proto_conn *hr_remotein; /* Connection for outgoing data. */ Copied: stable/8/sbin/hastd/hast_checksum.c (from r219351, head/sbin/hastd/hast_checksum.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sbin/hastd/hast_checksum.c Tue Mar 29 20:58:25 2011 (r220151, copy of r219351, head/sbin/hastd/hast_checksum.c) @@ -0,0 +1,169 @@ +/*- + * Copyright (c) 2011 Pawel Jakub Dawidek + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#ifdef HAVE_CRYPTO +#include +#endif + +#include +#include +#include +#include + +#include "hast_checksum.h" + +#ifdef HAVE_CRYPTO +#define MAX_HASH_SIZE SHA256_DIGEST_LENGTH +#else +#define MAX_HASH_SIZE 4 +#endif + +static int +hast_crc32_checksum(const unsigned char *data, size_t size, + unsigned char *hash, size_t *hsizep) +{ + uint32_t crc; + + crc = crc32(data, size); + /* XXXPJD: Do we have to use htole32() on crc first? */ + bcopy(&crc, hash, sizeof(crc)); + *hsizep = sizeof(crc); + + return (0); +} + +#ifdef HAVE_CRYPTO +static int +hast_sha256_checksum(const unsigned char *data, size_t size, + unsigned char *hash, size_t *hsizep) +{ + SHA256_CTX ctx; + + SHA256_Init(&ctx); + SHA256_Update(&ctx, data, size); + SHA256_Final(hash, &ctx); + *hsizep = SHA256_DIGEST_LENGTH; + + return (0); +} +#endif /* HAVE_CRYPTO */ + +const char * +checksum_name(int num) +{ + + switch (num) { + case HAST_CHECKSUM_NONE: + return ("none"); + case HAST_CHECKSUM_CRC32: + return ("crc32"); + case HAST_CHECKSUM_SHA256: + return ("sha256"); + } + return ("unknown"); +} + +int +checksum_send(const struct hast_resource *res, struct nv *nv, void **datap, + size_t *sizep, bool *freedatap __unused) +{ + unsigned char hash[MAX_HASH_SIZE]; + size_t hsize; + int ret; + + switch (res->hr_checksum) { + case HAST_CHECKSUM_NONE: + return (0); + case HAST_CHECKSUM_CRC32: + ret = hast_crc32_checksum(*datap, *sizep, hash, &hsize); + break; +#ifdef HAVE_CRYPTO + case HAST_CHECKSUM_SHA256: + ret = hast_sha256_checksum(*datap, *sizep, hash, &hsize); + break; +#endif + default: + PJDLOG_ABORT("Invalid checksum: %d.", res->hr_checksum); + } + + if (ret != 0) + return (ret); + nv_add_string(nv, checksum_name(res->hr_checksum), "checksum"); + nv_add_uint8_array(nv, hash, hsize, "hash"); + if (nv_error(nv) != 0) { + errno = nv_error(nv); + return (-1); + } + return (0); +} + +int +checksum_recv(const struct hast_resource *res __unused, struct nv *nv, + void **datap, size_t *sizep, bool *freedatap __unused) +{ + unsigned char chash[MAX_HASH_SIZE]; + const unsigned char *rhash; + size_t chsize, rhsize; + const char *algo; + int ret; + + algo = nv_get_string(nv, "checksum"); + if (algo == NULL) + return (0); /* No checksum. */ + rhash = nv_get_uint8_array(nv, &rhsize, "hash"); + if (rhash == NULL) { + pjdlog_error("Hash is missing."); + return (-1); /* Hash not found. */ + } + if (strcmp(algo, "crc32") == 0) + ret = hast_crc32_checksum(*datap, *sizep, chash, &chsize); +#ifdef HAVE_CRYPTO + else if (strcmp(algo, "sha256") == 0) + ret = hast_sha256_checksum(*datap, *sizep, chash, &chsize); +#endif + else { + pjdlog_error("Unknown checksum algorithm '%s'.", algo); + return (-1); /* Unknown checksum algorithm. */ + } + if (rhsize != chsize) { + pjdlog_error("Invalid hash size (%zu) for %s, should be %zu.", + rhsize, algo, chsize); + return (-1); /* Different hash size. */ + } + if (bcmp(rhash, chash, chsize) != 0) { + pjdlog_error("Hash mismatch."); + return (-1); /* Hash mismatch. */ + } + + return (0); +} Copied: stable/8/sbin/hastd/hast_checksum.h (from r219351, head/sbin/hastd/hast_checksum.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sbin/hastd/hast_checksum.h Tue Mar 29 20:58:25 2011 (r220151, copy of r219351, head/sbin/hastd/hast_checksum.h) @@ -0,0 +1,44 @@ +/*- + * Copyright (c) 2011 Pawel Jakub Dawidek + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _HAST_CHECKSUM_H_ +#define _HAST_CHECKSUM_H_ + +#include /* size_t */ + +#include +#include + +const char *checksum_name(int num); + +int checksum_send(const struct hast_resource *res, struct nv *nv, + void **datap, size_t *sizep, bool *freedatap); +int checksum_recv(const struct hast_resource *res, struct nv *nv, + void **datap, size_t *sizep, bool *freedatap); + +#endif /* !_HAST_CHECKSUM_H_ */ Copied: stable/8/sbin/hastd/hast_compression.c (from r219354, head/sbin/hastd/hast_compression.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sbin/hastd/hast_compression.c Tue Mar 29 20:58:25 2011 (r220151, copy of r219354, head/sbin/hastd/hast_compression.c) @@ -0,0 +1,283 @@ +/*- + * Copyright (c) 2011 Pawel Jakub Dawidek + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include "hast_compression.h" + +static bool +allzeros(const void *data, size_t size) +{ + const uint64_t *p = data; + unsigned int i; + uint64_t v; + + PJDLOG_ASSERT((size % sizeof(*p)) == 0); + + /* + * This is the fastest method I found for checking if the given + * buffer contain all zeros. + * Because inside the loop we don't check at every step, we would + * get an answer only after walking through entire buffer. + * To return early if the buffer doesn't contain all zeros, we probe + * 8 bytes at the begining, in the middle and at the end of the buffer + * first. + */ + + size >>= 3; /* divide by 8 */ + if ((p[0] | p[size >> 1] | p[size - 1]) != 0) + return (false); + v = 0; + for (i = 0; i < size; i++) + v |= *p++; + return (v == 0); +} + +static void * +hast_hole_compress(const unsigned char *data, size_t *sizep) +{ + uint32_t size; + void *newbuf; + + if (!allzeros(data, *sizep)) + return (NULL); + + newbuf = malloc(sizeof(size)); + if (newbuf == NULL) { + pjdlog_warning("Unable to compress (no memory: %zu).", + (size_t)*sizep); + return (NULL); + } + size = htole32((uint32_t)*sizep); + bcopy(&size, newbuf, sizeof(size)); + *sizep = sizeof(size); + + return (newbuf); +} + +static void * +hast_hole_decompress(const unsigned char *data, size_t *sizep) +{ + uint32_t size; + void *newbuf; + + if (*sizep != sizeof(size)) { + pjdlog_error("Unable to decompress (invalid size: %zu).", + *sizep); + return (NULL); + } + + bcopy(data, &size, sizeof(size)); + size = le32toh(size); + + newbuf = malloc(size); + if (newbuf == NULL) { + pjdlog_error("Unable to decompress (no memory: %zu).", + (size_t)size); + return (NULL); + } + bzero(newbuf, size); + *sizep = size; + + return (newbuf); +} + +/* Minimum block size to try to compress. */ +#define HAST_LZF_COMPRESS_MIN 1024 + +static void * +hast_lzf_compress(const unsigned char *data, size_t *sizep) +{ + unsigned char *newbuf; + uint32_t origsize; + size_t newsize; + + origsize = *sizep; + + if (origsize <= HAST_LZF_COMPRESS_MIN) + return (NULL); + + newsize = sizeof(origsize) + origsize - HAST_LZF_COMPRESS_MIN; + newbuf = malloc(newsize); + if (newbuf == NULL) { + pjdlog_warning("Unable to compress (no memory: %zu).", + newsize); + return (NULL); + } + newsize = lzf_compress(data, *sizep, newbuf + sizeof(origsize), + newsize - sizeof(origsize)); + if (newsize == 0) { + free(newbuf); + return (NULL); + } + origsize = htole32(origsize); + bcopy(&origsize, newbuf, sizeof(origsize)); + + *sizep = sizeof(origsize) + newsize; + return (newbuf); +} + +static void * +hast_lzf_decompress(const unsigned char *data, size_t *sizep) +{ + unsigned char *newbuf; + uint32_t origsize; + size_t newsize; + + PJDLOG_ASSERT(*sizep > sizeof(origsize)); + + bcopy(data, &origsize, sizeof(origsize)); + origsize = le32toh(origsize); + PJDLOG_ASSERT(origsize > HAST_LZF_COMPRESS_MIN); + + newbuf = malloc(origsize); + if (newbuf == NULL) { + pjdlog_error("Unable to decompress (no memory: %zu).", + (size_t)origsize); + return (NULL); + } + newsize = lzf_decompress(data + sizeof(origsize), + *sizep - sizeof(origsize), newbuf, origsize); + if (newsize == 0) { + free(newbuf); + pjdlog_error("Unable to decompress."); + return (NULL); + } + PJDLOG_ASSERT(newsize == origsize); + + *sizep = newsize; + return (newbuf); +} + +const char * +compression_name(int num) +{ + + switch (num) { + case HAST_COMPRESSION_NONE: + return ("none"); + case HAST_COMPRESSION_HOLE: + return ("hole"); + case HAST_COMPRESSION_LZF: + return ("lzf"); + } + return ("unknown"); +} + +int +compression_send(const struct hast_resource *res, struct nv *nv, void **datap, + size_t *sizep, bool *freedatap) +{ + unsigned char *newbuf; + int compression; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 01:10:12 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1F9BA1065670; Wed, 30 Mar 2011 01:10:12 +0000 (UTC) (envelope-from zack@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E8EE48FC0C; Wed, 30 Mar 2011 01:10:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2U1ABTK046033; Wed, 30 Mar 2011 01:10:11 GMT (envelope-from zack@svn.freebsd.org) Received: (from zack@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2U1ABB1046030; Wed, 30 Mar 2011 01:10:11 GMT (envelope-from zack@svn.freebsd.org) Message-Id: <201103300110.p2U1ABB1046030@svn.freebsd.org> From: Zack Kirsch Date: Wed, 30 Mar 2011 01:10:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220152 - head/sys/fs/nfsclient X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 01:10:12 -0000 Author: zack Date: Wed Mar 30 01:10:11 2011 New Revision: 220152 URL: http://svn.freebsd.org/changeset/base/220152 Log: This patch fixes the Experimental NFS client to properly deal with 32 bit or 64 bit fileid's in NFSv2 and NFSv3. Without this fix, invalid casting (and sign extension) was creating problems for any fileid greater than 2^31. We discovered this because we have test clusters with more than 2 billion allocated files and 64-bit ino_t's (and friend structures). Reviewed by: rmacklem Approved by: zml (mentor) MFC after: 2 weeks Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c head/sys/fs/nfsclient/nfs_clrpcops.c Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clcomsubs.c Tue Mar 29 20:58:25 2011 (r220151) +++ head/sys/fs/nfsclient/nfs_clcomsubs.c Wed Mar 30 01:10:11 2011 (r220152) @@ -289,8 +289,7 @@ nfsm_loadattr(struct nfsrv_descript *nd, nap->na_size = fxdr_hyper(&fp->fa3_size); nap->na_blocksize = NFS_FABLKSIZE; nap->na_bytes = fxdr_hyper(&fp->fa3_used); - nap->na_fileid = fxdr_unsigned(int32_t, - fp->fa3_fileid.nfsuquad[1]); + nap->na_fileid = fxdr_hyper(&fp->fa3_fileid); fxdr_nfsv3time(&fp->fa3_atime, &nap->na_atime); fxdr_nfsv3time(&fp->fa3_ctime, &nap->na_ctime); fxdr_nfsv3time(&fp->fa3_mtime, &nap->na_mtime); @@ -317,7 +316,7 @@ nfsm_loadattr(struct nfsrv_descript *nd, nap->na_bytes = (u_quad_t)fxdr_unsigned(int32_t, fp->fa2_blocks) * NFS_FABLKSIZE; - nap->na_fileid = fxdr_unsigned(int32_t, fp->fa2_fileid); + nap->na_fileid = fxdr_unsigned(uint64_t, fp->fa2_fileid); fxdr_nfsv2time(&fp->fa2_atime, &nap->na_atime); fxdr_nfsv2time(&fp->fa2_mtime, &nap->na_mtime); nap->na_flags = 0; Modified: head/sys/fs/nfsclient/nfs_clrpcops.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clrpcops.c Tue Mar 29 20:58:25 2011 (r220151) +++ head/sys/fs/nfsclient/nfs_clrpcops.c Wed Mar 30 01:10:11 2011 (r220152) @@ -2738,9 +2738,9 @@ nfsrpc_readdir(vnode_t vp, struct uio *u len = fxdr_unsigned(int, *tl); } else if (nd->nd_flag & ND_NFSV3) { NFSM_DISSECT(tl, u_int32_t *, 3*NFSX_UNSIGNED); - nfsva.na_fileid = - fxdr_unsigned(long, *++tl); - len = fxdr_unsigned(int, *++tl); + nfsva.na_fileid = fxdr_hyper(tl); + tl += 2; + len = fxdr_unsigned(int, *tl); } else { NFSM_DISSECT(tl, u_int32_t *, 2*NFSX_UNSIGNED); nfsva.na_fileid = From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 01:19:01 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 561C0106567B; Wed, 30 Mar 2011 01:19:01 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 442CC8FC1A; Wed, 30 Mar 2011 01:19:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2U1J1xq046344; Wed, 30 Mar 2011 01:19:01 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2U1J18L046334; Wed, 30 Mar 2011 01:19:01 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201103300119.p2U1J18L046334@svn.freebsd.org> From: Ed Maste Date: Wed, 30 Mar 2011 01:19:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220153 - head/etc/rc.d X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 01:19:01 -0000 Author: emaste Date: Wed Mar 30 01:19:00 2011 New Revision: 220153 URL: http://svn.freebsd.org/changeset/base/220153 Log: Replace ${SYSCTL_W} with ${SYSCTL} in rc.d scripts, as they are identical. This is a further clean up after r202988. SYSCTL_W is still initialized in rc.subr as some ports may still use it. Modified: head/etc/rc.d/faith head/etc/rc.d/hostid head/etc/rc.d/initrandom head/etc/rc.d/ipfw head/etc/rc.d/jail head/etc/rc.d/netoptions head/etc/rc.d/routing head/etc/rc.d/securelevel Modified: head/etc/rc.d/faith ============================================================================== --- head/etc/rc.d/faith Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/faith Wed Mar 30 01:19:00 2011 (r220153) @@ -21,7 +21,7 @@ faith_up() *) echo "Configuring IPv6-to-IPv4 TCP relay capturing interface:" \ " faith0." - ${SYSCTL_W} net.inet6.ip6.keepfaith=1 + ${SYSCTL} net.inet6.ip6.keepfaith=1 ifconfig faith0 create >/dev/null 2>&1 ifconfig faith0 up for prefix in ${ipv6_faith_prefix}; do @@ -48,7 +48,7 @@ faith_down() { echo "Removing IPv6-to-IPv4 TCP relay capturing interface: faith0." ifconfig faith0 destroy - ${SYSCTL_W} net.inet6.ip6.keepfaith=0 + ${SYSCTL} net.inet6.ip6.keepfaith=0 case ${ipv6_faith_prefix} in [Nn][Oo] | '') Modified: head/etc/rc.d/hostid ============================================================================== --- head/etc/rc.d/hostid Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/hostid Wed Mar 30 01:19:00 2011 (r220153) @@ -50,9 +50,9 @@ hostid_set() # Set both kern.hostuuid and kern.hostid. # check_startmsgs && echo "Setting hostuuid: ${uuid}." - ${SYSCTL_W} kern.hostuuid="${uuid}" >/dev/null + ${SYSCTL} kern.hostuuid="${uuid}" >/dev/null check_startmsgs && echo "Setting hostid: ${id}." - ${SYSCTL_W} kern.hostid=${id} >/dev/null + ${SYSCTL} kern.hostid=${id} >/dev/null } hostid_hardware() Modified: head/etc/rc.d/initrandom ============================================================================== --- head/etc/rc.d/initrandom Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/initrandom Wed Mar 30 01:19:00 2011 (r220153) @@ -31,24 +31,24 @@ initrandom_start() if [ -w /dev/random ]; then if checkyesno harvest_interrupt; then - ${SYSCTL_W} kern.random.sys.harvest.interrupt=1 >/dev/null + ${SYSCTL} kern.random.sys.harvest.interrupt=1 >/dev/null echo -n ' interrupts' else - ${SYSCTL_W} kern.random.sys.harvest.interrupt=0 >/dev/null + ${SYSCTL} kern.random.sys.harvest.interrupt=0 >/dev/null fi if checkyesno harvest_ethernet; then - ${SYSCTL_W} kern.random.sys.harvest.ethernet=1 >/dev/null + ${SYSCTL} kern.random.sys.harvest.ethernet=1 >/dev/null echo -n ' ethernet' else - ${SYSCTL_W} kern.random.sys.harvest.ethernet=0 >/dev/null + ${SYSCTL} kern.random.sys.harvest.ethernet=0 >/dev/null fi if checkyesno harvest_p_to_p; then - ${SYSCTL_W} kern.random.sys.harvest.point_to_point=1 >/dev/null + ${SYSCTL} kern.random.sys.harvest.point_to_point=1 >/dev/null echo -n ' point_to_point' else - ${SYSCTL_W} kern.random.sys.harvest.point_to_point=0 >/dev/null + ${SYSCTL} kern.random.sys.harvest.point_to_point=0 >/dev/null fi fi Modified: head/etc/rc.d/ipfw ============================================================================== --- head/etc/rc.d/ipfw Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/ipfw Wed Mar 30 01:19:00 2011 (r220153) @@ -73,11 +73,11 @@ ipfw_poststart() # Enable the firewall # - if ! ${SYSCTL_W} net.inet.ip.fw.enable=1 1>/dev/null 2>&1; then + if ! ${SYSCTL} net.inet.ip.fw.enable=1 1>/dev/null 2>&1; then warn "failed to enable IPv4 firewall" fi if afexists inet6; then - if ! ${SYSCTL_W} net.inet6.ip6.fw.enable=1 1>/dev/null 2>&1 + if ! ${SYSCTL} net.inet6.ip6.fw.enable=1 1>/dev/null 2>&1 then warn "failed to enable IPv6 firewall" fi @@ -90,9 +90,9 @@ ipfw_stop() # Disable the firewall # - ${SYSCTL_W} net.inet.ip.fw.enable=0 + ${SYSCTL} net.inet.ip.fw.enable=0 if afexists inet6; then - ${SYSCTL_W} net.inet6.ip6.fw.enable=0 + ${SYSCTL} net.inet6.ip6.fw.enable=0 fi # Stop firewall coscripts Modified: head/etc/rc.d/jail ============================================================================== --- head/etc/rc.d/jail Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/jail Wed Mar 30 01:19:00 2011 (r220153) @@ -219,12 +219,12 @@ set_sysctl() if checkyesno $_knob ; then if [ "$_current" -ne 1 ]; then echo -n " ${_msg}=YES" - ${SYSCTL_W} 1>/dev/null ${_mib}=1 + ${SYSCTL} 1>/dev/null ${_mib}=1 fi else if [ "$_current" -ne 0 ]; then echo -n " ${_msg}=NO" - ${SYSCTL_W} 1>/dev/null ${_mib}=0 + ${SYSCTL} 1>/dev/null ${_mib}=0 fi fi } Modified: head/etc/rc.d/netoptions ============================================================================== --- head/etc/rc.d/netoptions Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/netoptions Wed Mar 30 01:19:00 2011 (r220153) @@ -40,44 +40,44 @@ netoptions_inet() [12]) netoptions_init echo -n " log_in_vain=${log_in_vain}" - ${SYSCTL_W} net.inet.tcp.log_in_vain=${log_in_vain} >/dev/null - ${SYSCTL_W} net.inet.udp.log_in_vain=${log_in_vain} >/dev/null + ${SYSCTL} net.inet.tcp.log_in_vain=${log_in_vain} >/dev/null + ${SYSCTL} net.inet.udp.log_in_vain=${log_in_vain} >/dev/null ;; *) - ${SYSCTL_W} net.inet.tcp.log_in_vain=0 >/dev/null - ${SYSCTL_W} net.inet.udp.log_in_vain=0 >/dev/null + ${SYSCTL} net.inet.tcp.log_in_vain=0 >/dev/null + ${SYSCTL} net.inet.udp.log_in_vain=0 >/dev/null ;; esac if checkyesno tcp_extensions; then - ${SYSCTL_W} net.inet.tcp.rfc1323=1 >/dev/null + ${SYSCTL} net.inet.tcp.rfc1323=1 >/dev/null else netoptions_init echo -n " rfc1323 extensions=${tcp_extensions}" - ${SYSCTL_W} net.inet.tcp.rfc1323=0 >/dev/null + ${SYSCTL} net.inet.tcp.rfc1323=0 >/dev/null fi if checkyesno tcp_keepalive; then - ${SYSCTL_W} net.inet.tcp.always_keepalive=1 >/dev/null + ${SYSCTL} net.inet.tcp.always_keepalive=1 >/dev/null else netoptions_init echo -n " TCP keepalive=${tcp_keepalive}" - ${SYSCTL_W} net.inet.tcp.always_keepalive=0 >/dev/null + ${SYSCTL} net.inet.tcp.always_keepalive=0 >/dev/null fi if checkyesno tcp_drop_synfin; then netoptions_init echo -n " drop SYN+FIN packets=${tcp_drop_synfin}" - ${SYSCTL_W} net.inet.tcp.drop_synfin=1 >/dev/null + ${SYSCTL} net.inet.tcp.drop_synfin=1 >/dev/null else - ${SYSCTL_W} net.inet.tcp.drop_synfin=0 >/dev/null + ${SYSCTL} net.inet.tcp.drop_synfin=0 >/dev/null fi case ${ip_portrange_first} in [0-9]*) netoptions_init echo -n " ip_portrange_first=$ip_portrange_first" - ${SYSCTL_W} net.inet.ip.portrange.first=$ip_portrange_first >/dev/null + ${SYSCTL} net.inet.ip.portrange.first=$ip_portrange_first >/dev/null ;; esac @@ -85,7 +85,7 @@ netoptions_inet() [0-9]*) netoptions_init echo -n " ip_portrange_last=$ip_portrange_last" - ${SYSCTL_W} net.inet.ip.portrange.last=$ip_portrange_last >/dev/null + ${SYSCTL} net.inet.ip.portrange.last=$ip_portrange_last >/dev/null ;; esac } @@ -95,16 +95,16 @@ netoptions_inet6() if checkyesno ipv6_ipv4mapping; then netoptions_init echo -n " ipv4-mapped-ipv6=${ipv6_ipv4mapping}" - ${SYSCTL_W} net.inet6.ip6.v6only=0 >/dev/null + ${SYSCTL} net.inet6.ip6.v6only=0 >/dev/null else - ${SYSCTL_W} net.inet6.ip6.v6only=1 >/dev/null + ${SYSCTL} net.inet6.ip6.v6only=1 >/dev/null fi if checkyesno ipv6_privacy; then netoptions_init echo -n " IPv6 Privacy Addresses" - ${SYSCTL_W} net.inet6.ip6.use_tempaddr=1 >/dev/null - ${SYSCTL_W} net.inet6.ip6.prefer_tempaddr=1 >/dev/null + ${SYSCTL} net.inet6.ip6.use_tempaddr=1 >/dev/null + ${SYSCTL} net.inet6.ip6.prefer_tempaddr=1 >/dev/null fi } Modified: head/etc/rc.d/routing ============================================================================== --- head/etc/rc.d/routing Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/routing Wed Mar 30 01:19:00 2011 (r220153) @@ -264,57 +264,57 @@ options_inet() if checkyesno icmp_bmcastecho; then ropts_init echo -n ' broadcast ping responses=YES' - ${SYSCTL_W} net.inet.icmp.bmcastecho=1 > /dev/null + ${SYSCTL} net.inet.icmp.bmcastecho=1 > /dev/null else - ${SYSCTL_W} net.inet.icmp.bmcastecho=0 > /dev/null + ${SYSCTL} net.inet.icmp.bmcastecho=0 > /dev/null fi if checkyesno icmp_drop_redirect; then ropts_init echo -n ' ignore ICMP redirect=YES' - ${SYSCTL_W} net.inet.icmp.drop_redirect=1 > /dev/null + ${SYSCTL} net.inet.icmp.drop_redirect=1 > /dev/null else - ${SYSCTL_W} net.inet.icmp.drop_redirect=0 > /dev/null + ${SYSCTL} net.inet.icmp.drop_redirect=0 > /dev/null fi if checkyesno icmp_log_redirect; then ropts_init echo -n ' log ICMP redirect=YES' - ${SYSCTL_W} net.inet.icmp.log_redirect=1 > /dev/null + ${SYSCTL} net.inet.icmp.log_redirect=1 > /dev/null else - ${SYSCTL_W} net.inet.icmp.log_redirect=0 > /dev/null + ${SYSCTL} net.inet.icmp.log_redirect=0 > /dev/null fi if checkyesno gateway_enable; then ropts_init echo -n ' IPv4 gateway=YES' - ${SYSCTL_W} net.inet.ip.forwarding=1 > /dev/null + ${SYSCTL} net.inet.ip.forwarding=1 > /dev/null else - ${SYSCTL_W} net.inet.ip.forwarding=0 > /dev/null + ${SYSCTL} net.inet.ip.forwarding=0 > /dev/null fi if checkyesno forward_sourceroute; then ropts_init echo -n ' do source routing=YES' - ${SYSCTL_W} net.inet.ip.sourceroute=1 > /dev/null + ${SYSCTL} net.inet.ip.sourceroute=1 > /dev/null else - ${SYSCTL_W} net.inet.ip.sourceroute=0 > /dev/null + ${SYSCTL} net.inet.ip.sourceroute=0 > /dev/null fi if checkyesno accept_sourceroute; then ropts_init echo -n ' accept source routing=YES' - ${SYSCTL_W} net.inet.ip.accept_sourceroute=1 > /dev/null + ${SYSCTL} net.inet.ip.accept_sourceroute=1 > /dev/null else - ${SYSCTL_W} net.inet.ip.accept_sourceroute=0 > /dev/null + ${SYSCTL} net.inet.ip.accept_sourceroute=0 > /dev/null fi if checkyesno arpproxy_all; then ropts_init echo -n ' ARP proxyall=YES' - ${SYSCTL_W} net.link.ether.inet.proxyall=1 > /dev/null + ${SYSCTL} net.link.ether.inet.proxyall=1 > /dev/null else - ${SYSCTL_W} net.link.ether.inet.proxyall=0 > /dev/null + ${SYSCTL} net.link.ether.inet.proxyall=0 > /dev/null fi } @@ -323,9 +323,9 @@ options_inet6() if checkyesno ipv6_gateway_enable; then ropts_init echo -n ' IPv6 gateway=YES' - ${SYSCTL_W} net.inet6.ip6.forwarding=1 > /dev/null + ${SYSCTL} net.inet6.ip6.forwarding=1 > /dev/null else - ${SYSCTL_W} net.inet6.ip6.forwarding=0 > /dev/null + ${SYSCTL} net.inet6.ip6.forwarding=0 > /dev/null fi } @@ -338,9 +338,9 @@ options_ipx() if checkyesno ipxgateway_enable; then ropts_init echo -n ' IPX gateway=YES' - ${SYSCTL_W} net.ipx.ipx.ipxforwarding=1 > /dev/null + ${SYSCTL} net.ipx.ipx.ipxforwarding=1 > /dev/null else - ${SYSCTL_W} net.ipx.ipx.ipxforwarding=0 > /dev/null + ${SYSCTL} net.ipx.ipx.ipxforwarding=0 > /dev/null fi } Modified: head/etc/rc.d/securelevel ============================================================================== --- head/etc/rc.d/securelevel Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/securelevel Wed Mar 30 01:19:00 2011 (r220153) @@ -20,7 +20,7 @@ securelevel_start() { if [ ${kern_securelevel} -ge 0 ]; then echo 'Raising kernel security level: ' - ${SYSCTL_W} kern.securelevel=${kern_securelevel} + ${SYSCTL} kern.securelevel=${kern_securelevel} fi } From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 08:07:25 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B7821065670; Wed, 30 Mar 2011 08:07:25 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 383B98FC08; Wed, 30 Mar 2011 08:07:24 +0000 (UTC) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.4/8.14.4/NETPLEX) with ESMTP id p2U7oIFt015208; Wed, 30 Mar 2011 03:50:18 -0400 X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.2.6 (mail.netplex.net [204.213.176.10]); Wed, 30 Mar 2011 03:50:18 -0400 (EDT) Date: Wed, 30 Mar 2011 03:50:18 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: John Baldwin In-Reply-To: <201103291401.03565.jhb@freebsd.org> Message-ID: References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, Randall Stewart , svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r217592 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 08:07:25 -0000 On Tue, 29 Mar 2011, John Baldwin wrote: > On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: >> Author: rrs >> Date: Wed Jan 19 19:07:16 2011 >> New Revision: 217592 >> URL: http://svn.freebsd.org/changeset/base/217592 >> >> Log: >> Fix a bug where Multicast packets sent from a >> udp endpoint may end up echoing back to the sender >> even with OUT joining the multi-cast group. >> >> Reviewed by: gnn, bms, bz? >> Obtained from: deischen (with help from) >> >> Modified: >> head/sys/netinet/udp_usrreq.c >> >> Modified: head/sys/netinet/udp_usrreq.c >> > ============================================================================== >> --- head/sys/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 (r217591) >> +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 (r217592) >> @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) >> * and source-specific multicast. [RFC3678] >> */ >> imo = inp->inp_moptions; >> - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && >> - imo != NULL) { >> + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { >> struct sockaddr_in group; >> int blocked; >> - >> + if(imo == NULL) { >> + INP_RUNLOCK(inp); >> + continue; >> + } >> bzero(&group, sizeof(struct sockaddr_in)); >> group.sin_len = sizeof(struct sockaddr_in); >> group.sin_family = AF_INET; > > So it turns out that this is a feature, not a bug, and is how multicast has > always worked. Specifically, if you bind a UDP socket with a wildcard > address, it should receive all traffic for the bound port, unicast or > multicast. When you join a group, you have switched the socket into a mode > where it now has a whitelist of acceptable multicast groups, but if a socket > has no joined groups, it should receive all multicast traffic, not none. This > change breaks that. > > I did not find this behavior intuitive at first, but it does seem to be > required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for > example: > > 3. Overview of APIs > > There are a number of different APIs described in this document that > are appropriate for a number of different application types and IP > versions. Before providing detailed descriptions, this section > provides a "taxonomy" with a brief description of each. > > There are two categories of source-filter APIs, both of which are > designed to allow multicast receiver applications to designate the > unicast address(es) of sender(s) along with the multicast group > (destination address) to receive. > > o Basic (Delta-based): Some applications desire the simplicity of > a delta-based API in which each function call specifies a > single source address which should be added to or removed from > the existing filter for a given multicast group address on > which to listen. Such applications typically fall into either > of two categories: > > + Any-Source Multicast: By default, all sources are accepted. > Individual sources may be turned off and back on as needed > over time. This is also known as "exclude" mode, since the > source filter contains a list of excluded sources. > > + Source-Specific Multicast: Only sources in a given list are > allowed. The list may change over time. This is also known > as "include" mode, since the source filter contains a list > of included sources. > > This API would be used, for example, by "single-source" > applications such as audio/video broadcasting. It would > also be used for logical multi-source sessions where each > source independently allocates its own Source-Specific > Multicast group address. > > > ..... > > 4.1.1. IPv4 Any-Source Multicast API > > The following socket options are defined in for > applications in the Any-Source Multicast category: > > Socket option Argument type > IP_ADD_MEMBERSHIP struct ip_mreq > IP_BLOCK_SOURCE struct ip_mreq_source > IP_UNBLOCK_SOURCE struct ip_mreq_source > IP_DROP_MEMBERSHIP struct ip_mreq > > IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on > most operating systems, and are used to join and leave an any-source > group. > > IP_BLOCK_SOURCE can be used to block data from a given source to a > given group (e.g., if the user "mutes" that source), and > IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then > "unmutes" the source). > > As to why the packets loop back to the receiver, I believe that is a separate > issue on the output side, not the receive side. That may be, but the behavior is undesired if the no process on the system has joined the multicast group. I believe it was broke with r189359, and the comment in the code that broke it says: /* * Loop back multicast datagram if not expressly * forbidden to do so, even if we are not a member * of the group; ip_input() will filter it later, * thus deferring a hash lookup and mutex acquisition * at the expense of a cheap copy using m_copym(). */ The previous revision did a lookup of the multicast address and looped it if an entry was found for it. -- DE From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 08:22:29 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A6EEB1065675; Wed, 30 Mar 2011 08:22:29 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 93CA88FC15; Wed, 30 Mar 2011 08:22:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2U8MTBC057056; Wed, 30 Mar 2011 08:22:29 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2U8MT2E057047; Wed, 30 Mar 2011 08:22:29 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201103300822.p2U8MT2E057047@svn.freebsd.org> From: Ed Schouten Date: Wed, 30 Mar 2011 08:22:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220154 - in head/etc: etc.amd64 etc.arm etc.i386 etc.ia64 etc.mips etc.pc98 etc.powerpc etc.sparc64 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 08:22:29 -0000 Author: ed Date: Wed Mar 30 08:22:29 2011 New Revision: 220154 URL: http://svn.freebsd.org/changeset/base/220154 Log: Remove the reference to pseudo-terminals from the description. Pseudo-terminals are no longer listed in this file, since the utmpx implementation doesn't depend on ttyslot(). Modified: head/etc/etc.amd64/ttys head/etc/etc.arm/ttys head/etc/etc.i386/ttys head/etc/etc.ia64/ttys head/etc/etc.mips/ttys head/etc/etc.pc98/ttys head/etc/etc.powerpc/ttys head/etc/etc.sparc64/ttys Modified: head/etc/etc.amd64/ttys ============================================================================== --- head/etc/etc.amd64/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.amd64/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically xterm. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty Modified: head/etc/etc.arm/ttys ============================================================================== --- head/etc/etc.arm/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.arm/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically xterm. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty Modified: head/etc/etc.i386/ttys ============================================================================== --- head/etc/etc.i386/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.i386/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically xterm. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty Modified: head/etc/etc.ia64/ttys ============================================================================== --- head/etc/etc.ia64/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.ia64/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically xterm. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty Modified: head/etc/etc.mips/ttys ============================================================================== --- head/etc/etc.mips/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.mips/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically xterm. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty Modified: head/etc/etc.pc98/ttys ============================================================================== --- head/etc/etc.pc98/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.pc98/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically cons25w. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty Modified: head/etc/etc.powerpc/ttys ============================================================================== --- head/etc/etc.powerpc/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.powerpc/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically xterm. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty Modified: head/etc/etc.sparc64/ttys ============================================================================== --- head/etc/etc.sparc64/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.sparc64/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically xterm. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 11:27:43 2011 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6F718106566B; Wed, 30 Mar 2011 11:27:43 +0000 (UTC) (envelope-from rrs@lakerest.net) Received: from lakerest.net (unknown [IPv6:2001:240:585:2:213:d4ff:fef3:2d8d]) by mx1.freebsd.org (Postfix) with ESMTP id F18358FC12; Wed, 30 Mar 2011 11:27:42 +0000 (UTC) Received: from dhcp-54bc.meeting.ietf.org (dhcp-54bc.meeting.ietf.org [130.129.84.188]) (authenticated bits=0) by lakerest.net (8.14.4/8.14.3) with ESMTP id p2UBRbO7098163 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Wed, 30 Mar 2011 07:27:39 -0400 (EDT) (envelope-from rrs@lakerest.net) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Randall Stewart In-Reply-To: <201103291401.03565.jhb@freebsd.org> Date: Wed, 30 Mar 2011 07:27:36 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: <99FEFE99-455A-4A28-8C02-08DFAD28B6CD@lakerest.net> References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> To: John Baldwin X-Mailer: Apple Mail (2.1084) Cc: svn-src-head@FreeBSD.org, Daniel Eischen , svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r217592 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 11:27:43 -0000 John: The original complaint on this came from Daniel... I believe he claimed that up until bms's multi-cast work.. you would NOT get a packet sent to you if you did not join the multi-cast group. I will also comment in-line below... On Mar 29, 2011, at 2:01 PM, John Baldwin wrote: > On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: >> Author: rrs >> Date: Wed Jan 19 19:07:16 2011 >> New Revision: 217592 >> URL: http://svn.freebsd.org/changeset/base/217592 >>=20 >> Log: >> Fix a bug where Multicast packets sent from a >> udp endpoint may end up echoing back to the sender >> even with OUT joining the multi-cast group. >>=20 >> Reviewed by: gnn, bms, bz? >> Obtained from: deischen (with help from) >>=20 >> Modified: >> head/sys/netinet/udp_usrreq.c >>=20 >> Modified: head/sys/netinet/udp_usrreq.c >>=20 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- head/sys/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 = (r217591) >> +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 = (r217592) >> @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) >> * and source-specific multicast. [RFC3678] >> */ >> imo =3D inp->inp_moptions; >> - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && >> - imo !=3D NULL) { >> + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { >> struct sockaddr_in group; >> int blocked; >> - >> + if(imo =3D=3D NULL) { >> + INP_RUNLOCK(inp); >> + continue; >> + } >> bzero(&group, sizeof(struct = sockaddr_in)); >> group.sin_len =3D sizeof(struct = sockaddr_in); >> group.sin_family =3D AF_INET; >=20 > So it turns out that this is a feature, not a bug, and is how = multicast has=20 > always worked. Specifically, if you bind a UDP socket with a wildcard=20= > address, it should receive all traffic for the bound port, unicast or=20= > multicast. When you join a group, you have switched the socket into a = mode=20 > where it now has a whitelist of acceptable multicast groups, but if a = socket=20 > has no joined groups, it should receive all multicast traffic, not = none. This=20 > change breaks that. >=20 > I did not find this behavior intuitive at first, but it does seem to = be=20 > required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for=20= > example: I agree getting a packet that is coming to your port without joining the multi-cast group is not intuitive to me...=20 >=20 > 3. Overview of APIs >=20 > There are a number of different APIs described in this document that > are appropriate for a number of different application types and IP > versions. Before providing detailed descriptions, this section > provides a "taxonomy" with a brief description of each. >=20 > There are two categories of source-filter APIs, both of which are > designed to allow multicast receiver applications to designate the > unicast address(es) of sender(s) along with the multicast group > (destination address) to receive. >=20 > o Basic (Delta-based): Some applications desire the simplicity = of > a delta-based API in which each function call specifies a > single source address which should be added to or removed from > the existing filter for a given multicast group address on > which to listen. Such applications typically fall into either > of two categories: >=20 > + Any-Source Multicast: By default, all sources are accepted. > Individual sources may be turned off and back on as needed > over time. This is also known as "exclude" mode, since the > source filter contains a list of excluded sources. >=20 > + Source-Specific Multicast: Only sources in a given list are > allowed. The list may change over time. This is also = known > as "include" mode, since the source filter contains a list > of included sources. >=20 > This API would be used, for example, by "single-source" > applications such as audio/video broadcasting. It would > also be used for logical multi-source sessions where each > source independently allocates its own Source-Specific > Multicast group address. Not the above document is talking about a receiver that as joined the multicast group (or is joining it and wants some filtering)... I don't see how that applies to a UDP socket that has NOT joined the M-cast = group.. >=20 >=20 > ..... >=20 > 4.1.1. IPv4 Any-Source Multicast API >=20 > The following socket options are defined in for > applications in the Any-Source Multicast category: >=20 > Socket option Argument type > IP_ADD_MEMBERSHIP struct ip_mreq > IP_BLOCK_SOURCE struct ip_mreq_source > IP_UNBLOCK_SOURCE struct ip_mreq_source > IP_DROP_MEMBERSHIP struct ip_mreq >=20 > IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on > most operating systems, and are used to join and leave an any-source > group. >=20 > IP_BLOCK_SOURCE can be used to block data from a given source to a > given group (e.g., if the user "mutes" that source), and > IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then > "unmutes" the source). >=20 > As to why the packets loop back to the receiver, I believe that is a = separate=20 > issue on the output side, not the receive side. But that is what the commit fixes... and as to the above, it again is talking about Multicast members.. AFAIKT... I am actually at the IETF so if you would like I can gladly go talk to the authors of this RFC (if they are here) and get their opinion on this. One other thing.. note this is NOT a standard but a informational RFC. = Informational RFC are guidelines and NOT mandatory at all.. there will never be a = MUST/SHOULD etc within them. I see that the authors are Dave Thaler, Bill Fenner and B Quinn I don't know B Quinn.. not sure if Fenner is here (have not seen him).. = but I have seen Dave around.. I will look him up and ask him his opinion.. R >=20 > --=20 > John Baldwin >=20 ------------------------------ Randall Stewart 803-317-4952 (cell) From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 11:34:40 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 78EA0106564A; Wed, 30 Mar 2011 11:34:40 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 69A6C8FC15; Wed, 30 Mar 2011 11:34:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UBYemL062387; Wed, 30 Mar 2011 11:34:40 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UBYenv062385; Wed, 30 Mar 2011 11:34:40 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201103301134.p2UBYenv062385@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Wed, 30 Mar 2011 11:34:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220155 - head/share/man/man9 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 11:34:40 -0000 Author: ae Date: Wed Mar 30 11:34:40 2011 New Revision: 220155 URL: http://svn.freebsd.org/changeset/base/220155 Log: Remove duplicate sentence. Modified: head/share/man/man9/sbuf.9 Modified: head/share/man/man9/sbuf.9 ============================================================================== --- head/share/man/man9/sbuf.9 Wed Mar 30 08:22:29 2011 (r220154) +++ head/share/man/man9/sbuf.9 Wed Mar 30 11:34:40 2011 (r220155) @@ -395,10 +395,6 @@ returns the length of the un-drained dat returns non-zero if the .Fa sbuf is finished. -.Fn sbuf_done -returns non-zero if the -.Fa sbuf -is finished. .Sh NOTES If an operation caused an .Fa sbuf From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 12:27:27 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE9C8106564A; Wed, 30 Mar 2011 12:27:27 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id A245D8FC14; Wed, 30 Mar 2011 12:27:27 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 414F146B4C; Wed, 30 Mar 2011 08:27:27 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id CE4658A027; Wed, 30 Mar 2011 08:27:26 -0400 (EDT) From: John Baldwin To: Randall Stewart Date: Wed, 30 Mar 2011 08:23:53 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> <99FEFE99-455A-4A28-8C02-08DFAD28B6CD@lakerest.net> In-Reply-To: <99FEFE99-455A-4A28-8C02-08DFAD28B6CD@lakerest.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103300823.53986.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Wed, 30 Mar 2011 08:27:26 -0400 (EDT) Cc: svn-src-head@freebsd.org, Daniel Eischen , svn-src-all@freebsd.org, src-committers@freebsd.org, George Neville-Neil Subject: Re: svn commit: r217592 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 12:27:28 -0000 On Wednesday, March 30, 2011 7:27:36 am Randall Stewart wrote: > John: > > The original complaint on this came from Daniel... I believe he > claimed that up until bms's multi-cast work.. you would NOT > get a packet sent to you if you did not join the multi-cast group. Not necessarily. :( See below.. > I will also comment in-line below... > > On Mar 29, 2011, at 2:01 PM, John Baldwin wrote: > > > On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: > >> Author: rrs > >> Date: Wed Jan 19 19:07:16 2011 > >> New Revision: 217592 > >> URL: http://svn.freebsd.org/changeset/base/217592 > >> > >> Log: > >> Fix a bug where Multicast packets sent from a > >> udp endpoint may end up echoing back to the sender > >> even with OUT joining the multi-cast group. > >> > >> Reviewed by: gnn, bms, bz? > >> Obtained from: deischen (with help from) > >> > >> Modified: > >> head/sys/netinet/udp_usrreq.c > >> > >> Modified: head/sys/netinet/udp_usrreq.c > >> > > ============================================================================== > >> --- head/sys/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 (r217591) > >> +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 (r217592) > >> @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) > >> * and source-specific multicast. [RFC3678] > >> */ > >> imo = inp->inp_moptions; > >> - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && > >> - imo != NULL) { > >> + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { > >> struct sockaddr_in group; > >> int blocked; > >> - > >> + if(imo == NULL) { > >> + INP_RUNLOCK(inp); > >> + continue; > >> + } > >> bzero(&group, sizeof(struct sockaddr_in)); > >> group.sin_len = sizeof(struct sockaddr_in); > >> group.sin_family = AF_INET; > > > > So it turns out that this is a feature, not a bug, and is how multicast has > > always worked. Specifically, if you bind a UDP socket with a wildcard > > address, it should receive all traffic for the bound port, unicast or > > multicast. When you join a group, you have switched the socket into a mode > > where it now has a whitelist of acceptable multicast groups, but if a socket > > has no joined groups, it should receive all multicast traffic, not none. This > > change breaks that. > > > > I did not find this behavior intuitive at first, but it does seem to be > > required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for > > example: > > > I agree getting a packet that is coming to your port without joining the > multi-cast group is not intuitive to me... > > > > > 3. Overview of APIs > > > > There are a number of different APIs described in this document that > > are appropriate for a number of different application types and IP > > versions. Before providing detailed descriptions, this section > > provides a "taxonomy" with a brief description of each. > > > > There are two categories of source-filter APIs, both of which are > > designed to allow multicast receiver applications to designate the > > unicast address(es) of sender(s) along with the multicast group > > (destination address) to receive. > > > > o Basic (Delta-based): Some applications desire the simplicity of > > a delta-based API in which each function call specifies a > > single source address which should be added to or removed from > > the existing filter for a given multicast group address on > > which to listen. Such applications typically fall into either > > of two categories: > > > > + Any-Source Multicast: By default, all sources are accepted. > > Individual sources may be turned off and back on as needed > > over time. This is also known as "exclude" mode, since the > > source filter contains a list of excluded sources. > > > > + Source-Specific Multicast: Only sources in a given list are > > allowed. The list may change over time. This is also known > > as "include" mode, since the source filter contains a list > > of included sources. > > > > This API would be used, for example, by "single-source" > > applications such as audio/video broadcasting. It would > > also be used for logical multi-source sessions where each > > source independently allocates its own Source-Specific > > Multicast group address. > > > Not the above document is talking about a receiver that as joined the > multicast group (or is joining it and wants some filtering)... I don't > see how that applies to a UDP socket that has NOT joined the M-cast group.. > > > > > > > ..... > > > > 4.1.1. IPv4 Any-Source Multicast API > > > > The following socket options are defined in for > > applications in the Any-Source Multicast category: > > > > Socket option Argument type > > IP_ADD_MEMBERSHIP struct ip_mreq > > IP_BLOCK_SOURCE struct ip_mreq_source > > IP_UNBLOCK_SOURCE struct ip_mreq_source > > IP_DROP_MEMBERSHIP struct ip_mreq > > > > IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on > > most operating systems, and are used to join and leave an any-source > > group. > > > > IP_BLOCK_SOURCE can be used to block data from a given source to a > > given group (e.g., if the user "mutes" that source), and > > IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then > > "unmutes" the source). > > > > As to why the packets loop back to the receiver, I believe that is a separate > > issue on the output side, not the receive side. > > > > But that is what the commit fixes... Except you change receive, not transmit. I think the error in Daniel's case is on the transmit side, not receive. I would be happy to know what the true "official" behavior is for a socket that binds to INADDR_ANY but does not join any groups. As far as prior to BMS's changes: in the older version of udp_input() we only checked the membership list if inp->inp_moptions was != NULL. If it was NULL, we would send all multicast packets to a given socket for which the address fields matched (addr, port). BMS preserved this behavior and your patch changes it. UDP sockets start off with inp_moptions == NULL, so if you never do any multicast-related setsockopt() you will receive all matching multicast packets. However, once you do any multicast-related setsockopt() (IP_MULTICAST_LOOP, IP_ADD_MEMBERSHIP, etc.) then inp_moptions is allocated and is non-NULL. At that point it only accepts packets that match, except that even then we used a sysctl which defaulted to off (!) to see if we should check the list of memberships (net.inet.udp.strict_mcast_mship). This options structure was never free'd, however, so you could get the truly bizarre behavior of: - bind a new socket, it will not receive all matching multicast traffic - use IP_ADD_MEMBERSHIP to add a group, it will now receive only matching multicast traffic for the group - use IP_DROP_MEMBERSHIP to remove the group, it will now receive no multicast traffic The different behavior in states 1 and 3 I find confusing and odd. By default all sockets just always received all matching multicast traffic though. :) However, this change is not restoring "old" behavior, it is a change in behavior compared to the pre-BMS changes. > and as to the above, it again is > talking about Multicast members.. AFAIKT... I am actually at the IETF > so if you would like I can gladly go talk to the authors of this RFC > (if they are here) and get their opinion on this. > > One other thing.. note this is NOT a standard but a informational RFC. Informational > RFC are guidelines and NOT mandatory at all.. there will never be a MUST/SHOULD etc > within them. Well, for lack of anything else I was looking to that. I would really prefer the behavior in your change as I find it far more intuitive. I wasn't able to find anything else in Stevens or elsewhere that seemed to indicate what the proper behavior was beyond this. > I see that the authors are Dave Thaler, Bill Fenner and B Quinn > > I don't know B Quinn.. not sure if Fenner is here (have not seen him).. but I have > seen Dave around.. I will look him up and ask him his opinion.. > > R > > > > > > -- > > John Baldwin > > > > ------------------------------ > Randall Stewart > 803-317-4952 (cell) > > -- John Baldwin From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 12:27:28 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4F76E1065673; Wed, 30 Mar 2011 12:27:28 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 24E6F8FC15; Wed, 30 Mar 2011 12:27:28 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id AC17E46B0D; Wed, 30 Mar 2011 08:27:27 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 372F58A02A; Wed, 30 Mar 2011 08:27:27 -0400 (EDT) From: John Baldwin To: Daniel Eischen Date: Wed, 30 Mar 2011 08:27:25 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103300827.25260.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Wed, 30 Mar 2011 08:27:27 -0400 (EDT) Cc: svn-src-head@freebsd.org, Randall Stewart , svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r217592 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 12:27:28 -0000 On Wednesday, March 30, 2011 3:50:18 am Daniel Eischen wrote: > On Tue, 29 Mar 2011, John Baldwin wrote: > > > On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: > >> Author: rrs > >> Date: Wed Jan 19 19:07:16 2011 > >> New Revision: 217592 > >> URL: http://svn.freebsd.org/changeset/base/217592 > >> > >> Log: > >> Fix a bug where Multicast packets sent from a > >> udp endpoint may end up echoing back to the sender > >> even with OUT joining the multi-cast group. > >> > >> Reviewed by: gnn, bms, bz? > >> Obtained from: deischen (with help from) > >> > >> Modified: > >> head/sys/netinet/udp_usrreq.c > >> > >> Modified: head/sys/netinet/udp_usrreq.c > >> > > ============================================================================== > >> --- head/sys/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 (r217591) > >> +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 (r217592) > >> @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) > >> * and source-specific multicast. [RFC3678] > >> */ > >> imo = inp->inp_moptions; > >> - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && > >> - imo != NULL) { > >> + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { > >> struct sockaddr_in group; > >> int blocked; > >> - > >> + if(imo == NULL) { > >> + INP_RUNLOCK(inp); > >> + continue; > >> + } > >> bzero(&group, sizeof(struct sockaddr_in)); > >> group.sin_len = sizeof(struct sockaddr_in); > >> group.sin_family = AF_INET; > > > > So it turns out that this is a feature, not a bug, and is how multicast has > > always worked. Specifically, if you bind a UDP socket with a wildcard > > address, it should receive all traffic for the bound port, unicast or > > multicast. When you join a group, you have switched the socket into a mode > > where it now has a whitelist of acceptable multicast groups, but if a socket > > has no joined groups, it should receive all multicast traffic, not none. This > > change breaks that. > > > > I did not find this behavior intuitive at first, but it does seem to be > > required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for > > example: > > > > 3. Overview of APIs > > > > There are a number of different APIs described in this document that > > are appropriate for a number of different application types and IP > > versions. Before providing detailed descriptions, this section > > provides a "taxonomy" with a brief description of each. > > > > There are two categories of source-filter APIs, both of which are > > designed to allow multicast receiver applications to designate the > > unicast address(es) of sender(s) along with the multicast group > > (destination address) to receive. > > > > o Basic (Delta-based): Some applications desire the simplicity of > > a delta-based API in which each function call specifies a > > single source address which should be added to or removed from > > the existing filter for a given multicast group address on > > which to listen. Such applications typically fall into either > > of two categories: > > > > + Any-Source Multicast: By default, all sources are accepted. > > Individual sources may be turned off and back on as needed > > over time. This is also known as "exclude" mode, since the > > source filter contains a list of excluded sources. > > > > + Source-Specific Multicast: Only sources in a given list are > > allowed. The list may change over time. This is also known > > as "include" mode, since the source filter contains a list > > of included sources. > > > > This API would be used, for example, by "single-source" > > applications such as audio/video broadcasting. It would > > also be used for logical multi-source sessions where each > > source independently allocates its own Source-Specific > > Multicast group address. > > > > > > ..... > > > > 4.1.1. IPv4 Any-Source Multicast API > > > > The following socket options are defined in for > > applications in the Any-Source Multicast category: > > > > Socket option Argument type > > IP_ADD_MEMBERSHIP struct ip_mreq > > IP_BLOCK_SOURCE struct ip_mreq_source > > IP_UNBLOCK_SOURCE struct ip_mreq_source > > IP_DROP_MEMBERSHIP struct ip_mreq > > > > IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on > > most operating systems, and are used to join and leave an any-source > > group. > > > > IP_BLOCK_SOURCE can be used to block data from a given source to a > > given group (e.g., if the user "mutes" that source), and > > IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then > > "unmutes" the source). > > > > As to why the packets loop back to the receiver, I believe that is a separate > > issue on the output side, not the receive side. > > That may be, but the behavior is undesired if the no process > on the system has joined the multicast group. I believe it > was broke with r189359, and the comment in the code that broke > it says: > > /* > * Loop back multicast datagram if not expressly > * forbidden to do so, even if we are not a member > * of the group; ip_input() will filter it later, > * thus deferring a hash lookup and mutex acquisition > * at the expense of a cheap copy using m_copym(). > */ > > The previous revision did a lookup of the multicast address > and looped it if an entry was found for it. Well, for one, this patch changes the behavior even if there is a socket joined to the group. However, I suspect that in your case your app should probably be turning IP_MULTICAST_LOOP off explicitly regardless of what the changes end up being (or do you write to multiple groups and want a subset of those groups to loop back?). -- John Baldwin From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 12:35:40 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0C5E6106566B; Wed, 30 Mar 2011 12:35:40 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F16CC8FC08; Wed, 30 Mar 2011 12:35:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UCZds1063677; Wed, 30 Mar 2011 12:35:39 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UCZdwP063675; Wed, 30 Mar 2011 12:35:39 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201103301235.p2UCZdwP063675@svn.freebsd.org> From: John Baldwin Date: Wed, 30 Mar 2011 12:35:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220156 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 12:35:40 -0000 Author: jhb Date: Wed Mar 30 12:35:39 2011 New Revision: 220156 URL: http://svn.freebsd.org/changeset/base/220156 Log: Clamp the initial advertised receive window when responding to a SYN/ACK to the maximum allowed window. Growing the window too large would cause an underflow in the calculations in tcp_output() to decide if a window update should be sent which would prevent the persist timer from being started if data was pending and the other end of the connection advertised an initial window size of 0. PR: kern/154006 Submitted by: Stefan `Sec` Zehl sec 42 org Reviewed by: bz MFC after: 1 week Modified: head/sys/netinet/tcp_input.c Modified: head/sys/netinet/tcp_input.c ============================================================================== --- head/sys/netinet/tcp_input.c Wed Mar 30 11:34:40 2011 (r220155) +++ head/sys/netinet/tcp_input.c Wed Mar 30 12:35:39 2011 (r220156) @@ -1756,7 +1756,8 @@ tcp_do_segment(struct mbuf *m, struct tc (TF_RCVD_SCALE|TF_REQ_SCALE)) { tp->rcv_scale = tp->request_r_scale; } - tp->rcv_adv += tp->rcv_wnd; + tp->rcv_adv += imin(tp->rcv_wnd, + TCP_MAXWIN << tp->rcv_scale); tp->snd_una++; /* SYN is acked */ /* * If there's data, delay ACK; if there's also a FIN From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 14:15:18 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 833501065686; Wed, 30 Mar 2011 14:15:18 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 732E08FC0C; Wed, 30 Mar 2011 14:15:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UEFIC2065842; Wed, 30 Mar 2011 14:15:18 GMT (envelope-from pluknet@svn.freebsd.org) Received: (from pluknet@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UEFIkU065840; Wed, 30 Mar 2011 14:15:18 GMT (envelope-from pluknet@svn.freebsd.org) Message-Id: <201103301415.p2UEFIkU065840@svn.freebsd.org> From: Sergey Kandaurov Date: Wed, 30 Mar 2011 14:15:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220157 - head/lib/libc/gen X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 14:15:18 -0000 Author: pluknet Date: Wed Mar 30 14:15:18 2011 New Revision: 220157 URL: http://svn.freebsd.org/changeset/base/220157 Log: Use FD_CLOEXEC explicitly. MFC after: 3 days Modified: head/lib/libc/gen/syslog.c Modified: head/lib/libc/gen/syslog.c ============================================================================== --- head/lib/libc/gen/syslog.c Wed Mar 30 12:35:39 2011 (r220156) +++ head/lib/libc/gen/syslog.c Wed Mar 30 14:15:18 2011 (r220157) @@ -342,7 +342,7 @@ connectlog(void) if (LogFile == -1) { if ((LogFile = _socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) return; - (void)_fcntl(LogFile, F_SETFD, 1); + (void)_fcntl(LogFile, F_SETFD, FD_CLOEXEC); } if (LogFile != -1 && status == NOCONN) { SyslogAddr.sun_len = sizeof(SyslogAddr); From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 14:46:13 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 632CF106564A; Wed, 30 Mar 2011 14:46:13 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 51DAC8FC25; Wed, 30 Mar 2011 14:46:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UEkDLb066517; Wed, 30 Mar 2011 14:46:13 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UEkDDk066511; Wed, 30 Mar 2011 14:46:13 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103301446.p2UEkDDk066511@svn.freebsd.org> From: Konstantin Belousov Date: Wed, 30 Mar 2011 14:46:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220158 - in head/sys: compat/freebsd32 kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 14:46:13 -0000 Author: kib Date: Wed Mar 30 14:46:12 2011 New Revision: 220158 URL: http://svn.freebsd.org/changeset/base/220158 Log: Provide compat32 shims for kldstat(2). Requested and tested by: jpaetzel MFC after: 1 week Modified: head/sys/compat/freebsd32/freebsd32.h head/sys/compat/freebsd32/freebsd32_misc.c head/sys/compat/freebsd32/syscalls.master head/sys/kern/kern_linker.c head/sys/sys/syscallsubr.h Modified: head/sys/compat/freebsd32/freebsd32.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32.h Wed Mar 30 14:15:18 2011 (r220157) +++ head/sys/compat/freebsd32/freebsd32.h Wed Mar 30 14:46:12 2011 (r220158) @@ -336,4 +336,23 @@ struct kinfo_proc32 { int ki_tdflags; }; +struct kld32_file_stat_1 { + int version; /* set to sizeof(struct kld_file_stat_1) */ + char name[MAXPATHLEN]; + int refs; + int id; + uint32_t address; /* load address */ + uint32_t size; /* size in bytes */ +}; + +struct kld32_file_stat { + int version; /* set to sizeof(struct kld_file_stat) */ + char name[MAXPATHLEN]; + int refs; + int id; + uint32_t address; /* load address */ + uint32_t size; /* size in bytes */ + char pathname[MAXPATHLEN]; +}; + #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */ Modified: head/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_misc.c Wed Mar 30 14:15:18 2011 (r220157) +++ head/sys/compat/freebsd32/freebsd32_misc.c Wed Mar 30 14:46:12 2011 (r220158) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include /* Must come after sys/malloc.h */ @@ -2669,3 +2670,29 @@ freebsd32_copyout_strings(struct image_p return ((register_t *)stack_base); } +int +freebsd32_kldstat(struct thread *td, struct freebsd32_kldstat_args *uap) +{ + struct kld_file_stat stat; + struct kld32_file_stat stat32; + int error, version; + + if ((error = copyin(&uap->stat->version, &version, sizeof(version))) + != 0) + return (error); + if (version != sizeof(struct kld32_file_stat_1) && + version != sizeof(struct kld32_file_stat)) + return (EINVAL); + + error = kern_kldstat(td, uap->fileid, &stat); + if (error != 0) + return (error); + + bcopy(&stat.name[0], &stat32.name[0], sizeof(stat.name)); + CP(stat, stat32, refs); + CP(stat, stat32, id); + PTROUT_CP(stat, stat32, address); + CP(stat, stat32, size); + bcopy(&stat.pathname[0], &stat32.pathname[0], sizeof(stat.pathname)); + return (copyout(&stat32, uap->stat, version)); +} Modified: head/sys/compat/freebsd32/syscalls.master ============================================================================== --- head/sys/compat/freebsd32/syscalls.master Wed Mar 30 14:15:18 2011 (r220157) +++ head/sys/compat/freebsd32/syscalls.master Wed Mar 30 14:46:12 2011 (r220158) @@ -533,8 +533,8 @@ 305 AUE_MODUNLOAD NOPROTO { int kldunload(int fileid); } 306 AUE_NULL NOPROTO { int kldfind(const char *file); } 307 AUE_NULL NOPROTO { int kldnext(int fileid); } -308 AUE_NULL NOPROTO { int kldstat(int fileid, \ - struct kld_file_stat* stat); } +308 AUE_NULL STD { int freebsd32_kldstat(int fileid, \ + struct kld32_file_stat* stat); } 309 AUE_NULL NOPROTO { int kldfirstmod(int fileid); } 310 AUE_GETSID NOPROTO { int getsid(pid_t pid); } 311 AUE_SETRESUID NOPROTO { int setresuid(uid_t ruid, uid_t euid, \ Modified: head/sys/kern/kern_linker.c ============================================================================== --- head/sys/kern/kern_linker.c Wed Mar 30 14:15:18 2011 (r220157) +++ head/sys/kern/kern_linker.c Wed Mar 30 14:46:12 2011 (r220158) @@ -1201,29 +1201,39 @@ int kldstat(struct thread *td, struct kldstat_args *uap) { struct kld_file_stat stat; - linker_file_t lf; - int error, namelen, version, version_num; + int error, version; /* * Check the version of the user's structure. */ - if ((error = copyin(&uap->stat->version, &version, sizeof(version))) != 0) + if ((error = copyin(&uap->stat->version, &version, sizeof(version))) + != 0) return (error); - if (version == sizeof(struct kld_file_stat_1)) - version_num = 1; - else if (version == sizeof(struct kld_file_stat)) - version_num = 2; - else + if (version != sizeof(struct kld_file_stat_1) && + version != sizeof(struct kld_file_stat)) return (EINVAL); + error = kern_kldstat(td, uap->fileid, &stat); + if (error != 0) + return (error); + return (copyout(&stat, uap->stat, version)); +} + +int +kern_kldstat(struct thread *td, int fileid, struct kld_file_stat *stat) +{ + linker_file_t lf; + int namelen; #ifdef MAC + int error; + error = mac_kld_check_stat(td->td_ucred); if (error) return (error); #endif KLD_LOCK(); - lf = linker_find_file_by_id(uap->fileid); + lf = linker_find_file_by_id(fileid); if (lf == NULL) { KLD_UNLOCK(); return (ENOENT); @@ -1233,23 +1243,20 @@ kldstat(struct thread *td, struct kldsta namelen = strlen(lf->filename) + 1; if (namelen > MAXPATHLEN) namelen = MAXPATHLEN; - bcopy(lf->filename, &stat.name[0], namelen); - stat.refs = lf->refs; - stat.id = lf->id; - stat.address = lf->address; - stat.size = lf->size; - if (version_num > 1) { - /* Version 2 fields: */ - namelen = strlen(lf->pathname) + 1; - if (namelen > MAXPATHLEN) - namelen = MAXPATHLEN; - bcopy(lf->pathname, &stat.pathname[0], namelen); - } + bcopy(lf->filename, &stat->name[0], namelen); + stat->refs = lf->refs; + stat->id = lf->id; + stat->address = lf->address; + stat->size = lf->size; + /* Version 2 fields: */ + namelen = strlen(lf->pathname) + 1; + if (namelen > MAXPATHLEN) + namelen = MAXPATHLEN; + bcopy(lf->pathname, &stat->pathname[0], namelen); KLD_UNLOCK(); td->td_retval[0] = 0; - - return (copyout(&stat, uap->stat, version)); + return (0); } int Modified: head/sys/sys/syscallsubr.h ============================================================================== --- head/sys/sys/syscallsubr.h Wed Mar 30 14:15:18 2011 (r220157) +++ head/sys/sys/syscallsubr.h Wed Mar 30 14:46:12 2011 (r220158) @@ -48,6 +48,7 @@ struct sockaddr; struct stat; struct kevent; struct kevent_copyops; +struct kld_file_stat; struct ksiginfo; struct sendfile_args; struct thr_param; @@ -113,6 +114,7 @@ int kern_jail_set(struct thread *td, str int kern_kevent(struct thread *td, int fd, int nchanges, int nevents, struct kevent_copyops *k_ops, const struct timespec *timeout); int kern_kldload(struct thread *td, const char *file, int *fileid); +int kern_kldstat(struct thread *td, int fileid, struct kld_file_stat *stat); int kern_kldunload(struct thread *td, int fileid, int flags); int kern_lchown(struct thread *td, char *path, enum uio_seg pathseg, int uid, int gid); From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 14:46:56 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5722F106566B; Wed, 30 Mar 2011 14:46:56 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 465688FC21; Wed, 30 Mar 2011 14:46:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UEkuY8066567; Wed, 30 Mar 2011 14:46:56 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UEkurU066561; Wed, 30 Mar 2011 14:46:56 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103301446.p2UEkurU066561@svn.freebsd.org> From: Konstantin Belousov Date: Wed, 30 Mar 2011 14:46:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220159 - head/sys/compat/freebsd32 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 14:46:56 -0000 Author: kib Date: Wed Mar 30 14:46:55 2011 New Revision: 220159 URL: http://svn.freebsd.org/changeset/base/220159 Log: Regen. Modified: head/sys/compat/freebsd32/freebsd32_proto.h head/sys/compat/freebsd32/freebsd32_syscall.h head/sys/compat/freebsd32/freebsd32_syscalls.c head/sys/compat/freebsd32/freebsd32_sysent.c head/sys/compat/freebsd32/freebsd32_systrace_args.c Modified: head/sys/compat/freebsd32/freebsd32_proto.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_proto.h Wed Mar 30 14:46:12 2011 (r220158) +++ head/sys/compat/freebsd32/freebsd32_proto.h Wed Mar 30 14:46:55 2011 (r220159) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib */ #ifndef _FREEBSD32_SYSPROTO_H_ @@ -240,6 +240,10 @@ struct freebsd32_modstat_args { char modid_l_[PADL_(int)]; int modid; char modid_r_[PADR_(int)]; char stat_l_[PADL_(struct module_stat32 *)]; struct module_stat32 * stat; char stat_r_[PADR_(struct module_stat32 *)]; }; +struct freebsd32_kldstat_args { + char fileid_l_[PADL_(int)]; int fileid; char fileid_r_[PADR_(int)]; + char stat_l_[PADL_(struct kld32_file_stat *)]; struct kld32_file_stat * stat; char stat_r_[PADR_(struct kld32_file_stat *)]; +}; struct freebsd32_aio_return_args { char aiocbp_l_[PADL_(struct aiocb32 *)]; struct aiocb32 * aiocbp; char aiocbp_r_[PADR_(struct aiocb32 *)]; }; @@ -607,6 +611,7 @@ int freebsd32_lutimes(struct thread *, s int freebsd32_preadv(struct thread *, struct freebsd32_preadv_args *); int freebsd32_pwritev(struct thread *, struct freebsd32_pwritev_args *); int freebsd32_modstat(struct thread *, struct freebsd32_modstat_args *); +int freebsd32_kldstat(struct thread *, struct freebsd32_kldstat_args *); int freebsd32_aio_return(struct thread *, struct freebsd32_aio_return_args *); int freebsd32_aio_suspend(struct thread *, struct freebsd32_aio_suspend_args *); int freebsd32_aio_cancel(struct thread *, struct freebsd32_aio_cancel_args *); @@ -939,6 +944,7 @@ int freebsd7_freebsd32_shmctl(struct thr #define FREEBSD32_SYS_AUE_freebsd32_pwritev AUE_PWRITEV #define FREEBSD32_SYS_AUE_freebsd4_freebsd32_fhstatfs AUE_FHSTATFS #define FREEBSD32_SYS_AUE_freebsd32_modstat AUE_NULL +#define FREEBSD32_SYS_AUE_freebsd32_kldstat AUE_NULL #define FREEBSD32_SYS_AUE_freebsd32_aio_return AUE_NULL #define FREEBSD32_SYS_AUE_freebsd32_aio_suspend AUE_NULL #define FREEBSD32_SYS_AUE_freebsd32_aio_cancel AUE_NULL Modified: head/sys/compat/freebsd32/freebsd32_syscall.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_syscall.h Wed Mar 30 14:46:12 2011 (r220158) +++ head/sys/compat/freebsd32/freebsd32_syscall.h Wed Mar 30 14:46:55 2011 (r220159) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib */ #define FREEBSD32_SYS_syscall 0 @@ -234,7 +234,7 @@ #define FREEBSD32_SYS_kldunload 305 #define FREEBSD32_SYS_kldfind 306 #define FREEBSD32_SYS_kldnext 307 -#define FREEBSD32_SYS_kldstat 308 +#define FREEBSD32_SYS_freebsd32_kldstat 308 #define FREEBSD32_SYS_kldfirstmod 309 #define FREEBSD32_SYS_getsid 310 #define FREEBSD32_SYS_setresuid 311 Modified: head/sys/compat/freebsd32/freebsd32_syscalls.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_syscalls.c Wed Mar 30 14:46:12 2011 (r220158) +++ head/sys/compat/freebsd32/freebsd32_syscalls.c Wed Mar 30 14:46:55 2011 (r220159) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib */ const char *freebsd32_syscallnames[] = { @@ -318,7 +318,7 @@ const char *freebsd32_syscallnames[] = { "kldunload", /* 305 = kldunload */ "kldfind", /* 306 = kldfind */ "kldnext", /* 307 = kldnext */ - "kldstat", /* 308 = kldstat */ + "freebsd32_kldstat", /* 308 = freebsd32_kldstat */ "kldfirstmod", /* 309 = kldfirstmod */ "getsid", /* 310 = getsid */ "setresuid", /* 311 = setresuid */ Modified: head/sys/compat/freebsd32/freebsd32_sysent.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_sysent.c Wed Mar 30 14:46:12 2011 (r220158) +++ head/sys/compat/freebsd32/freebsd32_sysent.c Wed Mar 30 14:46:55 2011 (r220159) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib */ #include "opt_compat.h" @@ -355,7 +355,7 @@ struct sysent freebsd32_sysent[] = { { AS(kldunload_args), (sy_call_t *)kldunload, AUE_MODUNLOAD, NULL, 0, 0, 0, SY_THR_STATIC }, /* 305 = kldunload */ { AS(kldfind_args), (sy_call_t *)kldfind, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 306 = kldfind */ { AS(kldnext_args), (sy_call_t *)kldnext, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 307 = kldnext */ - { AS(kldstat_args), (sy_call_t *)kldstat, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 308 = kldstat */ + { AS(freebsd32_kldstat_args), (sy_call_t *)freebsd32_kldstat, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 308 = freebsd32_kldstat */ { AS(kldfirstmod_args), (sy_call_t *)kldfirstmod, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 309 = kldfirstmod */ { AS(getsid_args), (sy_call_t *)getsid, AUE_GETSID, NULL, 0, 0, 0, SY_THR_STATIC }, /* 310 = getsid */ { AS(setresuid_args), (sy_call_t *)setresuid, AUE_SETRESUID, NULL, 0, 0, 0, SY_THR_STATIC }, /* 311 = setresuid */ Modified: head/sys/compat/freebsd32/freebsd32_systrace_args.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_systrace_args.c Wed Mar 30 14:46:12 2011 (r220158) +++ head/sys/compat/freebsd32/freebsd32_systrace_args.c Wed Mar 30 14:46:55 2011 (r220159) @@ -1428,11 +1428,11 @@ systrace_args(int sysnum, void *params, *n_args = 1; break; } - /* kldstat */ + /* freebsd32_kldstat */ case 308: { - struct kldstat_args *p = params; + struct freebsd32_kldstat_args *p = params; iarg[0] = p->fileid; /* int */ - uarg[1] = (intptr_t) p->stat; /* struct kld_file_stat * */ + uarg[1] = (intptr_t) p->stat; /* struct kld32_file_stat * */ *n_args = 2; break; } @@ -5217,14 +5217,14 @@ systrace_setargdesc(int sysnum, int ndx, break; }; break; - /* kldstat */ + /* freebsd32_kldstat */ case 308: switch(ndx) { case 0: p = "int"; break; case 1: - p = "struct kld_file_stat *"; + p = "struct kld32_file_stat *"; break; default: break; From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 15:23:14 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 983F41065674; Wed, 30 Mar 2011 15:23:14 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 2422C8FC1F; Wed, 30 Mar 2011 15:23:13 +0000 (UTC) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.4/8.14.4/NETPLEX) with ESMTP id p2UFNDti020328; Wed, 30 Mar 2011 11:23:13 -0400 X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.2.6 (mail.netplex.net [204.213.176.10]); Wed, 30 Mar 2011 11:23:13 -0400 (EDT) Date: Wed, 30 Mar 2011 11:23:13 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: John Baldwin In-Reply-To: <201103300827.25260.jhb@freebsd.org> Message-ID: References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> <201103300827.25260.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, Randall Stewart , svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r217592 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 15:23:14 -0000 On Wed, 30 Mar 2011, John Baldwin wrote: > On Wednesday, March 30, 2011 3:50:18 am Daniel Eischen wrote: >> On Tue, 29 Mar 2011, John Baldwin wrote: >>> >>> As to why the packets loop back to the receiver, I believe that is a separate >>> issue on the output side, not the receive side. >> >> That may be, but the behavior is undesired if the no process >> on the system has joined the multicast group. I believe it >> was broke with r189359, and the comment in the code that broke >> it says: >> >> /* >> * Loop back multicast datagram if not expressly >> * forbidden to do so, even if we are not a member >> * of the group; ip_input() will filter it later, >> * thus deferring a hash lookup and mutex acquisition >> * at the expense of a cheap copy using m_copym(). >> */ >> >> The previous revision did a lookup of the multicast address >> and looped it if an entry was found for it. > > Well, for one, this patch changes the behavior even if there is a socket > joined to the group. Yes, I understand that. But before this patch, the behavior was correct for what you have stated, and for my particular case. When we fixed the problem, we took BMS' comment as guidance and filtered on the input side. > However, I suspect that in your case your app should > probably be turning IP_MULTICAST_LOOP off explicitly regardless of what the > changes end up being (or do you write to multiple groups and want a subset > of those groups to loop back?). In the _absence_ of setting multicast loopback on the socket, we should not be getting looped-back packets. This is the behavior we've seen on other OS's. -- DE From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 15:42:02 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BDE70106564A; Wed, 30 Mar 2011 15:42:02 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 742C68FC0A; Wed, 30 Mar 2011 15:42:02 +0000 (UTC) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.4/8.14.4/NETPLEX) with ESMTP id p2UFg1k4009790; Wed, 30 Mar 2011 11:42:01 -0400 X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.2.6 (mail.netplex.net [204.213.176.10]); Wed, 30 Mar 2011 11:42:01 -0400 (EDT) Date: Wed, 30 Mar 2011 11:42:01 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: John Baldwin In-Reply-To: <201103300823.53986.jhb@freebsd.org> Message-ID: References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> <99FEFE99-455A-4A28-8C02-08DFAD28B6CD@lakerest.net> <201103300823.53986.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, George Neville-Neil , svn-src-all@freebsd.org, src-committers@freebsd.org, Randall Stewart Subject: Re: svn commit: r217592 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 15:42:02 -0000 On Wed, 30 Mar 2011, John Baldwin wrote: > On Wednesday, March 30, 2011 7:27:36 am Randall Stewart wrote: >> John: >> >> The original complaint on this came from Daniel... I believe he >> claimed that up until bms's multi-cast work.. you would NOT >> get a packet sent to you if you did not join the multi-cast group. > > Not necessarily. :( See below.. > >> I will also comment in-line below... >> >> On Mar 29, 2011, at 2:01 PM, John Baldwin wrote: >> >>> On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: >>>> Author: rrs >>>> Date: Wed Jan 19 19:07:16 2011 >>>> New Revision: 217592 >>>> URL: http://svn.freebsd.org/changeset/base/217592 >>>> >>>> Log: >>>> Fix a bug where Multicast packets sent from a >>>> udp endpoint may end up echoing back to the sender >>>> even with OUT joining the multi-cast group. >>>> >>>> Reviewed by: gnn, bms, bz? >>>> Obtained from: deischen (with help from) >>>> >>>> Modified: >>>> head/sys/netinet/udp_usrreq.c >>>> >>>> Modified: head/sys/netinet/udp_usrreq.c >>>> >>> ============================================================================== >>>> --- head/sys/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 (r217591) >>>> +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 (r217592) >>>> @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) >>>> * and source-specific multicast. [RFC3678] >>>> */ >>>> imo = inp->inp_moptions; >>>> - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && >>>> - imo != NULL) { >>>> + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { >>>> struct sockaddr_in group; >>>> int blocked; >>>> - >>>> + if(imo == NULL) { >>>> + INP_RUNLOCK(inp); >>>> + continue; >>>> + } >>>> bzero(&group, sizeof(struct sockaddr_in)); >>>> group.sin_len = sizeof(struct sockaddr_in); >>>> group.sin_family = AF_INET; >>> >>> So it turns out that this is a feature, not a bug, and is how multicast has >>> always worked. Specifically, if you bind a UDP socket with a wildcard >>> address, it should receive all traffic for the bound port, unicast or >>> multicast. When you join a group, you have switched the socket into a mode >>> where it now has a whitelist of acceptable multicast groups, but if a socket >>> has no joined groups, it should receive all multicast traffic, not none. This >>> change breaks that. >>> >>> I did not find this behavior intuitive at first, but it does seem to be >>> required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for >>> example: >> >> >> I agree getting a packet that is coming to your port without joining the >> multi-cast group is not intuitive to me... >> >>> >>> 3. Overview of APIs >>> >>> There are a number of different APIs described in this document that >>> are appropriate for a number of different application types and IP >>> versions. Before providing detailed descriptions, this section >>> provides a "taxonomy" with a brief description of each. >>> >>> There are two categories of source-filter APIs, both of which are >>> designed to allow multicast receiver applications to designate the >>> unicast address(es) of sender(s) along with the multicast group >>> (destination address) to receive. >>> >>> o Basic (Delta-based): Some applications desire the simplicity of >>> a delta-based API in which each function call specifies a >>> single source address which should be added to or removed from >>> the existing filter for a given multicast group address on >>> which to listen. Such applications typically fall into either >>> of two categories: >>> >>> + Any-Source Multicast: By default, all sources are accepted. >>> Individual sources may be turned off and back on as needed >>> over time. This is also known as "exclude" mode, since the >>> source filter contains a list of excluded sources. >>> >>> + Source-Specific Multicast: Only sources in a given list are >>> allowed. The list may change over time. This is also known >>> as "include" mode, since the source filter contains a list >>> of included sources. >>> >>> This API would be used, for example, by "single-source" >>> applications such as audio/video broadcasting. It would >>> also be used for logical multi-source sessions where each >>> source independently allocates its own Source-Specific >>> Multicast group address. >> >> >> Not the above document is talking about a receiver that as joined the >> multicast group (or is joining it and wants some filtering)... I don't >> see how that applies to a UDP socket that has NOT joined the M-cast group.. >> >>> >>> >>> ..... >>> >>> 4.1.1. IPv4 Any-Source Multicast API >>> >>> The following socket options are defined in for >>> applications in the Any-Source Multicast category: >>> >>> Socket option Argument type >>> IP_ADD_MEMBERSHIP struct ip_mreq >>> IP_BLOCK_SOURCE struct ip_mreq_source >>> IP_UNBLOCK_SOURCE struct ip_mreq_source >>> IP_DROP_MEMBERSHIP struct ip_mreq >>> >>> IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on >>> most operating systems, and are used to join and leave an any-source >>> group. >>> >>> IP_BLOCK_SOURCE can be used to block data from a given source to a >>> given group (e.g., if the user "mutes" that source), and >>> IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then >>> "unmutes" the source). >>> >>> As to why the packets loop back to the receiver, I believe that is a separate >>> issue on the output side, not the receive side. >> >> >> >> But that is what the commit fixes... > > Except you change receive, not transmit. I think the error in Daniel's case > is on the transmit side, not receive. I would be happy to know what the true > "official" behavior is for a socket that binds to INADDR_ANY but does not join > any groups. > > As far as prior to BMS's changes: in the older version of udp_input() we only > checked the membership list if inp->inp_moptions was != NULL. If it was NULL, > we would send all multicast packets to a given socket for which the address > fields matched (addr, port). > > BMS preserved this behavior and your patch changes But he changed the behavior on output. Pre-BMS and post-BMS behave differently and not like Solaris 10 or VxWorks. Haven't tried Linux. > it. UDP sockets start off with inp_moptions == NULL, so if you never do any > multicast-related setsockopt() you will receive all matching multicast packets. > However, once you do any multicast-related setsockopt() (IP_MULTICAST_LOOP, > IP_ADD_MEMBERSHIP, etc.) then inp_moptions is allocated and is non-NULL. > At that point it only accepts packets that match, except that even then we > used a sysctl which defaulted to off (!) to see if we should check the list of > memberships (net.inet.udp.strict_mcast_mship). This options structure was never > free'd, however, so you could get the truly bizarre behavior of: > > - bind a new socket, it will not receive all matching multicast traffic > - use IP_ADD_MEMBERSHIP to add a group, it will now receive only matching multicast > traffic for the group > - use IP_DROP_MEMBERSHIP to remove the group, it will now receive no multicast > traffic > > The different behavior in states 1 and 3 I find confusing and odd. By default > all sockets just always received all matching multicast traffic though. :) Not if a multicast group was not joined. The pre-BMS changes did not loop back multicast packets in ip_output.c. > However, this change is not restoring "old" behavior, it is a change in behavior > compared to the pre-BMS changes. Agreed, to preserve pre-BMS behavior, the change should be made on output. >> and as to the above, it again is >> talking about Multicast members.. AFAIKT... I am actually at the IETF >> so if you would like I can gladly go talk to the authors of this RFC >> (if they are here) and get their opinion on this. >> >> One other thing.. note this is NOT a standard but a informational RFC. Informational >> RFC are guidelines and NOT mandatory at all.. there will never be a MUST/SHOULD etc >> within them. > > Well, for lack of anything else I was looking to that. I would really prefer > the behavior in your change as I find it far more intuitive. I wasn't able to > find anything else in Stevens or elsewhere that seemed to indicate what the > proper behavior was beyond this. I also agree :-) -- DE From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 17:33:53 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D8111065673; Wed, 30 Mar 2011 17:33:53 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2B40A8FC14; Wed, 30 Mar 2011 17:33:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UHXrcp070240; Wed, 30 Mar 2011 17:33:53 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UHXriT070238; Wed, 30 Mar 2011 17:33:53 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201103301733.p2UHXriT070238@svn.freebsd.org> From: Josh Paetzel Date: Wed, 30 Mar 2011 17:33:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220161 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 17:33:53 -0000 Author: jpaetzel Date: Wed Mar 30 17:33:52 2011 New Revision: 220161 URL: http://svn.freebsd.org/changeset/base/220161 Log: Fix syntax error from previous commit. Approved by: kib (mentor) Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Wed Mar 30 14:48:49 2011 (r220160) +++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Wed Mar 30 17:33:52 2011 (r220161) @@ -421,7 +421,7 @@ setup_disk_slice() # Check if we have an image file defined echo $line | grep -q "^image=" 2>/dev/null - if [ $? eq 0 ] ; then + if [ $? -eq 0 ] ; then # Found an image= entry, lets read / set it get_value_from_string "${line}" strip_white_space "$VAL" From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 17:37:04 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7CAD8106566B; Wed, 30 Mar 2011 17:37:04 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6A2788FC0C; Wed, 30 Mar 2011 17:37:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UHb4MA070334; Wed, 30 Mar 2011 17:37:04 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UHb4j7070331; Wed, 30 Mar 2011 17:37:04 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201103301737.p2UHb4j7070331@svn.freebsd.org> From: Josh Paetzel Date: Wed, 30 Mar 2011 17:37:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220162 - head/usr.sbin/pc-sysinstall/backend-partmanager X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 17:37:04 -0000 Author: jpaetzel Date: Wed Mar 30 17:37:04 2011 New Revision: 220162 URL: http://svn.freebsd.org/changeset/base/220162 Log: Check in two missing files missed in cleanup. Change expr to $(()) Switch test from "$?" = "0" to $? -eq 0 Approved by: kib (mentor) Modified: head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh head/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh Modified: head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh Wed Mar 30 17:33:52 2011 (r220161) +++ head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh Wed Mar 30 17:37:04 2011 (r220162) @@ -85,7 +85,7 @@ fi # If this is an empty disk, see if we need to create a new scheme for it gpart show ${DISK} >/dev/null 2>/dev/null -if [ "$?" != "0" -a "${SLICENUM}" = "1" ] ; then +if [ $? -eq 0 -a "${SLICENUM}" = "1" ] ; then gpart create -s ${TYPE} ${DISK} fi Modified: head/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh Wed Mar 30 17:33:52 2011 (r220161) +++ head/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh Wed Mar 30 17:37:04 2011 (r220162) @@ -57,10 +57,10 @@ PARTINDEX="" while z=1 do - CHARS=`expr $CHARS - 1` + CHARS=$((CHARS-1)) LAST_CHAR=`echo "${PARTITION}" | cut -c $CHARS` - echo "${LAST_CHAR}" | grep "^[0-9]$" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo "${LAST_CHAR}" | grep -q "^[0-9]$" 2>/dev/null + if [ $? -eq 0 ] ; then PARTINDEX="${LAST_CHAR}${PARTINDEX}" else break From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 17:48:15 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 601FA1065670; Wed, 30 Mar 2011 17:48:15 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4B73E8FC19; Wed, 30 Mar 2011 17:48:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UHmFBD070610; Wed, 30 Mar 2011 17:48:15 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UHmF0g070602; Wed, 30 Mar 2011 17:48:15 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103301748.p2UHmF0g070602@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 30 Mar 2011 17:48:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220163 - in head/sys: compat/freebsd32 conf kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 17:48:15 -0000 Author: trasz Date: Wed Mar 30 17:48:15 2011 New Revision: 220163 URL: http://svn.freebsd.org/changeset/base/220163 Log: Add rctl. It's used by racct to take user-configurable actions based on the set of rules it maintains and the current resource usage. It also privides userland API to manage that ruleset. Sponsored by: The FreeBSD Foundation Reviewed by: kib (earlier version) Added: head/sys/kern/kern_rctl.c (contents, props changed) head/sys/sys/rctl.h (contents, props changed) Modified: head/sys/compat/freebsd32/syscalls.master head/sys/conf/NOTES head/sys/conf/files head/sys/conf/options head/sys/kern/kern_jail.c head/sys/kern/syscalls.master head/sys/sys/priv.h Modified: head/sys/compat/freebsd32/syscalls.master ============================================================================== --- head/sys/compat/freebsd32/syscalls.master Wed Mar 30 17:37:04 2011 (r220162) +++ head/sys/compat/freebsd32/syscalls.master Wed Mar 30 17:48:15 2011 (r220163) @@ -965,3 +965,18 @@ 523 AUE_NULL NOPROTO { int getloginclass(char *namebuf, \ size_t namelen); } 524 AUE_NULL NOPROTO { int setloginclass(const char *namebuf); } +525 AUE_NULL NOPROTO { int rctl_get_racct(const void *inbufp, \ + size_t inbuflen, void *outbufp, \ + size_t outbuflen); } +526 AUE_NULL NOPROTO { int rctl_get_rules(const void *inbufp, \ + size_t inbuflen, void *outbufp, \ + size_t outbuflen); } +527 AUE_NULL NOPROTO { int rctl_get_limits(const void *inbufp, \ + size_t inbuflen, void *outbufp, \ + size_t outbuflen); } +528 AUE_NULL NOPROTO { int rctl_add_rule(const void *inbufp, \ + size_t inbuflen, void *outbufp, \ + size_t outbuflen); } +529 AUE_NULL NOPROTO { int rctl_remove_rule(const void *inbufp, \ + size_t inbuflen, void *outbufp, \ + size_t outbuflen); } Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Wed Mar 30 17:37:04 2011 (r220162) +++ head/sys/conf/NOTES Wed Mar 30 17:48:15 2011 (r220163) @@ -2933,6 +2933,9 @@ options AAC_DEBUG # Debugging levels: # Resource Accounting options RACCT +# Resource Limits +options RCTL + # Yet more undocumented options for linting. # BKTR_ALLOC_PAGES has no effect except to cause warnings, and # BROOKTREE_ALLOC_PAGES hasn't actually been superseded by it, since the Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Wed Mar 30 17:37:04 2011 (r220162) +++ head/sys/conf/files Wed Mar 30 17:48:15 2011 (r220163) @@ -2226,6 +2226,7 @@ kern/kern_priv.c standard kern/kern_proc.c standard kern/kern_prot.c standard kern/kern_racct.c standard +kern/kern_rctl.c standard kern/kern_resource.c standard kern/kern_rmlock.c standard kern/kern_rwlock.c standard Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Wed Mar 30 17:37:04 2011 (r220162) +++ head/sys/conf/options Wed Mar 30 17:48:15 2011 (r220163) @@ -876,6 +876,9 @@ IPOIB_CM opt_ofed.h # Resource Accounting RACCT opt_global.h +# Resource Limits +RCTL opt_global.h + # At least one of the AR71XX ubiquiti boards has a Redboot configuration # that "lies" about the amount of RAM it has. Until a cleaner method is # defined, this option will suffice in overriding what Redboot says. Modified: head/sys/kern/kern_jail.c ============================================================================== --- head/sys/kern/kern_jail.c Wed Mar 30 17:37:04 2011 (r220162) +++ head/sys/kern/kern_jail.c Wed Mar 30 17:48:15 2011 (r220163) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -2532,6 +2533,9 @@ prison_deref(struct prison *pr, int flag if (pr->pr_cpuset != NULL) cpuset_rel(pr->pr_cpuset); osd_jail_exit(pr); +#ifdef RCTL + rctl_racct_release(pr->pr_racct); +#endif racct_destroy(&pr->pr_racct); free(pr, M_PRISON); Added: head/sys/kern/kern_rctl.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/kern/kern_rctl.c Wed Mar 30 17:48:15 2011 (r220163) @@ -0,0 +1,1850 @@ +/*- + * Copyright (c) 2010 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Edward Tomasz Napierala under sponsorship + * from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef RCTL +#ifndef RACCT +#error "The RCTL option requires the RACCT option" +#endif + +FEATURE(rctl, "Resource Limits"); + +#define HRF_DEFAULT 0 +#define HRF_DONT_INHERIT 1 +#define HRF_DONT_ACCUMULATE 2 + +/* Default buffer size for rctl_get_rules(2). */ +#define RCTL_DEFAULT_BUFSIZE 4096 +#define RCTL_LOG_BUFSIZE 128 + +/* + * 'rctl_rule_link' connects a rule with every racct it's related to. + * For example, rule 'user:X:openfiles:deny=N/process' is linked + * with uidinfo for user X, and to each process of that user. + */ +struct rctl_rule_link { + LIST_ENTRY(rctl_rule_link) rrl_next; + struct rctl_rule *rrl_rule; + int rrl_exceeded; +}; + +struct dict { + const char *d_name; + int d_value; +}; + +static struct dict subjectnames[] = { + { "process", RCTL_SUBJECT_TYPE_PROCESS }, + { "user", RCTL_SUBJECT_TYPE_USER }, + { "loginclass", RCTL_SUBJECT_TYPE_LOGINCLASS }, + { "jail", RCTL_SUBJECT_TYPE_JAIL }, + { NULL, -1 }}; + +static struct dict resourcenames[] = { + { "cpu", RACCT_CPU }, + { "fsize", RACCT_FSIZE }, + { "data", RACCT_DATA }, + { "stack", RACCT_STACK }, + { "core", RACCT_CORE }, + { "rss", RACCT_RSS }, + { "memlock", RACCT_MEMLOCK }, + { "nproc", RACCT_NPROC }, + { "nofile", RACCT_NOFILE }, + { "sbsize", RACCT_SBSIZE }, + { "vmem", RACCT_VMEM }, + { "npts", RACCT_NPTS }, + { "swap", RACCT_SWAP }, + { "nthr", RACCT_NTHR }, + { "msgqqueued", RACCT_MSGQQUEUED }, + { "msgqsize", RACCT_MSGQSIZE }, + { "nmsgq", RACCT_NMSGQ }, + { "nsem", RACCT_NSEM }, + { "nsemop", RACCT_NSEMOP }, + { "nshm", RACCT_NSHM }, + { "shmsize", RACCT_SHMSIZE }, + { "wallclock", RACCT_WALLCLOCK }, + { NULL, -1 }}; + +static struct dict actionnames[] = { + { "sighup", RCTL_ACTION_SIGHUP }, + { "sigint", RCTL_ACTION_SIGINT }, + { "sigquit", RCTL_ACTION_SIGQUIT }, + { "sigill", RCTL_ACTION_SIGILL }, + { "sigtrap", RCTL_ACTION_SIGTRAP }, + { "sigabrt", RCTL_ACTION_SIGABRT }, + { "sigemt", RCTL_ACTION_SIGEMT }, + { "sigfpe", RCTL_ACTION_SIGFPE }, + { "sigkill", RCTL_ACTION_SIGKILL }, + { "sigbus", RCTL_ACTION_SIGBUS }, + { "sigsegv", RCTL_ACTION_SIGSEGV }, + { "sigsys", RCTL_ACTION_SIGSYS }, + { "sigpipe", RCTL_ACTION_SIGPIPE }, + { "sigalrm", RCTL_ACTION_SIGALRM }, + { "sigterm", RCTL_ACTION_SIGTERM }, + { "sigurg", RCTL_ACTION_SIGURG }, + { "sigstop", RCTL_ACTION_SIGSTOP }, + { "sigtstp", RCTL_ACTION_SIGTSTP }, + { "sigchld", RCTL_ACTION_SIGCHLD }, + { "sigttin", RCTL_ACTION_SIGTTIN }, + { "sigttou", RCTL_ACTION_SIGTTOU }, + { "sigio", RCTL_ACTION_SIGIO }, + { "sigxcpu", RCTL_ACTION_SIGXCPU }, + { "sigxfsz", RCTL_ACTION_SIGXFSZ }, + { "sigvtalrm", RCTL_ACTION_SIGVTALRM }, + { "sigprof", RCTL_ACTION_SIGPROF }, + { "sigwinch", RCTL_ACTION_SIGWINCH }, + { "siginfo", RCTL_ACTION_SIGINFO }, + { "sigusr1", RCTL_ACTION_SIGUSR1 }, + { "sigusr2", RCTL_ACTION_SIGUSR2 }, + { "sigthr", RCTL_ACTION_SIGTHR }, + { "deny", RCTL_ACTION_DENY }, + { "log", RCTL_ACTION_LOG }, + { "devctl", RCTL_ACTION_DEVCTL }, + { NULL, -1 }}; + +static void rctl_init(void); +SYSINIT(rctl, SI_SUB_RACCT, SI_ORDER_FIRST, rctl_init, NULL); + +static uma_zone_t rctl_rule_link_zone; +static uma_zone_t rctl_rule_zone; +static struct rwlock rctl_lock; +RW_SYSINIT(rctl_lock, &rctl_lock, "RCTL lock"); + +static int rctl_rule_fully_specified(const struct rctl_rule *rule); +static void rctl_rule_to_sbuf(struct sbuf *sb, const struct rctl_rule *rule); + +MALLOC_DEFINE(M_RCTL, "rctl", "Resource Limits"); + +static const char * +rctl_subject_type_name(int subject) +{ + int i; + + for (i = 0; subjectnames[i].d_name != NULL; i++) { + if (subjectnames[i].d_value == subject) + return (subjectnames[i].d_name); + } + + panic("rctl_subject_type_name: unknown subject type %d", subject); +} + +static const char * +rctl_action_name(int action) +{ + int i; + + for (i = 0; actionnames[i].d_name != NULL; i++) { + if (actionnames[i].d_value == action) + return (actionnames[i].d_name); + } + + panic("rctl_action_name: unknown action %d", action); +} + +const char * +rctl_resource_name(int resource) +{ + int i; + + for (i = 0; resourcenames[i].d_name != NULL; i++) { + if (resourcenames[i].d_value == resource) + return (resourcenames[i].d_name); + } + + panic("rctl_resource_name: unknown resource %d", resource); +} + +/* + * Return the amount of resource that can be allocated by 'p' before + * hitting 'rule'. + */ +static int64_t +rctl_available_resource(const struct proc *p, const struct rctl_rule *rule) +{ + int resource; + int64_t available = INT64_MAX; + struct ucred *cred = p->p_ucred; + + rw_assert(&rctl_lock, RA_LOCKED); + + resource = rule->rr_resource; + switch (rule->rr_per) { + case RCTL_SUBJECT_TYPE_PROCESS: + available = rule->rr_amount - + p->p_racct->r_resources[resource]; + break; + case RCTL_SUBJECT_TYPE_USER: + available = rule->rr_amount - + cred->cr_ruidinfo->ui_racct->r_resources[resource]; + break; + case RCTL_SUBJECT_TYPE_LOGINCLASS: + available = rule->rr_amount - + cred->cr_loginclass->lc_racct->r_resources[resource]; + break; + case RCTL_SUBJECT_TYPE_JAIL: + available = rule->rr_amount - + cred->cr_prison->pr_racct->r_resources[resource]; + break; + default: + panic("rctl_compute_available: unknown per %d", + rule->rr_per); + } + + return (available); +} + +/* + * Return non-zero if allocating 'amount' by proc 'p' would exceed + * resource limit specified by 'rule'. + */ +static int +rctl_would_exceed(const struct proc *p, const struct rctl_rule *rule, + int64_t amount) +{ + int64_t available; + + rw_assert(&rctl_lock, RA_LOCKED); + + available = rctl_available_resource(p, rule); + if (available >= amount) + return (0); + + return (1); +} + +/* + * Check whether the proc 'p' can allocate 'amount' of 'resource' in addition + * to what it keeps allocated now. Returns non-zero if the allocation should + * be denied, 0 otherwise. + */ +int +rctl_enforce(struct proc *p, int resource, uint64_t amount) +{ + struct rctl_rule *rule; + struct rctl_rule_link *link; + struct sbuf sb; + int should_deny = 0; + char *buf; + static int curtime = 0; + static struct timeval lasttime; + + rw_rlock(&rctl_lock); + + /* + * There may be more than one matching rule; go through all of them. + * Denial should be done last, after logging and sending signals. + */ + LIST_FOREACH(link, &p->p_racct->r_rule_links, rrl_next) { + rule = link->rrl_rule; + if (rule->rr_resource != resource) + continue; + if (!rctl_would_exceed(p, rule, amount)) { + link->rrl_exceeded = 0; + continue; + } + + switch (rule->rr_action) { + case RCTL_ACTION_DENY: + should_deny = 1; + continue; + case RCTL_ACTION_LOG: + /* + * If rrl_exceeded != 0, it means we've already + * logged a warning for this process. + */ + if (link->rrl_exceeded != 0) + continue; + + if (!ppsratecheck(&lasttime, &curtime, 10)) + continue; + + buf = malloc(RCTL_LOG_BUFSIZE, M_RCTL, M_NOWAIT); + if (buf == NULL) { + printf("rctl_enforce: out of memory\n"); + continue; + } + sbuf_new(&sb, buf, RCTL_LOG_BUFSIZE, SBUF_FIXEDLEN); + rctl_rule_to_sbuf(&sb, rule); + sbuf_finish(&sb); + printf("rctl: rule \"%s\" matched by pid %d " + "(%s), uid %d, jail %s\n", sbuf_data(&sb), + p->p_pid, p->p_comm, p->p_ucred->cr_uid, + p->p_ucred->cr_prison->pr_name); + sbuf_delete(&sb); + free(buf, M_RCTL); + link->rrl_exceeded = 1; + continue; + case RCTL_ACTION_DEVCTL: + if (link->rrl_exceeded != 0) + continue; + + buf = malloc(RCTL_LOG_BUFSIZE, M_RCTL, M_NOWAIT); + if (buf == NULL) { + printf("rctl_enforce: out of memory\n"); + continue; + } + sbuf_new(&sb, buf, RCTL_LOG_BUFSIZE, SBUF_FIXEDLEN); + sbuf_printf(&sb, "rule="); + rctl_rule_to_sbuf(&sb, rule); + sbuf_printf(&sb, " pid=%d ruid=%d jail=%s", + p->p_pid, p->p_ucred->cr_ruid, + p->p_ucred->cr_prison->pr_name); + sbuf_finish(&sb); + devctl_notify_f("RCTL", "rule", "matched", + sbuf_data(&sb), M_NOWAIT); + sbuf_delete(&sb); + free(buf, M_RCTL); + link->rrl_exceeded = 1; + continue; + default: + if (link->rrl_exceeded != 0) + continue; + + KASSERT(rule->rr_action > 0 && + rule->rr_action <= RCTL_ACTION_SIGNAL_MAX, + ("rctl_enforce: unknown action %d", + rule->rr_action)); + + /* + * We're using the fact that RCTL_ACTION_SIG* values + * are equal to their counterparts from sys/signal.h. + */ + psignal(p, rule->rr_action); + link->rrl_exceeded = 1; + continue; + } + } + + rw_runlock(&rctl_lock); + + if (should_deny) { + /* + * Return fake error code; the caller should change it + * into one proper for the situation - EFSIZ, ENOMEM etc. + */ + return (EDOOFUS); + } + + return (0); +} + +uint64_t +rctl_get_limit(struct proc *p, int resource) +{ + struct rctl_rule *rule; + struct rctl_rule_link *link; + uint64_t amount = UINT64_MAX; + + rw_rlock(&rctl_lock); + + /* + * There may be more than one matching rule; go through all of them. + * Denial should be done last, after logging and sending signals. + */ + LIST_FOREACH(link, &p->p_racct->r_rule_links, rrl_next) { + rule = link->rrl_rule; + if (rule->rr_resource != resource) + continue; + if (rule->rr_action != RCTL_ACTION_DENY) + continue; + if (rule->rr_amount < amount) + amount = rule->rr_amount; + } + + rw_runlock(&rctl_lock); + + return (amount); +} + +uint64_t +rctl_get_available(struct proc *p, int resource) +{ + struct rctl_rule *rule; + struct rctl_rule_link *link; + int64_t available, minavailable, allocated; + + minavailable = INT64_MAX; + + rw_rlock(&rctl_lock); + + /* + * There may be more than one matching rule; go through all of them. + * Denial should be done last, after logging and sending signals. + */ + LIST_FOREACH(link, &p->p_racct->r_rule_links, rrl_next) { + rule = link->rrl_rule; + if (rule->rr_resource != resource) + continue; + if (rule->rr_action != RCTL_ACTION_DENY) + continue; + available = rctl_available_resource(p, rule); + if (available < minavailable) + minavailable = available; + } + + rw_runlock(&rctl_lock); + + /* + * XXX: Think about this _hard_. + */ + allocated = p->p_racct->r_resources[resource]; + if (minavailable < INT64_MAX - allocated) + minavailable += allocated; + if (minavailable < 0) + minavailable = 0; + return (minavailable); +} + +static int +rctl_rule_matches(const struct rctl_rule *rule, const struct rctl_rule *filter) +{ + + if (filter->rr_subject_type != RCTL_SUBJECT_TYPE_UNDEFINED) { + if (rule->rr_subject_type != filter->rr_subject_type) + return (0); + + switch (filter->rr_subject_type) { + case RCTL_SUBJECT_TYPE_PROCESS: + if (filter->rr_subject.rs_proc != NULL && + rule->rr_subject.rs_proc != + filter->rr_subject.rs_proc) + return (0); + break; + case RCTL_SUBJECT_TYPE_USER: + if (filter->rr_subject.rs_uip != NULL && + rule->rr_subject.rs_uip != + filter->rr_subject.rs_uip) + return (0); + break; + case RCTL_SUBJECT_TYPE_LOGINCLASS: + if (filter->rr_subject.hr_loginclass != NULL && + rule->rr_subject.hr_loginclass != + filter->rr_subject.hr_loginclass) + return (0); + break; + case RCTL_SUBJECT_TYPE_JAIL: + if (filter->rr_subject.rs_prison != NULL && + rule->rr_subject.rs_prison != + filter->rr_subject.rs_prison) + return (0); + break; + default: + panic("rctl_rule_matches: unknown subject type %d", + filter->rr_subject_type); + } + } + + if (filter->rr_resource != RACCT_UNDEFINED) { + if (rule->rr_resource != filter->rr_resource) + return (0); + } + + if (filter->rr_action != RCTL_ACTION_UNDEFINED) { + if (rule->rr_action != filter->rr_action) + return (0); + } + + if (filter->rr_amount != RCTL_AMOUNT_UNDEFINED) { + if (rule->rr_amount != filter->rr_amount) + return (0); + } + + if (filter->rr_per != RCTL_SUBJECT_TYPE_UNDEFINED) { + if (rule->rr_per != filter->rr_per) + return (0); + } + + return (1); +} + +static int +str2value(const char *str, int *value, struct dict *table) +{ + int i; + + if (value == NULL) + return (EINVAL); + + for (i = 0; table[i].d_name != NULL; i++) { + if (strcasecmp(table[i].d_name, str) == 0) { + *value = table[i].d_value; + return (0); + } + } + + return (EINVAL); +} + +static int +str2id(const char *str, id_t *value) +{ + char *end; + + if (str == NULL) + return (EINVAL); + + *value = strtoul(str, &end, 10); + if ((size_t)(end - str) != strlen(str)) + return (EINVAL); + + return (0); +} + +static int +str2int64(const char *str, int64_t *value) +{ + char *end; + + if (str == NULL) + return (EINVAL); + + *value = strtoul(str, &end, 10); + if ((size_t)(end - str) != strlen(str)) + return (EINVAL); + + return (0); +} + +/* + * Connect the rule to the racct, increasing refcount for the rule. + */ +static void +rctl_racct_add_rule(struct racct *racct, struct rctl_rule *rule) +{ + struct rctl_rule_link *link; + + KASSERT(rctl_rule_fully_specified(rule), ("rule not fully specified")); + + rctl_rule_acquire(rule); + link = uma_zalloc(rctl_rule_link_zone, M_WAITOK); + link->rrl_rule = rule; + link->rrl_exceeded = 0; + + rw_wlock(&rctl_lock); + LIST_INSERT_HEAD(&racct->r_rule_links, link, rrl_next); + rw_wunlock(&rctl_lock); +} + +static int +rctl_racct_add_rule_locked(struct racct *racct, struct rctl_rule *rule) +{ + struct rctl_rule_link *link; + + KASSERT(rctl_rule_fully_specified(rule), ("rule not fully specified")); + rw_assert(&rctl_lock, RA_WLOCKED); + + link = uma_zalloc(rctl_rule_link_zone, M_NOWAIT); + if (link == NULL) + return (ENOMEM); + rctl_rule_acquire(rule); + link->rrl_rule = rule; + link->rrl_exceeded = 0; + + LIST_INSERT_HEAD(&racct->r_rule_links, link, rrl_next); + return (0); +} + +/* + * Remove limits for a rules matching the filter and release + * the refcounts for the rules, possibly freeing them. Returns + * the number of limit structures removed. + */ +static int +rctl_racct_remove_rules(struct racct *racct, + const struct rctl_rule *filter) +{ + int removed = 0; + struct rctl_rule_link *link, *linktmp; + + rw_assert(&rctl_lock, RA_WLOCKED); + + LIST_FOREACH_SAFE(link, &racct->r_rule_links, rrl_next, linktmp) { + if (!rctl_rule_matches(link->rrl_rule, filter)) + continue; + + LIST_REMOVE(link, rrl_next); + rctl_rule_release(link->rrl_rule); + uma_zfree(rctl_rule_link_zone, link); + removed++; + } + return (removed); +} + +static void +rctl_rule_acquire_subject(struct rctl_rule *rule) +{ + + switch (rule->rr_subject_type) { + case RCTL_SUBJECT_TYPE_UNDEFINED: + case RCTL_SUBJECT_TYPE_PROCESS: + case RCTL_SUBJECT_TYPE_JAIL: + break; + case RCTL_SUBJECT_TYPE_USER: + if (rule->rr_subject.rs_uip != NULL) + uihold(rule->rr_subject.rs_uip); + break; + case RCTL_SUBJECT_TYPE_LOGINCLASS: + if (rule->rr_subject.hr_loginclass != NULL) + loginclass_hold(rule->rr_subject.hr_loginclass); + break; + default: + panic("rctl_rule_acquire_subject: unknown subject type %d", + rule->rr_subject_type); + } +} + +static void +rctl_rule_release_subject(struct rctl_rule *rule) +{ + + switch (rule->rr_subject_type) { + case RCTL_SUBJECT_TYPE_UNDEFINED: + case RCTL_SUBJECT_TYPE_PROCESS: + case RCTL_SUBJECT_TYPE_JAIL: + break; + case RCTL_SUBJECT_TYPE_USER: + if (rule->rr_subject.rs_uip != NULL) + uifree(rule->rr_subject.rs_uip); + break; + case RCTL_SUBJECT_TYPE_LOGINCLASS: + if (rule->rr_subject.hr_loginclass != NULL) + loginclass_free(rule->rr_subject.hr_loginclass); + break; + default: + panic("rctl_rule_release_subject: unknown subject type %d", + rule->rr_subject_type); + } +} + +struct rctl_rule * +rctl_rule_alloc(int flags) +{ + struct rctl_rule *rule; + + rule = uma_zalloc(rctl_rule_zone, flags); + if (rule == NULL) + return (NULL); + rule->rr_subject_type = RCTL_SUBJECT_TYPE_UNDEFINED; + rule->rr_subject.rs_proc = NULL; + rule->rr_subject.rs_uip = NULL; + rule->rr_subject.hr_loginclass = NULL; + rule->rr_subject.rs_prison = NULL; + rule->rr_per = RCTL_SUBJECT_TYPE_UNDEFINED; + rule->rr_resource = RACCT_UNDEFINED; + rule->rr_action = RCTL_ACTION_UNDEFINED; + rule->rr_amount = RCTL_AMOUNT_UNDEFINED; + refcount_init(&rule->rr_refcount, 1); + + return (rule); +} + +struct rctl_rule * +rctl_rule_duplicate(const struct rctl_rule *rule, int flags) +{ + struct rctl_rule *copy; + + copy = uma_zalloc(rctl_rule_zone, flags); + if (copy == NULL) + return (NULL); + copy->rr_subject_type = rule->rr_subject_type; + copy->rr_subject.rs_proc = rule->rr_subject.rs_proc; + copy->rr_subject.rs_uip = rule->rr_subject.rs_uip; + copy->rr_subject.hr_loginclass = rule->rr_subject.hr_loginclass; + copy->rr_subject.rs_prison = rule->rr_subject.rs_prison; + copy->rr_per = rule->rr_per; + copy->rr_resource = rule->rr_resource; + copy->rr_action = rule->rr_action; + copy->rr_amount = rule->rr_amount; + refcount_init(©->rr_refcount, 1); + rctl_rule_acquire_subject(copy); + + return (copy); +} + +void +rctl_rule_acquire(struct rctl_rule *rule) +{ + + KASSERT(rule->rr_refcount > 0, ("rule->rr_refcount <= 0")); + + refcount_acquire(&rule->rr_refcount); +} + +static void +rctl_rule_free(void *context, int pending) +{ + struct rctl_rule *rule; + + rule = (struct rctl_rule *)context; + + KASSERT(rule->rr_refcount == 0, ("rule->rr_refcount != 0")); + + /* + * We don't need locking here; rule is guaranteed to be inaccessible. + */ + + rctl_rule_release_subject(rule); + uma_zfree(rctl_rule_zone, rule); +} + +void +rctl_rule_release(struct rctl_rule *rule) +{ + + KASSERT(rule->rr_refcount > 0, ("rule->rr_refcount <= 0")); + + if (refcount_release(&rule->rr_refcount)) { + /* + * rctl_rule_release() is often called when iterating + * over all the uidinfo structures in the system, + * holding uihashtbl_lock. Since rctl_rule_free() + * might end up calling uifree(), this would lead + * to lock recursion. Use taskqueue to avoid this. + */ + TASK_INIT(&rule->rr_task, 0, rctl_rule_free, rule); + taskqueue_enqueue(taskqueue_thread, &rule->rr_task); + } +} + +static int +rctl_rule_fully_specified(const struct rctl_rule *rule) +{ + + switch (rule->rr_subject_type) { + case RCTL_SUBJECT_TYPE_UNDEFINED: + return (0); + case RCTL_SUBJECT_TYPE_PROCESS: + if (rule->rr_subject.rs_proc == NULL) + return (0); + break; + case RCTL_SUBJECT_TYPE_USER: + if (rule->rr_subject.rs_uip == NULL) + return (0); + break; + case RCTL_SUBJECT_TYPE_LOGINCLASS: + if (rule->rr_subject.hr_loginclass == NULL) + return (0); + break; + case RCTL_SUBJECT_TYPE_JAIL: + if (rule->rr_subject.rs_prison == NULL) + return (0); + break; + default: + panic("rctl_rule_fully_specified: unknown subject type %d", + rule->rr_subject_type); + } + if (rule->rr_resource == RACCT_UNDEFINED) + return (0); + if (rule->rr_action == RCTL_ACTION_UNDEFINED) + return (0); + if (rule->rr_amount == RCTL_AMOUNT_UNDEFINED) + return (0); + if (rule->rr_per == RCTL_SUBJECT_TYPE_UNDEFINED) + return (0); + + return (1); +} + +static int +rctl_string_to_rule(char *rulestr, struct rctl_rule **rulep) +{ + int error = 0; + char *subjectstr, *subject_idstr, *resourcestr, *actionstr, + *amountstr, *perstr; + struct rctl_rule *rule; + id_t id; + + rule = rctl_rule_alloc(M_WAITOK); + + subjectstr = strsep(&rulestr, ":"); + subject_idstr = strsep(&rulestr, ":"); + resourcestr = strsep(&rulestr, ":"); + actionstr = strsep(&rulestr, "=/"); + amountstr = strsep(&rulestr, "/"); + perstr = rulestr; + + if (subjectstr == NULL || subjectstr[0] == '\0') + rule->rr_subject_type = RCTL_SUBJECT_TYPE_UNDEFINED; + else { + error = str2value(subjectstr, &rule->rr_subject_type, subjectnames); + if (error != 0) + goto out; + } + + if (subject_idstr == NULL || subject_idstr[0] == '\0') { + rule->rr_subject.rs_proc = NULL; + rule->rr_subject.rs_uip = NULL; + rule->rr_subject.hr_loginclass = NULL; + rule->rr_subject.rs_prison = NULL; + } else { + switch (rule->rr_subject_type) { + case RCTL_SUBJECT_TYPE_UNDEFINED: + error = EINVAL; + goto out; + case RCTL_SUBJECT_TYPE_PROCESS: + error = str2id(subject_idstr, &id); + if (error != 0) + goto out; + sx_assert(&allproc_lock, SA_LOCKED); + rule->rr_subject.rs_proc = pfind(id); + if (rule->rr_subject.rs_proc == NULL) { + error = ESRCH; + goto out; + } + PROC_UNLOCK(rule->rr_subject.rs_proc); + break; + case RCTL_SUBJECT_TYPE_USER: + error = str2id(subject_idstr, &id); + if (error != 0) + goto out; + rule->rr_subject.rs_uip = uifind(id); + break; + case RCTL_SUBJECT_TYPE_LOGINCLASS: + rule->rr_subject.hr_loginclass = + loginclass_find(subject_idstr); + if (rule->rr_subject.hr_loginclass == NULL) { + error = ENAMETOOLONG; + goto out; + } + break; + case RCTL_SUBJECT_TYPE_JAIL: + rule->rr_subject.rs_prison = + prison_find_name(&prison0, subject_idstr); + if (rule->rr_subject.rs_prison == NULL) { + /* + * No jail with that name; try with the JID. + */ + error = str2id(subject_idstr, &id); + if (error != 0) + goto out; + rule->rr_subject.rs_prison = prison_find(id); + if (rule->rr_subject.rs_prison == NULL) { + error = ESRCH; + goto out; + } + } + /* prison_find() returns with mutex held. */ + mtx_unlock(&rule->rr_subject.rs_prison->pr_mtx); + break; + default: + panic("rctl_string_to_rule: unknown subject type %d", + rule->rr_subject_type); + } + } + + if (resourcestr == NULL || resourcestr[0] == '\0') + rule->rr_resource = RACCT_UNDEFINED; + else { + error = str2value(resourcestr, &rule->rr_resource, + resourcenames); + if (error != 0) + goto out; + } + + if (actionstr == NULL || actionstr[0] == '\0') + rule->rr_action = RCTL_ACTION_UNDEFINED; + else { + error = str2value(actionstr, &rule->rr_action, actionnames); + if (error != 0) + goto out; + } + + if (amountstr == NULL || amountstr[0] == '\0') + rule->rr_amount = RCTL_AMOUNT_UNDEFINED; + else { + error = str2int64(amountstr, &rule->rr_amount); + if (error != 0) + goto out; + if (racct_is_in_thousands(rule->rr_resource)) + rule->rr_amount *= 1000; + } + + if (perstr == NULL || perstr[0] == '\0') + rule->rr_per = RCTL_SUBJECT_TYPE_UNDEFINED; + else { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 17:59:54 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7FAC1106564A; Wed, 30 Mar 2011 17:59:54 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6B96D8FC19; Wed, 30 Mar 2011 17:59:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UHxso1070913; Wed, 30 Mar 2011 17:59:54 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UHxsTW070901; Wed, 30 Mar 2011 17:59:54 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103301759.p2UHxsTW070901@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 30 Mar 2011 17:59:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220164 - in head/sys: compat/freebsd32 kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 17:59:54 -0000 Author: trasz Date: Wed Mar 30 17:59:54 2011 New Revision: 220164 URL: http://svn.freebsd.org/changeset/base/220164 Log: Regenerate. Modified: head/sys/compat/freebsd32/freebsd32_proto.h head/sys/compat/freebsd32/freebsd32_syscall.h head/sys/compat/freebsd32/freebsd32_syscalls.c head/sys/compat/freebsd32/freebsd32_sysent.c head/sys/compat/freebsd32/freebsd32_systrace_args.c head/sys/kern/init_sysent.c head/sys/kern/syscalls.c head/sys/kern/systrace_args.c head/sys/sys/syscall.h head/sys/sys/syscall.mk head/sys/sys/sysproto.h Modified: head/sys/compat/freebsd32/freebsd32_proto.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_proto.h Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/compat/freebsd32/freebsd32_proto.h Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ #ifndef _FREEBSD32_SYSPROTO_H_ Modified: head/sys/compat/freebsd32/freebsd32_syscall.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_syscall.h Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/compat/freebsd32/freebsd32_syscall.h Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ #define FREEBSD32_SYS_syscall 0 @@ -414,4 +414,9 @@ #define FREEBSD32_SYS_freebsd32_pselect 522 #define FREEBSD32_SYS_getloginclass 523 #define FREEBSD32_SYS_setloginclass 524 -#define FREEBSD32_SYS_MAXSYSCALL 525 +#define FREEBSD32_SYS_rctl_get_racct 525 +#define FREEBSD32_SYS_rctl_get_rules 526 +#define FREEBSD32_SYS_rctl_get_limits 527 +#define FREEBSD32_SYS_rctl_add_rule 528 +#define FREEBSD32_SYS_rctl_remove_rule 529 +#define FREEBSD32_SYS_MAXSYSCALL 530 Modified: head/sys/compat/freebsd32/freebsd32_syscalls.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_syscalls.c Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/compat/freebsd32/freebsd32_syscalls.c Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ const char *freebsd32_syscallnames[] = { @@ -548,4 +548,9 @@ const char *freebsd32_syscallnames[] = { "freebsd32_pselect", /* 522 = freebsd32_pselect */ "getloginclass", /* 523 = getloginclass */ "setloginclass", /* 524 = setloginclass */ + "rctl_get_racct", /* 525 = rctl_get_racct */ + "rctl_get_rules", /* 526 = rctl_get_rules */ + "rctl_get_limits", /* 527 = rctl_get_limits */ + "rctl_add_rule", /* 528 = rctl_add_rule */ + "rctl_remove_rule", /* 529 = rctl_remove_rule */ }; Modified: head/sys/compat/freebsd32/freebsd32_sysent.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_sysent.c Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/compat/freebsd32/freebsd32_sysent.c Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ #include "opt_compat.h" @@ -585,4 +585,9 @@ struct sysent freebsd32_sysent[] = { { AS(freebsd32_pselect_args), (sy_call_t *)freebsd32_pselect, AUE_SELECT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 522 = freebsd32_pselect */ { AS(getloginclass_args), (sy_call_t *)getloginclass, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 523 = getloginclass */ { AS(setloginclass_args), (sy_call_t *)setloginclass, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 524 = setloginclass */ + { AS(rctl_get_racct_args), (sy_call_t *)rctl_get_racct, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 525 = rctl_get_racct */ + { AS(rctl_get_rules_args), (sy_call_t *)rctl_get_rules, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 526 = rctl_get_rules */ + { AS(rctl_get_limits_args), (sy_call_t *)rctl_get_limits, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 527 = rctl_get_limits */ + { AS(rctl_add_rule_args), (sy_call_t *)rctl_add_rule, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 528 = rctl_add_rule */ + { AS(rctl_remove_rule_args), (sy_call_t *)rctl_remove_rule, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 529 = rctl_remove_rule */ }; Modified: head/sys/compat/freebsd32/freebsd32_systrace_args.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_systrace_args.c Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/compat/freebsd32/freebsd32_systrace_args.c Wed Mar 30 17:59:54 2011 (r220164) @@ -2957,6 +2957,56 @@ systrace_args(int sysnum, void *params, *n_args = 1; break; } + /* rctl_get_racct */ + case 525: { + struct rctl_get_racct_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_get_rules */ + case 526: { + struct rctl_get_rules_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_get_limits */ + case 527: { + struct rctl_get_limits_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_add_rule */ + case 528: { + struct rctl_add_rule_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_remove_rule */ + case 529: { + struct rctl_remove_rule_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } default: *n_args = 0; break; @@ -7873,6 +7923,101 @@ systrace_setargdesc(int sysnum, int ndx, break; }; break; + /* rctl_get_racct */ + case 525: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_get_rules */ + case 526: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_get_limits */ + case 527: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_add_rule */ + case 528: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_remove_rule */ + case 529: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; default: break; }; Modified: head/sys/kern/init_sysent.c ============================================================================== --- head/sys/kern/init_sysent.c Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/kern/init_sysent.c Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/kern/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/kern/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ #include "opt_compat.h" @@ -559,4 +559,9 @@ struct sysent sysent[] = { { AS(pselect_args), (sy_call_t *)pselect, AUE_SELECT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 522 = pselect */ { AS(getloginclass_args), (sy_call_t *)getloginclass, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 523 = getloginclass */ { AS(setloginclass_args), (sy_call_t *)setloginclass, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 524 = setloginclass */ + { AS(rctl_get_racct_args), (sy_call_t *)rctl_get_racct, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 525 = rctl_get_racct */ + { AS(rctl_get_rules_args), (sy_call_t *)rctl_get_rules, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 526 = rctl_get_rules */ + { AS(rctl_get_limits_args), (sy_call_t *)rctl_get_limits, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 527 = rctl_get_limits */ + { AS(rctl_add_rule_args), (sy_call_t *)rctl_add_rule, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 528 = rctl_add_rule */ + { AS(rctl_remove_rule_args), (sy_call_t *)rctl_remove_rule, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 529 = rctl_remove_rule */ }; Modified: head/sys/kern/syscalls.c ============================================================================== --- head/sys/kern/syscalls.c Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/kern/syscalls.c Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/kern/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/kern/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ const char *syscallnames[] = { @@ -532,4 +532,9 @@ const char *syscallnames[] = { "pselect", /* 522 = pselect */ "getloginclass", /* 523 = getloginclass */ "setloginclass", /* 524 = setloginclass */ + "rctl_get_racct", /* 525 = rctl_get_racct */ + "rctl_get_rules", /* 526 = rctl_get_rules */ + "rctl_get_limits", /* 527 = rctl_get_limits */ + "rctl_add_rule", /* 528 = rctl_add_rule */ + "rctl_remove_rule", /* 529 = rctl_remove_rule */ }; Modified: head/sys/kern/systrace_args.c ============================================================================== --- head/sys/kern/systrace_args.c Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/kern/systrace_args.c Wed Mar 30 17:59:54 2011 (r220164) @@ -3135,6 +3135,56 @@ systrace_args(int sysnum, void *params, *n_args = 1; break; } + /* rctl_get_racct */ + case 525: { + struct rctl_get_racct_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_get_rules */ + case 526: { + struct rctl_get_rules_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_get_limits */ + case 527: { + struct rctl_get_limits_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_add_rule */ + case 528: { + struct rctl_add_rule_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_remove_rule */ + case 529: { + struct rctl_remove_rule_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } default: *n_args = 0; break; @@ -8328,6 +8378,101 @@ systrace_setargdesc(int sysnum, int ndx, break; }; break; + /* rctl_get_racct */ + case 525: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_get_rules */ + case 526: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_get_limits */ + case 527: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_add_rule */ + case 528: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_remove_rule */ + case 529: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; default: break; }; Modified: head/sys/sys/syscall.h ============================================================================== --- head/sys/sys/syscall.h Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/sys/syscall.h Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/kern/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/kern/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ #define SYS_syscall 0 @@ -435,4 +435,9 @@ #define SYS_pselect 522 #define SYS_getloginclass 523 #define SYS_setloginclass 524 -#define SYS_MAXSYSCALL 525 +#define SYS_rctl_get_racct 525 +#define SYS_rctl_get_rules 526 +#define SYS_rctl_get_limits 527 +#define SYS_rctl_add_rule 528 +#define SYS_rctl_remove_rule 529 +#define SYS_MAXSYSCALL 530 Modified: head/sys/sys/syscall.mk ============================================================================== --- head/sys/sys/syscall.mk Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/sys/syscall.mk Wed Mar 30 17:59:54 2011 (r220164) @@ -1,7 +1,7 @@ # FreeBSD system call names. # DO NOT EDIT-- this file is automatically generated. # $FreeBSD$ -# created from FreeBSD: head/sys/kern/syscalls.master 219304 2011-03-05 12:40:35Z trasz +# created from FreeBSD: head/sys/kern/syscalls.master 220163 2011-03-30 17:48:15Z trasz MIASM = \ syscall.o \ exit.o \ @@ -383,4 +383,9 @@ MIASM = \ cap_getmode.o \ pselect.o \ getloginclass.o \ - setloginclass.o + setloginclass.o \ + rctl_get_racct.o \ + rctl_get_rules.o \ + rctl_get_limits.o \ + rctl_add_rule.o \ + rctl_remove_rule.o Modified: head/sys/sys/sysproto.h ============================================================================== --- head/sys/sys/sysproto.h Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/sys/sysproto.h Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/kern/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/kern/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ #ifndef _SYS_SYSPROTO_H_ @@ -1678,6 +1678,36 @@ struct getloginclass_args { struct setloginclass_args { char namebuf_l_[PADL_(const char *)]; const char * namebuf; char namebuf_r_[PADR_(const char *)]; }; +struct rctl_get_racct_args { + char inbufp_l_[PADL_(const void *)]; const void * inbufp; char inbufp_r_[PADR_(const void *)]; + char inbuflen_l_[PADL_(size_t)]; size_t inbuflen; char inbuflen_r_[PADR_(size_t)]; + char outbufp_l_[PADL_(void *)]; void * outbufp; char outbufp_r_[PADR_(void *)]; + char outbuflen_l_[PADL_(size_t)]; size_t outbuflen; char outbuflen_r_[PADR_(size_t)]; +}; +struct rctl_get_rules_args { + char inbufp_l_[PADL_(const void *)]; const void * inbufp; char inbufp_r_[PADR_(const void *)]; + char inbuflen_l_[PADL_(size_t)]; size_t inbuflen; char inbuflen_r_[PADR_(size_t)]; + char outbufp_l_[PADL_(void *)]; void * outbufp; char outbufp_r_[PADR_(void *)]; + char outbuflen_l_[PADL_(size_t)]; size_t outbuflen; char outbuflen_r_[PADR_(size_t)]; +}; +struct rctl_get_limits_args { + char inbufp_l_[PADL_(const void *)]; const void * inbufp; char inbufp_r_[PADR_(const void *)]; + char inbuflen_l_[PADL_(size_t)]; size_t inbuflen; char inbuflen_r_[PADR_(size_t)]; + char outbufp_l_[PADL_(void *)]; void * outbufp; char outbufp_r_[PADR_(void *)]; + char outbuflen_l_[PADL_(size_t)]; size_t outbuflen; char outbuflen_r_[PADR_(size_t)]; +}; +struct rctl_add_rule_args { + char inbufp_l_[PADL_(const void *)]; const void * inbufp; char inbufp_r_[PADR_(const void *)]; + char inbuflen_l_[PADL_(size_t)]; size_t inbuflen; char inbuflen_r_[PADR_(size_t)]; + char outbufp_l_[PADL_(void *)]; void * outbufp; char outbufp_r_[PADR_(void *)]; + char outbuflen_l_[PADL_(size_t)]; size_t outbuflen; char outbuflen_r_[PADR_(size_t)]; +}; +struct rctl_remove_rule_args { + char inbufp_l_[PADL_(const void *)]; const void * inbufp; char inbufp_r_[PADR_(const void *)]; + char inbuflen_l_[PADL_(size_t)]; size_t inbuflen; char inbuflen_r_[PADR_(size_t)]; + char outbufp_l_[PADL_(void *)]; void * outbufp; char outbufp_r_[PADR_(void *)]; + char outbuflen_l_[PADL_(size_t)]; size_t outbuflen; char outbuflen_r_[PADR_(size_t)]; +}; int nosys(struct thread *, struct nosys_args *); void sys_exit(struct thread *, struct sys_exit_args *); int fork(struct thread *, struct fork_args *); @@ -2043,6 +2073,11 @@ int cap_getmode(struct thread *, struct int pselect(struct thread *, struct pselect_args *); int getloginclass(struct thread *, struct getloginclass_args *); int setloginclass(struct thread *, struct setloginclass_args *); +int rctl_get_racct(struct thread *, struct rctl_get_racct_args *); +int rctl_get_rules(struct thread *, struct rctl_get_rules_args *); +int rctl_get_limits(struct thread *, struct rctl_get_limits_args *); +int rctl_add_rule(struct thread *, struct rctl_add_rule_args *); +int rctl_remove_rule(struct thread *, struct rctl_remove_rule_args *); #ifdef COMPAT_43 @@ -2722,6 +2757,11 @@ int freebsd7_shmctl(struct thread *, str #define SYS_AUE_pselect AUE_SELECT #define SYS_AUE_getloginclass AUE_NULL #define SYS_AUE_setloginclass AUE_NULL +#define SYS_AUE_rctl_get_racct AUE_NULL +#define SYS_AUE_rctl_get_rules AUE_NULL +#define SYS_AUE_rctl_get_limits AUE_NULL +#define SYS_AUE_rctl_add_rule AUE_NULL +#define SYS_AUE_rctl_remove_rule AUE_NULL #undef PAD_ #undef PADL_ From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 18:08:31 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6FCEE106564A; Wed, 30 Mar 2011 18:08:31 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5D4708FC08; Wed, 30 Mar 2011 18:08:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UI8VL3071161; Wed, 30 Mar 2011 18:08:31 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UI8Vj3071159; Wed, 30 Mar 2011 18:08:31 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103301808.p2UI8Vj3071159@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 30 Mar 2011 18:08:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220165 - head/lib/libc/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 18:08:31 -0000 Author: trasz Date: Wed Mar 30 18:08:31 2011 New Revision: 220165 URL: http://svn.freebsd.org/changeset/base/220165 Log: Expose the rctl(2) API in libc. Modified: head/lib/libc/sys/Symbol.map Modified: head/lib/libc/sys/Symbol.map ============================================================================== --- head/lib/libc/sys/Symbol.map Wed Mar 30 17:59:54 2011 (r220164) +++ head/lib/libc/sys/Symbol.map Wed Mar 30 18:08:31 2011 (r220165) @@ -364,6 +364,11 @@ FBSD_1.2 { cap_enter; cap_getmode; getloginclass; + rctl_get_racct; + rctl_get_rules; + rctl_get_limits; + rctl_add_rule; + rctl_remove_rule; setloginclass; }; From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 18:27:51 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 860B81065676; Wed, 30 Mar 2011 18:27:51 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 585E58FC1C; Wed, 30 Mar 2011 18:27:51 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id EB45546B06; Wed, 30 Mar 2011 14:27:50 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 76E258A01B; Wed, 30 Mar 2011 14:27:50 -0400 (EDT) From: John Baldwin To: Daniel Eischen Date: Wed, 30 Mar 2011 13:59:37 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103300823.53986.jhb@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103301359.37444.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Wed, 30 Mar 2011 14:27:50 -0400 (EDT) Cc: svn-src-head@freebsd.org, George Neville-Neil , svn-src-all@freebsd.org, src-committers@freebsd.org, Randall Stewart Subject: Re: svn commit: r217592 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 18:27:51 -0000 On Wednesday, March 30, 2011 11:42:01 am Daniel Eischen wrote: > > BMS preserved this behavior and your patch changes > > But he changed the behavior on output. Pre-BMS and post-BMS > behave differently and not like Solaris 10 or VxWorks. Haven't > tried Linux. Yes, I am not debating that. I'm merely talking about the input side. > > it. UDP sockets start off with inp_moptions == NULL, so if you never do any > > multicast-related setsockopt() you will receive all matching multicast packets. > > However, once you do any multicast-related setsockopt() (IP_MULTICAST_LOOP, > > IP_ADD_MEMBERSHIP, etc.) then inp_moptions is allocated and is non-NULL. > > At that point it only accepts packets that match, except that even then we > > used a sysctl which defaulted to off (!) to see if we should check the list of > > memberships (net.inet.udp.strict_mcast_mship). This options structure was never > > free'd, however, so you could get the truly bizarre behavior of: > > > > - bind a new socket, it will not receive all matching multicast traffic > > - use IP_ADD_MEMBERSHIP to add a group, it will now receive only matching multicast > > traffic for the group > > - use IP_DROP_MEMBERSHIP to remove the group, it will now receive no multicast > > traffic > > > > The different behavior in states 1 and 3 I find confusing and odd. By default > > all sockets just always received all matching multicast traffic though. :) > > Not if a multicast group was not joined. The pre-BMS changes > did not loop back multicast packets in ip_output.c. Well, they would receive all multicast traffic that wasn't loopback traffic. That is, if I had two sockets bound to *:2000 and *:4000 and one socket joined a group 224.1.2.3, then both sockets would receive traffic bound for 224.1.2.3 if it matched their ports in both the pre-BMS code and in post-BMS but pre-RRS. Now only the socket that did the join will receive the packets, so it is a change in behavior. Now I find this unintuitive, but other folks I have talked to have pointed out that that could be a valid interpretation of binding to INADDR_ANY. -- John Baldwin From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 18:27:53 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3BCD21065670; Wed, 30 Mar 2011 18:27:53 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 26DE88FC1D; Wed, 30 Mar 2011 18:27:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UIRrV4071629; Wed, 30 Mar 2011 18:27:53 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UIRrtJ071624; Wed, 30 Mar 2011 18:27:53 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103301827.p2UIRrtJ071624@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 30 Mar 2011 18:27:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220166 - in head/usr.bin: . rctl X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 18:27:53 -0000 Author: trasz Date: Wed Mar 30 18:27:52 2011 New Revision: 220166 URL: http://svn.freebsd.org/changeset/base/220166 Log: Add rctl(8), the utility to manage rctl rules. Sponsored by: The FreeBSD Foundation Reviewed by: kib (earlier version) Added: head/usr.bin/rctl/ head/usr.bin/rctl/Makefile (contents, props changed) head/usr.bin/rctl/rctl.8 (contents, props changed) head/usr.bin/rctl/rctl.c (contents, props changed) Modified: head/usr.bin/Makefile Modified: head/usr.bin/Makefile ============================================================================== --- head/usr.bin/Makefile Wed Mar 30 18:08:31 2011 (r220165) +++ head/usr.bin/Makefile Wed Mar 30 18:27:52 2011 (r220166) @@ -126,6 +126,7 @@ SUBDIR= alias \ printenv \ printf \ procstat \ + rctl \ renice \ rev \ revoke \ Added: head/usr.bin/rctl/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/rctl/Makefile Wed Mar 30 18:27:52 2011 (r220166) @@ -0,0 +1,11 @@ +# $FreeBSD$ + +PROG= rctl +MAN= rctl.8 + +DPADD= ${LIBUTIL} +LDADD= -lutil + +WARNS?= 6 + +.include Added: head/usr.bin/rctl/rctl.8 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/rctl/rctl.8 Wed Mar 30 18:27:52 2011 (r220166) @@ -0,0 +1,200 @@ +.\"- +.\" Copyright (c) 2009 Edward Tomasz Napierala +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE +.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd February 13, 2011 +.Dt RCTL 8 +.Os +.Sh NAME +.Nm rctl +.Nd display and update resource limits database +.Sh SYNOPSIS +.Nm +.Op Fl h +.Op Fl n +.Op Ar filter +.Nm +.Fl a +.Op Ar rule +.Nm +.Op Fl h +.Op Fl n +.Fl l +.Op Ar filter +.Nm +.Fl r +.Op Ar filter +.Nm +.Op Fl h +.Fl u +.Op Ar filter +.Sh DESCRIPTION +When called without options, the +.Nm +command writes currently defined RCTL rules to standard output. +.Pp +If a +.Ar filter +argument is specified, only rules matching the filter are displayed. +The options are as follows: +.Bl -tag -width indent +.It Fl a Ar rule +Add +.Ar rule +to the RCTL database. +.It Fl l Ar filter +Display rules applicable to the process defined by +.Ar filter . +.It Fl r Ar filter +Remove rules matching +.Ar filter +from the RCTL database. +.It Fl u Ar filter +Display resource usage for a subject (process, user, login class +or jail) matching the +.Ar filter . +.It Fl h +"Human-readable" output. +Use unit suffixes: Byte, Kilobyte, Megabyte, +Gigabyte, Terabyte and Petabyte. +.It Fl n +Display user IDs numerically rather than converting them to a user name. +.Pp +.Sh RULE SYNTAX +Syntax for a rule is subject:subject-id:resource:action=amount/per. +.Pp +Subject defines the kind of entity the rule applies to. +It can be either process, user, login class, or jail. +.Pp +Subject ID identifies the subject. It can be user name, +numerical user ID, login class name, jail name, or numerical jail ID. +.Pp +Resource identifies the resource the rule controls. +.Pp +Action defines what will happen when a process exceeds the allowed amount. +.Pp +Amount defines how much of the resource a process can use before +the defined action triggers. +.Pp +The per field defines what entity the amount gets accounted for. +For example, rule "loginclass:users:vmem:deny=100M/process" means +that each process of any user belonging to login class "users" may allocate +up to 100MB of virtual memory. +Rule "loginclass:users:vmem:deny=100M/user" would mean that for each +user belonging to the login class "users", the sum of virtual memory allocated +by all the processes of a that user will not exceed 100MB. +Rule "loginclass:users:vmem:deny=100M/loginclass" would mean that the sum of +virtual memory allocated by all processes of all users belonging to that login +class will not exceed 100MB. +.Pp +Valid rule has all those fields specified, except for the per, which defaults +to the value of subject. +.Pp +A filter is a rule for which one of more fields other than per is left empty. +For example, a filter that matches every rule could be written as ":::=/", +or, in short, ":". +A filter that matches all the login classes would be "loginclass:". +A filter that matches all defined rules for nproc resource would be +"::nproc". +.Pp +.Sh RESOURCES +.Bl -column -offset 3n "msgqqueued" +.It cpu CPU time, in milliseconds +.It fsize maximum file size, in bytes +.It data data size, in bytes +.It stack stack size, in bytes +.It core core dump size, in bytes +.It rss resident set size, in bytes +.It memlock locked memory, in bytes +.It nproc number of processes +.It nofile file descriptor table size +.It sbsize memory consumed by socket buffers, in bytes +.It vmem address space limit, in bytes +.It npts number of PTYs +.It swap swap usage, in bytes +.It nthr number of threads +.It msgqqueued number of queued SysV messages +.It msgqsize SysV message queue size, in bytes +.It nmsgq number of SysV message queues +.It nsem number of SysV semaphores +.It nsemop number of SysV semaphores modified in a single semop(2) call +.It nshm number of SysV shared memory segments +.It shmsize SysV shared memory size, in bytes +.It wallclock wallclock time, in milliseconds +.It pctcpu %cpu time +.El +.Pp +.Sh ACTIONS +.Bl -column -offset 3n "msgqqueued" +.It deny deny the allocation; not supported for cpu and wallclock +.It log log a warning to the console +.It devctl send notification to +.Xr devd 8 +.It sig* e.g. sigterm; send a signal to the offending process +.El +.Pp +See +.Xr signal 3 +for a list of supported signals. +.Pp +Not all actions are supported for all resources. +Attempt to add rule with action not supported by a given resouce will result +in error. +.Pp +Note that limiting RSS may kill the machine due to thrashing. +.Pp +.Sh EXIT STATUS +.Ex -std +.Sh EXAMPLES +.Dl rctl -a user:joe:vmem:deny=1g +.Pp +Prevent user "joe" from allocating more than 1GB of virtual memory. +.Pp +.Dl rctl -r : +.Pp +Remove all RCTL rules. +.Pp +.Dl rctl -hu jail:5 +.Pp +Display resource usage information for jail with JID 5. +.Pp +.Dl rctl -l process:512 +.Pp +Display all the rules applicable to process with PID 512. +.Sh SEE ALSO +.Xr jailstat 8 , +.Xr userstat 8 +.Sh HISTORY +The +.Nm +command appeared in +.Fx 9.0. +.Sh AUTHORS +.An -nosplit +The +.Nm +command was written by +.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . Added: head/usr.bin/rctl/rctl.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/rctl/rctl.c Wed Mar 30 18:27:52 2011 (r220166) @@ -0,0 +1,539 @@ +/*- + * Copyright (c) 2010 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Edward Tomasz Napierala under sponsorship + * from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RCTL_DEFAULT_BUFSIZE 4096 + +static id_t +parse_user(const char *s) +{ + id_t id; + char *end; + struct passwd *pwd; + + pwd = getpwnam(s); + if (pwd != NULL) + return (pwd->pw_uid); + + if (!isnumber(s[0])) + errx(1, "uknown user '%s'", s); + + id = strtod(s, &end); + if ((size_t)(end - s) != strlen(s)) + errx(1, "trailing characters after numerical id"); + + return (id); +} + +static id_t +parse_group(const char *s) +{ + id_t id; + char *end; + struct group *grp; + + grp = getgrnam(s); + if (grp != NULL) + return (grp->gr_gid); + + if (!isnumber(s[0])) + errx(1, "uknown group '%s'", s); + + id = strtod(s, &end); + if ((size_t)(end - s) != strlen(s)) + errx(1, "trailing characters after numerical id"); + + return (id); +} + +/* + * This routine replaces user/group name with numeric id. + */ +static char * +resolve_ids(char *rule) +{ + id_t id; + const char *subject, *textid, *rest; + char *resolved; + + subject = strsep(&rule, ":"); + textid = strsep(&rule, ":"); + if (textid == NULL) + errx(1, "error in rule specification -- no subject"); + if (rule != NULL) + rest = rule; + else + rest = ""; + + if (strcasecmp(subject, "u") == 0) + subject = "user"; + else if (strcasecmp(subject, "g") == 0) + subject = "group"; + else if (strcasecmp(subject, "p") == 0) + subject = "process"; + else if (strcasecmp(subject, "l") == 0 || + strcasecmp(subject, "c") == 0 || + strcasecmp(subject, "class") == 0) + subject = "loginclass"; + else if (strcasecmp(subject, "j") == 0) + subject = "jail"; + + if (strcasecmp(subject, "user") == 0 && strlen(textid) > 0) { + id = parse_user(textid); + asprintf(&resolved, "%s:%d:%s", subject, (int)id, rest); + } else if (strcasecmp(subject, "group") == 0 && strlen(textid) > 0) { + id = parse_group(textid); + asprintf(&resolved, "%s:%d:%s", subject, (int)id, rest); + } else + asprintf(&resolved, "%s:%s:%s", subject, textid, rest); + + if (resolved == NULL) + err(1, "asprintf"); + + return (resolved); +} + +/* + * This routine replaces "human-readable" number with its expanded form. + */ +static char * +expand_amount(char *rule) +{ + uint64_t num; + const char *subject, *subject_id, *resource, *action, *amount, *per; + char *copy, *expanded; + + copy = strdup(rule); + if (copy == NULL) + err(1, "strdup"); + + subject = strsep(©, ":"); + subject_id = strsep(©, ":"); + resource = strsep(©, ":"); + action = strsep(©, "=/"); + amount = strsep(©, "/"); + per = copy; + + if (amount == NULL || strlen(amount) == 0) { + free(copy); + return (rule); + } + + assert(subject != NULL); + assert(subject_id != NULL); + assert(resource != NULL); + assert(action != NULL); + + if (expand_number(amount, &num)) + err(1, "expand_number"); + + if (per == NULL) + asprintf(&expanded, "%s:%s:%s:%s=%ju", subject, subject_id, + resource, action, (uintmax_t)num); + else + asprintf(&expanded, "%s:%s:%s:%s=%ju/%s", subject, subject_id, + resource, action, (uintmax_t)num, per); + + if (expanded == NULL) + err(1, "asprintf"); + + return (expanded); +} + +static char * +humanize_ids(char *rule) +{ + id_t id; + struct passwd *pwd; + struct group *grp; + const char *subject, *textid, *rest; + char *humanized; + + subject = strsep(&rule, ":"); + textid = strsep(&rule, ":"); + if (textid == NULL) + errx(1, "rule passed from the kernel didn't contain subject"); + if (rule != NULL) + rest = rule; + else + rest = ""; + + /* Replace numerical user and group ids with names. */ + if (strcasecmp(subject, "user") == 0) { + id = parse_user(textid); + pwd = getpwuid(id); + if (pwd != NULL) + textid = pwd->pw_name; + } else if (strcasecmp(subject, "group") == 0) { + id = parse_group(textid); + grp = getgrgid(id); + if (grp != NULL) + textid = grp->gr_name; + } + + asprintf(&humanized, "%s:%s:%s", subject, textid, rest); + + if (humanized == NULL) + err(1, "asprintf"); + + return (humanized); +} + +static int +str2int64(const char *str, int64_t *value) +{ + char *end; + + if (str == NULL) + return (EINVAL); + + *value = strtoul(str, &end, 10); + if ((size_t)(end - str) != strlen(str)) + return (EINVAL); + + return (0); +} + +static char * +humanize_amount(char *rule) +{ + int64_t num; + const char *subject, *subject_id, *resource, *action, *amount, *per; + char *copy, *humanized, buf[6]; + + copy = strdup(rule); + if (copy == NULL) + err(1, "strdup"); + + subject = strsep(©, ":"); + subject_id = strsep(©, ":"); + resource = strsep(©, ":"); + action = strsep(©, "=/"); + amount = strsep(©, "/"); + per = copy; + + if (amount == NULL || strlen(amount) == 0 || + str2int64(amount, &num) != 0) { + free(copy); + return (rule); + } + + assert(subject != NULL); + assert(subject_id != NULL); + assert(resource != NULL); + assert(action != NULL); + + if (humanize_number(buf, sizeof(buf), num, "", HN_AUTOSCALE, + HN_DECIMAL | HN_NOSPACE) == -1) + err(1, "humanize_number"); + + if (per == NULL) + asprintf(&humanized, "%s:%s:%s:%s=%s", subject, subject_id, + resource, action, buf); + else + asprintf(&humanized, "%s:%s:%s:%s=%s/%s", subject, subject_id, + resource, action, buf, per); + + if (humanized == NULL) + err(1, "asprintf"); + + return (humanized); +} + +/* + * Print rules, one per line. + */ +static void +print_rules(char *rules, int hflag, int nflag) +{ + char *rule; + + while ((rule = strsep(&rules, ",")) != NULL) { + if (rule[0] == '\0') + break; /* XXX */ + if (nflag == 0) + rule = humanize_ids(rule); + if (hflag) + rule = humanize_amount(rule); + printf("%s\n", rule); + } +} + +static void +add_rule(char *rule) +{ + int error; + + error = rctl_add_rule(rule, strlen(rule) + 1, NULL, 0); + if (error != 0) + err(1, "rctl_add_rule"); + free(rule); +} + +static void +show_limits(char *filter, int hflag, int nflag) +{ + int error; + char *outbuf = NULL; + size_t outbuflen = RCTL_DEFAULT_BUFSIZE / 4; + + do { + outbuflen *= 4; + outbuf = realloc(outbuf, outbuflen); + if (outbuf == NULL) + err(1, "realloc"); + + error = rctl_get_limits(filter, strlen(filter) + 1, outbuf, + outbuflen); + if (error && errno != ERANGE) + err(1, "rctl_get_limits"); + } while (error && errno == ERANGE); + + print_rules(outbuf, hflag, nflag); + free(filter); + free(outbuf); +} + +static void +remove_rule(char *filter) +{ + int error; + + error = rctl_remove_rule(filter, strlen(filter) + 1, NULL, 0); + if (error != 0) + err(1, "rctl_remove_rule"); + free(filter); +} + +static char * +humanize_usage_amount(char *usage) +{ + int64_t num; + const char *resource, *amount; + char *copy, *humanized, buf[6]; + + copy = strdup(usage); + if (copy == NULL) + err(1, "strdup"); + + resource = strsep(©, "="); + amount = copy; + + assert(resource != NULL); + assert(amount != NULL); + + if (str2int64(amount, &num) != 0 || + humanize_number(buf, sizeof(buf), num, "", HN_AUTOSCALE, + HN_DECIMAL | HN_NOSPACE) == -1) { + free(copy); + return (usage); + } + + asprintf(&humanized, "%s=%s", resource, buf); + if (humanized == NULL) + err(1, "asprintf"); + + return (humanized); +} + +/* + * Query the kernel about a resource usage and print it out. + */ +static void +show_usage(char *filter, int hflag) +{ + int error; + char *outbuf = NULL, *tmp; + size_t outbuflen = RCTL_DEFAULT_BUFSIZE / 4; + + do { + outbuflen *= 4; + outbuf = realloc(outbuf, outbuflen); + if (outbuf == NULL) + err(1, "realloc"); + + error = rctl_get_racct(filter, strlen(filter) + 1, outbuf, + outbuflen); + if (error && errno != ERANGE) + err(1, "rctl_get_racct"); + } while (error && errno == ERANGE); + + while ((tmp = strsep(&outbuf, ",")) != NULL) { + if (tmp[0] == '\0') + break; /* XXX */ + + if (hflag) + tmp = humanize_usage_amount(tmp); + + printf("%s\n", tmp); + } + + free(filter); + free(outbuf); +} + +/* + * Query the kernel about resource limit rules and print them out. + */ +static void +show_rules(char *filter, int hflag, int nflag) +{ + int error; + char *outbuf = NULL; + size_t filterlen, outbuflen = RCTL_DEFAULT_BUFSIZE / 4; + + if (filter != NULL) + filterlen = strlen(filter) + 1; + else + filterlen = 0; + + do { + outbuflen *= 4; + outbuf = realloc(outbuf, outbuflen); + if (outbuf == NULL) + err(1, "realloc"); + + error = rctl_get_rules(filter, filterlen, outbuf, outbuflen); + if (error && errno != ERANGE) + err(1, "rctl_get_rules"); + } while (error && errno == ERANGE); + + print_rules(outbuf, hflag, nflag); + free(outbuf); +} + +static void +usage(void) +{ + + fprintf(stderr, "usage: rctl [ -h ] [-a rule | -l filter | -r filter " + "| -u filter | filter]\n"); + exit(1); +} + +int +main(int argc __unused, char **argv __unused) +{ + int ch, aflag = 0, hflag = 0, nflag = 0, lflag = 0, rflag = 0, + uflag = 0; + char *rule = NULL; + + while ((ch = getopt(argc, argv, "a:hl:nr:u:")) != -1) { + switch (ch) { + case 'a': + aflag = 1; + rule = strdup(optarg); + break; + case 'h': + hflag = 1; + break; + case 'l': + lflag = 1; + rule = strdup(optarg); + break; + case 'n': + nflag = 1; + break; + case 'r': + rflag = 1; + rule = strdup(optarg); + break; + case 'u': + uflag = 1; + rule = strdup(optarg); + break; + + case '?': + default: + usage(); + } + } + + argc -= optind; + argv += optind; + + if (argc > 1) + usage(); + + if (rule == NULL) { + if (argc == 1) + rule = strdup(argv[0]); + else + rule = strdup("::"); + } + + if (aflag + lflag + rflag + uflag + argc > 1) + errx(1, "only one flag or argument may be specified " + "at the same time"); + + rule = resolve_ids(rule); + rule = expand_amount(rule); + + if (aflag) { + add_rule(rule); + return (0); + } + + if (lflag) { + show_limits(rule, hflag, nflag); + return (0); + } + + if (rflag) { + remove_rule(rule); + return (0); + } + + if (uflag) { + show_usage(rule, hflag); + return (0); + } + + show_rules(rule, hflag, nflag); + return (0); +} From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 18:32:45 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 664D11065676; Wed, 30 Mar 2011 18:32:45 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 53AF58FC16; Wed, 30 Mar 2011 18:32:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UIWjK5071778; Wed, 30 Mar 2011 18:32:45 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UIWjH0071775; Wed, 30 Mar 2011 18:32:45 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103301832.p2UIWjH0071775@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 30 Mar 2011 18:32:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220167 - head/etc/rc.d X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 18:32:45 -0000 Author: trasz Date: Wed Mar 30 18:32:45 2011 New Revision: 220167 URL: http://svn.freebsd.org/changeset/base/220167 Log: Add startup script, to load rules from /etc/rctl.conf. Sponsored by: The FreeBSD Foundation Reviewed by: kib (ealier version) Added: head/etc/rc.d/rctl (contents, props changed) Modified: head/etc/rc.d/Makefile Modified: head/etc/rc.d/Makefile ============================================================================== --- head/etc/rc.d/Makefile Wed Mar 30 18:27:52 2011 (r220166) +++ head/etc/rc.d/Makefile Wed Mar 30 18:32:45 2011 (r220167) @@ -29,7 +29,7 @@ FILES= DAEMON FILESYSTEMS LOGIN NETWORKI pf pflog pfsync \ powerd power_profile ppp pppoed pwcheck \ quota \ - random rarpd resolv rfcomm_pppd_server root \ + random rarpd rctl resolv rfcomm_pppd_server root \ route6d routed routing rpcbind rtadvd rtsold rwho \ savecore sdpd securelevel sendmail \ serial sppp statd static_arp stf swap1 \ Added: head/etc/rc.d/rctl ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/etc/rc.d/rctl Wed Mar 30 18:32:45 2011 (r220167) @@ -0,0 +1,39 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: rctl +# BEFORE: LOGIN +# KEYWORD: nojail + +. /etc/rc.subr + +name="rctl" +start_cmd="rctl_start" +stop_cmd="rctl_stop" + +rctl_start() +{ + if [ -f /etc/rctl.conf ]; then + while read var comments + do + case ${var} in + \#*|'') + ;; + *) + rctl -a "${var}" + ;; + esac + done < /etc/rctl.conf + fi +} + +rctl_stop() +{ + + rctl -r : +} + +load_rc_config $name +run_rc_command "$1" From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 18:35:02 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B96D4106566B; Wed, 30 Mar 2011 18:35:02 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A2A418FC15; Wed, 30 Mar 2011 18:35:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UIZ2bg071887; Wed, 30 Mar 2011 18:35:02 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UIZ2O8071886; Wed, 30 Mar 2011 18:35:02 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103301835.p2UIZ2O8071886@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 30 Mar 2011 18:35:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220168 - head/etc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 18:35:02 -0000 Author: trasz Date: Wed Mar 30 18:35:02 2011 New Revision: 220168 URL: http://svn.freebsd.org/changeset/base/220168 Log: Add example devd.conf entry. Modified: head/etc/devd.conf Modified: head/etc/devd.conf ============================================================================== --- head/etc/devd.conf Wed Mar 30 18:32:45 2011 (r220167) +++ head/etc/devd.conf Wed Mar 30 18:35:02 2011 (r220168) @@ -301,6 +301,7 @@ detach 10 { # Button: Button pressed (0 for power, 1 for sleep) # CMBAT: ACPI battery events # Lid: Lid state (0 is closed, 1 is open) +# RCTL: Resource limits # Suspend, Resume: Suspend and resume notification # Thermal: ACPI thermal zone events # @@ -313,4 +314,13 @@ notify 10 { match "subsystem" "ACAD"; action "/etc/acpi_ac $notify"; }; + +# This example works around a memory leak in PostgreSQL, restarting +# it when "user:pgsql:swap:devctl=1G" rctl(8) rule gets triggered. +notify 0 { + match "system" "RCTL"; + match "rule" "user:70:swap:.*"; + action "/usr/local/etc/rc.d/postgresql restart" +}; + */ From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 20:13:55 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A3ACB106566B; Wed, 30 Mar 2011 20:13:55 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 90D768FC1B; Wed, 30 Mar 2011 20:13:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UKDtFa079850; Wed, 30 Mar 2011 20:13:55 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UKDtlV079848; Wed, 30 Mar 2011 20:13:55 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103302013.p2UKDtlV079848@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 30 Mar 2011 20:13:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220169 - head/usr.bin/rctl X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 20:13:55 -0000 Author: trasz Date: Wed Mar 30 20:13:55 2011 New Revision: 220169 URL: http://svn.freebsd.org/changeset/base/220169 Log: Fix grammar and bump date. Submitted by: trociny Modified: head/usr.bin/rctl/rctl.8 Modified: head/usr.bin/rctl/rctl.8 ============================================================================== --- head/usr.bin/rctl/rctl.8 Wed Mar 30 18:35:02 2011 (r220168) +++ head/usr.bin/rctl/rctl.8 Wed Mar 30 20:13:55 2011 (r220169) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 13, 2011 +.Dd March 30, 2011 .Dt RCTL 8 .Os .Sh NAME @@ -105,7 +105,7 @@ that each process of any user belonging up to 100MB of virtual memory. Rule "loginclass:users:vmem:deny=100M/user" would mean that for each user belonging to the login class "users", the sum of virtual memory allocated -by all the processes of a that user will not exceed 100MB. +by all the processes of that user will not exceed 100MB. Rule "loginclass:users:vmem:deny=100M/loginclass" would mean that the sum of virtual memory allocated by all processes of all users belonging to that login class will not exceed 100MB. From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 21:33:23 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6881A1065672; Wed, 30 Mar 2011 21:33:23 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 557038FC0C; Wed, 30 Mar 2011 21:33:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2ULXNnA081574; Wed, 30 Mar 2011 21:33:23 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2ULXNGk081572; Wed, 30 Mar 2011 21:33:23 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <201103302133.p2ULXNGk081572@svn.freebsd.org> From: Edwin Groothuis Date: Wed, 30 Mar 2011 21:33:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220172 - head/usr.sbin/tzsetup X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 21:33:23 -0000 Author: edwin Date: Wed Mar 30 21:33:23 2011 New Revision: 220172 URL: http://svn.freebsd.org/changeset/base/220172 Log: Add a menu entry for UTC in the main menu. PR: bin/156019 Submitted by: Daniel O'Conner Reviewed by: Garrett Cooper MFC after: 1 week Modified: head/usr.sbin/tzsetup/tzsetup.c Modified: head/usr.sbin/tzsetup/tzsetup.c ============================================================================== --- head/usr.sbin/tzsetup/tzsetup.c Wed Mar 30 21:22:25 2011 (r220171) +++ head/usr.sbin/tzsetup/tzsetup.c Wed Mar 30 21:33:23 2011 (r220172) @@ -66,10 +66,13 @@ static int usedialog = 1; static char *chrootenv = NULL; static void usage(void); +static int confirm_zone(const char *filename); static int continent_country_menu(dialogMenuItem *); +static int install_zoneinfo_file(const char *zoneinfo_file); static int set_zone_multi(dialogMenuItem *); static int set_zone_whole_country(dialogMenuItem *); static int set_zone_menu(dialogMenuItem *); +static int set_zone_utc(void); struct continent { dialogMenuItem *menu; @@ -79,7 +82,7 @@ struct continent { }; static struct continent africa, america, antarctica, arctic, asia, atlantic; -static struct continent australia, europe, indian, pacific; +static struct continent australia, europe, indian, pacific, utc; static struct continent_names { const char *name; @@ -94,7 +97,8 @@ static struct continent_names { { "Australia", &australia }, { "Europe", &europe }, { "Indian", &indian }, - { "Pacific", &pacific } + { "Pacific", &pacific }, + { "UTC", &utc } }; static struct continent_items { @@ -110,7 +114,8 @@ static struct continent_items { { "7", "Australia" }, { "8", "Europe" }, { "9", "Indian Ocean" }, - { "0", "Pacific Ocean" } + { "0", "Pacific Ocean" }, + { "a", "UTC" } }; #define NCONTINENTS \ @@ -128,6 +133,9 @@ continent_country_menu(dialogMenuItem *c int menulen; int rv; + if (strcmp(continent->title, "UTC") == 0) + return set_zone_utc(); + /* Short cut -- if there's only one country, don't post a menu. */ if (contp->nitems == 1) return (contp->menu[0].fire(&contp->menu[0])); @@ -502,6 +510,15 @@ set_zone_menu(dialogMenuItem *dmi) return (DITEM_LEAVE_MENU); } +int +set_zone_utc(void) +{ + if (!confirm_zone(NULL)) + return (DITEM_FAILURE | DITEM_RECREATE); + + return (install_zoneinfo_file(NULL)); +} + static int install_zoneinfo_file(const char *zoneinfo_file) { @@ -526,7 +543,8 @@ install_zoneinfo_file(const char *zonein else snprintf(prompt, sizeof(prompt), "Creating symbolic link %s to %s", - path_localtime, zoneinfo_file); + path_localtime, + zoneinfo_file == NULL ? "(UTC)" : zoneinfo_file); if (usedialog) dialog_notify(prompt); else @@ -534,6 +552,22 @@ install_zoneinfo_file(const char *zonein #endif if (reallydoit) { + if (zoneinfo_file == NULL) { + if (unlink(path_localtime) < 0 && errno != ENOENT) { + snprintf(title, sizeof(title), "Error"); + snprintf(prompt, sizeof(prompt), + "Could not delete %s: %s", path_localtime, + strerror(errno)); + if (usedialog) + dialog_mesgbox(title, prompt, 8, 72); + else + fprintf(stderr, "%s\n", prompt); + + return (DITEM_FAILURE | DITEM_RECREATE); + } + return (DITEM_LEAVE_MENU); + } + if (copymode) { fd1 = open(zoneinfo_file, O_RDONLY, 0); if (fd1 < 0) { @@ -656,7 +690,7 @@ confirm_zone(const char *filename) struct tm *tm; int rv; - setenv("TZ", filename, 1); + setenv("TZ", filename == NULL ? "" : filename, 1); tzset(); tm = localtime(&t); From owner-svn-src-all@FreeBSD.ORG Wed Mar 30 21:40:14 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CF4FB1065670; Wed, 30 Mar 2011 21:40:14 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BC5B48FC1B; Wed, 30 Mar 2011 21:40:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2ULeEpd081780; Wed, 30 Mar 2011 21:40:14 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2ULeE6G081778; Wed, 30 Mar 2011 21:40:14 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103302140.p2ULeE6G081778@svn.freebsd.org> From: Mikolaj Golub Date: Wed, 30 Mar 2011 21:40:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220173 - head/sys/geom/gate X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 21:40:14 -0000 Author: trociny Date: Wed Mar 30 21:40:14 2011 New Revision: 220173 URL: http://svn.freebsd.org/changeset/base/220173 Log: Increase debug level on g_gate device destruction and add message on device creation. Suggested by: danger Approved by: pjd (mentor) MFC after: 3 days Modified: head/sys/geom/gate/g_gate.c Modified: head/sys/geom/gate/g_gate.c ============================================================================== --- head/sys/geom/gate/g_gate.c Wed Mar 30 21:33:23 2011 (r220172) +++ head/sys/geom/gate/g_gate.c Wed Mar 30 21:40:14 2011 (r220173) @@ -136,7 +136,7 @@ g_gate_destroy(struct g_gate_softc *sc, mtx_unlock(&g_gate_units_lock); mtx_destroy(&sc->sc_queue_mtx); g_topology_lock(); - G_GATE_DEBUG(0, "Device %s destroyed.", gp->name); + G_GATE_DEBUG(1, "Device %s destroyed.", gp->name); gp->softc = NULL; g_wither_geom(gp, ENXIO); sc->sc_provider = NULL; @@ -438,6 +438,7 @@ g_gate_create(struct g_gate_ctl_create * mtx_lock(&g_gate_units_lock); sc->sc_name = sc->sc_provider->name; mtx_unlock(&g_gate_units_lock); + G_GATE_DEBUG(1, "Device %s created.", gp->name); if (sc->sc_timeout > 0) { callout_reset(&sc->sc_callout, sc->sc_timeout * hz, From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 00:46:28 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1C36E106564A; Thu, 31 Mar 2011 00:46:28 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 092AF8FC16; Thu, 31 Mar 2011 00:46:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V0kSAg085879; Thu, 31 Mar 2011 00:46:28 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V0kR7e085873; Thu, 31 Mar 2011 00:46:27 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201103310046.p2V0kR7e085873@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 31 Mar 2011 00:46:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220174 - in vendor/NetBSD/libedit: . dist dist/TEST X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 00:46:28 -0000 Author: obrien Date: Thu Mar 31 00:46:27 2011 New Revision: 220174 URL: http://svn.freebsd.org/changeset/base/220174 Log: Vendor import NetBSD's libedit of "1997-06-25 01:14:45 -0700". Obtained from: NetBSD Added: vendor/NetBSD/libedit/ vendor/NetBSD/libedit/dist/ vendor/NetBSD/libedit/dist/Makefile (contents, props changed) vendor/NetBSD/libedit/dist/TEST/ vendor/NetBSD/libedit/dist/TEST/test.c (contents, props changed) vendor/NetBSD/libedit/dist/chared.c (contents, props changed) vendor/NetBSD/libedit/dist/chared.h (contents, props changed) vendor/NetBSD/libedit/dist/common.c (contents, props changed) vendor/NetBSD/libedit/dist/editline.3 (contents, props changed) vendor/NetBSD/libedit/dist/editrc.5 (contents, props changed) vendor/NetBSD/libedit/dist/el.c (contents, props changed) vendor/NetBSD/libedit/dist/el.h (contents, props changed) vendor/NetBSD/libedit/dist/emacs.c (contents, props changed) vendor/NetBSD/libedit/dist/hist.c (contents, props changed) vendor/NetBSD/libedit/dist/hist.h (contents, props changed) vendor/NetBSD/libedit/dist/histedit.h (contents, props changed) vendor/NetBSD/libedit/dist/history.c (contents, props changed) vendor/NetBSD/libedit/dist/key.c (contents, props changed) vendor/NetBSD/libedit/dist/key.h (contents, props changed) vendor/NetBSD/libedit/dist/makelist vendor/NetBSD/libedit/dist/map.c (contents, props changed) vendor/NetBSD/libedit/dist/map.h (contents, props changed) vendor/NetBSD/libedit/dist/parse.c (contents, props changed) vendor/NetBSD/libedit/dist/parse.h (contents, props changed) vendor/NetBSD/libedit/dist/prompt.c (contents, props changed) vendor/NetBSD/libedit/dist/prompt.h (contents, props changed) vendor/NetBSD/libedit/dist/read.c (contents, props changed) vendor/NetBSD/libedit/dist/refresh.c (contents, props changed) vendor/NetBSD/libedit/dist/refresh.h (contents, props changed) vendor/NetBSD/libedit/dist/search.c (contents, props changed) vendor/NetBSD/libedit/dist/search.h (contents, props changed) vendor/NetBSD/libedit/dist/shlib_version vendor/NetBSD/libedit/dist/sig.c (contents, props changed) vendor/NetBSD/libedit/dist/sig.h (contents, props changed) vendor/NetBSD/libedit/dist/sys.h (contents, props changed) vendor/NetBSD/libedit/dist/term.c (contents, props changed) vendor/NetBSD/libedit/dist/term.h (contents, props changed) vendor/NetBSD/libedit/dist/termcap.h (contents, props changed) vendor/NetBSD/libedit/dist/tokenizer.c (contents, props changed) vendor/NetBSD/libedit/dist/tokenizer.h (contents, props changed) vendor/NetBSD/libedit/dist/tty.c (contents, props changed) vendor/NetBSD/libedit/dist/tty.h (contents, props changed) vendor/NetBSD/libedit/dist/vi.c (contents, props changed) Added: vendor/NetBSD/libedit/dist/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/dist/Makefile Thu Mar 31 00:46:27 2011 (r220174) @@ -0,0 +1,63 @@ +# $NetBSD: Makefile,v 1.8 1997/05/09 07:50:14 mycroft Exp $ +# @(#)Makefile 8.1 (Berkeley) 6/4/93 + +LIB= edit + +OSRCS= chared.c common.c el.c emacs.c fcns.c help.c hist.c key.c map.c \ + parse.c prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c + +MAN= editline.3 editrc.5 + +MLINKS= editline.3 el_init.3 editline.3 el_end.3 editline.3 el_reset.3 \ + editline.3 el_gets.3 editline.3 el_getc.3 editline.3 el_push.3 \ + editline.3 el_parse.3 editline.3 el_set.3 editline.3 el_source.3 \ + editline.3 el_resize.3 editline.3 el_line.3 \ + editline.3 el_insertstr.3 editline.3 el_deletestr.3 \ + editline.3 history_init.3 editline.3 history_end.3 editline.3 history.3 + +# For speed and debugging +#SRCS= ${OSRCS} tokenizer.c history.c +# For protection +SRCS= editline.c tokenizer.c history.c + +SRCS+= common.h emacs.h fcns.h help.h vi.h + +INCS= histedit.h +INCSDIR=/usr/include + +CLEANFILES+=common.h editline.c emacs.h fcns.c fcns.h help.c help.h vi.h +CFLAGS+=-I. -I${.CURDIR} +CFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH +CFLAGS+=#-DDEBUG_PASTE + +AHDR=vi.h emacs.h common.h +ASRC=${.CURDIR}/vi.c ${.CURDIR}/emacs.c ${.CURDIR}/common.c + +vi.h: vi.c makelist + sh ${.CURDIR}/makelist -h ${.CURDIR}/vi.c > ${.TARGET} + +emacs.h: emacs.c makelist + sh ${.CURDIR}/makelist -h ${.CURDIR}/emacs.c > ${.TARGET} + +common.h: common.c makelist + sh ${.CURDIR}/makelist -h ${.CURDIR}/common.c > ${.TARGET} + +fcns.h: ${AHDR} makelist + sh ${.CURDIR}/makelist -fh ${AHDR} > ${.TARGET} + +fcns.c: ${AHDR} fcns.h makelist + sh ${.CURDIR}/makelist -fc ${AHDR} > ${.TARGET} + +help.c: ${ASRC} makelist + sh ${.CURDIR}/makelist -bc ${ASRC} > ${.TARGET} + +help.h: ${ASRC} makelist + sh ${.CURDIR}/makelist -bh ${ASRC} > ${.TARGET} + +editline.c: ${OSRCS} + sh ${.CURDIR}/makelist -e ${.ALLSRC:T} > ${.TARGET} + +test: libedit.a test.o + ${CC} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermcap + +.include Added: vendor/NetBSD/libedit/dist/TEST/test.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/dist/TEST/test.c Thu Mar 31 00:46:27 2011 (r220174) @@ -0,0 +1,250 @@ +/* $NetBSD */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Christos Zoulas of Cornell University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1992, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#if !defined(lint) && !defined(SCCSID) +#if 0 +static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93"; +#else +static char rcsid[] = "$NetBSD"; +#endif +#endif /* not lint && not SCCSID */ + +/* + * test.c: A little test program + */ +#include "sys.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "histedit.h" +#include "tokenizer.h" + +static int continuation = 0; +static EditLine *el = NULL; + +static char * +/*ARGSUSED*/ +prompt(el) + EditLine *el; +{ + static char a[] = "Edit$"; + static char b[] = "Edit>"; + return continuation ? b : a; +} + +static void +sig(i) + int i; +{ + (void) fprintf(stderr, "Got signal %d.\n", i); + el_reset(el); +} + +static unsigned char +/*ARGSUSED*/ +complete(el, ch) + EditLine *el; + int ch; +{ + DIR *dd = opendir("."); + struct dirent *dp; + const char* ptr; + const LineInfo *lf = el_line(el); + int len; + + /* + * Find the last word + */ + for (ptr = lf->cursor - 1; !isspace(*ptr) && ptr > lf->buffer; ptr--) + continue; + len = lf->cursor - ++ptr; + + for (dp = readdir(dd); dp != NULL; dp = readdir(dd)) { + if (len > strlen(dp->d_name)) + continue; + if (strncmp(dp->d_name, ptr, len) == 0) { + closedir(dd); + if (el_insertstr(el, &dp->d_name[len]) == -1) + return CC_ERROR; + else + return CC_REFRESH; + } + } + + closedir(dd); + return CC_ERROR; +} + +int +/*ARGSUSED*/ +main(argc, argv) + int argc; + char *argv[]; +{ + int num; + const char *buf; + Tokenizer *tok; + History *hist; + + (void) signal(SIGINT, sig); + (void) signal(SIGQUIT, sig); + (void) signal(SIGHUP, sig); + (void) signal(SIGTERM, sig); + + hist = history_init(); /* Init the builtin history */ + history(hist, H_EVENT, 100); /* Remember 100 events */ + + tok = tok_init(NULL); /* Initialize the tokenizer */ + + el = el_init(*argv, stdin, stdout); /* Initialize editline */ + + el_set(el, EL_EDITOR, "vi"); /* Default editor is vi */ + el_set(el, EL_SIGNAL, 1); /* Handle signals gracefully */ + el_set(el, EL_PROMPT, prompt); /* Set the prompt function */ + + /* Tell editline to use this history interface */ + el_set(el, EL_HIST, history, hist); + + /* Add a user-defined function */ + el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete); + + el_set(el, EL_BIND, "^I", "ed-complete", NULL);/* Bind tab to it */ + + /* + * Bind j, k in vi command mode to previous and next line, instead + * of previous and next history. + */ + el_set(el, EL_BIND, "-a", "k", "ed-prev-line", NULL); + el_set(el, EL_BIND, "-a", "j", "ed-next-line", NULL); + + /* + * Source the user's defaults file. + */ + el_source(el, NULL); + + while ((buf = el_gets(el, &num)) != NULL && num != 0) { + int ac; + char **av; +#ifdef DEBUG + (void) fprintf(stderr, "got %d %s", num, buf); +#endif + if (!continuation && num == 1) + continue; + + if (tok_line(tok, buf, &ac, &av) > 0) { + history(hist, continuation ? H_ADD : H_ENTER, buf); + continuation = 1; + continue; + } + + history(hist, continuation ? H_ADD : H_ENTER, buf); + + continuation = 0; + + if (strcmp(av[0], "history") == 0) { + const struct HistEvent *he; + + switch (ac) { + case 1: + for (he = history(hist, H_LAST); he; + he = history(hist, H_PREV)) + (void) fprintf(stdout, "%4d %s", he->num, he->str); + break; + + case 2: + if (strcmp(av[1], "clear") == 0) + history(hist, H_CLEAR); + else + goto badhist; + break; + + case 3: + if (strcmp(av[1], "load") == 0) + history(hist, H_LOAD, av[2]); + else if (strcmp(av[1], "save") == 0) + history(hist, H_SAVE, av[2]); + break; + + badhist: + default: + (void) fprintf(stderr, "Bad history arguments\n"); + break; + } + } + else if (el_parse(el, ac, av) == -1) { + switch (fork()) { + case 0: + execvp(av[0], av); + perror(av[0]); + _exit(1); + /*NOTREACHED*/ + break; + + case -1: + perror("fork"); + break; + + default: + if (wait(&num) == -1) + perror("wait"); + (void) fprintf(stderr, "Exit %x\n", num); + break; + } + } + + tok_reset(tok); + } + + el_end(el); + tok_end(tok); + history_end(hist); + + return 0; +} Added: vendor/NetBSD/libedit/dist/chared.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/dist/chared.c Thu Mar 31 00:46:27 2011 (r220174) @@ -0,0 +1,645 @@ +/* $NetBSD: chared.c,v 1.2 1997/01/11 06:47:48 lukem Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Christos Zoulas of Cornell University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if !defined(lint) && !defined(SCCSID) +#if 0 +static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; +#else +static char rcsid[] = "$NetBSD: chared.c,v 1.2 1997/01/11 06:47:48 lukem Exp $"; +#endif +#endif /* not lint && not SCCSID */ + +/* + * chared.c: Character editor utilities + */ +#include "sys.h" + +#include +#include "el.h" + +/* cv_undo(): + * Handle state for the vi undo command + */ +protected void +cv_undo(el, action, size, ptr) + EditLine *el; + int action, size; + char *ptr; +{ + c_undo_t *vu = &el->el_chared.c_undo; + vu->action = action; + vu->ptr = ptr; + vu->isize = size; + (void) memcpy(vu->buf, vu->ptr, size); +#ifdef DEBUG_UNDO + (void) fprintf(el->el_errfile, "Undo buffer \"%s\" size = +%d -%d\n", + vu->ptr, vu->isize, vu->dsize); +#endif +} + + +/* c_insert(): + * Insert num characters + */ +protected void +c_insert(el, num) + EditLine *el; + int num; +{ + char *cp; + + if (el->el_line.lastchar + num >= el->el_line.limit) + return; /* can't go past end of buffer */ + + if (el->el_line.cursor < el->el_line.lastchar) { + /* if I must move chars */ + for (cp = el->el_line.lastchar; cp >= el->el_line.cursor; cp--) + cp[num] = *cp; + } + el->el_line.lastchar += num; +} /* end c_insert */ + + +/* c_delafter(): + * Delete num characters after the cursor + */ +protected void +c_delafter(el, num) + EditLine *el; + int num; +{ + + if (el->el_line.cursor + num > el->el_line.lastchar) + num = el->el_line.lastchar - el->el_line.cursor; + + if (num > 0) { + char *cp; + + if (el->el_map.current != el->el_map.emacs) + cv_undo(el, INSERT, num, el->el_line.cursor); + + for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) + *cp = cp[num]; + + el->el_line.lastchar -= num; + } +} + + +/* c_delbefore(): + * Delete num characters before the cursor + */ +protected void +c_delbefore(el, num) + EditLine *el; + int num; +{ + + if (el->el_line.cursor - num < el->el_line.buffer) + num = el->el_line.cursor - el->el_line.buffer; + + if (num > 0) { + char *cp; + + if (el->el_map.current != el->el_map.emacs) + cv_undo(el, INSERT, num, el->el_line.cursor - num); + + for (cp = el->el_line.cursor - num; cp <= el->el_line.lastchar; cp++) + *cp = cp[num]; + + el->el_line.lastchar -= num; + } +} + + +/* ce__isword(): + * Return if p is part of a word according to emacs + */ +protected int +ce__isword(p) + int p; +{ + return isalpha(p) || isdigit(p) || strchr("*?_-.[]~=", p) != NULL; +} + + +/* cv__isword(): + * Return if p is part of a word according to vi + */ +protected int +cv__isword(p) + int p; +{ + return !isspace(p); +} + + +/* c__prev_word(): + * Find the previous word + */ +protected char * +c__prev_word(p, low, n, wtest) + register char *p, *low; + register int n; + int (*wtest) __P((int)); +{ + p--; + + while (n--) { + while ((p >= low) && !(*wtest)((unsigned char) *p)) + p--; + while ((p >= low) && (*wtest)((unsigned char) *p)) + p--; + } + + /* cp now points to one character before the word */ + p++; + if (p < low) + p = low; + /* cp now points where we want it */ + return p; +} + + +/* c__next_word(): + * Find the next word + */ +protected char * +c__next_word(p, high, n, wtest) + register char *p, *high; + register int n; + int (*wtest) __P((int)); +{ + while (n--) { + while ((p < high) && !(*wtest)((unsigned char) *p)) + p++; + while ((p < high) && (*wtest)((unsigned char) *p)) + p++; + } + if (p > high) + p = high; + /* p now points where we want it */ + return p; +} + +/* cv_next_word(): + * Find the next word vi style + */ +protected char * +cv_next_word(el, p, high, n, wtest) + EditLine *el; + register char *p, *high; + register int n; + int (*wtest) __P((int)); +{ + int test; + + while (n--) { + test = (*wtest)((unsigned char) *p); + while ((p < high) && (*wtest)((unsigned char) *p) == test) + p++; + /* + * vi historically deletes with cw only the word preserving the + * trailing whitespace! This is not what 'w' does.. + */ + if (el->el_chared.c_vcmd.action != (DELETE|INSERT)) + while ((p < high) && isspace((unsigned char) *p)) + p++; + } + + /* p now points where we want it */ + if (p > high) + return high; + else + return p; +} + + +/* cv_prev_word(): + * Find the previous word vi style + */ +protected char * +cv_prev_word(el, p, low, n, wtest) + EditLine *el; + register char *p, *low; + register int n; + int (*wtest) __P((int)); +{ + int test; + + while (n--) { + p--; + /* + * vi historically deletes with cb only the word preserving the + * leading whitespace! This is not what 'b' does.. + */ + if (el->el_chared.c_vcmd.action != (DELETE|INSERT)) + while ((p > low) && isspace((unsigned char) *p)) + p--; + test = (*wtest)((unsigned char) *p); + while ((p >= low) && (*wtest)((unsigned char) *p) == test) + p--; + p++; + while (isspace((unsigned char) *p)) + p++; + } + + /* p now points where we want it */ + if (p < low) + return low; + else + return p; +} + + +#ifdef notdef +/* c__number(): + * Ignore character p points to, return number appearing after that. + * A '$' by itself means a big number; "$-" is for negative; '^' means 1. + * Return p pointing to last char used. + */ +protected char * +c__number(p, num, dval) + char *p; /* character position */ + int *num; /* Return value */ + int dval; /* dval is the number to subtract from like $-3 */ +{ + register int i; + register int sign = 1; + + if (*++p == '^') { + *num = 1; + return p; + } + if (*p == '$') { + if (*++p != '-') { + *num = 0x7fffffff; /* Handle $ */ + return --p; + } + sign = -1; /* Handle $- */ + ++p; + } + for (i = 0; isdigit((unsigned char) *p); i = 10 * i + *p++ - '0') + continue; + *num = (sign < 0 ? dval - i : i); + return --p; +} +#endif + +/* cv_delfini(): + * Finish vi delete action + */ +protected void +cv_delfini(el) + EditLine *el; +{ + register int size; + int oaction; + + if (el->el_chared.c_vcmd.action & INSERT) + el->el_map.current = el->el_map.key; + + oaction = el->el_chared.c_vcmd.action; + el->el_chared.c_vcmd.action = NOP; + + if (el->el_chared.c_vcmd.pos == 0) + return; + + + if (el->el_line.cursor > el->el_chared.c_vcmd.pos) { + size = (int) (el->el_line.cursor - el->el_chared.c_vcmd.pos); + c_delbefore(el, size); + el->el_line.cursor = el->el_chared.c_vcmd.pos; + re_refresh_cursor(el); + } + else if (el->el_line.cursor < el->el_chared.c_vcmd.pos) { + size = (int)(el->el_chared.c_vcmd.pos - el->el_line.cursor); + c_delafter(el, size); + } + else { + size = 1; + c_delafter(el, size); + } + switch (oaction) { + case DELETE|INSERT: + el->el_chared.c_undo.action = DELETE|INSERT; + break; + case DELETE: + el->el_chared.c_undo.action = INSERT; + break; + case NOP: + case INSERT: + default: + abort(); + break; + } + + + el->el_chared.c_undo.ptr = el->el_line.cursor; + el->el_chared.c_undo.dsize = size; +} + + +#ifdef notdef +/* ce__endword(): + * Go to the end of this word according to emacs + */ +protected char * +ce__endword(p, high, n) + char *p, *high; + int n; +{ + p++; + + while (n--) { + while ((p < high) && isspace((unsigned char) *p)) + p++; + while ((p < high) && !isspace((unsigned char) *p)) + p++; + } + + p--; + return p; +} +#endif + + +/* cv__endword(): + * Go to the end of this word according to vi + */ +protected char * +cv__endword(p, high, n) + char *p, *high; + int n; +{ + p++; + + while (n--) { + while ((p < high) && isspace((unsigned char) *p)) + p++; + + if (isalnum((unsigned char) *p)) + while ((p < high) && isalnum((unsigned char) *p)) + p++; + else + while ((p < high) && !(isspace((unsigned char) *p) || + isalnum((unsigned char) *p))) + p++; + } + p--; + return p; +} + +/* ch_init(): + * Initialize the character editor + */ +protected int +ch_init(el) + EditLine *el; +{ + el->el_line.buffer = (char *) el_malloc(EL_BUFSIZ); + (void) memset(el->el_line.buffer, 0, EL_BUFSIZ); + el->el_line.cursor = el->el_line.buffer; + el->el_line.lastchar = el->el_line.buffer; + el->el_line.limit = &el->el_line.buffer[EL_BUFSIZ - 2]; + + el->el_chared.c_undo.buf = (char *) el_malloc(EL_BUFSIZ); + (void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ); + el->el_chared.c_undo.action = NOP; + el->el_chared.c_undo.isize = 0; + el->el_chared.c_undo.dsize = 0; + el->el_chared.c_undo.ptr = el->el_line.buffer; + + el->el_chared.c_vcmd.action = NOP; + el->el_chared.c_vcmd.pos = el->el_line.buffer; + el->el_chared.c_vcmd.ins = el->el_line.buffer; + + el->el_chared.c_kill.buf = (char *) el_malloc(EL_BUFSIZ); + (void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ); + el->el_chared.c_kill.mark = el->el_line.buffer; + el->el_chared.c_kill.last = el->el_chared.c_kill.buf; + + el->el_map.current = el->el_map.key; + + el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */ + el->el_state.doingarg = 0; + el->el_state.metanext = 0; + el->el_state.argument = 1; + el->el_state.lastcmd = ED_UNASSIGNED; + + el->el_chared.c_macro.nline = NULL; + el->el_chared.c_macro.level = -1; + el->el_chared.c_macro.macro = (char **) el_malloc(EL_MAXMACRO * + sizeof(char *)); + return 0; +} + +/* ch_reset(): + * Reset the character editor + */ +protected void +ch_reset(el) + EditLine *el; +{ + el->el_line.cursor = el->el_line.buffer; + el->el_line.lastchar = el->el_line.buffer; + + el->el_chared.c_undo.action = NOP; + el->el_chared.c_undo.isize = 0; + el->el_chared.c_undo.dsize = 0; + el->el_chared.c_undo.ptr = el->el_line.buffer; + + el->el_chared.c_vcmd.action = NOP; + el->el_chared.c_vcmd.pos = el->el_line.buffer; + el->el_chared.c_vcmd.ins = el->el_line.buffer; + + el->el_chared.c_kill.mark = el->el_line.buffer; + + el->el_map.current = el->el_map.key; + + el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */ + el->el_state.doingarg = 0; + el->el_state.metanext = 0; + el->el_state.argument = 1; + el->el_state.lastcmd = ED_UNASSIGNED; + + el->el_chared.c_macro.level = -1; + + el->el_history.eventno = 0; +} + + +/* ch_end(): + * Free the data structures used by the editor + */ +protected void +ch_end(el) + EditLine *el; +{ + el_free((ptr_t) el->el_line.buffer); + el->el_line.buffer = NULL; + el->el_line.limit = NULL; + el_free((ptr_t) el->el_chared.c_undo.buf); + el->el_chared.c_undo.buf = NULL; + el_free((ptr_t) el->el_chared.c_kill.buf); + el->el_chared.c_kill.buf = NULL; + el_free((ptr_t) el->el_chared.c_macro.macro); + el->el_chared.c_macro.macro = NULL; + ch_reset(el); +} + + +/* el_insertstr(): + * Insert string at cursorI + */ +public int +el_insertstr(el, s) + EditLine *el; + char *s; +{ + int len; + + if ((len = strlen(s)) == 0) + return -1; + if (el->el_line.lastchar + len >= el->el_line.limit) + return -1; + + c_insert(el, len); + while (*s) + *el->el_line.cursor++ = *s++; + return 0; +} + + +/* el_deletestr(): + * Delete num characters before the cursor + */ +public void +el_deletestr(el, n) + EditLine *el; + int n; +{ + if (n <= 0) + return; + + if (el->el_line.cursor < &el->el_line.buffer[n]) + return; + + c_delbefore(el, n); /* delete before dot */ + el->el_line.cursor -= n; + if (el->el_line.cursor < el->el_line.buffer) + el->el_line.cursor = el->el_line.buffer; +} + +/* c_gets(): + * Get a string + */ +protected int +c_gets(el, buf) + EditLine *el; + char *buf; +{ + char ch; + int len = 0; + + for (ch = 0; ch == 0;) { + if (el_getc(el, &ch) != 1) + return ed_end_of_file(el, 0); + switch (ch) { + case 0010: /* Delete and backspace */ + case 0177: + if (len > 1) { + *el->el_line.cursor-- = '\0'; + el->el_line.lastchar = el->el_line.cursor; + buf[len--] = '\0'; + } + else { + el->el_line.buffer[0] = '\0'; + el->el_line.lastchar = el->el_line.buffer; + el->el_line.cursor = el->el_line.buffer; + return CC_REFRESH; + } + re_refresh(el); + ch = 0; + break; + + case 0033: /* ESC */ + case '\r': /* Newline */ + case '\n': + break; + + default: + if (len >= EL_BUFSIZ) + term_beep(el); + else { + buf[len++] = ch; + *el->el_line.cursor++ = ch; + el->el_line.lastchar = el->el_line.cursor; + } + re_refresh(el); + ch = 0; + break; + } + } + buf[len] = ch; + return len; +} + + +/* c_hpos(): + * Return the current horizontal position of the cursor + */ +protected int +c_hpos(el) + EditLine *el; +{ + char *ptr; + + /* + * Find how many characters till the beginning of this line. + */ + if (el->el_line.cursor == el->el_line.buffer) + return 0; + else { + for (ptr = el->el_line.cursor - 1; + ptr >= el->el_line.buffer && *ptr != '\n'; + ptr--) + continue; + return el->el_line.cursor - ptr - 1; + } +} Added: vendor/NetBSD/libedit/dist/chared.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/dist/chared.h Thu Mar 31 00:46:27 2011 (r220174) @@ -0,0 +1,160 @@ +/* $NetBSD: chared.h,v 1.2 1997/01/11 06:47:49 lukem Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Christos Zoulas of Cornell University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 00:47:17 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 30BC6106564A; Thu, 31 Mar 2011 00:47:17 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 05D178FC0C; Thu, 31 Mar 2011 00:47:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V0lGOU085935; Thu, 31 Mar 2011 00:47:16 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V0lGsb085934; Thu, 31 Mar 2011 00:47:16 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201103310047.p2V0lGsb085934@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 31 Mar 2011 00:47:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220175 - vendor/NetBSD/libedit/1997-06-25 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 00:47:17 -0000 Author: obrien Date: Thu Mar 31 00:47:16 2011 New Revision: 220175 URL: http://svn.freebsd.org/changeset/base/220175 Log: "Tag" the "1997-06-25 01:14:45 -0700" import. Added: vendor/NetBSD/libedit/1997-06-25/ - copied from r220174, vendor/NetBSD/libedit/dist/ From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 01:00:32 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0760B1065673; Thu, 31 Mar 2011 01:00:32 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E91208FC18; Thu, 31 Mar 2011 01:00:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V10VGA086272; Thu, 31 Mar 2011 01:00:31 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V10V6s086267; Thu, 31 Mar 2011 01:00:31 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201103310100.p2V10V6s086267@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 31 Mar 2011 01:00:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220176 - in vendor/NetBSD/libedit/dist: . TEST readline X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 01:00:32 -0000 Author: obrien Date: Thu Mar 31 01:00:31 2011 New Revision: 220176 URL: http://svn.freebsd.org/changeset/base/220176 Log: Vendor import NetBSD's libedit of "2001/09/29 17:52:10 UTC". Obtained from: NetBSD Added: vendor/NetBSD/libedit/dist/read.h (contents, props changed) vendor/NetBSD/libedit/dist/readline/ vendor/NetBSD/libedit/dist/readline.c (contents, props changed) vendor/NetBSD/libedit/dist/readline/Makefile (contents, props changed) vendor/NetBSD/libedit/dist/readline/readline.h (contents, props changed) Deleted: vendor/NetBSD/libedit/dist/termcap.h Modified: vendor/NetBSD/libedit/dist/Makefile vendor/NetBSD/libedit/dist/TEST/test.c vendor/NetBSD/libedit/dist/chared.c vendor/NetBSD/libedit/dist/chared.h vendor/NetBSD/libedit/dist/common.c vendor/NetBSD/libedit/dist/editline.3 vendor/NetBSD/libedit/dist/editrc.5 vendor/NetBSD/libedit/dist/el.c vendor/NetBSD/libedit/dist/el.h vendor/NetBSD/libedit/dist/emacs.c vendor/NetBSD/libedit/dist/hist.c vendor/NetBSD/libedit/dist/hist.h vendor/NetBSD/libedit/dist/histedit.h vendor/NetBSD/libedit/dist/history.c vendor/NetBSD/libedit/dist/key.c vendor/NetBSD/libedit/dist/key.h vendor/NetBSD/libedit/dist/makelist vendor/NetBSD/libedit/dist/map.c vendor/NetBSD/libedit/dist/map.h vendor/NetBSD/libedit/dist/parse.c vendor/NetBSD/libedit/dist/parse.h vendor/NetBSD/libedit/dist/prompt.c vendor/NetBSD/libedit/dist/prompt.h vendor/NetBSD/libedit/dist/read.c vendor/NetBSD/libedit/dist/refresh.c vendor/NetBSD/libedit/dist/refresh.h vendor/NetBSD/libedit/dist/search.c vendor/NetBSD/libedit/dist/search.h vendor/NetBSD/libedit/dist/shlib_version vendor/NetBSD/libedit/dist/sig.c vendor/NetBSD/libedit/dist/sig.h vendor/NetBSD/libedit/dist/sys.h vendor/NetBSD/libedit/dist/term.c vendor/NetBSD/libedit/dist/term.h vendor/NetBSD/libedit/dist/tokenizer.c vendor/NetBSD/libedit/dist/tokenizer.h vendor/NetBSD/libedit/dist/tty.c vendor/NetBSD/libedit/dist/tty.h vendor/NetBSD/libedit/dist/vi.c Modified: vendor/NetBSD/libedit/dist/Makefile ============================================================================== --- vendor/NetBSD/libedit/dist/Makefile Thu Mar 31 00:47:16 2011 (r220175) +++ vendor/NetBSD/libedit/dist/Makefile Thu Mar 31 01:00:31 2011 (r220176) @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.8 1997/05/09 07:50:14 mycroft Exp $ +# $NetBSD: Makefile,v 1.20 2001/01/05 21:15:49 jdolecek Exp $ # @(#)Makefile 8.1 (Berkeley) 6/4/93 LIB= edit @@ -10,54 +10,78 @@ MAN= editline.3 editrc.5 MLINKS= editline.3 el_init.3 editline.3 el_end.3 editline.3 el_reset.3 \ editline.3 el_gets.3 editline.3 el_getc.3 editline.3 el_push.3 \ - editline.3 el_parse.3 editline.3 el_set.3 editline.3 el_source.3 \ - editline.3 el_resize.3 editline.3 el_line.3 \ + editline.3 el_parse.3 editline.3 el_set.3 editline.3 el_get.3 \ + editline.3 el_source.3 editline.3 el_resize.3 editline.3 el_line.3 \ editline.3 el_insertstr.3 editline.3 el_deletestr.3 \ editline.3 history_init.3 editline.3 history_end.3 editline.3 history.3 # For speed and debugging -#SRCS= ${OSRCS} tokenizer.c history.c +#SRCS= ${OSRCS} tokenizer.c history.c readline.c # For protection -SRCS= editline.c tokenizer.c history.c +SRCS= editline.c tokenizer.c history.c readline.c SRCS+= common.h emacs.h fcns.h help.h vi.h +LIBEDITDIR?=${.CURDIR} + INCS= histedit.h INCSDIR=/usr/include CLEANFILES+=common.h editline.c emacs.h fcns.c fcns.h help.c help.h vi.h -CFLAGS+=-I. -I${.CURDIR} -CFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH -CFLAGS+=#-DDEBUG_PASTE +CLEANFILES+=common.h.tmp editline.c.tmp emacs.h.tmp fcns.c.tmp fcns.h.tmp +CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp +CPPFLAGS+=-I. -I${LIBEDITDIR} +CPPFLAGS+=-I. -I${.CURDIR} +CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH +CPPFLAGS+=#-DDEBUG_PASTE AHDR=vi.h emacs.h common.h -ASRC=${.CURDIR}/vi.c ${.CURDIR}/emacs.c ${.CURDIR}/common.c +ASRC=${LIBEDITDIR}/vi.c ${LIBEDITDIR}/emacs.c ${LIBEDITDIR}/common.c + +SUBDIR= readline vi.h: vi.c makelist - sh ${.CURDIR}/makelist -h ${.CURDIR}/vi.c > ${.TARGET} + sh ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/vi.c > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} emacs.h: emacs.c makelist - sh ${.CURDIR}/makelist -h ${.CURDIR}/emacs.c > ${.TARGET} + sh ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/emacs.c > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} common.h: common.c makelist - sh ${.CURDIR}/makelist -h ${.CURDIR}/common.c > ${.TARGET} + sh ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/common.c > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} fcns.h: ${AHDR} makelist - sh ${.CURDIR}/makelist -fh ${AHDR} > ${.TARGET} + sh ${LIBEDITDIR}/makelist -fh ${AHDR} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} fcns.c: ${AHDR} fcns.h makelist - sh ${.CURDIR}/makelist -fc ${AHDR} > ${.TARGET} + sh ${LIBEDITDIR}/makelist -fc ${AHDR} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} help.c: ${ASRC} makelist - sh ${.CURDIR}/makelist -bc ${ASRC} > ${.TARGET} + sh ${LIBEDITDIR}/makelist -bc ${ASRC} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} help.h: ${ASRC} makelist - sh ${.CURDIR}/makelist -bh ${ASRC} > ${.TARGET} + sh ${LIBEDITDIR}/makelist -bh ${ASRC} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} editline.c: ${OSRCS} - sh ${.CURDIR}/makelist -e ${.ALLSRC:T} > ${.TARGET} + sh ${LIBEDITDIR}/makelist -e ${.ALLSRC:T} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} +test.o: ${LIBEDITDIR}/TEST/test.c + test: libedit.a test.o - ${CC} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermcap + ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermcap + +# minimal dependency to make "make depend" optional +editline.o editline.po editline.so editline.ln: \ + common.h emacs.h fcns.c fcns.h help.c help.h vi.h +readline.o readline.po readline.so readline.ln: \ + common.h emacs.h fcns.h help.h vi.h .include +.include Modified: vendor/NetBSD/libedit/dist/TEST/test.c ============================================================================== --- vendor/NetBSD/libedit/dist/TEST/test.c Thu Mar 31 00:47:16 2011 (r220175) +++ vendor/NetBSD/libedit/dist/TEST/test.c Thu Mar 31 01:00:31 2011 (r220176) @@ -1,4 +1,4 @@ -/* $NetBSD */ +/* $NetBSD: test.c,v 1.9 2000/09/04 23:36:41 lukem Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -36,17 +36,17 @@ * SUCH DAMAGE. */ +#include #ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1992, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; +__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\ + The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #if !defined(lint) && !defined(SCCSID) #if 0 static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93"; #else -static char rcsid[] = "$NetBSD"; +__RCSID("$NetBSD: test.c,v 1.9 2000/09/04 23:36:41 lukem Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -69,182 +69,200 @@ static char rcsid[] = "$NetBSD"; static int continuation = 0; static EditLine *el = NULL; +static u_char complete(EditLine *, int); + int main(int, char **); +static char *prompt(EditLine *); +static void sig(int); + static char * -/*ARGSUSED*/ -prompt(el) - EditLine *el; +prompt(EditLine *el) { - static char a[] = "Edit$"; - static char b[] = "Edit>"; - return continuation ? b : a; + static char a[] = "Edit$"; + static char b[] = "Edit>"; + + return (continuation ? b : a); } static void -sig(i) - int i; +sig(int i) { - (void) fprintf(stderr, "Got signal %d.\n", i); - el_reset(el); + + (void) fprintf(stderr, "Got signal %d.\n", i); + el_reset(el); } static unsigned char -/*ARGSUSED*/ -complete(el, ch) - EditLine *el; - int ch; +complete(EditLine *el, int ch) { - DIR *dd = opendir("."); - struct dirent *dp; - const char* ptr; - const LineInfo *lf = el_line(el); - int len; - - /* - * Find the last word - */ - for (ptr = lf->cursor - 1; !isspace(*ptr) && ptr > lf->buffer; ptr--) - continue; - len = lf->cursor - ++ptr; - - for (dp = readdir(dd); dp != NULL; dp = readdir(dd)) { - if (len > strlen(dp->d_name)) - continue; - if (strncmp(dp->d_name, ptr, len) == 0) { - closedir(dd); - if (el_insertstr(el, &dp->d_name[len]) == -1) - return CC_ERROR; - else - return CC_REFRESH; + DIR *dd = opendir("."); + struct dirent *dp; + const char* ptr; + const LineInfo *lf = el_line(el); + int len; + + /* + * Find the last word + */ + for (ptr = lf->cursor - 1; !isspace(*ptr) && ptr > lf->buffer; ptr--) + continue; + len = lf->cursor - ++ptr; + + for (dp = readdir(dd); dp != NULL; dp = readdir(dd)) { + if (len > strlen(dp->d_name)) + continue; + if (strncmp(dp->d_name, ptr, len) == 0) { + closedir(dd); + if (el_insertstr(el, &dp->d_name[len]) == -1) + return (CC_ERROR); + else + return (CC_REFRESH); + } } - } - closedir(dd); - return CC_ERROR; + closedir(dd); + return (CC_ERROR); } int -/*ARGSUSED*/ -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { - int num; - const char *buf; - Tokenizer *tok; - History *hist; - - (void) signal(SIGINT, sig); - (void) signal(SIGQUIT, sig); - (void) signal(SIGHUP, sig); - (void) signal(SIGTERM, sig); - - hist = history_init(); /* Init the builtin history */ - history(hist, H_EVENT, 100); /* Remember 100 events */ - - tok = tok_init(NULL); /* Initialize the tokenizer */ - - el = el_init(*argv, stdin, stdout); /* Initialize editline */ - - el_set(el, EL_EDITOR, "vi"); /* Default editor is vi */ - el_set(el, EL_SIGNAL, 1); /* Handle signals gracefully */ - el_set(el, EL_PROMPT, prompt); /* Set the prompt function */ - - /* Tell editline to use this history interface */ - el_set(el, EL_HIST, history, hist); - - /* Add a user-defined function */ - el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete); - - el_set(el, EL_BIND, "^I", "ed-complete", NULL);/* Bind tab to it */ - - /* - * Bind j, k in vi command mode to previous and next line, instead - * of previous and next history. - */ - el_set(el, EL_BIND, "-a", "k", "ed-prev-line", NULL); - el_set(el, EL_BIND, "-a", "j", "ed-next-line", NULL); - - /* - * Source the user's defaults file. - */ - el_source(el, NULL); - - while ((buf = el_gets(el, &num)) != NULL && num != 0) { - int ac; - char **av; + int num; + const char *buf; + Tokenizer *tok; + int lastevent = 0, ncontinuation; + History *hist; + HistEvent ev; + + (void) signal(SIGINT, sig); + (void) signal(SIGQUIT, sig); + (void) signal(SIGHUP, sig); + (void) signal(SIGTERM, sig); + + hist = history_init(); /* Init the builtin history */ + /* Remember 100 events */ + history(hist, &ev, H_SETSIZE, 100); + + tok = tok_init(NULL); /* Initialize the tokenizer */ + + /* Initialize editline */ + el = el_init(*argv, stdin, stdout, stderr); + + el_set(el, EL_EDITOR, "vi"); /* Default editor is vi */ + el_set(el, EL_SIGNAL, 1); /* Handle signals gracefully */ + el_set(el, EL_PROMPT, prompt); /* Set the prompt function */ + + /* Tell editline to use this history interface */ + el_set(el, EL_HIST, history, hist); + + /* Add a user-defined function */ + el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete); + + /* Bind tab to it */ + el_set(el, EL_BIND, "^I", "ed-complete", NULL); + + /* + * Bind j, k in vi command mode to previous and next line, instead + * of previous and next history. + */ + el_set(el, EL_BIND, "-a", "k", "ed-prev-line", NULL); + el_set(el, EL_BIND, "-a", "j", "ed-next-line", NULL); + + /* + * Source the user's defaults file. + */ + el_source(el, NULL); + + while ((buf = el_gets(el, &num)) != NULL && num != 0) { + int ac; + char **av; #ifdef DEBUG - (void) fprintf(stderr, "got %d %s", num, buf); + (void) fprintf(stderr, "got %d %s", num, buf); #endif - if (!continuation && num == 1) - continue; + if (!continuation && num == 1) + continue; - if (tok_line(tok, buf, &ac, &av) > 0) { - history(hist, continuation ? H_ADD : H_ENTER, buf); - continuation = 1; - continue; - } + if (tok_line(tok, buf, &ac, &av) > 0) + ncontinuation = 1; + +#if 0 + if (continuation) { + /* + * Append to the right event in case the user + * moved around in history. + */ + if (history(hist, &ev, H_SET, lastevent) == -1) + err(1, "%d: %s\n", lastevent, ev.str); + history(hist, &ev, H_ADD , buf); + } else { + history(hist, &ev, H_ENTER, buf); + lastevent = ev.num; + } +#else + /* Simpler */ + history(hist, &ev, continuation ? H_APPEND : H_ENTER, buf); +#endif - history(hist, continuation ? H_ADD : H_ENTER, buf); + continuation = ncontinuation; + ncontinuation = 0; - continuation = 0; + if (strcmp(av[0], "history") == 0) { + int rv; - if (strcmp(av[0], "history") == 0) { - const struct HistEvent *he; + switch (ac) { + case 1: + for (rv = history(hist, &ev, H_LAST); rv != -1; + rv = history(hist, &ev, H_PREV)) + (void) fprintf(stdout, "%4d %s", + ev.num, ev.str); + break; + + case 2: + if (strcmp(av[1], "clear") == 0) + history(hist, &ev, H_CLEAR); + else + goto badhist; + break; + + case 3: + if (strcmp(av[1], "load") == 0) + history(hist, &ev, H_LOAD, av[2]); + else if (strcmp(av[1], "save") == 0) + history(hist, &ev, H_SAVE, av[2]); + break; + + badhist: + default: + (void) fprintf(stderr, + "Bad history arguments\n"); + break; + } + } else if (el_parse(el, ac, av) == -1) { + switch (fork()) { + case 0: + execvp(av[0], av); + perror(av[0]); + _exit(1); + /*NOTREACHED*/ + break; + + case -1: + perror("fork"); + break; + + default: + if (wait(&num) == -1) + perror("wait"); + (void) fprintf(stderr, "Exit %x\n", num); + break; + } + } - switch (ac) { - case 1: - for (he = history(hist, H_LAST); he; - he = history(hist, H_PREV)) - (void) fprintf(stdout, "%4d %s", he->num, he->str); - break; - - case 2: - if (strcmp(av[1], "clear") == 0) - history(hist, H_CLEAR); - else - goto badhist; - break; - - case 3: - if (strcmp(av[1], "load") == 0) - history(hist, H_LOAD, av[2]); - else if (strcmp(av[1], "save") == 0) - history(hist, H_SAVE, av[2]); - break; - - badhist: - default: - (void) fprintf(stderr, "Bad history arguments\n"); - break; - } + tok_reset(tok); } - else if (el_parse(el, ac, av) == -1) { - switch (fork()) { - case 0: - execvp(av[0], av); - perror(av[0]); - _exit(1); - /*NOTREACHED*/ - break; - - case -1: - perror("fork"); - break; - - default: - if (wait(&num) == -1) - perror("wait"); - (void) fprintf(stderr, "Exit %x\n", num); - break; - } - } - - tok_reset(tok); - } - el_end(el); - tok_end(tok); - history_end(hist); + el_end(el); + tok_end(tok); + history_end(hist); - return 0; + return (0); } Modified: vendor/NetBSD/libedit/dist/chared.c ============================================================================== --- vendor/NetBSD/libedit/dist/chared.c Thu Mar 31 00:47:16 2011 (r220175) +++ vendor/NetBSD/libedit/dist/chared.c Thu Mar 31 01:00:31 2011 (r220176) @@ -1,4 +1,4 @@ -/* $NetBSD: chared.c,v 1.2 1997/01/11 06:47:48 lukem Exp $ */ +/* $NetBSD: chared.c,v 1.14 2001/05/17 01:02:17 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -36,15 +36,16 @@ * SUCH DAMAGE. */ +#include #if !defined(lint) && !defined(SCCSID) #if 0 static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; #else -static char rcsid[] = "$NetBSD: chared.c,v 1.2 1997/01/11 06:47:48 lukem Exp $"; +__RCSID("$NetBSD: chared.c,v 1.14 2001/05/17 01:02:17 christos Exp $"); #endif #endif /* not lint && not SCCSID */ -/* +/* * chared.c: Character editor utilities */ #include "sys.h" @@ -52,72 +53,68 @@ static char rcsid[] = "$NetBSD: chared.c #include #include "el.h" +/* value to leave unused in line buffer */ +#define EL_LEAVE 2 + /* cv_undo(): * Handle state for the vi undo command */ protected void -cv_undo(el, action, size, ptr) - EditLine *el; - int action, size; - char *ptr; -{ - c_undo_t *vu = &el->el_chared.c_undo; - vu->action = action; - vu->ptr = ptr; - vu->isize = size; - (void) memcpy(vu->buf, vu->ptr, size); +cv_undo(EditLine *el,int action, size_t size, char *ptr) +{ + c_undo_t *vu = &el->el_chared.c_undo; + vu->action = action; + vu->ptr = ptr; + vu->isize = size; + (void) memcpy(vu->buf, vu->ptr, size); #ifdef DEBUG_UNDO - (void) fprintf(el->el_errfile, "Undo buffer \"%s\" size = +%d -%d\n", - vu->ptr, vu->isize, vu->dsize); + (void) fprintf(el->el_errfile, "Undo buffer \"%s\" size = +%d -%d\n", + vu->ptr, vu->isize, vu->dsize); #endif } -/* c_insert(): +/* c_insert(): * Insert num characters */ protected void -c_insert(el, num) - EditLine *el; - int num; -{ - char *cp; - - if (el->el_line.lastchar + num >= el->el_line.limit) - return; /* can't go past end of buffer */ - - if (el->el_line.cursor < el->el_line.lastchar) { - /* if I must move chars */ - for (cp = el->el_line.lastchar; cp >= el->el_line.cursor; cp--) - cp[num] = *cp; - } - el->el_line.lastchar += num; -} /* end c_insert */ +c_insert(EditLine *el, int num) +{ + char *cp; + + if (el->el_line.lastchar + num >= el->el_line.limit) + return; /* can't go past end of buffer */ + + if (el->el_line.cursor < el->el_line.lastchar) { + /* if I must move chars */ + for (cp = el->el_line.lastchar; cp >= el->el_line.cursor; cp--) + cp[num] = *cp; + } + el->el_line.lastchar += num; +} /* c_delafter(): * Delete num characters after the cursor */ protected void -c_delafter(el, num) - EditLine *el; - int num; +c_delafter(EditLine *el, int num) { - if (el->el_line.cursor + num > el->el_line.lastchar) - num = el->el_line.lastchar - el->el_line.cursor; + if (el->el_line.cursor + num > el->el_line.lastchar) + num = el->el_line.lastchar - el->el_line.cursor; - if (num > 0) { - char *cp; + if (num > 0) { + char *cp; - if (el->el_map.current != el->el_map.emacs) - cv_undo(el, INSERT, num, el->el_line.cursor); + if (el->el_map.current != el->el_map.emacs) + cv_undo(el, INSERT, (size_t)num, el->el_line.cursor); - for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) - *cp = cp[num]; + for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) + *cp = cp[num]; - el->el_line.lastchar -= num; - } + el->el_line.lastchar -= num; + } } @@ -125,25 +122,26 @@ c_delafter(el, num) * Delete num characters before the cursor */ protected void -c_delbefore(el, num) - EditLine *el; - int num; +c_delbefore(EditLine *el, int num) { - if (el->el_line.cursor - num < el->el_line.buffer) - num = el->el_line.cursor - el->el_line.buffer; + if (el->el_line.cursor - num < el->el_line.buffer) + num = el->el_line.cursor - el->el_line.buffer; - if (num > 0) { - char *cp; + if (num > 0) { + char *cp; - if (el->el_map.current != el->el_map.emacs) - cv_undo(el, INSERT, num, el->el_line.cursor - num); + if (el->el_map.current != el->el_map.emacs) + cv_undo(el, INSERT, (size_t)num, + el->el_line.cursor - num); - for (cp = el->el_line.cursor - num; cp <= el->el_line.lastchar; cp++) - *cp = cp[num]; + for (cp = el->el_line.cursor - num; + cp <= el->el_line.lastchar; + cp++) + *cp = cp[num]; - el->el_line.lastchar -= num; - } + el->el_line.lastchar -= num; + } } @@ -151,10 +149,9 @@ c_delbefore(el, num) * Return if p is part of a word according to emacs */ protected int -ce__isword(p) - int p; +ce__isword(int p) { - return isalpha(p) || isdigit(p) || strchr("*?_-.[]~=", p) != NULL; + return (isalpha(p) || isdigit(p) || strchr("*?_-.[]~=", p) != NULL); } @@ -162,10 +159,9 @@ ce__isword(p) * Return if p is part of a word according to vi */ protected int -cv__isword(p) - int p; +cv__isword(int p) { - return !isspace(p); + return (!isspace(p)); } @@ -173,26 +169,23 @@ cv__isword(p) * Find the previous word */ protected char * -c__prev_word(p, low, n, wtest) - register char *p, *low; - register int n; - int (*wtest) __P((int)); -{ - p--; - - while (n--) { - while ((p >= low) && !(*wtest)((unsigned char) *p)) - p--; - while ((p >= low) && (*wtest)((unsigned char) *p)) - p--; - } - - /* cp now points to one character before the word */ - p++; - if (p < low) - p = low; - /* cp now points where we want it */ - return p; +c__prev_word(char *p, char *low, int n, int (*wtest)(int)) +{ + p--; + + while (n--) { + while ((p >= low) && !(*wtest)((unsigned char) *p)) + p--; + while ((p >= low) && (*wtest)((unsigned char) *p)) + p--; + } + + /* cp now points to one character before the word */ + p++; + if (p < low) + p = low; + /* cp now points where we want it */ + return (p); } @@ -200,53 +193,46 @@ c__prev_word(p, low, n, wtest) * Find the next word */ protected char * -c__next_word(p, high, n, wtest) - register char *p, *high; - register int n; - int (*wtest) __P((int)); -{ - while (n--) { - while ((p < high) && !(*wtest)((unsigned char) *p)) - p++; - while ((p < high) && (*wtest)((unsigned char) *p)) - p++; - } - if (p > high) - p = high; - /* p now points where we want it */ - return p; +c__next_word(char *p, char *high, int n, int (*wtest)(int)) +{ + while (n--) { + while ((p < high) && !(*wtest)((unsigned char) *p)) + p++; + while ((p < high) && (*wtest)((unsigned char) *p)) + p++; + } + if (p > high) + p = high; + /* p now points where we want it */ + return (p); } /* cv_next_word(): * Find the next word vi style */ protected char * -cv_next_word(el, p, high, n, wtest) - EditLine *el; - register char *p, *high; - register int n; - int (*wtest) __P((int)); -{ - int test; - - while (n--) { - test = (*wtest)((unsigned char) *p); - while ((p < high) && (*wtest)((unsigned char) *p) == test) - p++; - /* - * vi historically deletes with cw only the word preserving the - * trailing whitespace! This is not what 'w' does.. - */ - if (el->el_chared.c_vcmd.action != (DELETE|INSERT)) - while ((p < high) && isspace((unsigned char) *p)) - p++; - } +cv_next_word(EditLine *el, char *p, char *high, int n, int (*wtest)(int)) +{ + int test; + + while (n--) { + test = (*wtest)((unsigned char) *p); + while ((p < high) && (*wtest)((unsigned char) *p) == test) + p++; + /* + * vi historically deletes with cw only the word preserving the + * trailing whitespace! This is not what 'w' does.. + */ + if (el->el_chared.c_vcmd.action != (DELETE|INSERT)) + while ((p < high) && isspace((unsigned char) *p)) + p++; + } - /* p now points where we want it */ - if (p > high) - return high; - else - return p; + /* p now points where we want it */ + if (p > high) + return (high); + else + return (p); } @@ -254,36 +240,32 @@ cv_next_word(el, p, high, n, wtest) * Find the previous word vi style */ protected char * -cv_prev_word(el, p, low, n, wtest) - EditLine *el; - register char *p, *low; - register int n; - int (*wtest) __P((int)); +cv_prev_word(EditLine *el, char *p, char *low, int n, int (*wtest)(int)) { - int test; + int test; - while (n--) { - p--; - /* - * vi historically deletes with cb only the word preserving the - * leading whitespace! This is not what 'b' does.. - */ - if (el->el_chared.c_vcmd.action != (DELETE|INSERT)) - while ((p > low) && isspace((unsigned char) *p)) + while (n--) { p--; - test = (*wtest)((unsigned char) *p); - while ((p >= low) && (*wtest)((unsigned char) *p) == test) - p--; - p++; - while (isspace((unsigned char) *p)) + /* + * vi historically deletes with cb only the word preserving the + * leading whitespace! This is not what 'b' does.. + */ + if (el->el_chared.c_vcmd.action != (DELETE|INSERT)) + while ((p > low) && isspace((unsigned char) *p)) + p--; + test = (*wtest)((unsigned char) *p); + while ((p >= low) && (*wtest)((unsigned char) *p) == test) + p--; p++; - } + while (isspace((unsigned char) *p)) + p++; + } - /* p now points where we want it */ - if (p < low) - return low; - else - return p; + /* p now points where we want it */ + if (p < low) + return (low); + else + return (p); } @@ -294,30 +276,30 @@ cv_prev_word(el, p, low, n, wtest) * Return p pointing to last char used. */ protected char * -c__number(p, num, dval) - char *p; /* character position */ - int *num; /* Return value */ - int dval; /* dval is the number to subtract from like $-3 */ -{ - register int i; - register int sign = 1; - - if (*++p == '^') { - *num = 1; - return p; - } - if (*p == '$') { - if (*++p != '-') { - *num = 0x7fffffff; /* Handle $ */ - return --p; - } - sign = -1; /* Handle $- */ - ++p; - } - for (i = 0; isdigit((unsigned char) *p); i = 10 * i + *p++ - '0') - continue; - *num = (sign < 0 ? dval - i : i); - return --p; +c__number( + char *p, /* character position */ + int *num, /* Return value */ + int dval) /* dval is the number to subtract from like $-3 */ +{ + int i; + int sign = 1; + + if (*++p == '^') { + *num = 1; + return (p); + } + if (*p == '$') { + if (*++p != '-') { + *num = 0x7fffffff; /* Handle $ */ + return (--p); + } + sign = -1; /* Handle $- */ + ++p; + } + for (i = 0; isdigit((unsigned char) *p); i = 10 * i + *p++ - '0') + continue; + *num = (sign < 0 ? dval - i : i); + return (--p); } #endif @@ -325,53 +307,50 @@ c__number(p, num, dval) * Finish vi delete action */ protected void -cv_delfini(el) - EditLine *el; +cv_delfini(EditLine *el) { - register int size; - int oaction; + int size; + int oaction; - if (el->el_chared.c_vcmd.action & INSERT) - el->el_map.current = el->el_map.key; + if (el->el_chared.c_vcmd.action & INSERT) + el->el_map.current = el->el_map.key; + + oaction = el->el_chared.c_vcmd.action; + el->el_chared.c_vcmd.action = NOP; + + if (el->el_chared.c_vcmd.pos == 0) + return; + + + if (el->el_line.cursor > el->el_chared.c_vcmd.pos) { + size = (int) (el->el_line.cursor - el->el_chared.c_vcmd.pos); + c_delbefore(el, size); + el->el_line.cursor = el->el_chared.c_vcmd.pos; + re_refresh_cursor(el); + } else if (el->el_line.cursor < el->el_chared.c_vcmd.pos) { + size = (int)(el->el_chared.c_vcmd.pos - el->el_line.cursor); + c_delafter(el, size); + } else { + size = 1; + c_delafter(el, size); + } + switch (oaction) { + case DELETE|INSERT: + el->el_chared.c_undo.action = DELETE|INSERT; + break; + case DELETE: + el->el_chared.c_undo.action = INSERT; + break; + case NOP: + case INSERT: + default: + EL_ABORT((el->el_errfile, "Bad oaction %d\n", oaction)); + break; + } - oaction = el->el_chared.c_vcmd.action; - el->el_chared.c_vcmd.action = NOP; - - if (el->el_chared.c_vcmd.pos == 0) - return; - - - if (el->el_line.cursor > el->el_chared.c_vcmd.pos) { - size = (int) (el->el_line.cursor - el->el_chared.c_vcmd.pos); - c_delbefore(el, size); - el->el_line.cursor = el->el_chared.c_vcmd.pos; - re_refresh_cursor(el); - } - else if (el->el_line.cursor < el->el_chared.c_vcmd.pos) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 01:03:25 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28A72106564A; Thu, 31 Mar 2011 01:03:25 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F22D18FC14; Thu, 31 Mar 2011 01:03:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V13O6K086384; Thu, 31 Mar 2011 01:03:24 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V13Ou1086383; Thu, 31 Mar 2011 01:03:24 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201103310103.p2V13Ou1086383@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 31 Mar 2011 01:03:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220177 - vendor/NetBSD/libedit/2001-09-29 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 01:03:25 -0000 Author: obrien Date: Thu Mar 31 01:03:24 2011 New Revision: 220177 URL: http://svn.freebsd.org/changeset/base/220177 Log: "Tag" the "2001/09/29 17:52:10 UTC" import. Added: vendor/NetBSD/libedit/2001-09-29/ - copied from r220176, vendor/NetBSD/libedit/dist/ From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 01:13:05 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC7CA106566B; Thu, 31 Mar 2011 01:13:05 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BA4E08FC14; Thu, 31 Mar 2011 01:13:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V1D5e3086613; Thu, 31 Mar 2011 01:13:05 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V1D5dh086606; Thu, 31 Mar 2011 01:13:05 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201103310113.p2V1D5dh086606@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 31 Mar 2011 01:13:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220178 - in vendor/NetBSD/libedit/dist: . TEST readline X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 01:13:05 -0000 Author: obrien Date: Thu Mar 31 01:13:05 2011 New Revision: 220178 URL: http://svn.freebsd.org/changeset/base/220178 Log: Vendor import NetBSD's libedit of "2005/08/02 12:11:14 UTC". Obtained from: NetBSD Added: vendor/NetBSD/libedit/dist/TEST/Makefile (contents, props changed) vendor/NetBSD/libedit/dist/config.h (contents, props changed) vendor/NetBSD/libedit/dist/filecomplete.c (contents, props changed) vendor/NetBSD/libedit/dist/filecomplete.h (contents, props changed) Deleted: vendor/NetBSD/libedit/dist/tokenizer.h Modified: vendor/NetBSD/libedit/dist/Makefile vendor/NetBSD/libedit/dist/TEST/test.c vendor/NetBSD/libedit/dist/chared.c vendor/NetBSD/libedit/dist/chared.h vendor/NetBSD/libedit/dist/common.c vendor/NetBSD/libedit/dist/editline.3 vendor/NetBSD/libedit/dist/editrc.5 vendor/NetBSD/libedit/dist/el.c vendor/NetBSD/libedit/dist/el.h vendor/NetBSD/libedit/dist/emacs.c vendor/NetBSD/libedit/dist/hist.c vendor/NetBSD/libedit/dist/hist.h vendor/NetBSD/libedit/dist/histedit.h vendor/NetBSD/libedit/dist/history.c vendor/NetBSD/libedit/dist/key.c vendor/NetBSD/libedit/dist/key.h vendor/NetBSD/libedit/dist/makelist vendor/NetBSD/libedit/dist/map.c vendor/NetBSD/libedit/dist/map.h vendor/NetBSD/libedit/dist/parse.c vendor/NetBSD/libedit/dist/parse.h vendor/NetBSD/libedit/dist/prompt.c vendor/NetBSD/libedit/dist/prompt.h vendor/NetBSD/libedit/dist/read.c vendor/NetBSD/libedit/dist/read.h vendor/NetBSD/libedit/dist/readline.c vendor/NetBSD/libedit/dist/readline/Makefile vendor/NetBSD/libedit/dist/readline/readline.h vendor/NetBSD/libedit/dist/refresh.c vendor/NetBSD/libedit/dist/refresh.h vendor/NetBSD/libedit/dist/search.c vendor/NetBSD/libedit/dist/search.h vendor/NetBSD/libedit/dist/shlib_version vendor/NetBSD/libedit/dist/sig.c vendor/NetBSD/libedit/dist/sig.h vendor/NetBSD/libedit/dist/sys.h vendor/NetBSD/libedit/dist/term.c vendor/NetBSD/libedit/dist/term.h vendor/NetBSD/libedit/dist/tokenizer.c vendor/NetBSD/libedit/dist/tty.c vendor/NetBSD/libedit/dist/tty.h vendor/NetBSD/libedit/dist/vi.c Modified: vendor/NetBSD/libedit/dist/Makefile ============================================================================== --- vendor/NetBSD/libedit/dist/Makefile Thu Mar 31 01:03:24 2011 (r220177) +++ vendor/NetBSD/libedit/dist/Makefile Thu Mar 31 01:13:05 2011 (r220178) @@ -1,9 +1,15 @@ -# $NetBSD: Makefile,v 1.20 2001/01/05 21:15:49 jdolecek Exp $ +# $NetBSD: Makefile,v 1.34 2005/05/28 12:02:53 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 6/4/93 +USE_SHLIBDIR= yes + +WARNS= 3 LIB= edit -OSRCS= chared.c common.c el.c emacs.c fcns.c help.c hist.c key.c map.c \ +LIBDPLIBS= termcap ${.CURDIR}/../libterm + +OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c hist.c \ + key.c map.c \ parse.c prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c MAN= editline.3 editrc.5 @@ -13,75 +19,86 @@ MLINKS= editline.3 el_init.3 editline.3 editline.3 el_parse.3 editline.3 el_set.3 editline.3 el_get.3 \ editline.3 el_source.3 editline.3 el_resize.3 editline.3 el_line.3 \ editline.3 el_insertstr.3 editline.3 el_deletestr.3 \ - editline.3 history_init.3 editline.3 history_end.3 editline.3 history.3 + editline.3 history_init.3 editline.3 history_end.3 \ + editline.3 history.3 \ + editline.3 tok_init.3 editline.3 tok_end.3 editline.3 tok_reset.3 \ + editline.3 tok_line.3 editline.3 tok_str.3 # For speed and debugging #SRCS= ${OSRCS} tokenizer.c history.c readline.c # For protection SRCS= editline.c tokenizer.c history.c readline.c -SRCS+= common.h emacs.h fcns.h help.h vi.h - LIBEDITDIR?=${.CURDIR} INCS= histedit.h INCSDIR=/usr/include -CLEANFILES+=common.h editline.c emacs.h fcns.c fcns.h help.c help.h vi.h +CLEANFILES+=editline.c CLEANFILES+=common.h.tmp editline.c.tmp emacs.h.tmp fcns.c.tmp fcns.h.tmp CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp +CLEANFILES+=test.o test CPPFLAGS+=-I. -I${LIBEDITDIR} CPPFLAGS+=-I. -I${.CURDIR} CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH -CPPFLAGS+=#-DDEBUG_PASTE +CPPFLAGS+=#-DDEBUG_PASTE -DDEBUG_EDIT AHDR=vi.h emacs.h common.h ASRC=${LIBEDITDIR}/vi.c ${LIBEDITDIR}/emacs.c ${LIBEDITDIR}/common.c +DPSRCS+= ${AHDR} fcns.h help.h fcns.c help.c +CLEANFILES+= ${AHDR} fcns.h help.h fcns.c help.c + SUBDIR= readline -vi.h: vi.c makelist - sh ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/vi.c > ${.TARGET}.tmp && \ +vi.h: vi.c makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/vi.c \ + > ${.TARGET}.tmp && \ mv ${.TARGET}.tmp ${.TARGET} -emacs.h: emacs.c makelist - sh ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/emacs.c > ${.TARGET}.tmp && \ +emacs.h: emacs.c makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/emacs.c \ + > ${.TARGET}.tmp && \ mv ${.TARGET}.tmp ${.TARGET} -common.h: common.c makelist - sh ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/common.c > ${.TARGET}.tmp && \ +common.h: common.c makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/common.c \ + > ${.TARGET}.tmp && \ mv ${.TARGET}.tmp ${.TARGET} -fcns.h: ${AHDR} makelist - sh ${LIBEDITDIR}/makelist -fh ${AHDR} > ${.TARGET}.tmp && \ +fcns.h: ${AHDR} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -fh ${AHDR} > ${.TARGET}.tmp && \ mv ${.TARGET}.tmp ${.TARGET} -fcns.c: ${AHDR} fcns.h makelist - sh ${LIBEDITDIR}/makelist -fc ${AHDR} > ${.TARGET}.tmp && \ +fcns.c: ${AHDR} fcns.h help.h makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -fc ${AHDR} > ${.TARGET}.tmp && \ mv ${.TARGET}.tmp ${.TARGET} -help.c: ${ASRC} makelist - sh ${LIBEDITDIR}/makelist -bc ${ASRC} > ${.TARGET}.tmp && \ +help.c: ${ASRC} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -bc ${ASRC} > ${.TARGET}.tmp && \ mv ${.TARGET}.tmp ${.TARGET} -help.h: ${ASRC} makelist - sh ${LIBEDITDIR}/makelist -bh ${ASRC} > ${.TARGET}.tmp && \ +help.h: ${ASRC} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -bh ${ASRC} > ${.TARGET}.tmp && \ mv ${.TARGET}.tmp ${.TARGET} -editline.c: ${OSRCS} - sh ${LIBEDITDIR}/makelist -e ${.ALLSRC:T} > ${.TARGET}.tmp && \ +editline.c: ${OSRCS} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -e ${OSRCS:T} > ${.TARGET}.tmp && \ mv ${.TARGET}.tmp ${.TARGET} test.o: ${LIBEDITDIR}/TEST/test.c test: libedit.a test.o + ${_MKTARGET_LINK} ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermcap -# minimal dependency to make "make depend" optional -editline.o editline.po editline.so editline.ln: \ - common.h emacs.h fcns.c fcns.h help.c help.h vi.h -readline.o readline.po readline.so readline.ln: \ - common.h emacs.h fcns.h help.h vi.h - .include .include Added: vendor/NetBSD/libedit/dist/TEST/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/dist/TEST/Makefile Thu Mar 31 01:13:05 2011 (r220178) @@ -0,0 +1,13 @@ +# $NetBSD: Makefile,v 1.2 2003/12/05 13:37:48 lukem Exp $ + +NOMAN=1 +PROG=test +CPPFLAGS=-I${.CURDIR}/.. +LDADD+=-ledit -ltermcap +DPADD+=${LIBEDIT} ${LIBTERMCAP} + +.ifdef DEBUG +CPPFLAGS+=-DDEBUG +.endif + +.include Modified: vendor/NetBSD/libedit/dist/TEST/test.c ============================================================================== --- vendor/NetBSD/libedit/dist/TEST/test.c Thu Mar 31 01:03:24 2011 (r220177) +++ vendor/NetBSD/libedit/dist/TEST/test.c Thu Mar 31 01:13:05 2011 (r220178) @@ -1,4 +1,4 @@ -/* $NetBSD: test.c,v 1.9 2000/09/04 23:36:41 lukem Exp $ */ +/* $NetBSD: test.c,v 1.18 2005/06/01 11:37:52 lukem Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -15,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +32,7 @@ * SUCH DAMAGE. */ -#include +#include "config.h" #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\ The Regents of the University of California. All rights reserved.\n"); @@ -46,14 +42,13 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19 #if 0 static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: test.c,v 1.9 2000/09/04 23:36:41 lukem Exp $"); +__RCSID("$NetBSD: test.c,v 1.18 2005/06/01 11:37:52 lukem Exp $"); #endif #endif /* not lint && not SCCSID */ /* * test.c: A little test program */ -#include "sys.h" #include #include #include @@ -64,12 +59,11 @@ __RCSID("$NetBSD: test.c,v 1.9 2000/09/0 #include #include "histedit.h" -#include "tokenizer.h" static int continuation = 0; -static EditLine *el = NULL; +volatile sig_atomic_t gotsig = 0; -static u_char complete(EditLine *, int); +static unsigned char complete(EditLine *, int); int main(int, char **); static char *prompt(EditLine *); static void sig(int); @@ -77,8 +71,8 @@ static void sig(int); static char * prompt(EditLine *el) { - static char a[] = "Edit$"; - static char b[] = "Edit>"; + static char a[] = "Edit$ "; + static char b[] = "Edit> "; return (continuation ? b : a); } @@ -86,9 +80,7 @@ prompt(EditLine *el) static void sig(int i) { - - (void) fprintf(stderr, "Got signal %d.\n", i); - el_reset(el); + gotsig = i; } static unsigned char @@ -103,7 +95,8 @@ complete(EditLine *el, int ch) /* * Find the last word */ - for (ptr = lf->cursor - 1; !isspace(*ptr) && ptr > lf->buffer; ptr--) + for (ptr = lf->cursor - 1; + !isspace((unsigned char)*ptr) && ptr > lf->buffer; ptr--) continue; len = lf->cursor - ++ptr; @@ -126,10 +119,14 @@ complete(EditLine *el, int ch) int main(int argc, char *argv[]) { + EditLine *el = NULL; int num; const char *buf; Tokenizer *tok; - int lastevent = 0, ncontinuation; +#if 0 + int lastevent = 0; +#endif + int ncontinuation; History *hist; HistEvent ev; @@ -173,17 +170,41 @@ main(int argc, char *argv[]) el_source(el, NULL); while ((buf = el_gets(el, &num)) != NULL && num != 0) { - int ac; - char **av; + int ac, cc, co; #ifdef DEBUG - (void) fprintf(stderr, "got %d %s", num, buf); + int i; #endif + const char **av; + const LineInfo *li; + li = el_line(el); +#ifdef DEBUG + (void) fprintf(stderr, "==> got %d %s", num, buf); + (void) fprintf(stderr, " > li `%.*s_%.*s'\n", + (li->cursor - li->buffer), li->buffer, + (li->lastchar - 1 - li->cursor), + (li->cursor >= li->lastchar) ? "" : li->cursor); + +#endif + if (gotsig) { + (void) fprintf(stderr, "Got signal %d.\n", gotsig); + gotsig = 0; + el_reset(el); + } + if (!continuation && num == 1) continue; - if (tok_line(tok, buf, &ac, &av) > 0) - ncontinuation = 1; - + ac = cc = co = 0; + ncontinuation = tok_line(tok, li, &ac, &av, &cc, &co); + if (ncontinuation < 0) { + (void) fprintf(stderr, "Internal error\n"); + continuation = 0; + continue; + } +#ifdef DEBUG + (void) fprintf(stderr, " > nc %d ac %d cc %d co %d\n", + ncontinuation, ac, cc, co); +#endif #if 0 if (continuation) { /* @@ -191,7 +212,7 @@ main(int argc, char *argv[]) * moved around in history. */ if (history(hist, &ev, H_SET, lastevent) == -1) - err(1, "%d: %s\n", lastevent, ev.str); + err(1, "%d: %s", lastevent, ev.str); history(hist, &ev, H_ADD , buf); } else { history(hist, &ev, H_ENTER, buf); @@ -204,6 +225,18 @@ main(int argc, char *argv[]) continuation = ncontinuation; ncontinuation = 0; + if (continuation) + continue; +#ifdef DEBUG + for (i = 0; i < ac; i++) { + (void) fprintf(stderr, " > arg# %2d ", i); + if (i != cc) + (void) fprintf(stderr, "`%s'\n", av[i]); + else + (void) fprintf(stderr, "`%.*s_%s'\n", + co, av[i], av[i] + co); + } +#endif if (strcmp(av[0], "history") == 0) { int rv; @@ -239,7 +272,7 @@ main(int argc, char *argv[]) } else if (el_parse(el, ac, av) == -1) { switch (fork()) { case 0: - execvp(av[0], av); + execvp(av[0], (char *const *)__UNCONST(av)); perror(av[0]); _exit(1); /*NOTREACHED*/ Modified: vendor/NetBSD/libedit/dist/chared.c ============================================================================== --- vendor/NetBSD/libedit/dist/chared.c Thu Mar 31 01:03:24 2011 (r220177) +++ vendor/NetBSD/libedit/dist/chared.c Thu Mar 31 01:13:05 2011 (r220178) @@ -1,4 +1,4 @@ -/* $NetBSD: chared.c,v 1.14 2001/05/17 01:02:17 christos Exp $ */ +/* $NetBSD: chared.c,v 1.24 2005/08/01 23:00:15 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -15,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,23 +32,23 @@ * SUCH DAMAGE. */ -#include +#include "config.h" #if !defined(lint) && !defined(SCCSID) #if 0 static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: chared.c,v 1.14 2001/05/17 01:02:17 christos Exp $"); +__RCSID("$NetBSD: chared.c,v 1.24 2005/08/01 23:00:15 christos Exp $"); #endif #endif /* not lint && not SCCSID */ /* * chared.c: Character editor utilities */ -#include "sys.h" - #include #include "el.h" +private void ch__clearmacro __P((EditLine *)); + /* value to leave unused in line buffer */ #define EL_LEAVE 2 @@ -60,17 +56,36 @@ __RCSID("$NetBSD: chared.c,v 1.14 2001/0 * Handle state for the vi undo command */ protected void -cv_undo(EditLine *el,int action, size_t size, char *ptr) +cv_undo(EditLine *el) { c_undo_t *vu = &el->el_chared.c_undo; - vu->action = action; - vu->ptr = ptr; - vu->isize = size; - (void) memcpy(vu->buf, vu->ptr, size); -#ifdef DEBUG_UNDO - (void) fprintf(el->el_errfile, "Undo buffer \"%s\" size = +%d -%d\n", - vu->ptr, vu->isize, vu->dsize); -#endif + c_redo_t *r = &el->el_chared.c_redo; + unsigned int size; + + /* Save entire line for undo */ + size = el->el_line.lastchar - el->el_line.buffer; + vu->len = size; + vu->cursor = el->el_line.cursor - el->el_line.buffer; + memcpy(vu->buf, el->el_line.buffer, size); + + /* save command info for redo */ + r->count = el->el_state.doingarg ? el->el_state.argument : 0; + r->action = el->el_chared.c_vcmd.action; + r->pos = r->buf; + r->cmd = el->el_state.thiscmd; + r->ch = el->el_state.thisch; +} + +/* cv_yank(): + * Save yank/delete data for paste + */ +protected void +cv_yank(EditLine *el, const char *ptr, int size) +{ + c_kill_t *k = &el->el_chared.c_kill; + + memcpy(k->buf, ptr, size +0u); + k->last = k->buf + size; } @@ -82,8 +97,10 @@ c_insert(EditLine *el, int num) { char *cp; - if (el->el_line.lastchar + num >= el->el_line.limit) - return; /* can't go past end of buffer */ + if (el->el_line.lastchar + num >= el->el_line.limit) { + if (!ch_enlargebufs(el, num +0u)) + return; /* can't go past end of buffer */ + } if (el->el_line.cursor < el->el_line.lastchar) { /* if I must move chars */ @@ -104,12 +121,14 @@ c_delafter(EditLine *el, int num) if (el->el_line.cursor + num > el->el_line.lastchar) num = el->el_line.lastchar - el->el_line.cursor; + if (el->el_map.current != el->el_map.emacs) { + cv_undo(el); + cv_yank(el, el->el_line.cursor, num); + } + if (num > 0) { char *cp; - if (el->el_map.current != el->el_map.emacs) - cv_undo(el, INSERT, (size_t)num, el->el_line.cursor); - for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) *cp = cp[num]; @@ -118,6 +137,21 @@ c_delafter(EditLine *el, int num) } +/* c_delafter1(): + * Delete the character after the cursor, do not yank + */ +protected void +c_delafter1(EditLine *el) +{ + char *cp; + + for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) + *cp = cp[1]; + + el->el_line.lastchar--; +} + + /* c_delbefore(): * Delete num characters before the cursor */ @@ -128,13 +162,14 @@ c_delbefore(EditLine *el, int num) if (el->el_line.cursor - num < el->el_line.buffer) num = el->el_line.cursor - el->el_line.buffer; + if (el->el_map.current != el->el_map.emacs) { + cv_undo(el); + cv_yank(el, el->el_line.cursor - num, num); + } + if (num > 0) { char *cp; - if (el->el_map.current != el->el_map.emacs) - cv_undo(el, INSERT, (size_t)num, - el->el_line.cursor - num); - for (cp = el->el_line.cursor - num; cp <= el->el_line.lastchar; cp++) @@ -145,13 +180,28 @@ c_delbefore(EditLine *el, int num) } +/* c_delbefore1(): + * Delete the character before the cursor, do not yank + */ +protected void +c_delbefore1(EditLine *el) +{ + char *cp; + + for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++) + *cp = cp[1]; + + el->el_line.lastchar--; +} + + /* ce__isword(): * Return if p is part of a word according to emacs */ protected int ce__isword(int p) { - return (isalpha(p) || isdigit(p) || strchr("*?_-.[]~=", p) != NULL); + return (isalnum(p) || strchr("*?_-.[]~=", p) != NULL); } @@ -161,6 +211,20 @@ ce__isword(int p) protected int cv__isword(int p) { + if (isalnum(p) || p == '_') + return 1; + if (isgraph(p)) + return 2; + return 0; +} + + +/* cv__isWord(): + * Return if p is part of a big word according to vi + */ +protected int +cv__isWord(int p) +{ return (!isspace(p)); } @@ -223,7 +287,7 @@ cv_next_word(EditLine *el, char *p, char * vi historically deletes with cw only the word preserving the * trailing whitespace! This is not what 'w' does.. */ - if (el->el_chared.c_vcmd.action != (DELETE|INSERT)) + if (n || el->el_chared.c_vcmd.action != (DELETE|INSERT)) while ((p < high) && isspace((unsigned char) *p)) p++; } @@ -240,26 +304,19 @@ cv_next_word(EditLine *el, char *p, char * Find the previous word vi style */ protected char * -cv_prev_word(EditLine *el, char *p, char *low, int n, int (*wtest)(int)) +cv_prev_word(char *p, char *low, int n, int (*wtest)(int)) { int test; + p--; while (n--) { - p--; - /* - * vi historically deletes with cb only the word preserving the - * leading whitespace! This is not what 'b' does.. - */ - if (el->el_chared.c_vcmd.action != (DELETE|INSERT)) - while ((p > low) && isspace((unsigned char) *p)) - p--; + while ((p > low) && isspace((unsigned char) *p)) + p--; test = (*wtest)((unsigned char) *p); while ((p >= low) && (*wtest)((unsigned char) *p) == test) p--; - p++; - while (isspace((unsigned char) *p)) - p++; } + p++; /* p now points where we want it */ if (p < low) @@ -310,47 +367,34 @@ protected void cv_delfini(EditLine *el) { int size; - int oaction; + int action = el->el_chared.c_vcmd.action; - if (el->el_chared.c_vcmd.action & INSERT) + if (action & INSERT) el->el_map.current = el->el_map.key; - oaction = el->el_chared.c_vcmd.action; - el->el_chared.c_vcmd.action = NOP; - if (el->el_chared.c_vcmd.pos == 0) + /* sanity */ return; - - if (el->el_line.cursor > el->el_chared.c_vcmd.pos) { - size = (int) (el->el_line.cursor - el->el_chared.c_vcmd.pos); - c_delbefore(el, size); - el->el_line.cursor = el->el_chared.c_vcmd.pos; - re_refresh_cursor(el); - } else if (el->el_line.cursor < el->el_chared.c_vcmd.pos) { - size = (int)(el->el_chared.c_vcmd.pos - el->el_line.cursor); - c_delafter(el, size); - } else { + size = el->el_line.cursor - el->el_chared.c_vcmd.pos; + if (size == 0) size = 1; - c_delafter(el, size); - } - switch (oaction) { - case DELETE|INSERT: - el->el_chared.c_undo.action = DELETE|INSERT; - break; - case DELETE: - el->el_chared.c_undo.action = INSERT; - break; - case NOP: - case INSERT: - default: - EL_ABORT((el->el_errfile, "Bad oaction %d\n", oaction)); - break; + el->el_line.cursor = el->el_chared.c_vcmd.pos; + if (action & YANK) { + if (size > 0) + cv_yank(el, el->el_line.cursor, size); + else + cv_yank(el, el->el_line.cursor + size, -size); + } else { + if (size > 0) { + c_delafter(el, size); + re_refresh_cursor(el); + } else { + c_delbefore(el, -size); + el->el_line.cursor += size; + } } - - - el->el_chared.c_undo.ptr = el->el_line.cursor; - el->el_chared.c_undo.dsize = size; + el->el_chared.c_vcmd.action = NOP; } @@ -380,21 +424,19 @@ ce__endword(char *p, char *high, int n) * Go to the end of this word according to vi */ protected char * -cv__endword(char *p, char *high, int n) +cv__endword(char *p, char *high, int n, int (*wtest)(int)) { + int test; + p++; while (n--) { while ((p < high) && isspace((unsigned char) *p)) p++; - if (isalnum((unsigned char) *p)) - while ((p < high) && isalnum((unsigned char) *p)) - p++; - else - while ((p < high) && !(isspace((unsigned char) *p) || - isalnum((unsigned char) *p))) - p++; + test = (*wtest)((unsigned char) *p); + while ((p < high) && (*wtest)((unsigned char) *p) == test) + p++; } p--; return (p); @@ -406,6 +448,8 @@ cv__endword(char *p, char *high, int n) protected int ch_init(EditLine *el) { + c_macro_t *ma = &el->el_chared.c_macro; + el->el_line.buffer = (char *) el_malloc(EL_BUFSIZ); if (el->el_line.buffer == NULL) return (-1); @@ -413,20 +457,23 @@ ch_init(EditLine *el) (void) memset(el->el_line.buffer, 0, EL_BUFSIZ); el->el_line.cursor = el->el_line.buffer; el->el_line.lastchar = el->el_line.buffer; - el->el_line.limit = &el->el_line.buffer[EL_BUFSIZ - 2]; + el->el_line.limit = &el->el_line.buffer[EL_BUFSIZ - EL_LEAVE]; el->el_chared.c_undo.buf = (char *) el_malloc(EL_BUFSIZ); if (el->el_chared.c_undo.buf == NULL) return (-1); (void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ); - el->el_chared.c_undo.action = NOP; - el->el_chared.c_undo.isize = 0; - el->el_chared.c_undo.dsize = 0; - el->el_chared.c_undo.ptr = el->el_line.buffer; + el->el_chared.c_undo.len = -1; + el->el_chared.c_undo.cursor = 0; + el->el_chared.c_redo.buf = (char *) el_malloc(EL_BUFSIZ); + if (el->el_chared.c_redo.buf == NULL) + return (-1); + el->el_chared.c_redo.pos = el->el_chared.c_redo.buf; + el->el_chared.c_redo.lim = el->el_chared.c_redo.buf + EL_BUFSIZ; + el->el_chared.c_redo.cmd = ED_UNASSIGNED; el->el_chared.c_vcmd.action = NOP; el->el_chared.c_vcmd.pos = el->el_line.buffer; - el->el_chared.c_vcmd.ins = el->el_line.buffer; el->el_chared.c_kill.buf = (char *) el_malloc(EL_BUFSIZ); if (el->el_chared.c_kill.buf == NULL) @@ -443,11 +490,10 @@ ch_init(EditLine *el) el->el_state.argument = 1; el->el_state.lastcmd = ED_UNASSIGNED; - el->el_chared.c_macro.nline = NULL; - el->el_chared.c_macro.level = -1; - el->el_chared.c_macro.macro = (char **) el_malloc(EL_MAXMACRO * - sizeof(char *)); - if (el->el_chared.c_macro.macro == NULL) + ma->level = -1; + ma->offset = 0; + ma->macro = (char **) el_malloc(EL_MAXMACRO * sizeof(char *)); + if (ma->macro == NULL) return (-1); return (0); } @@ -456,19 +502,16 @@ ch_init(EditLine *el) * Reset the character editor */ protected void -ch_reset(EditLine *el) +ch_reset(EditLine *el, int mclear) { el->el_line.cursor = el->el_line.buffer; el->el_line.lastchar = el->el_line.buffer; - el->el_chared.c_undo.action = NOP; - el->el_chared.c_undo.isize = 0; - el->el_chared.c_undo.dsize = 0; - el->el_chared.c_undo.ptr = el->el_line.buffer; + el->el_chared.c_undo.len = -1; + el->el_chared.c_undo.cursor = 0; el->el_chared.c_vcmd.action = NOP; el->el_chared.c_vcmd.pos = el->el_line.buffer; - el->el_chared.c_vcmd.ins = el->el_line.buffer; el->el_chared.c_kill.mark = el->el_line.buffer; @@ -480,9 +523,17 @@ ch_reset(EditLine *el) el->el_state.argument = 1; el->el_state.lastcmd = ED_UNASSIGNED; - el->el_chared.c_macro.level = -1; + if (mclear) + ch__clearmacro(el); +} - el->el_history.eventno = 0; +private void +ch__clearmacro(el) + EditLine *el; +{ + c_macro_t *ma = &el->el_chared.c_macro; + while (ma->level >= 0) + el_free((ptr_t)ma->macro[ma->level--]); } /* ch_enlargebufs(): @@ -523,7 +574,8 @@ ch_enlargebufs(el, addlen) el->el_line.buffer = newbuffer; el->el_line.cursor = newbuffer + (el->el_line.cursor - oldbuf); el->el_line.lastchar = newbuffer + (el->el_line.lastchar - oldbuf); - el->el_line.limit = &newbuffer[newsz - EL_LEAVE]; + /* don't set new size until all buffers are enlarged */ + el->el_line.limit = &newbuffer[sz - EL_LEAVE]; /* * Reallocate kill buffer. @@ -552,14 +604,22 @@ ch_enlargebufs(el, addlen) /* zero the newly added memory, leave old data in */ (void) memset(&newbuffer[sz], 0, newsz - sz); - - el->el_chared.c_undo.ptr = el->el_line.buffer + - (el->el_chared.c_undo.ptr - oldbuf); el->el_chared.c_undo.buf = newbuffer; + + newbuffer = el_realloc(el->el_chared.c_redo.buf, newsz); + if (!newbuffer) + return 0; + el->el_chared.c_redo.pos = newbuffer + + (el->el_chared.c_redo.pos - el->el_chared.c_redo.buf); + el->el_chared.c_redo.lim = newbuffer + + (el->el_chared.c_redo.lim - el->el_chared.c_redo.buf); + el->el_chared.c_redo.buf = newbuffer; if (!hist_enlargebuf(el, sz, newsz)) return 0; + /* Safe to set enlarged buffer size */ + el->el_line.limit = &el->el_line.buffer[newsz - EL_LEAVE]; return 1; } @@ -574,11 +634,16 @@ ch_end(EditLine *el) el->el_line.limit = NULL; el_free((ptr_t) el->el_chared.c_undo.buf); el->el_chared.c_undo.buf = NULL; + el_free((ptr_t) el->el_chared.c_redo.buf); + el->el_chared.c_redo.buf = NULL; + el->el_chared.c_redo.pos = NULL; + el->el_chared.c_redo.lim = NULL; + el->el_chared.c_redo.cmd = ED_UNASSIGNED; el_free((ptr_t) el->el_chared.c_kill.buf); el->el_chared.c_kill.buf = NULL; + ch_reset(el, 1); el_free((ptr_t) el->el_chared.c_macro.macro); el->el_chared.c_macro.macro = NULL; - ch_reset(el); } @@ -626,51 +691,64 @@ el_deletestr(EditLine *el, int n) * Get a string */ protected int -c_gets(EditLine *el, char *buf) +c_gets(EditLine *el, char *buf, const char *prompt) { char ch; - int len = 0; + int len; + char *cp = el->el_line.buffer; + + if (prompt) { + len = strlen(prompt); + memcpy(cp, prompt, len + 0u); + cp += len; + } + len = 0; + + for (;;) { + el->el_line.cursor = cp; + *cp = ' '; + el->el_line.lastchar = cp + 1; + re_refresh(el); + + if (el_getc(el, &ch) != 1) { + ed_end_of_file(el, 0); + len = -1; + break; + } - for (ch = 0; ch == 0;) { - if (el_getc(el, &ch) != 1) - return (ed_end_of_file(el, 0)); switch (ch) { + case 0010: /* Delete and backspace */ case 0177: - if (len > 1) { - *el->el_line.cursor-- = '\0'; - el->el_line.lastchar = el->el_line.cursor; - buf[len--] = '\0'; - } else { - el->el_line.buffer[0] = '\0'; - el->el_line.lastchar = el->el_line.buffer; - el->el_line.cursor = el->el_line.buffer; - return (CC_REFRESH); + if (len <= 0) { + len = -1; + break; } - re_refresh(el); - ch = 0; - break; + cp--; + continue; case 0033: /* ESC */ case '\r': /* Newline */ case '\n': + buf[len] = ch; break; default: - if (len >= EL_BUFSIZ) + if (len >= EL_BUFSIZ - 16) term_beep(el); else { buf[len++] = ch; - *el->el_line.cursor++ = ch; - el->el_line.lastchar = el->el_line.cursor; + *cp++ = ch; } - re_refresh(el); - ch = 0; - break; + continue; } + break; } - buf[len] = ch; - return (len); + + el->el_line.buffer[0] = '\0'; + el->el_line.lastchar = el->el_line.buffer; + el->el_line.cursor = el->el_line.buffer; + return len; } Modified: vendor/NetBSD/libedit/dist/chared.h ============================================================================== --- vendor/NetBSD/libedit/dist/chared.h Thu Mar 31 01:03:24 2011 (r220177) +++ vendor/NetBSD/libedit/dist/chared.h Thu Mar 31 01:13:05 2011 (r220178) @@ -1,4 +1,4 @@ -/* $NetBSD: chared.h,v 1.6 2001/01/10 07:45:41 jdolecek Exp $ */ +/* $NetBSD: chared.h,v 1.15 2005/08/01 23:00:15 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -15,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -66,28 +62,36 @@ typedef struct c_macro_t { int level; + int offset; char **macro; - char *nline; } c_macro_t; /* - * Undo information for both vi and emacs + * Undo information for vi - no undo in emacs (yet) */ typedef struct c_undo_t { - int action; - size_t isize; - size_t dsize; - char *ptr; - char *buf; + int len; /* length of saved line */ + int cursor; /* position of saved cursor */ + char *buf; /* full saved text */ } c_undo_t; +/* redo for vi */ +typedef struct c_redo_t { + char *buf; /* redo insert key sequence */ + char *pos; + char *lim; + el_action_t cmd; /* command to redo */ + char ch; /* char that invoked it */ + int count; + int action; /* from cv_action() */ +} c_redo_t; + /* * Current action information for vi */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 01:14:06 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73F591065677; Thu, 31 Mar 2011 01:14:06 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 60E0A8FC12; Thu, 31 Mar 2011 01:14:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V1E6Ta086681; Thu, 31 Mar 2011 01:14:06 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V1E6Zo086675; Thu, 31 Mar 2011 01:14:06 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201103310114.p2V1E6Zo086675@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 31 Mar 2011 01:14:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220179 - in vendor/NetBSD/libedit/2005-08-02: . TEST readline X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 01:14:06 -0000 Author: obrien Date: Thu Mar 31 01:14:06 2011 New Revision: 220179 URL: http://svn.freebsd.org/changeset/base/220179 Log: "Tag" the "2005/08/02 12:11:14 UTC" import. Added: vendor/NetBSD/libedit/2005-08-02/ - copied from r220176, vendor/NetBSD/libedit/dist/ vendor/NetBSD/libedit/2005-08-02/TEST/Makefile - copied unchanged from r220178, vendor/NetBSD/libedit/dist/TEST/Makefile vendor/NetBSD/libedit/2005-08-02/config.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/config.h vendor/NetBSD/libedit/2005-08-02/filecomplete.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/filecomplete.c vendor/NetBSD/libedit/2005-08-02/filecomplete.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/filecomplete.h Replaced: vendor/NetBSD/libedit/2005-08-02/Makefile - copied unchanged from r220178, vendor/NetBSD/libedit/dist/Makefile vendor/NetBSD/libedit/2005-08-02/TEST/test.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/TEST/test.c vendor/NetBSD/libedit/2005-08-02/chared.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/chared.c vendor/NetBSD/libedit/2005-08-02/chared.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/chared.h vendor/NetBSD/libedit/2005-08-02/common.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/common.c vendor/NetBSD/libedit/2005-08-02/editline.3 - copied unchanged from r220178, vendor/NetBSD/libedit/dist/editline.3 vendor/NetBSD/libedit/2005-08-02/editrc.5 - copied unchanged from r220178, vendor/NetBSD/libedit/dist/editrc.5 vendor/NetBSD/libedit/2005-08-02/el.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/el.c vendor/NetBSD/libedit/2005-08-02/el.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/el.h vendor/NetBSD/libedit/2005-08-02/emacs.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/emacs.c vendor/NetBSD/libedit/2005-08-02/hist.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/hist.c vendor/NetBSD/libedit/2005-08-02/hist.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/hist.h vendor/NetBSD/libedit/2005-08-02/histedit.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/histedit.h vendor/NetBSD/libedit/2005-08-02/history.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/history.c vendor/NetBSD/libedit/2005-08-02/key.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/key.c vendor/NetBSD/libedit/2005-08-02/key.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/key.h vendor/NetBSD/libedit/2005-08-02/makelist - copied unchanged from r220178, vendor/NetBSD/libedit/dist/makelist vendor/NetBSD/libedit/2005-08-02/map.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/map.c vendor/NetBSD/libedit/2005-08-02/map.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/map.h vendor/NetBSD/libedit/2005-08-02/parse.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/parse.c vendor/NetBSD/libedit/2005-08-02/parse.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/parse.h vendor/NetBSD/libedit/2005-08-02/prompt.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/prompt.c vendor/NetBSD/libedit/2005-08-02/prompt.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/prompt.h vendor/NetBSD/libedit/2005-08-02/read.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/read.c vendor/NetBSD/libedit/2005-08-02/read.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/read.h vendor/NetBSD/libedit/2005-08-02/readline.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/readline.c vendor/NetBSD/libedit/2005-08-02/readline/Makefile - copied unchanged from r220178, vendor/NetBSD/libedit/dist/readline/Makefile vendor/NetBSD/libedit/2005-08-02/readline/readline.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/readline/readline.h vendor/NetBSD/libedit/2005-08-02/refresh.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/refresh.c vendor/NetBSD/libedit/2005-08-02/refresh.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/refresh.h vendor/NetBSD/libedit/2005-08-02/search.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/search.c vendor/NetBSD/libedit/2005-08-02/search.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/search.h vendor/NetBSD/libedit/2005-08-02/shlib_version - copied unchanged from r220178, vendor/NetBSD/libedit/dist/shlib_version vendor/NetBSD/libedit/2005-08-02/sig.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/sig.c vendor/NetBSD/libedit/2005-08-02/sig.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/sig.h vendor/NetBSD/libedit/2005-08-02/sys.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/sys.h vendor/NetBSD/libedit/2005-08-02/term.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/term.c vendor/NetBSD/libedit/2005-08-02/term.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/term.h vendor/NetBSD/libedit/2005-08-02/tokenizer.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/tokenizer.c vendor/NetBSD/libedit/2005-08-02/tty.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/tty.c vendor/NetBSD/libedit/2005-08-02/tty.h - copied unchanged from r220178, vendor/NetBSD/libedit/dist/tty.h vendor/NetBSD/libedit/2005-08-02/vi.c - copied unchanged from r220178, vendor/NetBSD/libedit/dist/vi.c Deleted: vendor/NetBSD/libedit/2005-08-02/tokenizer.h Copied: vendor/NetBSD/libedit/2005-08-02/Makefile (from r220178, vendor/NetBSD/libedit/dist/Makefile) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/2005-08-02/Makefile Thu Mar 31 01:14:06 2011 (r220179, copy of r220178, vendor/NetBSD/libedit/dist/Makefile) @@ -0,0 +1,104 @@ +# $NetBSD: Makefile,v 1.34 2005/05/28 12:02:53 lukem Exp $ +# @(#)Makefile 8.1 (Berkeley) 6/4/93 + +USE_SHLIBDIR= yes + +WARNS= 3 +LIB= edit + +LIBDPLIBS= termcap ${.CURDIR}/../libterm + +OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c hist.c \ + key.c map.c \ + parse.c prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c + +MAN= editline.3 editrc.5 + +MLINKS= editline.3 el_init.3 editline.3 el_end.3 editline.3 el_reset.3 \ + editline.3 el_gets.3 editline.3 el_getc.3 editline.3 el_push.3 \ + editline.3 el_parse.3 editline.3 el_set.3 editline.3 el_get.3 \ + editline.3 el_source.3 editline.3 el_resize.3 editline.3 el_line.3 \ + editline.3 el_insertstr.3 editline.3 el_deletestr.3 \ + editline.3 history_init.3 editline.3 history_end.3 \ + editline.3 history.3 \ + editline.3 tok_init.3 editline.3 tok_end.3 editline.3 tok_reset.3 \ + editline.3 tok_line.3 editline.3 tok_str.3 + +# For speed and debugging +#SRCS= ${OSRCS} tokenizer.c history.c readline.c +# For protection +SRCS= editline.c tokenizer.c history.c readline.c + +LIBEDITDIR?=${.CURDIR} + +INCS= histedit.h +INCSDIR=/usr/include + +CLEANFILES+=editline.c +CLEANFILES+=common.h.tmp editline.c.tmp emacs.h.tmp fcns.c.tmp fcns.h.tmp +CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp +CLEANFILES+=test.o test +CPPFLAGS+=-I. -I${LIBEDITDIR} +CPPFLAGS+=-I. -I${.CURDIR} +CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH +CPPFLAGS+=#-DDEBUG_PASTE -DDEBUG_EDIT + +AHDR=vi.h emacs.h common.h +ASRC=${LIBEDITDIR}/vi.c ${LIBEDITDIR}/emacs.c ${LIBEDITDIR}/common.c + +DPSRCS+= ${AHDR} fcns.h help.h fcns.c help.c +CLEANFILES+= ${AHDR} fcns.h help.h fcns.c help.c + +SUBDIR= readline + +vi.h: vi.c makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/vi.c \ + > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +emacs.h: emacs.c makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/emacs.c \ + > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +common.h: common.c makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/common.c \ + > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +fcns.h: ${AHDR} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -fh ${AHDR} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +fcns.c: ${AHDR} fcns.h help.h makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -fc ${AHDR} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +help.c: ${ASRC} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -bc ${ASRC} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +help.h: ${ASRC} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -bh ${ASRC} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +editline.c: ${OSRCS} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -e ${OSRCS:T} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +test.o: ${LIBEDITDIR}/TEST/test.c + +test: libedit.a test.o + ${_MKTARGET_LINK} + ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermcap + +.include +.include Copied: vendor/NetBSD/libedit/2005-08-02/TEST/Makefile (from r220178, vendor/NetBSD/libedit/dist/TEST/Makefile) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/2005-08-02/TEST/Makefile Thu Mar 31 01:14:06 2011 (r220179, copy of r220178, vendor/NetBSD/libedit/dist/TEST/Makefile) @@ -0,0 +1,13 @@ +# $NetBSD: Makefile,v 1.2 2003/12/05 13:37:48 lukem Exp $ + +NOMAN=1 +PROG=test +CPPFLAGS=-I${.CURDIR}/.. +LDADD+=-ledit -ltermcap +DPADD+=${LIBEDIT} ${LIBTERMCAP} + +.ifdef DEBUG +CPPFLAGS+=-DDEBUG +.endif + +.include Copied: vendor/NetBSD/libedit/2005-08-02/TEST/test.c (from r220178, vendor/NetBSD/libedit/dist/TEST/test.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/2005-08-02/TEST/test.c Thu Mar 31 01:14:06 2011 (r220179, copy of r220178, vendor/NetBSD/libedit/dist/TEST/test.c) @@ -0,0 +1,301 @@ +/* $NetBSD: test.c,v 1.18 2005/06/01 11:37:52 lukem Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Christos Zoulas of Cornell University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "config.h" +#ifndef lint +__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\ + The Regents of the University of California. All rights reserved.\n"); +#endif /* not lint */ + +#if !defined(lint) && !defined(SCCSID) +#if 0 +static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: test.c,v 1.18 2005/06/01 11:37:52 lukem Exp $"); +#endif +#endif /* not lint && not SCCSID */ + +/* + * test.c: A little test program + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "histedit.h" + +static int continuation = 0; +volatile sig_atomic_t gotsig = 0; + +static unsigned char complete(EditLine *, int); + int main(int, char **); +static char *prompt(EditLine *); +static void sig(int); + +static char * +prompt(EditLine *el) +{ + static char a[] = "Edit$ "; + static char b[] = "Edit> "; + + return (continuation ? b : a); +} + +static void +sig(int i) +{ + gotsig = i; +} + +static unsigned char +complete(EditLine *el, int ch) +{ + DIR *dd = opendir("."); + struct dirent *dp; + const char* ptr; + const LineInfo *lf = el_line(el); + int len; + + /* + * Find the last word + */ + for (ptr = lf->cursor - 1; + !isspace((unsigned char)*ptr) && ptr > lf->buffer; ptr--) + continue; + len = lf->cursor - ++ptr; + + for (dp = readdir(dd); dp != NULL; dp = readdir(dd)) { + if (len > strlen(dp->d_name)) + continue; + if (strncmp(dp->d_name, ptr, len) == 0) { + closedir(dd); + if (el_insertstr(el, &dp->d_name[len]) == -1) + return (CC_ERROR); + else + return (CC_REFRESH); + } + } + + closedir(dd); + return (CC_ERROR); +} + +int +main(int argc, char *argv[]) +{ + EditLine *el = NULL; + int num; + const char *buf; + Tokenizer *tok; +#if 0 + int lastevent = 0; +#endif + int ncontinuation; + History *hist; + HistEvent ev; + + (void) signal(SIGINT, sig); + (void) signal(SIGQUIT, sig); + (void) signal(SIGHUP, sig); + (void) signal(SIGTERM, sig); + + hist = history_init(); /* Init the builtin history */ + /* Remember 100 events */ + history(hist, &ev, H_SETSIZE, 100); + + tok = tok_init(NULL); /* Initialize the tokenizer */ + + /* Initialize editline */ + el = el_init(*argv, stdin, stdout, stderr); + + el_set(el, EL_EDITOR, "vi"); /* Default editor is vi */ + el_set(el, EL_SIGNAL, 1); /* Handle signals gracefully */ + el_set(el, EL_PROMPT, prompt); /* Set the prompt function */ + + /* Tell editline to use this history interface */ + el_set(el, EL_HIST, history, hist); + + /* Add a user-defined function */ + el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete); + + /* Bind tab to it */ + el_set(el, EL_BIND, "^I", "ed-complete", NULL); + + /* + * Bind j, k in vi command mode to previous and next line, instead + * of previous and next history. + */ + el_set(el, EL_BIND, "-a", "k", "ed-prev-line", NULL); + el_set(el, EL_BIND, "-a", "j", "ed-next-line", NULL); + + /* + * Source the user's defaults file. + */ + el_source(el, NULL); + + while ((buf = el_gets(el, &num)) != NULL && num != 0) { + int ac, cc, co; +#ifdef DEBUG + int i; +#endif + const char **av; + const LineInfo *li; + li = el_line(el); +#ifdef DEBUG + (void) fprintf(stderr, "==> got %d %s", num, buf); + (void) fprintf(stderr, " > li `%.*s_%.*s'\n", + (li->cursor - li->buffer), li->buffer, + (li->lastchar - 1 - li->cursor), + (li->cursor >= li->lastchar) ? "" : li->cursor); + +#endif + if (gotsig) { + (void) fprintf(stderr, "Got signal %d.\n", gotsig); + gotsig = 0; + el_reset(el); + } + + if (!continuation && num == 1) + continue; + + ac = cc = co = 0; + ncontinuation = tok_line(tok, li, &ac, &av, &cc, &co); + if (ncontinuation < 0) { + (void) fprintf(stderr, "Internal error\n"); + continuation = 0; + continue; + } +#ifdef DEBUG + (void) fprintf(stderr, " > nc %d ac %d cc %d co %d\n", + ncontinuation, ac, cc, co); +#endif +#if 0 + if (continuation) { + /* + * Append to the right event in case the user + * moved around in history. + */ + if (history(hist, &ev, H_SET, lastevent) == -1) + err(1, "%d: %s", lastevent, ev.str); + history(hist, &ev, H_ADD , buf); + } else { + history(hist, &ev, H_ENTER, buf); + lastevent = ev.num; + } +#else + /* Simpler */ + history(hist, &ev, continuation ? H_APPEND : H_ENTER, buf); +#endif + + continuation = ncontinuation; + ncontinuation = 0; + if (continuation) + continue; +#ifdef DEBUG + for (i = 0; i < ac; i++) { + (void) fprintf(stderr, " > arg# %2d ", i); + if (i != cc) + (void) fprintf(stderr, "`%s'\n", av[i]); + else + (void) fprintf(stderr, "`%.*s_%s'\n", + co, av[i], av[i] + co); + } +#endif + + if (strcmp(av[0], "history") == 0) { + int rv; + + switch (ac) { + case 1: + for (rv = history(hist, &ev, H_LAST); rv != -1; + rv = history(hist, &ev, H_PREV)) + (void) fprintf(stdout, "%4d %s", + ev.num, ev.str); + break; + + case 2: + if (strcmp(av[1], "clear") == 0) + history(hist, &ev, H_CLEAR); + else + goto badhist; + break; + + case 3: + if (strcmp(av[1], "load") == 0) + history(hist, &ev, H_LOAD, av[2]); + else if (strcmp(av[1], "save") == 0) + history(hist, &ev, H_SAVE, av[2]); + break; + + badhist: + default: + (void) fprintf(stderr, + "Bad history arguments\n"); + break; + } + } else if (el_parse(el, ac, av) == -1) { + switch (fork()) { + case 0: + execvp(av[0], (char *const *)__UNCONST(av)); + perror(av[0]); + _exit(1); + /*NOTREACHED*/ + break; + + case -1: + perror("fork"); + break; + + default: + if (wait(&num) == -1) + perror("wait"); + (void) fprintf(stderr, "Exit %x\n", num); + break; + } + } + + tok_reset(tok); + } + + el_end(el); + tok_end(tok); + history_end(hist); + + return (0); +} Copied: vendor/NetBSD/libedit/2005-08-02/chared.c (from r220178, vendor/NetBSD/libedit/dist/chared.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/2005-08-02/chared.c Thu Mar 31 01:14:06 2011 (r220179, copy of r220178, vendor/NetBSD/libedit/dist/chared.c) @@ -0,0 +1,775 @@ +/* $NetBSD: chared.c,v 1.24 2005/08/01 23:00:15 christos Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Christos Zoulas of Cornell University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "config.h" +#if !defined(lint) && !defined(SCCSID) +#if 0 +static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: chared.c,v 1.24 2005/08/01 23:00:15 christos Exp $"); +#endif +#endif /* not lint && not SCCSID */ + +/* + * chared.c: Character editor utilities + */ +#include +#include "el.h" + +private void ch__clearmacro __P((EditLine *)); + +/* value to leave unused in line buffer */ +#define EL_LEAVE 2 + +/* cv_undo(): + * Handle state for the vi undo command + */ +protected void +cv_undo(EditLine *el) +{ + c_undo_t *vu = &el->el_chared.c_undo; + c_redo_t *r = &el->el_chared.c_redo; + unsigned int size; + + /* Save entire line for undo */ + size = el->el_line.lastchar - el->el_line.buffer; + vu->len = size; + vu->cursor = el->el_line.cursor - el->el_line.buffer; + memcpy(vu->buf, el->el_line.buffer, size); + + /* save command info for redo */ + r->count = el->el_state.doingarg ? el->el_state.argument : 0; + r->action = el->el_chared.c_vcmd.action; + r->pos = r->buf; + r->cmd = el->el_state.thiscmd; + r->ch = el->el_state.thisch; +} + +/* cv_yank(): + * Save yank/delete data for paste + */ +protected void +cv_yank(EditLine *el, const char *ptr, int size) +{ + c_kill_t *k = &el->el_chared.c_kill; + + memcpy(k->buf, ptr, size +0u); + k->last = k->buf + size; +} + + +/* c_insert(): + * Insert num characters + */ +protected void +c_insert(EditLine *el, int num) +{ + char *cp; + + if (el->el_line.lastchar + num >= el->el_line.limit) { + if (!ch_enlargebufs(el, num +0u)) + return; /* can't go past end of buffer */ + } + + if (el->el_line.cursor < el->el_line.lastchar) { + /* if I must move chars */ + for (cp = el->el_line.lastchar; cp >= el->el_line.cursor; cp--) + cp[num] = *cp; + } + el->el_line.lastchar += num; +} + + +/* c_delafter(): + * Delete num characters after the cursor + */ +protected void +c_delafter(EditLine *el, int num) +{ + + if (el->el_line.cursor + num > el->el_line.lastchar) + num = el->el_line.lastchar - el->el_line.cursor; + + if (el->el_map.current != el->el_map.emacs) { + cv_undo(el); + cv_yank(el, el->el_line.cursor, num); + } + + if (num > 0) { + char *cp; + + for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) + *cp = cp[num]; + + el->el_line.lastchar -= num; + } +} + + +/* c_delafter1(): + * Delete the character after the cursor, do not yank + */ +protected void +c_delafter1(EditLine *el) +{ + char *cp; + + for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) + *cp = cp[1]; + + el->el_line.lastchar--; +} + + +/* c_delbefore(): + * Delete num characters before the cursor + */ +protected void +c_delbefore(EditLine *el, int num) +{ + + if (el->el_line.cursor - num < el->el_line.buffer) + num = el->el_line.cursor - el->el_line.buffer; + + if (el->el_map.current != el->el_map.emacs) { + cv_undo(el); + cv_yank(el, el->el_line.cursor - num, num); + } + + if (num > 0) { + char *cp; + + for (cp = el->el_line.cursor - num; + cp <= el->el_line.lastchar; + cp++) + *cp = cp[num]; + + el->el_line.lastchar -= num; + } +} + + +/* c_delbefore1(): + * Delete the character before the cursor, do not yank + */ +protected void +c_delbefore1(EditLine *el) +{ + char *cp; + + for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++) + *cp = cp[1]; + + el->el_line.lastchar--; +} + + +/* ce__isword(): + * Return if p is part of a word according to emacs + */ +protected int +ce__isword(int p) +{ + return (isalnum(p) || strchr("*?_-.[]~=", p) != NULL); +} + + +/* cv__isword(): + * Return if p is part of a word according to vi + */ +protected int +cv__isword(int p) +{ + if (isalnum(p) || p == '_') + return 1; + if (isgraph(p)) + return 2; + return 0; +} + + +/* cv__isWord(): + * Return if p is part of a big word according to vi + */ +protected int +cv__isWord(int p) +{ + return (!isspace(p)); +} + + +/* c__prev_word(): + * Find the previous word + */ +protected char * +c__prev_word(char *p, char *low, int n, int (*wtest)(int)) +{ + p--; + + while (n--) { + while ((p >= low) && !(*wtest)((unsigned char) *p)) + p--; + while ((p >= low) && (*wtest)((unsigned char) *p)) + p--; + } + + /* cp now points to one character before the word */ + p++; + if (p < low) + p = low; + /* cp now points where we want it */ + return (p); +} + + +/* c__next_word(): + * Find the next word + */ +protected char * +c__next_word(char *p, char *high, int n, int (*wtest)(int)) +{ + while (n--) { + while ((p < high) && !(*wtest)((unsigned char) *p)) + p++; + while ((p < high) && (*wtest)((unsigned char) *p)) + p++; + } + if (p > high) + p = high; + /* p now points where we want it */ + return (p); +} + +/* cv_next_word(): + * Find the next word vi style + */ +protected char * +cv_next_word(EditLine *el, char *p, char *high, int n, int (*wtest)(int)) +{ + int test; + + while (n--) { + test = (*wtest)((unsigned char) *p); + while ((p < high) && (*wtest)((unsigned char) *p) == test) + p++; + /* + * vi historically deletes with cw only the word preserving the + * trailing whitespace! This is not what 'w' does.. + */ + if (n || el->el_chared.c_vcmd.action != (DELETE|INSERT)) + while ((p < high) && isspace((unsigned char) *p)) + p++; + } + + /* p now points where we want it */ + if (p > high) + return (high); + else + return (p); +} + + +/* cv_prev_word(): + * Find the previous word vi style + */ +protected char * +cv_prev_word(char *p, char *low, int n, int (*wtest)(int)) +{ + int test; + + p--; + while (n--) { + while ((p > low) && isspace((unsigned char) *p)) + p--; + test = (*wtest)((unsigned char) *p); + while ((p >= low) && (*wtest)((unsigned char) *p) == test) + p--; + } + p++; + + /* p now points where we want it */ + if (p < low) + return (low); + else + return (p); +} + + +#ifdef notdef +/* c__number(): + * Ignore character p points to, return number appearing after that. + * A '$' by itself means a big number; "$-" is for negative; '^' means 1. + * Return p pointing to last char used. + */ +protected char * +c__number( + char *p, /* character position */ + int *num, /* Return value */ + int dval) /* dval is the number to subtract from like $-3 */ +{ + int i; + int sign = 1; + + if (*++p == '^') { + *num = 1; + return (p); + } + if (*p == '$') { + if (*++p != '-') { + *num = 0x7fffffff; /* Handle $ */ + return (--p); + } + sign = -1; /* Handle $- */ + ++p; + } + for (i = 0; isdigit((unsigned char) *p); i = 10 * i + *p++ - '0') + continue; + *num = (sign < 0 ? dval - i : i); + return (--p); +} +#endif + +/* cv_delfini(): + * Finish vi delete action + */ +protected void +cv_delfini(EditLine *el) +{ + int size; + int action = el->el_chared.c_vcmd.action; + + if (action & INSERT) + el->el_map.current = el->el_map.key; + + if (el->el_chared.c_vcmd.pos == 0) + /* sanity */ + return; + + size = el->el_line.cursor - el->el_chared.c_vcmd.pos; + if (size == 0) + size = 1; + el->el_line.cursor = el->el_chared.c_vcmd.pos; + if (action & YANK) { + if (size > 0) + cv_yank(el, el->el_line.cursor, size); + else + cv_yank(el, el->el_line.cursor + size, -size); + } else { + if (size > 0) { + c_delafter(el, size); + re_refresh_cursor(el); + } else { + c_delbefore(el, -size); + el->el_line.cursor += size; + } + } + el->el_chared.c_vcmd.action = NOP; +} + + +#ifdef notdef +/* ce__endword(): + * Go to the end of this word according to emacs + */ +protected char * +ce__endword(char *p, char *high, int n) +{ + p++; + + while (n--) { + while ((p < high) && isspace((unsigned char) *p)) + p++; + while ((p < high) && !isspace((unsigned char) *p)) + p++; + } + + p--; + return (p); +} +#endif + + +/* cv__endword(): + * Go to the end of this word according to vi + */ +protected char * +cv__endword(char *p, char *high, int n, int (*wtest)(int)) +{ + int test; + + p++; + + while (n--) { + while ((p < high) && isspace((unsigned char) *p)) + p++; + + test = (*wtest)((unsigned char) *p); + while ((p < high) && (*wtest)((unsigned char) *p) == test) + p++; + } + p--; + return (p); +} + +/* ch_init(): + * Initialize the character editor + */ +protected int +ch_init(EditLine *el) +{ + c_macro_t *ma = &el->el_chared.c_macro; + + el->el_line.buffer = (char *) el_malloc(EL_BUFSIZ); + if (el->el_line.buffer == NULL) + return (-1); + + (void) memset(el->el_line.buffer, 0, EL_BUFSIZ); + el->el_line.cursor = el->el_line.buffer; + el->el_line.lastchar = el->el_line.buffer; + el->el_line.limit = &el->el_line.buffer[EL_BUFSIZ - EL_LEAVE]; + + el->el_chared.c_undo.buf = (char *) el_malloc(EL_BUFSIZ); + if (el->el_chared.c_undo.buf == NULL) + return (-1); + (void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ); + el->el_chared.c_undo.len = -1; + el->el_chared.c_undo.cursor = 0; + el->el_chared.c_redo.buf = (char *) el_malloc(EL_BUFSIZ); + if (el->el_chared.c_redo.buf == NULL) + return (-1); + el->el_chared.c_redo.pos = el->el_chared.c_redo.buf; + el->el_chared.c_redo.lim = el->el_chared.c_redo.buf + EL_BUFSIZ; + el->el_chared.c_redo.cmd = ED_UNASSIGNED; + + el->el_chared.c_vcmd.action = NOP; + el->el_chared.c_vcmd.pos = el->el_line.buffer; + + el->el_chared.c_kill.buf = (char *) el_malloc(EL_BUFSIZ); + if (el->el_chared.c_kill.buf == NULL) + return (-1); + (void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ); + el->el_chared.c_kill.mark = el->el_line.buffer; + el->el_chared.c_kill.last = el->el_chared.c_kill.buf; + + el->el_map.current = el->el_map.key; + + el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */ + el->el_state.doingarg = 0; + el->el_state.metanext = 0; + el->el_state.argument = 1; + el->el_state.lastcmd = ED_UNASSIGNED; + + ma->level = -1; + ma->offset = 0; + ma->macro = (char **) el_malloc(EL_MAXMACRO * sizeof(char *)); + if (ma->macro == NULL) + return (-1); + return (0); +} + +/* ch_reset(): + * Reset the character editor + */ +protected void +ch_reset(EditLine *el, int mclear) +{ + el->el_line.cursor = el->el_line.buffer; + el->el_line.lastchar = el->el_line.buffer; + + el->el_chared.c_undo.len = -1; + el->el_chared.c_undo.cursor = 0; + + el->el_chared.c_vcmd.action = NOP; + el->el_chared.c_vcmd.pos = el->el_line.buffer; + + el->el_chared.c_kill.mark = el->el_line.buffer; + + el->el_map.current = el->el_map.key; + + el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */ + el->el_state.doingarg = 0; + el->el_state.metanext = 0; + el->el_state.argument = 1; + el->el_state.lastcmd = ED_UNASSIGNED; + + if (mclear) + ch__clearmacro(el); +} + +private void +ch__clearmacro(el) + EditLine *el; +{ + c_macro_t *ma = &el->el_chared.c_macro; + while (ma->level >= 0) + el_free((ptr_t)ma->macro[ma->level--]); +} + +/* ch_enlargebufs(): + * Enlarge line buffer to be able to hold twice as much characters. + * Returns 1 if successful, 0 if not. + */ +protected int +ch_enlargebufs(el, addlen) + EditLine *el; + size_t addlen; +{ + size_t sz, newsz; + char *newbuffer, *oldbuf, *oldkbuf; + + sz = el->el_line.limit - el->el_line.buffer + EL_LEAVE; + newsz = sz * 2; + /* + * If newly required length is longer than current buffer, we need + * to make the buffer big enough to hold both old and new stuff. + */ + if (addlen > sz) { + while(newsz - sz < addlen) + newsz *= 2; + } + + /* + * Reallocate line buffer. + */ + newbuffer = el_realloc(el->el_line.buffer, newsz); + if (!newbuffer) + return 0; + + /* zero the newly added memory, leave old data in */ + (void) memset(&newbuffer[sz], 0, newsz - sz); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 01:26:18 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A7C20106564A; Thu, 31 Mar 2011 01:26:18 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id 46EDF8FC16; Thu, 31 Mar 2011 01:26:18 +0000 (UTC) Received: by iyj12 with SMTP id 12so2378986iyj.13 for ; Wed, 30 Mar 2011 18:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=jy/2Ls3Vr08SXeNeGkjAItzFMDxP2/NcahZQXYrsNWY=; b=uuIdHGe5hei6uRRk1M4iVSC1C74l7odVheHX8fItTb5+nilT5rNQqJ6gJr71AzPzDj IwZ0lyf9Zepl3p77/zSDNAE6EcFBC2JTyzKOCSOCkUXRDNEHgnn5zNvdLkyv+tCTurls 9YtPIUH9cWx8KQBRqskhzoRDeFXHYqZ8Kb5hE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=HO3A5llL/tRvoWDs/tpwEmHsLIutmOQa5jUku6cfPK7niUKeIrO0Vf70y/VIh4l8X8 ApiTTUsH07BULieChVzSztUWYyWR5+nPvosMCpOLTlJ2gY3o6TDvtmpcmvXBJ+B+4Hcd fypMKOuqX3TWE9UexWFdw43PUFxF/iwCXwyMk= MIME-Version: 1.0 Received: by 10.43.45.7 with SMTP id ui7mr1946638icb.262.1301534775964; Wed, 30 Mar 2011 18:26:15 -0700 (PDT) Received: by 10.231.168.74 with HTTP; Wed, 30 Mar 2011 18:26:15 -0700 (PDT) In-Reply-To: <201103301737.p2UHb4j7070331@svn.freebsd.org> References: <201103301737.p2UHb4j7070331@svn.freebsd.org> Date: Wed, 30 Mar 2011 18:26:15 -0700 Message-ID: From: Garrett Cooper To: Josh Paetzel Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220162 - head/usr.sbin/pc-sysinstall/backend-partmanager X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 01:26:18 -0000 On Wed, Mar 30, 2011 at 10:37 AM, Josh Paetzel wrote= : > Author: jpaetzel > Date: Wed Mar 30 17:37:04 2011 > New Revision: 220162 > URL: http://svn.freebsd.org/changeset/base/220162 > > Log: > =A0Check in two missing files missed in cleanup. > =A0Change expr to $(()) > =A0Switch test from "$?" =3D "0" to $? -eq 0 > > =A0Approved by: =A0kib (mentor) > > Modified: > =A0head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh > =A0head/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh > > Modified: head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh =A0 = =A0 =A0Wed Mar 30 17:33:52 2011 =A0 =A0 =A0 =A0(r220161) > +++ head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh =A0 = =A0 =A0Wed Mar 30 17:37:04 2011 =A0 =A0 =A0 =A0(r220162) > @@ -85,7 +85,7 @@ fi > > =A0# If this is an empty disk, see if we need to create a new scheme for = it > =A0gpart show ${DISK} >/dev/null 2>/dev/null > -if [ "$?" !=3D "0" -a "${SLICENUM}" =3D "1" ] ; then > +if [ $? -eq 0 -a "${SLICENUM}" =3D "1" ] ; then > =A0gpart create -s ${TYPE} ${DISK} > =A0fi > > > Modified: head/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh =A0 = =A0 =A0Wed Mar 30 17:33:52 2011 =A0 =A0 =A0 =A0(r220161) > +++ head/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh =A0 = =A0 =A0Wed Mar 30 17:37:04 2011 =A0 =A0 =A0 =A0(r220162) > @@ -57,10 +57,10 @@ PARTINDEX=3D"" > =A0while > =A0z=3D1 > =A0do > - =A0CHARS=3D`expr $CHARS - 1` > + =A0CHARS=3D$((CHARS-1)) This can also be done with the null operator: : $(( CHARS -=3D 1 )) it's the way that the LTP project (which I'm still a member of) does things in order to be 'portable' (non-portable being bash/korn shell isms for what little it's worth :)..). > =A0 LAST_CHAR=3D`echo "${PARTITION}" | cut -c $CHARS` > - =A0echo "${LAST_CHAR}" | grep "^[0-9]$" >/dev/null 2>/dev/null > - =A0if [ "$?" =3D "0" ] ; then > + =A0echo "${LAST_CHAR}" | grep -q "^[0-9]$" 2>/dev/null > + =A0if [ $? -eq 0 ] ; then > =A0 =A0 PARTINDEX=3D"${LAST_CHAR}${PARTINDEX}" > =A0 else > =A0 =A0 break Thanks! -Garrett From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 02:36:22 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F1FBF106564A; Thu, 31 Mar 2011 02:36:22 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C74AB8FC21; Thu, 31 Mar 2011 02:36:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V2aMLX088679; Thu, 31 Mar 2011 02:36:22 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V2aMwD088676; Thu, 31 Mar 2011 02:36:22 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103310236.p2V2aMwD088676@svn.freebsd.org> From: Adrian Chadd Date: Thu, 31 Mar 2011 02:36:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220180 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 02:36:23 -0000 Author: adrian Date: Thu Mar 31 02:36:22 2011 New Revision: 220180 URL: http://svn.freebsd.org/changeset/base/220180 Log: Implement AR724x USB initialisation code. This (again) still requires an offset for the AR913x/AR724x before USB will function. Submitted by: Luiz Otavio O Souzau Modified: head/sys/mips/atheros/ar724x_chip.c head/sys/mips/atheros/ar724xreg.h Modified: head/sys/mips/atheros/ar724x_chip.c ============================================================================== --- head/sys/mips/atheros/ar724x_chip.c Thu Mar 31 01:14:06 2011 (r220179) +++ head/sys/mips/atheros/ar724x_chip.c Thu Mar 31 02:36:22 2011 (r220180) @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include static void @@ -151,6 +152,50 @@ ar724x_chip_get_eth_pll(unsigned int mac return 0; } +static void +ar724x_chip_init_usb_peripheral(void) +{ + + switch (ar71xx_soc) { + case AR71XX_SOC_AR7240: + + ar71xx_device_stop(AR724X_RESET_MODULE_USB_OHCI_DLL | + AR724X_RESET_USB_HOST); + DELAY(1000); + + ar71xx_device_start(AR724X_RESET_MODULE_USB_OHCI_DLL | + AR724X_RESET_USB_HOST); + DELAY(1000); + + /* + * WAR for HW bug. Here it adjusts the duration + * between two SOFS. + */ + ATH_WRITE_REG(AR71XX_USB_CTRL_FLADJ, + (3 << USB_CTRL_FLADJ_A0_SHIFT)); + + break; + + case AR71XX_SOC_AR7241: + case AR71XX_SOC_AR7242: + + ar71xx_device_start(AR724X_RESET_MODULE_USB_OHCI_DLL); + DELAY(100); + + ar71xx_device_start(AR724X_RESET_USB_HOST); + DELAY(100); + + ar71xx_device_start(AR724X_RESET_USB_PHY); + DELAY(100); + + break; + + default: + /* fallthrough */ + break; + } +} + struct ar71xx_cpu_def ar724x_chip_def = { &ar724x_chip_detect_mem_size, &ar724x_chip_detect_sys_frequency, @@ -163,5 +208,5 @@ struct ar71xx_cpu_def ar724x_chip_def = &ar724x_chip_ddr_flush_ge1, &ar724x_chip_get_eth_pll, NULL, /* ar71xx_chip_irq_flush_ip2 */ - NULL /* ar71xx_chip_init_usb_peripheral */ + &ar724x_chip_init_usb_peripheral }; Modified: head/sys/mips/atheros/ar724xreg.h ============================================================================== --- head/sys/mips/atheros/ar724xreg.h Thu Mar 31 01:14:06 2011 (r220179) +++ head/sys/mips/atheros/ar724xreg.h Thu Mar 31 02:36:22 2011 (r220180) @@ -51,6 +51,8 @@ #define AR724X_DDR_REG_FLUSH_GE1 (AR71XX_DDR_CONFIG + 0x80) #define AR724X_RESET_REG_RESET_MODULE AR71XX_RST_BLOCK_BASE + 0x1c +#define AR724X_RESET_USB_HOST (1 << 5) +#define AR724X_RESET_USB_PHY (1 << 4) #define AR724X_RESET_MODULE_USB_OHCI_DLL (1 << 3) /* XXX so USB requires different init code? -adrian */ From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 04:49:08 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 697E4106566B; Thu, 31 Mar 2011 04:49:08 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 582AC8FC13; Thu, 31 Mar 2011 04:49:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V4n8nY091828; Thu, 31 Mar 2011 04:49:08 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V4n8O4091826; Thu, 31 Mar 2011 04:49:08 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201103310449.p2V4n8O4091826@svn.freebsd.org> From: Andriy Gapon Date: Thu, 31 Mar 2011 04:49:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-svnadmin@freebsd.org X-SVN-Group: svnadmin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220181 - svnadmin/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 04:49:08 -0000 Author: avg Date: Thu Mar 31 04:49:07 2011 New Revision: 220181 URL: http://svn.freebsd.org/changeset/base/220181 Log: New src committer: Artem Belevich Artem has been helping in a number of areas including ZFS and DTrace, and he is going to expand his coverage for sure. Approved by: core Modified: svnadmin/conf/mentors Modified: svnadmin/conf/mentors ============================================================================== --- svnadmin/conf/mentors Thu Mar 31 02:36:22 2011 (r220180) +++ svnadmin/conf/mentors Thu Mar 31 04:49:07 2011 (r220181) @@ -13,6 +13,7 @@ anchie bz andreast nwhitehorn andrew imp +art avg Co-mentor: marcel eri mlaier Co-mentor: thompsa gabor delphij hselasky thompsa From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 06:11:50 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 546EA106566C; Thu, 31 Mar 2011 06:11:50 +0000 (UTC) (envelope-from martymac@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 290DA8FC08; Thu, 31 Mar 2011 06:11:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V6Bob0093483; Thu, 31 Mar 2011 06:11:50 GMT (envelope-from martymac@svn.freebsd.org) Received: (from martymac@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V6Bowt093481; Thu, 31 Mar 2011 06:11:50 GMT (envelope-from martymac@svn.freebsd.org) Message-Id: <201103310611.p2V6Bowt093481@svn.freebsd.org> From: Ganael LAPLANCHE Date: Thu, 31 Mar 2011 06:11:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220182 - head/share/misc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 06:11:50 -0000 Author: martymac (ports committer) Date: Thu Mar 31 06:11:49 2011 New Revision: 220182 URL: http://svn.freebsd.org/changeset/base/220182 Log: Add relation to my mentor (ehaupt) Modified: head/share/misc/committers-ports.dot Modified: head/share/misc/committers-ports.dot ============================================================================== --- head/share/misc/committers-ports.dot Thu Mar 31 04:49:07 2011 (r220181) +++ head/share/misc/committers-ports.dot Thu Mar 31 06:11:49 2011 (r220182) @@ -231,6 +231,7 @@ edwin -> linimon edwin -> lx ehaupt -> db +ehaupt -> martymac eik -> sem eik -> trhodes From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 06:29:16 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 290B3106566C; Thu, 31 Mar 2011 06:29:16 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 15ADA8FC0C; Thu, 31 Mar 2011 06:29:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V6TG5T093914; Thu, 31 Mar 2011 06:29:16 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V6TG6n093911; Thu, 31 Mar 2011 06:29:16 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <201103310629.p2V6TG6n093911@svn.freebsd.org> From: Edwin Groothuis Date: Thu, 31 Mar 2011 06:29:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220183 - stable/8/usr.sbin/tzsetup X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 06:29:16 -0000 Author: edwin Date: Thu Mar 31 06:29:15 2011 New Revision: 220183 URL: http://svn.freebsd.org/changeset/base/220183 Log: MFC of 198254, 198255, 198350, 198267, 209190, 208831, 208830, 210243 198254: When tzsetup is run as non-root and the "CMOS clock question on UTC" is answered as No, it would abort without properly ending the dialog session. 198255: Make the usage of the default zoneinfo file to install clearer. 198350: - Add support for chrooted installs. - Add examples to the man-page. 198267: Instead of having to know which timezone was picked last time, you now can run "tzsetup -r" which will reinstall the last choice. This data is recorded in /var/db/zoneinfo. 209190: Use literal format strings. Found by clang. 208831: Add comment that this value is unused. It is obvious that it isn't used, but both clang and Coverity talk about it. 208830: When there is a problem with writing, also bail out. Found with the clang checker. 210243: Fix support for chrooted installs. Modified: stable/8/usr.sbin/tzsetup/tzsetup.8 stable/8/usr.sbin/tzsetup/tzsetup.c Directory Properties: stable/8/usr.sbin/tzsetup/ (props changed) Modified: stable/8/usr.sbin/tzsetup/tzsetup.8 ============================================================================== --- stable/8/usr.sbin/tzsetup/tzsetup.8 Thu Mar 31 06:11:49 2011 (r220182) +++ stable/8/usr.sbin/tzsetup/tzsetup.8 Thu Mar 31 06:29:15 2011 (r220183) @@ -31,8 +31,9 @@ .Nd set local timezone .Sh SYNOPSIS .Nm -.Op Fl ns -.Op Ar default +.Op Fl nrs +.Op Fl C Ar chroot directory +.Op Ar zoneinfo file | zoneinfo name .Sh DESCRIPTION The .Nm @@ -49,17 +50,26 @@ the hardware clock does not keep .Pp The following option is available: .Bl -tag -offset indent -width Fl +.It Fl C Ar chroot directory +Open all files and directories relative to +.Ar chroot directory . .It Fl n Do not create or copy files. +.It Fl r +Reinstall the zoneinfo file installed last time. The name is obtained from +.Pa /var/db/zoneinfo . .It Fl s Skip the initial question about adjusting the clock if not set to .Tn UTC . .El .Pp -It is possible to short-circuit the menu system by specifying a -.Ar default -on the command line; this is intended mainly for pre-configured -installation scripts. +It is possible to short-circuit the menu system by specifying the +location of a +.Ar zoneinfo file +or the name of the +.Ar zoneinfo name +on the command line; this is intended mainly for pre-configured installation +scripts or people who know which zoneinfo they want to install. .Sh TIMEZONE DATABASE The contents of the timezone database are indexed by .Pa /usr/share/zoneinfo/zone.tab . @@ -93,19 +103,36 @@ historically minded. .Sh FILES .Bl -tag -width /usr/share/zoneinfo/zone.tab -compact .It Pa /etc/localtime -current time zone file +current time zone file. .It Pa /etc/wall_cmos_clock see .Xr adjkerntz 8 . .It Pa /usr/share/misc/iso3166 mapping of .Tn ISO -3166 territory codes to names +3166 territory codes to names. .It Pa /usr/share/zoneinfo -directory for zoneinfo files +directory for zoneinfo files. .It Pa /usr/share/zoneinfo/zone.tab -mapping of timezone file to country and location +mapping of timezone file to country and location. +.It Pa /var/db/zoneinfo +saved name of the timezone file installed last. .El +.Sh EXAMPLES +Normal usage, to select the right zoneinfo file via the dialog-based +user interface: +.Dl # tzsetup +Install the file +.Pa /usr/share/zoneinfo/Australia/Sydney : +.Dl # tzsetup /usr/share/zoneinfo/Australia/Sydney +Install the zoneinfo file for Australia/Sydney, assumed to be located +in +.Pa /usr/share/zoneinfo : +.Dl # tzsetup Australia/Sydney +After a reinstall of the zoneinfo files, you can reinstall the +latest installed zoneinfo file: (as specified in +.Pa /var/db/zoneinfo ) +.Dl # tzsetup -r .Sh SEE ALSO .Xr date 1 , .Xr adjtime 2 , Modified: stable/8/usr.sbin/tzsetup/tzsetup.c ============================================================================== --- stable/8/usr.sbin/tzsetup/tzsetup.c Thu Mar 31 06:11:49 2011 (r220182) +++ stable/8/usr.sbin/tzsetup/tzsetup.c Thu Mar 31 06:29:15 2011 (r220183) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -52,9 +53,17 @@ __FBSDID("$FreeBSD$"); #define _PATH_ISO3166 "/usr/share/misc/iso3166" #define _PATH_ZONEINFO "/usr/share/zoneinfo" #define _PATH_LOCALTIME "/etc/localtime" +#define _PATH_DB "/var/db/zoneinfo" #define _PATH_WALL_CMOS_CLOCK "/etc/wall_cmos_clock" +static char path_zonetab[MAXPATHLEN], path_iso3166[MAXPATHLEN], + path_zoneinfo[MAXPATHLEN], path_localtime[MAXPATHLEN], + path_db[MAXPATHLEN], path_wall_cmos_clock[MAXPATHLEN]; + static int reallydoit = 1; +static int reinstall = 0; +static int usedialog = 1; +static char *chrootenv = NULL; static void usage(void); static int continent_country_menu(dialogMenuItem *); @@ -193,15 +202,15 @@ read_iso3166_table(void) char *s, *t, *name; int lineno; - fp = fopen(_PATH_ISO3166, "r"); + fp = fopen(path_iso3166, "r"); if (!fp) - err(1, _PATH_ISO3166); + err(1, "%s", path_iso3166); lineno = 0; while ((s = fgetln(fp, &len)) != 0) { lineno++; if (s[len - 1] != '\n') - errx(1, _PATH_ISO3166 ":%d: invalid format", lineno); + errx(1, "%s:%d: invalid format", path_iso3166, lineno); s[len - 1] = '\0'; if (s[0] == '#' || strspn(s, " \t") == len - 1) continue; @@ -209,26 +218,25 @@ read_iso3166_table(void) /* Isolate the two-letter code. */ t = strsep(&s, "\t"); if (t == 0 || strlen(t) != 2) - errx(1, _PATH_ISO3166 ":%d: invalid format", lineno); + errx(1, "%s:%d: invalid format", path_iso3166, lineno); if (t[0] < 'A' || t[0] > 'Z' || t[1] < 'A' || t[1] > 'Z') - errx(1, _PATH_ISO3166 ":%d: invalid code `%s'", + errx(1, "%s:%d: invalid code `%s'", path_iso3166, lineno, t); /* Now skip past the three-letter and numeric codes. */ name = strsep(&s, "\t"); /* 3-let */ if (name == 0 || strlen(name) != 3) - errx(1, _PATH_ISO3166 ":%d: invalid format", lineno); + errx(1, "%s:%d: invalid format", path_iso3166, lineno); name = strsep(&s, "\t"); /* numeric */ if (name == 0 || strlen(name) != 3) - errx(1, _PATH_ISO3166 ":%d: invalid format", lineno); + errx(1, "%s:%d: invalid format", path_iso3166, lineno); name = s; cp = &countries[CODE2INT(t)]; if (cp->name) - errx(1, _PATH_ISO3166 - ":%d: country code `%s' multiply defined: %s", - lineno, t, cp->name); + errx(1, "%s:%d: country code `%s' multiply defined: %s", + path_iso3166, lineno, t, cp->name); cp->name = strdup(name); if (cp->name == NULL) errx(1, "malloc failed"); @@ -248,18 +256,18 @@ add_zone_to_country(int lineno, const ch struct country *cp; if (tlc[0] < 'A' || tlc[0] > 'Z' || tlc[1] < 'A' || tlc[1] > 'Z') - errx(1, _PATH_ZONETAB ":%d: country code `%s' invalid", + errx(1, "%s:%d: country code `%s' invalid", path_zonetab, lineno, tlc); cp = &countries[CODE2INT(tlc)]; if (cp->name == 0) - errx(1, _PATH_ZONETAB ":%d: country code `%s' unknown", + errx(1, "%s:%d: country code `%s' unknown", path_zonetab, lineno, tlc); if (descr) { if (cp->nzones < 0) - errx(1, _PATH_ZONETAB - ":%d: conflicting zone definition", lineno); + errx(1, "%s:%d: conflicting zone definition", + path_zonetab, lineno); zp = malloc(sizeof(*zp)); if (zp == 0) @@ -279,11 +287,11 @@ add_zone_to_country(int lineno, const ch cp->nzones++; } else { if (cp->nzones > 0) - errx(1, _PATH_ZONETAB - ":%d: zone must have description", lineno); + errx(1, "%s:%d: zone must have description", + path_zonetab, lineno); if (cp->nzones < 0) - errx(1, _PATH_ZONETAB - ":%d: zone multiply defined", lineno); + errx(1, "%s:%d: zone multiply defined", + path_zonetab, lineno); cp->nzones = -1; cp->filename = strdup(file); if (cp->filename == NULL) @@ -333,34 +341,34 @@ read_zones(void) char *line, *tlc, *coord, *file, *descr, *p; int lineno; - fp = fopen(_PATH_ZONETAB, "r"); + fp = fopen(path_zonetab, "r"); if (!fp) - err(1, _PATH_ZONETAB); + err(1, "%s", path_zonetab); lineno = 0; while ((line = fgetln(fp, &len)) != 0) { lineno++; if (line[len - 1] != '\n') - errx(1, _PATH_ZONETAB ":%d: invalid format", lineno); + errx(1, "%s:%d: invalid format", path_zonetab, lineno); line[len - 1] = '\0'; if (line[0] == '#') continue; tlc = strsep(&line, "\t"); if (strlen(tlc) != 2) - errx(1, _PATH_ZONETAB ":%d: invalid country code `%s'", - lineno, tlc); - coord = strsep(&line, "\t"); + errx(1, "%s:%d: invalid country code `%s'", + path_zonetab, lineno, tlc); + coord = strsep(&line, "\t"); /* Unused */ file = strsep(&line, "\t"); p = strchr(file, '/'); if (p == 0) - errx(1, _PATH_ZONETAB ":%d: invalid zone name `%s'", + errx(1, "%s:%d: invalid zone name `%s'", path_zonetab, lineno, file); contbuf[0] = '\0'; strncat(contbuf, file, p - file); cont = find_continent(contbuf); if (!cont) - errx(1, _PATH_ZONETAB ":%d: invalid region `%s'", + errx(1, "%s:%d: invalid region `%s'", path_zonetab, lineno, contbuf); descr = (line != NULL && *line != '\0') ? line : NULL; @@ -495,7 +503,7 @@ set_zone_menu(dialogMenuItem *dmi) } static int -install_zone_file(const char *filename) +install_zoneinfo_file(const char *zoneinfo_file) { char buf[1024]; char title[64], prompt[64]; @@ -503,7 +511,7 @@ install_zone_file(const char *filename) ssize_t len; int fd1, fd2, copymode; - if (lstat(_PATH_LOCALTIME, &sb) < 0) { + if (lstat(path_localtime, &sb) < 0) { /* Nothing there yet... */ copymode = 1; } else if (S_ISLNK(sb.st_mode)) @@ -514,70 +522,89 @@ install_zone_file(const char *filename) #ifdef VERBOSE if (copymode) snprintf(prompt, sizeof(prompt), - "Copying %s to " _PATH_LOCALTIME, filename); + "Copying %s to %s", zoneinfo_file, path_localtime); else snprintf(prompt, sizeof(prompt), - "Creating symbolic link " _PATH_LOCALTIME " to %s", - filename); - dialog_notify(prompt); + "Creating symbolic link %s to %s", + path_localtime, zoneinfo_file); + if (usedialog) + dialog_notify(prompt); + else + fprintf(stderr, "%s\n", prompt); #endif if (reallydoit) { if (copymode) { - fd1 = open(filename, O_RDONLY, 0); + fd1 = open(zoneinfo_file, O_RDONLY, 0); if (fd1 < 0) { snprintf(title, sizeof(title), "Error"); snprintf(prompt, sizeof(prompt), - "Could not open %s: %s", filename, + "Could not open %s: %s", zoneinfo_file, strerror(errno)); - dialog_mesgbox(title, prompt, 8, 72); + if (usedialog) + dialog_mesgbox(title, prompt, 8, 72); + else + fprintf(stderr, "%s\n", prompt); return (DITEM_FAILURE | DITEM_RECREATE); } - unlink(_PATH_LOCALTIME); - fd2 = open(_PATH_LOCALTIME, O_CREAT | O_EXCL | O_WRONLY, + unlink(path_localtime); + fd2 = open(path_localtime, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IRGRP | S_IROTH); if (fd2 < 0) { snprintf(title, sizeof(title), "Error"); snprintf(prompt, sizeof(prompt), - "Could not open " _PATH_LOCALTIME ": %s", - strerror(errno)); - dialog_mesgbox(title, prompt, 8, 72); + "Could not open %s: %s", + path_localtime, strerror(errno)); + if (usedialog) + dialog_mesgbox(title, prompt, 8, 72); + else + fprintf(stderr, "%s\n", prompt); return (DITEM_FAILURE | DITEM_RECREATE); } while ((len = read(fd1, buf, sizeof(buf))) > 0) - len = write(fd2, buf, len); + if ((len = write(fd2, buf, len)) < 0) + break; if (len == -1) { snprintf(title, sizeof(title), "Error"); snprintf(prompt, sizeof(prompt), - "Error copying %s to " _PATH_LOCALTIME - ": %s", filename, strerror(errno)); - dialog_mesgbox(title, prompt, 8, 72); + "Error copying %s to %s %s", zoneinfo_file, + path_localtime, strerror(errno)); + if (usedialog) + dialog_mesgbox(title, prompt, 8, 72); + else + fprintf(stderr, "%s\n", prompt); /* Better to leave none than a corrupt one. */ - unlink(_PATH_LOCALTIME); + unlink(path_localtime); return (DITEM_FAILURE | DITEM_RECREATE); } close(fd1); close(fd2); } else { - if (access(filename, R_OK) != 0) { + if (access(zoneinfo_file, R_OK) != 0) { snprintf(title, sizeof(title), "Error"); snprintf(prompt, sizeof(prompt), - "Cannot access %s: %s", filename, + "Cannot access %s: %s", zoneinfo_file, strerror(errno)); - dialog_mesgbox(title, prompt, 8, 72); + if (usedialog) + dialog_mesgbox(title, prompt, 8, 72); + else + fprintf(stderr, "%s\n", prompt); return (DITEM_FAILURE | DITEM_RECREATE); } - unlink(_PATH_LOCALTIME); - if (symlink(filename, _PATH_LOCALTIME) < 0) { + unlink(path_localtime); + if (symlink(zoneinfo_file, path_localtime) < 0) { snprintf(title, sizeof(title), "Error"); snprintf(prompt, sizeof(prompt), - "Cannot create symbolic link " - _PATH_LOCALTIME " to %s: %s", filename, + "Cannot create symbolic link %s to %s: %s", + path_localtime, zoneinfo_file, strerror(errno)); - dialog_mesgbox(title, prompt, 8, 72); + if (usedialog) + dialog_mesgbox(title, prompt, 8, 72); + else + fprintf(stderr, "%s\n", prompt); return (DITEM_FAILURE | DITEM_RECREATE); } } @@ -587,17 +614,41 @@ install_zone_file(const char *filename) snprintf(title, sizeof(title), "Done"); if (copymode) snprintf(prompt, sizeof(prompt), - "Copied timezone file from %s to " _PATH_LOCALTIME, - filename); + "Copied timezone file from %s to %s", zoneinfo_file, + path_localtime); + else + snprintf(prompt, sizeof(prompt), + "Created symbolic link from %s to %s", zoneinfo_file, + path_localtime); + if (usedialog) + dialog_mesgbox(title, prompt, 8, 72); else - snprintf(prompt, sizeof(prompt), "Created symbolic link from " - _PATH_LOCALTIME " to %s", filename); - dialog_mesgbox(title, prompt, 8, 72); + fprintf(stderr, "%s\n", prompt); #endif + return (DITEM_LEAVE_MENU); } static int +install_zoneinfo(const char *zoneinfo) +{ + int rv; + FILE *f; + char path_zoneinfo_file[MAXPATHLEN]; + + sprintf(path_zoneinfo_file, "%s/%s", path_zoneinfo, zoneinfo); + rv = install_zoneinfo_file(path_zoneinfo_file); + + /* Save knowledge for later */ + if ((f = fopen(path_db, "w")) != NULL) { + fprintf(f, "%s\n", zoneinfo); + fclose(f); + } + + return (rv); +} + +static int confirm_zone(const char *filename) { char title[64], prompt[64]; @@ -620,15 +671,12 @@ static int set_zone_multi(dialogMenuItem *dmi) { struct zone *zp = dmi->data; - char *fn; int rv; if (!confirm_zone(zp->filename)) return (DITEM_FAILURE | DITEM_RECREATE); - asprintf(&fn, "%s/%s", _PATH_ZONEINFO, zp->filename); - rv = install_zone_file(fn); - free(fn); + rv = install_zoneinfo(zp->filename); return (rv); } @@ -636,15 +684,12 @@ static int set_zone_whole_country(dialogMenuItem *dmi) { struct country *cp = dmi->data; - char *fn; int rv; if (!confirm_zone(cp->filename)) return (DITEM_FAILURE | DITEM_RECREATE); - asprintf(&fn, "%s/%s", _PATH_ZONEINFO, cp->filename); - rv = install_zone_file(fn); - free(fn); + rv = install_zoneinfo(cp->filename); return (rv); } @@ -652,7 +697,7 @@ static void usage(void) { - fprintf(stderr, "usage: tzsetup [-ns]\n"); + fprintf(stderr, "usage: tzsetup [-nrs] [zoneinfo file]\n"); exit(1); } @@ -666,14 +711,21 @@ int main(int argc, char **argv) { char title[64], prompt[128]; - int c, fd, skiputc; + int c, fd, rv, skiputc; skiputc = 0; - while ((c = getopt(argc, argv, "ns")) != -1) { + while ((c = getopt(argc, argv, "C:nrs")) != -1) { switch(c) { + case 'C': + chrootenv = optarg; + break; case 'n': reallydoit = 0; break; + case 'r': + reinstall = 1; + usedialog = 0; + break; case 's': skiputc = 1; break; @@ -685,6 +737,24 @@ main(int argc, char **argv) if (argc - optind > 1) usage(); + if (chrootenv == NULL) { + strcpy(path_zonetab, _PATH_ZONETAB); + strcpy(path_iso3166, _PATH_ISO3166); + strcpy(path_zoneinfo, _PATH_ZONEINFO); + strcpy(path_localtime, _PATH_LOCALTIME); + strcpy(path_db, _PATH_DB); + strcpy(path_wall_cmos_clock, _PATH_WALL_CMOS_CLOCK); + } else { + sprintf(path_zonetab, "%s/%s", chrootenv, _PATH_ZONETAB); + sprintf(path_iso3166, "%s/%s", chrootenv, _PATH_ISO3166); + sprintf(path_zoneinfo, "%s/%s", chrootenv, _PATH_ZONEINFO); + sprintf(path_localtime, "%s/%s", chrootenv, _PATH_LOCALTIME); + sprintf(path_db, "%s/%s", chrootenv, _PATH_DB); + sprintf(path_wall_cmos_clock, "%s/%s", chrootenv, + _PATH_WALL_CMOS_CLOCK); + } + + /* Override the user-supplied umask. */ (void)umask(S_IWGRP | S_IWOTH); @@ -693,6 +763,54 @@ main(int argc, char **argv) sort_countries(); make_menus(); + if (reinstall == 1) { + FILE *f; + char zonefile[MAXPATHLEN]; + char path_db[MAXPATHLEN]; + + zonefile[0] = '\0'; + path_db[0] = '\0'; + if (chrootenv != NULL) { + sprintf(zonefile, "%s/", chrootenv); + sprintf(path_db, "%s/", chrootenv); + } + strcat(zonefile, _PATH_ZONEINFO); + strcat(zonefile, "/"); + strcat(path_db, _PATH_DB); + + if ((f = fopen(path_db, "r")) != NULL) { + if (fgets(zonefile, sizeof(zonefile), f) != NULL) { + zonefile[sizeof(zonefile) - 1] = 0; + if (strlen(zonefile) > 0) { + zonefile[strlen(zonefile) - 1] = 0; + rv = install_zoneinfo(zonefile); + exit(rv & ~DITEM_LEAVE_MENU); + } + errx(1, "Error reading %s.\n", path_db); + } + fclose(f); + errx(1, + "Unable to determine earlier installed zoneinfo " + "file. Check %s", path_db); + } + errx(1, "Cannot open %s for reading. Does it exist?", path_db); + } + + /* + * If the arguments on the command-line do not specify a file, + * then interpret it as a zoneinfo name + */ + if (optind == argc - 1) { + struct stat sb; + + if (stat(argv[optind], &sb) != 0) { + usedialog = 0; + rv = install_zoneinfo(argv[optind]); + exit(rv & ~DITEM_LEAVE_MENU); + } + /* FALLTHROUGH */ + } + init_dialog(); if (skiputc == 0) { snprintf(title, sizeof(title), @@ -703,15 +821,17 @@ main(int argc, char **argv) "or you don't know, please choose NO here!"); if (!DIALOG_UTC(title, prompt, 7, 72)) { if (reallydoit) - unlink(_PATH_WALL_CMOS_CLOCK); + unlink(path_wall_cmos_clock); } else { if (reallydoit) { - fd = open(_PATH_WALL_CMOS_CLOCK, + fd = open(path_wall_cmos_clock, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IRGRP | S_IROTH); - if (fd < 0) + if (fd < 0) { + end_dialog(); err(1, "create %s", - _PATH_WALL_CMOS_CLOCK); + path_wall_cmos_clock); + } close(fd); } } @@ -722,10 +842,10 @@ main(int argc, char **argv) snprintf(prompt, sizeof(prompt), "\nUse the default `%s' zone?", argv[optind]); if (!dialog_yesno(title, prompt, 7, 72)) { - install_zone_file(argv[optind]); + rv = install_zoneinfo_file(argv[optind]); dialog_clear(); end_dialog(); - return (0); + exit(rv & ~DITEM_LEAVE_MENU); } dialog_clear_norefresh(); } From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 06:31:00 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 33F941065670; Thu, 31 Mar 2011 06:31:00 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 22FB38FC19; Thu, 31 Mar 2011 06:31:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V6V0bt093993; Thu, 31 Mar 2011 06:31:00 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V6V0ap093991; Thu, 31 Mar 2011 06:31:00 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201103310631.p2V6V0ap093991@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 31 Mar 2011 06:31:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220184 - head/sys/geom/nop X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 06:31:00 -0000 Author: ae Date: Thu Mar 31 06:30:59 2011 New Revision: 220184 URL: http://svn.freebsd.org/changeset/base/220184 Log: Remove unneeded checks, g_new_xxx functions can not return NULL. Reviewed by: pjd MFC after: 1 week Modified: head/sys/geom/nop/g_nop.c Modified: head/sys/geom/nop/g_nop.c ============================================================================== --- head/sys/geom/nop/g_nop.c Thu Mar 31 06:29:15 2011 (r220183) +++ head/sys/geom/nop/g_nop.c Thu Mar 31 06:30:59 2011 (r220184) @@ -189,10 +189,6 @@ g_nop_create(struct gctl_req *req, struc } } gp = g_new_geomf(mp, name); - if (gp == NULL) { - gctl_error(req, "Cannot create geom %s.", name); - return (ENOMEM); - } sc = g_malloc(sizeof(*sc), M_WAITOK); sc->sc_offset = offset; sc->sc_error = ioerror; @@ -209,20 +205,10 @@ g_nop_create(struct gctl_req *req, struc gp->dumpconf = g_nop_dumpconf; newpp = g_new_providerf(gp, gp->name); - if (newpp == NULL) { - gctl_error(req, "Cannot create provider %s.", name); - error = ENOMEM; - goto fail; - } newpp->mediasize = size; newpp->sectorsize = secsize; cp = g_new_consumer(gp); - if (cp == NULL) { - gctl_error(req, "Cannot create consumer for %s.", gp->name); - error = ENOMEM; - goto fail; - } error = g_attach(cp, pp); if (error != 0) { gctl_error(req, "Cannot attach to provider %s.", pp->name); @@ -233,18 +219,12 @@ g_nop_create(struct gctl_req *req, struc G_NOP_DEBUG(0, "Device %s created.", gp->name); return (0); fail: - if (cp != NULL) { - if (cp->provider != NULL) - g_detach(cp); - g_destroy_consumer(cp); - } - if (newpp != NULL) - g_destroy_provider(newpp); - if (gp != NULL) { - if (gp->softc != NULL) - g_free(gp->softc); - g_destroy_geom(gp); - } + if (cp->provider != NULL) + g_detach(cp); + g_destroy_consumer(cp); + g_destroy_provider(newpp); + g_free(gp->softc); + g_destroy_geom(gp); return (error); } From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 07:33:21 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 74B8B106564A; Thu, 31 Mar 2011 07:33:21 +0000 (UTC) (envelope-from inyaoo@gmail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id 894948FC15; Thu, 31 Mar 2011 07:33:20 +0000 (UTC) Received: by wwc33 with SMTP id 33so2361436wwc.31 for ; Thu, 31 Mar 2011 00:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=klQiR4eO0devedTFbYsUS75UNr9DnuDCw4enHfMdjZA=; b=ofoJGIRdmSn+BRa86cfQ5nITjnLj5/Cn1zMmFpRcGyZXzRJ2tJ7pxy7g6Z29WPd2jG buz0COpypeg0CNOyjeH/i6bOmbTko1ddMKLa9yyhWTusollyV6OOzov0oOzFe9wG8k7U a5d+YIKOfCUDIyl+74SkFO5hUPEm01MdQFeDU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=f+EAdj7MDPUtzTyUj9IwDNt915L9KoSCaDZ+c6Ropmz1m2S8L8RjK/fYzX3MvG9G96 i4CAdjuT0C3Ig5wCEqbgCtdFOpn5ToF1kkX6oYwx0MrYGvc8t8ulA7hoz1D/EAOhuhCP xZdikyZ3rd2cojnOBcnkRYXYdNnQ8Y2P9Pi5Y= Received: by 10.227.200.75 with SMTP id ev11mr2384763wbb.56.1301555274140; Thu, 31 Mar 2011 00:07:54 -0700 (PDT) Received: from localhost (tor6.anonymizer.ccc.de [80.237.226.76]) by mx.google.com with ESMTPS id x1sm474230wbh.2.2011.03.31.00.07.48 (version=SSLv3 cipher=OTHER); Thu, 31 Mar 2011 00:07:52 -0700 (PDT) From: Pan Tsu To: Konstantin Belousov References: <201103301446.p2UEkDDk066511@svn.freebsd.org> Date: Thu, 31 Mar 2011 11:07:36 +0400 In-Reply-To: <201103301446.p2UEkDDk066511@svn.freebsd.org> (Konstantin Belousov's message of "Wed, 30 Mar 2011 14:46:13 +0000 (UTC)") Message-ID: <8662qzu5s7.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220158 - in head/sys: compat/freebsd32 kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 07:33:21 -0000 Konstantin Belousov writes: > Author: kib > Date: Wed Mar 30 14:46:12 2011 > New Revision: 220158 > URL: http://svn.freebsd.org/changeset/base/220158 > > Log: > Provide compat32 shims for kldstat(2). > > Requested and tested by: jpaetzel > MFC after: 1 week It breaks loading modules from loader(8) for me. The box panics early #13 0xffffffff804f2f2a in sysctl_find_oidname (name=0xffffffff80eec156 "kstat", list=0x657a69735f796c) at /usr/src/sys/kern/kern_sysctl.c:106 #14 0xffffffff804f3e69 in sysctl_register_oid (oidp=0xffffffff80ef0a80) at /usr/src/sys/kern/kern_sysctl.c:149 #15 0xffffffff804cb83c in linker_file_register_sysctls (lf=Variable "lf" is not available. ) at /usr/src/sys/kern/kern_linker.c:301 #16 0xffffffff804cd112 in linker_preload (arg=Variable "arg" is not available. ) at /usr/src/sys/kern/kern_linker.c:1624 #17 0xffffffff80499ad7 in mi_startup () at /usr/src/sys/kern/init_main.c:258 #18 0xffffffff80299a3c in btext () at /usr/src/sys/amd64/amd64/locore.S:81 [...] From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 08:07:13 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A8532106566C; Thu, 31 Mar 2011 08:07:13 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 962CC8FC15; Thu, 31 Mar 2011 08:07:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V87DGs096069; Thu, 31 Mar 2011 08:07:13 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V87DHV096049; Thu, 31 Mar 2011 08:07:13 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103310807.p2V87DHV096049@svn.freebsd.org> From: Adrian Chadd Date: Thu, 31 Mar 2011 08:07:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220185 - in head/sys: amd64/conf arm/conf conf dev/ath i386/conf mips/conf modules modules/ath modules/ath_ahb modules/ath_pci pc98/conf sparc64/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 08:07:13 -0000 Author: adrian Date: Thu Mar 31 08:07:13 2011 New Revision: 220185 URL: http://svn.freebsd.org/changeset/base/220185 Log: Break out the ath PCI logic into a separate device/module. Introduce the AHB glue for Atheros embedded systems. Right now it's hard-coded for the AR9130 chip whose support isn't yet in this HAL; it'll be added in a subsequent commit. Kernel configuration files now need both 'ath' and 'ath_pci' devices; both modules need to be loaded for the ath device to work. Added: head/sys/dev/ath/if_ath_ahb.c (contents, props changed) head/sys/modules/ath_ahb/ head/sys/modules/ath_ahb/Makefile (contents, props changed) head/sys/modules/ath_pci/ head/sys/modules/ath_pci/Makefile (contents, props changed) Modified: head/sys/amd64/conf/GENERIC head/sys/arm/conf/AVILA head/sys/arm/conf/CAMBRIA head/sys/conf/files head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_ath_pci.c head/sys/i386/conf/GENERIC head/sys/i386/conf/PAE head/sys/mips/conf/AR71XX head/sys/mips/conf/IDT head/sys/mips/conf/OCTEON1 head/sys/mips/conf/SENTRY5 head/sys/modules/Makefile head/sys/modules/ath/Makefile head/sys/pc98/conf/GENERIC head/sys/sparc64/conf/GENERIC Modified: head/sys/amd64/conf/GENERIC ============================================================================== --- head/sys/amd64/conf/GENERIC Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/amd64/conf/GENERIC Thu Mar 31 08:07:13 2011 (r220185) @@ -257,7 +257,8 @@ device wlan_ccmp # 802.11 CCMP support device wlan_tkip # 802.11 TKIP support device wlan_amrr # AMRR transmit rate control algorithm device an # Aironet 4500/4800 802.11 wireless NICs. -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's +device ath_pci # Atheros pci/cardbus glue device ath_hal # pci/cardbus chip support options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath Modified: head/sys/arm/conf/AVILA ============================================================================== --- head/sys/arm/conf/AVILA Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/arm/conf/AVILA Thu Mar 31 08:07:13 2011 (r220185) @@ -120,7 +120,8 @@ device wlan_ccmp # 802.11 CCMP support device wlan_tkip # 802.11 TKIP support device wlan_xauth -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's +device ath_pci # Atheros pci/cardbus glue options ATH_DEBUG options ATH_DIAGAPI #options ATH_TX99_DIAG Modified: head/sys/arm/conf/CAMBRIA ============================================================================== --- head/sys/arm/conf/CAMBRIA Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/arm/conf/CAMBRIA Thu Mar 31 08:07:13 2011 (r220185) @@ -123,7 +123,8 @@ device wlan_ccmp # 802.11 CCMP support device wlan_tkip # 802.11 TKIP support device wlan_xauth -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's +device ath_pci # Atheros pci/cardbus glue options ATH_DEBUG options ATH_DIAGAPI #options ATH_TX99_DIAG Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/conf/files Thu Mar 31 08:07:13 2011 (r220185) @@ -570,6 +570,12 @@ dev/ata/atapi-fd.c optional atapifd dev/ata/atapi-tape.c optional atapist dev/ata/atapi-cam.c optional atapicam # +dev/ath/if_ath_pci.c optional ath_pci pci \ + compile-with "${NORMAL_C} -I$S/dev/ath" +# +dev/ath/if_ath_ahb.c optional ath_ahb \ + compile-with "${NORMAL_C} -I$S/dev/ath" +# dev/ath/if_ath.c optional ath \ compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/if_ath_debug.c optional ath \ @@ -582,8 +588,6 @@ dev/ath/if_ath_tx_ht.c optional ath \ compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/if_ath_sysctl.c optional ath \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_pci.c optional ath pci \ - compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/ah_osdep.c optional ath \ compile-with "${NORMAL_C} -I$S/dev/ath" # Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/dev/ath/if_ath.c Thu Mar 31 08:07:13 2011 (r220185) @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -5591,3 +5592,5 @@ ath_tdma_beacon_send(struct ath_softc *s } #endif /* IEEE80211_SUPPORT_TDMA */ +MODULE_VERSION(if_ath, 1); +MODULE_DEPEND(if_ath, wlan, 1, 1, 1); /* 802.11 media layer */ Added: head/sys/dev/ath/if_ath_ahb.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/ath/if_ath_ahb.c Thu Mar 31 08:07:13 2011 (r220185) @@ -0,0 +1,287 @@ +/*- + * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting + * Copyright (c) 2010-2011 Adrian Chadd, Xenion Pty Ltd + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + * redistribution must be conditioned upon including a substantially + * similar Disclaimer requirement for further binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGES. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * AHB bus front-end for the Atheros Wireless LAN controller driver. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include + +/* + * bus glue. + */ + +/* number of 16 bit words */ +#define ATH_EEPROM_DATA_SIZE 2048 + +struct ath_ahb_softc { + struct ath_softc sc_sc; + struct resource *sc_sr; /* memory resource */ + struct resource *sc_irq; /* irq resource */ + struct resource *sc_eeprom; /* eeprom location */ + void *sc_ih; /* interrupt handler */ +}; + +#define VENDOR_ATHEROS 0x168c +#define AR9100_DEVID 0x000b + +static int +ath_ahb_probe(device_t dev) +{ + const char* devname; + + /* Atheros / ar9100 */ + devname = ath_hal_probe(VENDOR_ATHEROS, AR9100_DEVID); + + if (devname != NULL) { + device_set_desc(dev, devname); + return BUS_PROBE_DEFAULT; + } + return ENXIO; +} + +static int +ath_ahb_attach(device_t dev) +{ + struct ath_ahb_softc *psc = device_get_softc(dev); + struct ath_softc *sc = &psc->sc_sc; + int error = ENXIO; + int rid; + long eepromaddr; + uint8_t *p; + + sc->sc_dev = dev; + + rid = 0; + psc->sc_sr = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); + if (psc->sc_sr == NULL) { + device_printf(dev, "cannot map register space\n"); + goto bad; + } + + if (resource_long_value(device_get_name(dev), device_get_unit(dev), + "eepromaddr", &eepromaddr) != 0) { + device_printf(dev, "cannot fetch 'eepromaddr' from hints\n"); + goto bad0; + } + rid = 0; + device_printf(sc->sc_dev, "eeprom @ %p\n", (void *) eepromaddr); + psc->sc_eeprom = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, (uintptr_t) eepromaddr, + (uintptr_t) eepromaddr + (uintptr_t) ((ATH_EEPROM_DATA_SIZE * 2) - 1), 0, RF_ACTIVE); + if (psc->sc_sr == NULL) { + device_printf(dev, "cannot map eeprom space\n"); + goto bad0; + } + + /* XXX uintptr_t is a bandaid for ia64; to be fixed */ + sc->sc_st = (HAL_BUS_TAG)(uintptr_t) rman_get_bustag(psc->sc_sr); + sc->sc_sh = (HAL_BUS_HANDLE) rman_get_bushandle(psc->sc_sr); + /* + * Mark device invalid so any interrupts (shared or otherwise) + * that arrive before the HAL is setup are discarded. + */ + sc->sc_invalid = 1; + + /* Copy the EEPROM data out */ + sc->sc_eepromdata = malloc(ATH_EEPROM_DATA_SIZE * 2, M_TEMP, M_NOWAIT | M_ZERO); + device_printf(sc->sc_dev, "eeprom data @ %p\n", (void *) rman_get_bushandle(psc->sc_eeprom)); + /* XXX why doesn't this work? -adrian */ +#if 0 + bus_space_read_multi_1( + rman_get_bustag(psc->sc_eeprom), + rman_get_bushandle(psc->sc_eeprom), + 0, (u_int8_t *) sc->sc_eepromdata, ATH_EEPROM_DATA_SIZE * 2); +#endif + p = (void *) rman_get_bushandle(psc->sc_eeprom); + memcpy(sc->sc_eepromdata, p, ATH_EEPROM_DATA_SIZE * 2); + + /* + * Arrange interrupt line. + */ + rid = 0; + psc->sc_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_SHAREABLE|RF_ACTIVE); + if (psc->sc_irq == NULL) { + device_printf(dev, "could not map interrupt\n"); + goto bad1; + } + if (bus_setup_intr(dev, psc->sc_irq, + INTR_TYPE_NET | INTR_MPSAFE, + NULL, ath_intr, sc, &psc->sc_ih)) { + device_printf(dev, "could not establish interrupt\n"); + goto bad2; + } + + /* + * Setup DMA descriptor area. + */ + if (bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */ + 1, 0, /* alignment, bounds */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + 0x3ffff, /* maxsize XXX */ + ATH_MAX_SCATTER, /* nsegments */ + 0x3ffff, /* maxsegsize XXX */ + BUS_DMA_ALLOCNOW, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockarg */ + &sc->sc_dmat)) { + device_printf(dev, "cannot allocate DMA tag\n"); + goto bad3; + } + + ATH_LOCK_INIT(sc); + + error = ath_attach(AR9100_DEVID, sc); + if (error == 0) /* success */ + return 0; + + ATH_LOCK_DESTROY(sc); + bus_dma_tag_destroy(sc->sc_dmat); +bad3: + bus_teardown_intr(dev, psc->sc_irq, psc->sc_ih); +bad2: + bus_release_resource(dev, SYS_RES_IRQ, 0, psc->sc_irq); +bad1: + bus_release_resource(dev, SYS_RES_MEMORY, 0, psc->sc_eeprom); +bad0: + bus_release_resource(dev, SYS_RES_MEMORY, 0, psc->sc_sr); +bad: + /* XXX?! */ + if (sc->sc_eepromdata) + free(sc->sc_eepromdata, M_TEMP); + return (error); +} + +static int +ath_ahb_detach(device_t dev) +{ + struct ath_ahb_softc *psc = device_get_softc(dev); + struct ath_softc *sc = &psc->sc_sc; + + /* check if device was removed */ + sc->sc_invalid = !bus_child_present(dev); + + ath_detach(sc); + + bus_generic_detach(dev); + bus_teardown_intr(dev, psc->sc_irq, psc->sc_ih); + bus_release_resource(dev, SYS_RES_IRQ, 0, psc->sc_irq); + + bus_dma_tag_destroy(sc->sc_dmat); + bus_release_resource(dev, SYS_RES_MEMORY, 0, psc->sc_sr); + bus_release_resource(dev, SYS_RES_MEMORY, 0, psc->sc_eeprom); + /* XXX?! */ + if (sc->sc_eepromdata) + free(sc->sc_eepromdata, M_TEMP); + + ATH_LOCK_DESTROY(sc); + + return (0); +} + +static int +ath_ahb_shutdown(device_t dev) +{ + struct ath_ahb_softc *psc = device_get_softc(dev); + + ath_shutdown(&psc->sc_sc); + return (0); +} + +static int +ath_ahb_suspend(device_t dev) +{ + struct ath_ahb_softc *psc = device_get_softc(dev); + + ath_suspend(&psc->sc_sc); + + return (0); +} + +static int +ath_ahb_resume(device_t dev) +{ + struct ath_ahb_softc *psc = device_get_softc(dev); + + ath_resume(&psc->sc_sc); + + return (0); +} + +static device_method_t ath_ahb_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, ath_ahb_probe), + DEVMETHOD(device_attach, ath_ahb_attach), + DEVMETHOD(device_detach, ath_ahb_detach), + DEVMETHOD(device_shutdown, ath_ahb_shutdown), + DEVMETHOD(device_suspend, ath_ahb_suspend), + DEVMETHOD(device_resume, ath_ahb_resume), + + { 0,0 } +}; +static driver_t ath_ahb_driver = { + "ath", + ath_ahb_methods, + sizeof (struct ath_ahb_softc) +}; +static devclass_t ath_devclass; +DRIVER_MODULE(ath, nexus, ath_ahb_driver, ath_devclass, 0, 0); +MODULE_VERSION(ath, 1); +MODULE_DEPEND(ath, wlan, 1, 1, 1); /* 802.11 media layer */ +MODULE_DEPEND(ath, if_ath, 1, 1, 1); /* if_ath driver */ Modified: head/sys/dev/ath/if_ath_pci.c ============================================================================== --- head/sys/dev/ath/if_ath_pci.c Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/dev/ath/if_ath_pci.c Thu Mar 31 08:07:13 2011 (r220185) @@ -250,6 +250,7 @@ static driver_t ath_pci_driver = { sizeof (struct ath_pci_softc) }; static devclass_t ath_devclass; -DRIVER_MODULE(ath, pci, ath_pci_driver, ath_devclass, 0, 0); -MODULE_VERSION(ath, 1); -MODULE_DEPEND(ath, wlan, 1, 1, 1); /* 802.11 media layer */ +DRIVER_MODULE(ath_pci, pci, ath_pci_driver, ath_devclass, 0, 0); +MODULE_VERSION(ath_pci, 1); +MODULE_DEPEND(ath_pci, wlan, 1, 1, 1); /* 802.11 media layer */ +MODULE_DEPEND(ath_pci, if_ath, 1, 1, 1); /* if_ath driver */ Modified: head/sys/i386/conf/GENERIC ============================================================================== --- head/sys/i386/conf/GENERIC Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/i386/conf/GENERIC Thu Mar 31 08:07:13 2011 (r220185) @@ -269,7 +269,8 @@ device wlan_ccmp # 802.11 CCMP support device wlan_tkip # 802.11 TKIP support device wlan_amrr # AMRR transmit rate control algorithm device an # Aironet 4500/4800 802.11 wireless NICs. -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's +device ath_pci # Atheros pci/cardbus glue device ath_hal # pci/cardbus chip support options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath Modified: head/sys/i386/conf/PAE ============================================================================== --- head/sys/i386/conf/PAE Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/i386/conf/PAE Thu Mar 31 08:07:13 2011 (r220185) @@ -74,6 +74,7 @@ nodevice xe nodevice an nodevice ath # Atheros pci/cardbus NIC's +nodevice ath_pci nodevice ath_hal nodevice ath_rate_sample # SampleRate tx rate control for ath nodevice ral Modified: head/sys/mips/conf/AR71XX ============================================================================== --- head/sys/mips/conf/AR71XX Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/mips/conf/AR71XX Thu Mar 31 08:07:13 2011 (r220185) @@ -55,7 +55,8 @@ device wlan_wep # 802.11 WEP sup device wlan_ccmp # 802.11 CCMP support device wlan_tkip # 802.11 TKIP support -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's +device ath_pci # Atheros pci/cardbus glue options ATH_DEBUG device ath_hal option AH_SUPPORT_AR5416 Modified: head/sys/mips/conf/IDT ============================================================================== --- head/sys/mips/conf/IDT Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/mips/conf/IDT Thu Mar 31 08:07:13 2011 (r220185) @@ -44,7 +44,8 @@ device md device wlan # 802.11 support device wlan_wep # 802.11 WEP support device wlan_tkip # 802.11 TKIP support -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's +device ath_pci # Atheros pci/cardbus glue device ath_hal # pci/cardbus chip support options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath Modified: head/sys/mips/conf/OCTEON1 ============================================================================== --- head/sys/mips/conf/OCTEON1 Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/mips/conf/OCTEON1 Thu Mar 31 08:07:13 2011 (r220185) @@ -237,7 +237,7 @@ device wlan_ccmp # 802.11 CCMP support device wlan_tkip # 802.11 TKIP support device wlan_amrr # AMRR transmit rate control algorithm device an # Aironet 4500/4800 802.11 wireless NICs. -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's device ath_hal # pci/cardbus chip support options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath Modified: head/sys/mips/conf/SENTRY5 ============================================================================== --- head/sys/mips/conf/SENTRY5 Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/mips/conf/SENTRY5 Thu Mar 31 08:07:13 2011 (r220185) @@ -66,6 +66,7 @@ device pci # siba_pcib # pci devices # notyet: #device ath # in pci slot +#device ath_pci # Atheros pci/cardbus glue #device ath_hal # pci chip support #options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors Modified: head/sys/modules/Makefile ============================================================================== --- head/sys/modules/Makefile Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/modules/Makefile Thu Mar 31 08:07:13 2011 (r220185) @@ -35,6 +35,8 @@ SUBDIR= ${_3dfx} \ ${_asr} \ ata \ ath \ + ath_ahb \ + ath_pci \ ${_auxio} \ bce \ bfe \ Modified: head/sys/modules/ath/Makefile ============================================================================== --- head/sys/modules/ath/Makefile Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/modules/ath/Makefile Thu Mar 31 08:07:13 2011 (r220185) @@ -35,7 +35,7 @@ ATH_RATE?= sample # tx rate control alg .PATH: ${.CURDIR}/../../dev/ath/ath_hal KMOD= if_ath -SRCS= if_ath.c if_ath_pci.c if_ath_debug.c if_ath_keycache.c if_ath_sysctl.c +SRCS= if_ath.c if_ath_debug.c if_ath_keycache.c if_ath_sysctl.c SRCS+= if_ath_tx.c if_ath_tx_ht.c # NB: v3 eeprom support used by both AR5211 and AR5212; just include it SRCS+= ah_osdep.c ah.c ah_regdomain.c ah_eeprom_v3.c Added: head/sys/modules/ath_ahb/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/ath_ahb/Makefile Thu Mar 31 08:07:13 2011 (r220185) @@ -0,0 +1,41 @@ +# +# Copyright (c) 2011 Adrian Chadd, Xenion Pty Ltd +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer, +# without modification. +# 2. Redistributions in binary form must reproduce at minimum a disclaimer +# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any +# redistribution must be conditioned upon including a substantially +# similar Disclaimer requirement for further binary redistribution. +# +# NO WARRANTY +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY +# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, +# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGES. +# +# $FreeBSD$ +# + +.PATH: ${.CURDIR}/../../dev/ath +.PATH: ${.CURDIR}/../../dev/ath/ath_hal + +KMOD= if_ath_ahb +SRCS= if_ath_ahb.c +SRCS+= device_if.h bus_if.h + +CFLAGS+= -I. -I${.CURDIR}/../../dev/ath -I${.CURDIR}/../../dev/ath/ath_hal + +.include Added: head/sys/modules/ath_pci/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/ath_pci/Makefile Thu Mar 31 08:07:13 2011 (r220185) @@ -0,0 +1,41 @@ +# +# Copyright (c) 2011 Adrian Chadd, Xenion Pty Ltd +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer, +# without modification. +# 2. Redistributions in binary form must reproduce at minimum a disclaimer +# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any +# redistribution must be conditioned upon including a substantially +# similar Disclaimer requirement for further binary redistribution. +# +# NO WARRANTY +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY +# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, +# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGES. +# +# $FreeBSD$ +# + +.PATH: ${.CURDIR}/../../dev/ath +.PATH: ${.CURDIR}/../../dev/ath/ath_hal + +KMOD= if_ath_pci +SRCS= if_ath_pci.c +SRCS+= device_if.h bus_if.h pci_if.h + +CFLAGS+= -I. -I${.CURDIR}/../../dev/ath -I${.CURDIR}/../../dev/ath/ath_hal + +.include Modified: head/sys/pc98/conf/GENERIC ============================================================================== --- head/sys/pc98/conf/GENERIC Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/pc98/conf/GENERIC Thu Mar 31 08:07:13 2011 (r220185) @@ -221,7 +221,8 @@ device xe # Xircom pccard Ethernet #device wlan_tkip # 802.11 TKIP support #device wlan_amrr # AMRR transmit rate control algorithm #device an # Aironet 4500/4800 802.11 wireless NICs. -#device ath # Atheros pci/cardbus NIC's +#device ath # Atheros NIC's +#device ath_pci # Atheros pci/cardbus glue #device ath_hal # pci/cardbus chip support #options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors #device ath_rate_sample # SampleRate tx rate control for ath Modified: head/sys/sparc64/conf/GENERIC ============================================================================== --- head/sys/sparc64/conf/GENERIC Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/sparc64/conf/GENERIC Thu Mar 31 08:07:13 2011 (r220185) @@ -203,7 +203,8 @@ device wlan_wep # 802.11 WEP support device wlan_ccmp # 802.11 CCMP support device wlan_tkip # 802.11 TKIP support device wlan_amrr # AMRR transmit rate control algorithm -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's +device ath_pci # Atheros pci/cardbus glue device ath_hal # Atheros HAL (Hardware Access Layer) options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 08:14:52 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3476C106564A; Thu, 31 Mar 2011 08:14:52 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0AE728FC0A; Thu, 31 Mar 2011 08:14:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V8EpHV096313; Thu, 31 Mar 2011 08:14:51 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V8Epds096309; Thu, 31 Mar 2011 08:14:51 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201103310814.p2V8Epds096309@svn.freebsd.org> From: Andriy Gapon Date: Thu, 31 Mar 2011 08:14:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220186 - in head/sys: amd64/linux32 compat/linux i386/linux X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 08:14:52 -0000 Author: avg Date: Thu Mar 31 08:14:51 2011 New Revision: 220186 URL: http://svn.freebsd.org/changeset/base/220186 Log: Revert r220032:linux compat: add SO_PASSCRED option with basic handling I have not properly thought through the commit. After r220031 (linux compat: improve and fix sendmsg/recvmsg compatibility) the basic handling for SO_PASSCRED is not sufficient as it breaks recvmsg functionality for SCM_CREDS messages because now we would need to handle sockcred data in addition to cmsgcred. And that is not implemented yet. Pointyhat to: avg Modified: head/sys/amd64/linux32/linux.h head/sys/compat/linux/linux_socket.c head/sys/i386/linux/linux.h Modified: head/sys/amd64/linux32/linux.h ============================================================================== --- head/sys/amd64/linux32/linux.h Thu Mar 31 08:07:13 2011 (r220185) +++ head/sys/amd64/linux32/linux.h Thu Mar 31 08:14:51 2011 (r220186) @@ -695,7 +695,6 @@ union l_semun { #define LINUX_SO_NO_CHECK 11 #define LINUX_SO_PRIORITY 12 #define LINUX_SO_LINGER 13 -#define LINUX_SO_PASSCRED 16 #define LINUX_SO_PEERCRED 17 #define LINUX_SO_RCVLOWAT 18 #define LINUX_SO_SNDLOWAT 19 Modified: head/sys/compat/linux/linux_socket.c ============================================================================== --- head/sys/compat/linux/linux_socket.c Thu Mar 31 08:07:13 2011 (r220185) +++ head/sys/compat/linux/linux_socket.c Thu Mar 31 08:14:51 2011 (r220186) @@ -300,8 +300,6 @@ linux_to_bsd_so_sockopt(int opt) return (SO_OOBINLINE); case LINUX_SO_LINGER: return (SO_LINGER); - case LINUX_SO_PASSCRED: - return (LOCAL_CREDS); case LINUX_SO_PEERCRED: return (LOCAL_PEERCRED); case LINUX_SO_RCVLOWAT: @@ -1469,12 +1467,6 @@ linux_setsockopt(struct thread *td, stru switch (bsd_args.level) { case SOL_SOCKET: name = linux_to_bsd_so_sockopt(args->optname); - switch (args->optname) { - case LINUX_SO_PASSCRED: - /* FreeBSD bug? socket level opts at non socket level */ - bsd_args.level = 0; - break; - } switch (name) { case SO_RCVTIMEO: /* FALLTHROUGH */ @@ -1552,12 +1544,6 @@ linux_getsockopt(struct thread *td, stru switch (bsd_args.level) { case SOL_SOCKET: name = linux_to_bsd_so_sockopt(args->optname); - switch (args->optname) { - case LINUX_SO_PASSCRED: - /* FreeBSD bug? socket level opts at non socket level */ - bsd_args.level = 0; - break; - } switch (name) { case SO_RCVTIMEO: /* FALLTHROUGH */ Modified: head/sys/i386/linux/linux.h ============================================================================== --- head/sys/i386/linux/linux.h Thu Mar 31 08:07:13 2011 (r220185) +++ head/sys/i386/linux/linux.h Thu Mar 31 08:14:51 2011 (r220186) @@ -671,7 +671,6 @@ union l_semun { #define LINUX_SO_NO_CHECK 11 #define LINUX_SO_PRIORITY 12 #define LINUX_SO_LINGER 13 -#define LINUX_SO_PASSCRED 16 #define LINUX_SO_PEERCRED 17 #define LINUX_SO_RCVLOWAT 18 #define LINUX_SO_SNDLOWAT 19 From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 08:32:54 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 35AE9106566C; Thu, 31 Mar 2011 08:32:54 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2762C8FC1C; Thu, 31 Mar 2011 08:32:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V8WsxW096771; Thu, 31 Mar 2011 08:32:54 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V8WsBD096769; Thu, 31 Mar 2011 08:32:54 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103310832.p2V8WsBD096769@svn.freebsd.org> From: Adrian Chadd Date: Thu, 31 Mar 2011 08:32:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220187 - head X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 08:32:54 -0000 Author: adrian Date: Thu Mar 31 08:32:53 2011 New Revision: 220187 URL: http://svn.freebsd.org/changeset/base/220187 Log: Document the ath glue changes. Modified: head/UPDATING Modified: head/UPDATING ============================================================================== --- head/UPDATING Thu Mar 31 08:14:51 2011 (r220186) +++ head/UPDATING Thu Mar 31 08:32:53 2011 (r220187) @@ -22,6 +22,16 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9. machines to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) +20110331: + ath(4) has been split into bus- and device- modules. if_ath contains + the HAL, the TX rate control and the network device code. if_ath_pci + contains the PCI bus glue. For Atheros MIPS embedded systems, if_ath_ahb + contains the AHB glue. Users need to load both if_ath_pci and if_ath + in order to use ath on everything else. + + TO REPEAT: if_ath_ahb is not needed for normal users. Normal users only + need to load if_ath and if_ath_pci for ath(4) operation. + 20110218: GNU binutils 2.17.50 (as of 2007-07-03) has been merged to -HEAD. This is the last available version under GPLv2. It brings a number of new From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 08:48:06 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 625941065674; Thu, 31 Mar 2011 08:48:06 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 393DB8FC14; Thu, 31 Mar 2011 08:48:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V8m6p2097270; Thu, 31 Mar 2011 08:48:06 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V8m6g8097266; Thu, 31 Mar 2011 08:48:06 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103310848.p2V8m6g8097266@svn.freebsd.org> From: Adrian Chadd Date: Thu, 31 Mar 2011 08:48:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220188 - in head/sys: conf dev/ath/ath_hal/ar5416 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 08:48:06 -0000 Author: adrian Date: Thu Mar 31 08:48:05 2011 New Revision: 220188 URL: http://svn.freebsd.org/changeset/base/220188 Log: Introduce AH_AR5416_INTERRUPT_MITIGATION which enables interrupt mitigation for the AR5416 and later. Rename the older HAL option to use this. Modified: head/sys/conf/options head/sys/dev/ath/ath_hal/ar5416/ar5416_interrupts.c head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Thu Mar 31 08:32:53 2011 (r220187) +++ head/sys/conf/options Thu Mar 31 08:48:05 2011 (r220188) @@ -786,6 +786,9 @@ AH_USE_INIPDGAIN opt_ah.h AH_MAXCHAN opt_ah.h AH_RXCFG_SDMAMW_4BYTES opt_ah.h +# AR5416 and later interrupt mitigation +AH_AR5416_INTERRUPT_MITIGATION opt_ah.h + # options for the Broadcom BCM43xx driver (bwi) BWI_DEBUG opt_bwi.h BWI_DEBUG_VERBOSE opt_bwi.h Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_interrupts.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_interrupts.c Thu Mar 31 08:32:53 2011 (r220187) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_interrupts.c Thu Mar 31 08:48:05 2011 (r220188) @@ -128,7 +128,7 @@ ar5416GetPendingInterrupts(struct ath_ha } /* Interrupt Mitigation on AR5416 */ -#ifdef AR5416_INT_MITIGATION +#ifdef AH_AR5416_INTERRUPT_MITIGATION if (isr & (AR_ISR_RXMINTR | AR_ISR_RXINTM)) *masked |= HAL_INT_RX; if (isr & (AR_ISR_TXMINTR | AR_ISR_TXINTM)) @@ -194,7 +194,7 @@ ar5416SetInterrupts(struct ath_hal *ah, mask = ints & HAL_INT_COMMON; mask2 = 0; -#ifdef AR5416_INT_MITIGATION +#ifdef AH_AR5416_INTERRUPT_MITIGATION /* * Overwrite default mask if Interrupt mitigation * is specified for AR5416 Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c Thu Mar 31 08:32:53 2011 (r220187) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c Thu Mar 31 08:48:05 2011 (r220188) @@ -305,7 +305,7 @@ ar5416Reset(struct ath_hal *ah, HAL_OPMO */ OS_REG_WRITE(ah, AR_OBS, 8); -#ifdef AR5416_INT_MITIGATION +#ifdef AH_AR5416_INTERRUPT_MITIGATION OS_REG_WRITE(ah, AR_MIRT, 0); OS_REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 500); @@ -538,7 +538,7 @@ ar5416InitIMR(struct ath_hal *ah, HAL_OP | AR_IMR_RXERR | AR_IMR_RXORN | AR_IMR_BCNMISC; -#ifdef AR5416_INT_MITIGATION +#ifdef AH_AR5416_INTERRUPT_MITIGATION ahp->ah_maskReg |= AR_IMR_TXINTM | AR_IMR_RXINTM | AR_IMR_TXMINTR | AR_IMR_RXMINTR; #else From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 08:55:01 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E583E106564A; Thu, 31 Mar 2011 08:55:00 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D27538FC14; Thu, 31 Mar 2011 08:55:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V8t0GW097455; Thu, 31 Mar 2011 08:55:00 GMT (envelope-from pluknet@svn.freebsd.org) Received: (from pluknet@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V8t0w8097453; Thu, 31 Mar 2011 08:55:00 GMT (envelope-from pluknet@svn.freebsd.org) Message-Id: <201103310855.p2V8t0w8097453@svn.freebsd.org> From: Sergey Kandaurov Date: Thu, 31 Mar 2011 08:55:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220189 - stable/8/lib/libutil X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 08:55:01 -0000 Author: pluknet Date: Thu Mar 31 08:55:00 2011 New Revision: 220189 URL: http://svn.freebsd.org/changeset/base/220189 Log: MFC r219963: Add missing resource limits: - RLIMIT_NPTS - RLIMIT_SWAP Modified: stable/8/lib/libutil/login_class.3 Directory Properties: stable/8/lib/libutil/ (props changed) Modified: stable/8/lib/libutil/login_class.3 ============================================================================== --- stable/8/lib/libutil/login_class.3 Thu Mar 31 08:48:05 2011 (r220188) +++ stable/8/lib/libutil/login_class.3 Thu Mar 31 08:55:00 2011 (r220189) @@ -19,7 +19,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 20, 2008 +.Dd March 24, 2011 .Dt LOGIN_CLASS 3 .Os .Sh NAME @@ -105,17 +105,19 @@ Class capability tags used, with and wit or -max (hard limit) suffixes and the corresponding resource setting: .Bd -literal -cputime RLIMIT_CPU -filesize RLIMIT_FSIZE -datasize RLIMIT_DATA -stacksize RLIMIT_STACK -coredumpsize RLIMIT_CORE -memoryuse RLIMIT_RSS -memorylocked RLIMIT_MEMLOCK -maxproc RLIMIT_NPROC -openfiles RLIMIT_NOFILE -sbsize RLIMIT_SBSIZE -vmemoryuse RLIMIT_VMEM +cputime RLIMIT_CPU +filesize RLIMIT_FSIZE +datasize RLIMIT_DATA +stacksize RLIMIT_STACK +coredumpsize RLIMIT_CORE +memoryuse RLIMIT_RSS +memorylocked RLIMIT_MEMLOCK +maxproc RLIMIT_NPROC +openfiles RLIMIT_NOFILE +sbsize RLIMIT_SBSIZE +vmemoryuse RLIMIT_VMEM +pseudoterminals RLIMIT_NPTS +swapuse RLIMIT_SWAP .Ed .It LOGIN_SETPRIORITY Set the scheduling priority for the current process based on the From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 09:34:56 2011 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7D61D106564A; Thu, 31 Mar 2011 09:34:56 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from ixe-mta-27.emailfiltering.com (ixe-mta-27-tx.emailfiltering.com [194.116.199.158]) by mx1.freebsd.org (Postfix) with ESMTP id 49FE28FC14; Thu, 31 Mar 2011 09:34:55 +0000 (UTC) Received: from mail-gw13.york.ac.uk ([144.32.129.163]) by ixe-mta-27.emailfiltering.com with emfmta (version 4.8.0.437) by TLS id 1016860602 for trasz@FreeBSD.org; 62062b75f56ea33b; Thu, 31 Mar 2011 10:34:54 +0100 Received: from buffy-128.york.ac.uk ([144.32.128.160]:10082 helo=buffy.york.ac.uk) by mail-gw13.york.ac.uk with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1Q5EHF-0002wJ-MT; Thu, 31 Mar 2011 10:34:53 +0100 Received: from buffy.york.ac.uk (localhost [127.0.0.1]) by buffy.york.ac.uk (8.14.4/8.14.4) with ESMTP id p2V9YrDm037579; Thu, 31 Mar 2011 10:34:53 +0100 (BST) (envelope-from gavin@FreeBSD.org) Received: (from ga9@localhost) by buffy.york.ac.uk (8.14.4/8.14.4/Submit) id p2V9YrHY037578; Thu, 31 Mar 2011 10:34:53 +0100 (BST) (envelope-from gavin@FreeBSD.org) X-Authentication-Warning: buffy.york.ac.uk: ga9 set sender to gavin@FreeBSD.org using -f From: Gavin Atkinson To: Edward Tomasz Napierala In-Reply-To: <201103301835.p2UIZ2O8071886@svn.freebsd.org> References: <201103301835.p2UIZ2O8071886@svn.freebsd.org> Content-Type: text/plain; charset="ASCII" Content-Transfer-Encoding: quoted-printable Date: Thu, 31 Mar 2011 10:34:52 +0100 Message-ID: <1301564092.37476.1.camel@buffy.york.ac.uk> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r220168 - head/etc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 09:34:56 -0000 On Wed, 2011-03-30 at 18:35 +0000, Edward Tomasz Napierala wrote: > Author: trasz > Date: Wed Mar 30 18:35:02 2011 > New Revision: 220168 > URL: http://svn.freebsd.org/changeset/base/220168 >=20 > Log: > Add example devd.conf entry. >=20 > + > +# This example works around a memory leak in PostgreSQL, restarting > +# it when "user:pgsql:swap:devctl=3D1G" rctl(8) rule gets triggered. > +notify 0 { > + match "system" "RCTL"; > + match "rule" "user:70:swap:.*"; > + action "/usr/local/etc/rc.d/postgresql restart" > +}; > + > */ This seems like a dangerous rule to have enabled by default? Gavin --=20 Gavin Atkinson FreeBSD committer and bugmeister GPG: A093262B (313A A79F 697D 3A5C 216A EDF5 935D EF44 A093 262B) From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 10:05:04 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CE3AC1065673; Thu, 31 Mar 2011 10:05:04 +0000 (UTC) (envelope-from etnapierala@googlemail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id D8B298FC0A; Thu, 31 Mar 2011 10:05:03 +0000 (UTC) Received: by wwc33 with SMTP id 33so2487118wwc.31 for ; Thu, 31 Mar 2011 03:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:sender:subject:mime-version:content-type:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to:x-mailer; bh=H0eqCsWe1P+rS78rou68bYuBco3lQXepfGT0K+awJJQ=; b=eS6myfSp+uolsKw1JB9hJVy6fNZQOsDcV/Am3ZpRmUfkZB6Fw1hxt3velVS3XA3c0U hlhVHBOykVo5PnhyW3u+DGi+fELcX8ExMKRirukiqX+1yv3wC91FXZi9YoYbgy79JWIs 1z9c+jKgwr8c2jHfPXijO/aj0vlxofU83s11o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=sender:subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=IHt7REkwWSKmz81TsxeAMt+IL4Z0izVbFxXsQzoHc66Ix/AjMcQfeK9aDsYCkgCV1h 4qW7m6Ivy/SgGPFPTatqr/646TNsvxkTdgLgl79DgL8y+y7MRRFHuqng7VZxfRmJXy2c lb1ic+qieNA7Cy/e0P7xd/FWZpfYmz5iPO9yU= Received: by 10.227.195.143 with SMTP id ec15mr2527165wbb.213.1301564559547; Thu, 31 Mar 2011 02:42:39 -0700 (PDT) Received: from enapierala.whl (58.wheelsystems.com [83.12.187.58]) by mx.google.com with ESMTPS id l24sm538749wbc.47.2011.03.31.02.42.37 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 Mar 2011 02:42:38 -0700 (PDT) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=iso-8859-2 From: =?iso-8859-2?Q?Edward_Tomasz_Napiera=B3a?= In-Reply-To: <1301564092.37476.1.camel@buffy.york.ac.uk> Date: Thu, 31 Mar 2011 11:42:35 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201103301835.p2UIZ2O8071886@svn.freebsd.org> <1301564092.37476.1.camel@buffy.york.ac.uk> To: Gavin Atkinson X-Mailer: Apple Mail (2.1084) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r220168 - head/etc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 10:05:05 -0000 Wiadomo=B6=E6 napisana przez Gavin Atkinson w dniu 2011-03-31, o godz. = 11:34: > On Wed, 2011-03-30 at 18:35 +0000, Edward Tomasz Napierala wrote: >> Author: trasz >> Date: Wed Mar 30 18:35:02 2011 >> New Revision: 220168 >> URL: http://svn.freebsd.org/changeset/base/220168 >>=20 >> Log: >> Add example devd.conf entry. >>=20 >> + >> +# This example works around a memory leak in PostgreSQL, restarting >> +# it when "user:pgsql:swap:devctl=3D1G" rctl(8) rule gets triggered. >> +notify 0 { >> + match "system" "RCTL"; >> + match "rule" "user:70:swap:.*"; >> + action "/usr/local/etc/rc.d/postgresql restart" >> +}; >> + >> */ >=20 > This seems like a dangerous rule to have enabled by default? Yes. Note, however, the "*/" in the last line above - the whole block is commented out. -- If you cut off my head, what would I say? Me and my head, or me and my = body? From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 10:05:27 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 041A9106566B; Thu, 31 Mar 2011 10:05:27 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id 9409F8FC0C; Thu, 31 Mar 2011 10:05:26 +0000 (UTC) Received: by iyj12 with SMTP id 12so2824657iyj.13 for ; Thu, 31 Mar 2011 03:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:references:in-reply-to:mime-version :content-transfer-encoding:content-type:message-id:cc:x-mailer:from :subject:date:to; bh=3iuWKbAx3jkxNKRW3lI3tLAzBpfBlQlQFZtCXPu8//4=; b=oUSlWypVhWKyQmAPNN5MzT0ej4xDBE4phDLLHr7noMqELyoNZWyJG73GYzj48e2CjW T49TVBJZladsMTlym/Peq7aoxhpPP3IQVB8Xeza9OU6R3SAFJVVYafEo/zD3+Pcai31A utLEeDBNMguZm+4uz5UX68dwPVOlUXq4768jU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=references:in-reply-to:mime-version:content-transfer-encoding :content-type:message-id:cc:x-mailer:from:subject:date:to; b=XG3Ov9nQPQyGzgfr27EAQbasDkK/peEX/G7ltJdG067vy14PsRGhMg27XL0snN2nKt yrqhguUJtAZF9FBgUJWjSDxgB5fddfVUYWPznh59mKytXkb5BjD4GIvxeMWMd1DFS5jV b5Dmz7UkHDbLYsW7w/mg8Yjv0hbsAUF7J9wP8= Received: by 10.231.113.194 with SMTP id b2mr2376332ibq.103.1301565925918; Thu, 31 Mar 2011 03:05:25 -0700 (PDT) Received: from [192.168.20.50] (c-24-4-33-131.hsd1.ca.comcast.net [24.4.33.131]) by mx.google.com with ESMTPS id o3sm649039ibd.61.2011.03.31.03.05.22 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 Mar 2011 03:05:24 -0700 (PDT) References: <201103301835.p2UIZ2O8071886@svn.freebsd.org> <1301564092.37476.1.camel@buffy.york.ac.uk> In-Reply-To: <1301564092.37476.1.camel@buffy.york.ac.uk> Mime-Version: 1.0 (iPhone Mail 8C148) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Message-Id: <2C7FCC70-E923-4EE3-8C32-1DE0E1FADCEC@gmail.com> X-Mailer: iPhone Mail (8C148) From: Garrett Cooper Date: Thu, 31 Mar 2011 03:05:15 -0700 To: Gavin Atkinson Cc: "svn-src-head@FreeBSD.org" , "svn-src-all@FreeBSD.org" , "src-committers@FreeBSD.org" , Edward Tomasz Napierala Subject: Re: svn commit: r220168 - head/etc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 10:05:27 -0000 On Mar 31, 2011, at 2:34 AM, Gavin Atkinson wrote: > On Wed, 2011-03-30 at 18:35 +0000, Edward Tomasz Napierala wrote: >> Author: trasz >> Date: Wed Mar 30 18:35:02 2011 >> New Revision: 220168 >> URL: http://svn.freebsd.org/changeset/base/220168 >>=20 >> Log: >> Add example devd.conf entry. >>=20 >> + >> +# This example works around a memory leak in PostgreSQL, restarting >> +# it when "user:pgsql:swap:devctl=3D1G" rctl(8) rule gets triggered. >> +notify 0 { >> + match "system" "RCTL"; >> + match "rule" "user:70:swap:.*"; >> + action "/usr/local/etc/rc.d/postgresql restart" >> +}; >> + >> */ >=20 > This seems like a dangerous rule to have enabled by default? It's commented out (devd.conf supports multiline C-style comments and this w= as added at the end of the file). Hth, -Garrett= From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 10:27:06 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4EC151065673; Thu, 31 Mar 2011 10:27:06 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id BEF798FC1E; Thu, 31 Mar 2011 10:27:05 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p2VAR1Vb084911 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 31 Mar 2011 13:27:01 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p2VAR1Mk047110; Thu, 31 Mar 2011 13:27:01 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p2VAR19A047109; Thu, 31 Mar 2011 13:27:01 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 31 Mar 2011 13:27:01 +0300 From: Kostik Belousov To: Pan Tsu Message-ID: <20110331102700.GH78089@deviant.kiev.zoral.com.ua> References: <201103301446.p2UEkDDk066511@svn.freebsd.org> <8662qzu5s7.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="n/ThMq0iISHMWp2N" Content-Disposition: inline In-Reply-To: <8662qzu5s7.fsf@gmail.com> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220158 - in head/sys: compat/freebsd32 kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 10:27:06 -0000 --n/ThMq0iISHMWp2N Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Mar 31, 2011 at 11:07:36AM +0400, Pan Tsu wrote: > Konstantin Belousov writes: >=20 > > Author: kib > > Date: Wed Mar 30 14:46:12 2011 > > New Revision: 220158 > > URL: http://svn.freebsd.org/changeset/base/220158 > > > > Log: > > Provide compat32 shims for kldstat(2). > > =20 > > Requested and tested by: jpaetzel > > MFC after: 1 week >=20 > It breaks loading modules from loader(8) for me. The box panics early >=20 > #13 0xffffffff804f2f2a in sysctl_find_oidname (name=3D0xffffffff80eec15= 6 "kstat", list=3D0x657a69735f796c) > at /usr/src/sys/kern/kern_sysctl.c:106 > #14 0xffffffff804f3e69 in sysctl_register_oid (oidp=3D0xffffffff80ef0a8= 0) > at /usr/src/sys/kern/kern_sysctl.c:149 > #15 0xffffffff804cb83c in linker_file_register_sysctls (lf=3DVariable "= lf" is not available. > ) at /usr/src/sys/kern/kern_linker.c:301 > #16 0xffffffff804cd112 in linker_preload (arg=3DVariable "arg" is not a= vailable. > ) at /usr/src/sys/kern/kern_linker.c:1624 > #17 0xffffffff80499ad7 in mi_startup () at /usr/src/sys/kern/init_main.= c:258 > #18 0xffffffff80299a3c in btext () at /usr/src/sys/amd64/amd64/locore.S= :81 > [...] What supports your claim that the referenced commit breaks early module loading ? You even did not provided the panic message, btw. Commit only changed the wrapper around kldstat(2) syscall, that cannot be used during bootstrap, and the changed code does not reference kldstat(9= ). The later cannot prove that the change did not break something, but due to its nature, it is unlikely. --n/ThMq0iISHMWp2N Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk2UVvQACgkQC3+MBN1Mb4gqdgCfYY9BaWEtFbDTYm8/MUIPa8G9 aIQAn37G3mqOOmD8Mp2xQTUOQ997iuI1 =3m6w -----END PGP SIGNATURE----- --n/ThMq0iISHMWp2N-- From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 11:09:45 2011 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C4C60106564A; Thu, 31 Mar 2011 11:09:45 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from gse-mta-27.emailfiltering.com (gse-mta-27-tx.emailfiltering.com [194.116.198.158]) by mx1.freebsd.org (Postfix) with ESMTP id 9A49C8FC14; Thu, 31 Mar 2011 11:09:44 +0000 (UTC) Received: from mail-gw13.york.ac.uk ([144.32.129.163]) by gse-mta-27.emailfiltering.com with emfmta (version 4.8.0.437) by TLS id 956194972 for trasz@FreeBSD.org; f07e01c26ff13416; Thu, 31 Mar 2011 12:09:43 +0100 Received: from buffy-128.york.ac.uk ([144.32.128.160]:18090 helo=buffy.york.ac.uk) by mail-gw13.york.ac.uk with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1Q5FbO-0002Om-5f; Thu, 31 Mar 2011 11:59:46 +0100 Received: from buffy.york.ac.uk (localhost [127.0.0.1]) by buffy.york.ac.uk (8.14.4/8.14.4) with ESMTP id p2VAxjv4037847; Thu, 31 Mar 2011 11:59:45 +0100 (BST) (envelope-from gavin@FreeBSD.org) Received: (from ga9@localhost) by buffy.york.ac.uk (8.14.4/8.14.4/Submit) id p2VAxjVu037846; Thu, 31 Mar 2011 11:59:45 +0100 (BST) (envelope-from gavin@FreeBSD.org) X-Authentication-Warning: buffy.york.ac.uk: ga9 set sender to gavin@FreeBSD.org using -f From: Gavin Atkinson To: Edward Tomasz =?iso-8859-2?Q?Napiera=B3a?= In-Reply-To: References: <201103301835.p2UIZ2O8071886@svn.freebsd.org> <1301564092.37476.1.camel@buffy.york.ac.uk> Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable Date: Thu, 31 Mar 2011 11:59:45 +0100 Message-ID: <1301569185.37476.2.camel@buffy.york.ac.uk> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r220168 - head/etc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 11:09:45 -0000 On Thu, 2011-03-31 at 11:42 +0200, Edward Tomasz Napiera=B3a wrote: > Wiadomo=B6=E6 napisana przez Gavin Atkinson w dniu 2011-03-31, o godz. 11= :34: > > On Wed, 2011-03-30 at 18:35 +0000, Edward Tomasz Napierala wrote: > >> Author: trasz > >> Date: Wed Mar 30 18:35:02 2011 > >> New Revision: 220168 > >> URL: http://svn.freebsd.org/changeset/base/220168 > >>=20 > >> Log: > >> Add example devd.conf entry. > >>=20 > >> + > >> +# This example works around a memory leak in PostgreSQL, restarting > >> +# it when "user:pgsql:swap:devctl=3D1G" rctl(8) rule gets triggered. > >> +notify 0 { > >> + match "system" "RCTL"; > >> + match "rule" "user:70:swap:.*"; > >> + action "/usr/local/etc/rc.d/postgresql restart" > >> +}; > >> + > >> */ > >=20 > > This seems like a dangerous rule to have enabled by default? >=20 > Yes. Note, however, the "*/" in the last line above - the whole block > is commented out. Gah, sorry for the noise. Gavin From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 11:40:21 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E1BC2106566B; Thu, 31 Mar 2011 11:40:21 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id B4BED8FC0C; Thu, 31 Mar 2011 11:40:21 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 2471046B51; Thu, 31 Mar 2011 07:40:21 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id B74508A01B; Thu, 31 Mar 2011 07:40:20 -0400 (EDT) From: John Baldwin To: Adrian Chadd Date: Thu, 31 Mar 2011 07:40:20 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201103310807.p2V87DHV096049@svn.freebsd.org> In-Reply-To: <201103310807.p2V87DHV096049@svn.freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201103310740.20265.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Thu, 31 Mar 2011 07:40:20 -0400 (EDT) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220185 - in head/sys: amd64/conf arm/conf conf dev/ath i386/conf mips/conf modules modules/ath modules/ath_ahb modules/ath_pci pc98/conf sparc64/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 11:40:22 -0000 On Thursday, March 31, 2011 4:07:13 am Adrian Chadd wrote: > Author: adrian > Date: Thu Mar 31 08:07:13 2011 > New Revision: 220185 > URL: http://svn.freebsd.org/changeset/base/220185 > > Log: > Break out the ath PCI logic into a separate device/module. > > Introduce the AHB glue for Atheros embedded systems. Right now it's > hard-coded for the AR9130 chip whose support isn't yet in this HAL; > it'll be added in a subsequent commit. > > Kernel configuration files now need both 'ath' and 'ath_pci' devices; both > modules need to be loaded for the ath device to work. Err, there's no need to break the kernel config. Just have the kernel DTRT if both ath and pci are enabled using something like: sys/dev/ath/if_ath_pci.c ath pci in sys/conf/files. You can still have an if_ath_pci.ko module with this arrangement. This is what almost all other drivers due that have multiple bus backends. -- John Baldwin From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 12:03:30 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C09E2106566C; Thu, 31 Mar 2011 12:03:30 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A15108FC14; Thu, 31 Mar 2011 12:03:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VC3UDC005526; Thu, 31 Mar 2011 12:03:30 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VC3U40005524; Thu, 31 Mar 2011 12:03:30 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103311203.p2VC3U40005524@svn.freebsd.org> From: Adrian Chadd Date: Thu, 31 Mar 2011 12:03:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220190 - head/sys/modules X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 12:03:30 -0000 Author: adrian Date: Thu Mar 31 12:03:30 2011 New Revision: 220190 URL: http://svn.freebsd.org/changeset/base/220190 Log: ath_ahb shouldn't be compiled normally; it is atheros chip specific. Remove it from here; users can compile it manually if needed. Modified: head/sys/modules/Makefile Modified: head/sys/modules/Makefile ============================================================================== --- head/sys/modules/Makefile Thu Mar 31 08:55:00 2011 (r220189) +++ head/sys/modules/Makefile Thu Mar 31 12:03:30 2011 (r220190) @@ -35,7 +35,6 @@ SUBDIR= ${_3dfx} \ ${_asr} \ ata \ ath \ - ath_ahb \ ath_pci \ ${_auxio} \ bce \ From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 13:14:24 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2932106564A; Thu, 31 Mar 2011 13:14:24 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C27A98FC13; Thu, 31 Mar 2011 13:14:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VDEOig007307; Thu, 31 Mar 2011 13:14:24 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VDEOro007304; Thu, 31 Mar 2011 13:14:24 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201103311314.p2VDEOro007304@svn.freebsd.org> From: Fabien Thomas Date: Thu, 31 Mar 2011 13:14:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220194 - head/sys/netipsec X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 13:14:24 -0000 Author: fabient Date: Thu Mar 31 13:14:24 2011 New Revision: 220194 URL: http://svn.freebsd.org/changeset/base/220194 Log: Fix two SA refcount: - AH does not release the SA like in ESP/IPCOMP when handling EAGAIN - ipsec_process_done incorrectly release the SA. Reviewed by: vanhu MFC after: 1 week Modified: head/sys/netipsec/ipsec_output.c head/sys/netipsec/xform_ah.c Modified: head/sys/netipsec/ipsec_output.c ============================================================================== --- head/sys/netipsec/ipsec_output.c Thu Mar 31 13:06:51 2011 (r220193) +++ head/sys/netipsec/ipsec_output.c Thu Mar 31 13:14:24 2011 (r220194) @@ -247,7 +247,6 @@ ipsec_process_done(struct mbuf *m, struc panic("ipsec_process_done"); bad: m_freem(m); - KEY_FREESAV(&sav); return (error); } Modified: head/sys/netipsec/xform_ah.c ============================================================================== --- head/sys/netipsec/xform_ah.c Thu Mar 31 13:06:51 2011 (r220193) +++ head/sys/netipsec/xform_ah.c Thu Mar 31 13:14:24 2011 (r220194) @@ -785,6 +785,7 @@ ah_input_cb(struct cryptop *crp) sav->tdb_cryptoid = crp->crp_sid; if (crp->crp_etype == EAGAIN) { + KEY_FREESAV(&sav); error = crypto_dispatch(crp); return error; } From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 13:22:13 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0ABC81065674; Thu, 31 Mar 2011 13:22:13 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ED9F08FC16; Thu, 31 Mar 2011 13:22:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VDMCKE007519; Thu, 31 Mar 2011 13:22:12 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VDMCG4007514; Thu, 31 Mar 2011 13:22:12 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201103311322.p2VDMCG4007514@svn.freebsd.org> From: John Baldwin Date: Thu, 31 Mar 2011 13:22:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220195 - head/sys/dev/pci X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 13:22:13 -0000 Author: jhb Date: Thu Mar 31 13:22:12 2011 New Revision: 220195 URL: http://svn.freebsd.org/changeset/base/220195 Log: Explicitly track the state of all known BARs for each PCI device. The PCI bus driver will now remember the size of a BAR obtained during the initial bus scan and use that size when doing lazy resource allocation rather than resizing the BAR. The bus driver will now also report unallocated BARs to userland for display by 'pciconf -lb'. Psuedo-resources that are not BARs (such as the implicit I/O port resources for master/slave ATA controllers) will no longer be listed as BARs in 'pciconf -lb'. During resume, BARs are restored from their new saved state instead of having the raw registers saved and restored across resume. This also fixes restoring BARs at unusual loactions if said BAR has been allocated by a driver. Add a constant for the offset of the ROM BIOS BAR in PCI-PCI bridges and properly handle ROM BIOS BARs in PCI-PCI bridges. The PCI bus now also properly handles the lack of a ROM BIOS BAR in a PCI-Cardbus bridge. Tested by: jkim Modified: head/sys/dev/pci/pci.c head/sys/dev/pci/pci_user.c head/sys/dev/pci/pcireg.h head/sys/dev/pci/pcivar.h Modified: head/sys/dev/pci/pci.c ============================================================================== --- head/sys/dev/pci/pci.c Thu Mar 31 13:14:24 2011 (r220194) +++ head/sys/dev/pci/pci.c Thu Mar 31 13:22:12 2011 (r220195) @@ -69,6 +69,11 @@ __FBSDID("$FreeBSD$"); #include "pcib_if.h" #include "pci_if.h" +#define PCIR_IS_BIOS(cfg, reg) \ + (((cfg)->hdrtype == PCIM_HDRTYPE_NORMAL && reg == PCIR_BIOS) || \ + ((cfg)->hdrtype == PCIM_HDRTYPE_BRIDGE && reg == PCIR_BIOS_1)) + + static pci_addr_t pci_mapbase(uint64_t mapreg); static const char *pci_maptype(uint64_t mapreg); static int pci_mapsize(uint64_t testval); @@ -531,6 +536,7 @@ pci_read_device(device_t pcib, int d, in cfg->mfdev = (cfg->hdrtype & PCIM_MFDEV) != 0; cfg->hdrtype &= ~PCIM_MFDEV; + STAILQ_INIT(&cfg->maps); pci_fixancient(cfg); pci_hdrtypedata(pcib, b, s, f, cfg); @@ -2106,6 +2112,7 @@ int pci_freecfg(struct pci_devinfo *dinfo) { struct devlist *devlist_head; + struct pci_map *pm, *next; int i; devlist_head = &pci_devq; @@ -2119,6 +2126,9 @@ pci_freecfg(struct pci_devinfo *dinfo) free(dinfo->cfg.vpd.vpd_w[i].value, M_DEVBUF); free(dinfo->cfg.vpd.vpd_w, M_DEVBUF); } + STAILQ_FOREACH_SAFE(pm, &dinfo->cfg.maps, pm_link, next) { + free(pm, M_DEVBUF); + } STAILQ_REMOVE(devlist_head, dinfo, pci_devinfo, pci_links); free(dinfo, M_DEVBUF); @@ -2393,6 +2403,7 @@ pci_memen(device_t dev) static void pci_read_bar(device_t dev, int reg, pci_addr_t *mapp, pci_addr_t *testvalp) { + struct pci_devinfo *dinfo; pci_addr_t map, testval; int ln2range; uint16_t cmd; @@ -2402,7 +2413,8 @@ pci_read_bar(device_t dev, int reg, pci_ * memory BAR. Bit 0 is special and should not be set when * sizing the BAR. */ - if (reg == PCIR_BIOS) { + dinfo = device_get_ivars(dev); + if (PCIR_IS_BIOS(&dinfo->cfg, reg)) { map = pci_read_config(dev, reg, 4); pci_write_config(dev, reg, 0xfffffffe, 4); testval = pci_read_config(dev, reg, 4); @@ -2453,20 +2465,99 @@ pci_read_bar(device_t dev, int reg, pci_ } static void -pci_write_bar(device_t dev, int reg, pci_addr_t base) +pci_write_bar(device_t dev, struct pci_map *pm, pci_addr_t base) { - pci_addr_t map; + struct pci_devinfo *dinfo; int ln2range; - map = pci_read_config(dev, reg, 4); - - /* The device ROM BAR is always 32-bits. */ - if (reg == PCIR_BIOS) - return; - ln2range = pci_maprange(map); - pci_write_config(dev, reg, base, 4); + /* The device ROM BAR is always a 32-bit memory BAR. */ + dinfo = device_get_ivars(dev); + if (PCIR_IS_BIOS(&dinfo->cfg, pm->pm_reg)) + ln2range = 32; + else + ln2range = pci_maprange(pm->pm_value); + pci_write_config(dev, pm->pm_reg, base, 4); + if (ln2range == 64) + pci_write_config(dev, pm->pm_reg + 4, base >> 32, 4); + pm->pm_value = pci_read_config(dev, pm->pm_reg, 4); if (ln2range == 64) - pci_write_config(dev, reg + 4, base >> 32, 4); + pm->pm_value |= (pci_addr_t)pci_read_config(dev, pm->pm_reg + 4, 4) << 32; +} + +struct pci_map * +pci_find_bar(device_t dev, int reg) +{ + struct pci_devinfo *dinfo; + struct pci_map *pm; + + dinfo = device_get_ivars(dev); + STAILQ_FOREACH(pm, &dinfo->cfg.maps, pm_link) { + if (pm->pm_reg == reg) + return (pm); + } + return (NULL); +} + +int +pci_bar_enabled(device_t dev, struct pci_map *pm) +{ + struct pci_devinfo *dinfo; + uint16_t cmd; + + dinfo = device_get_ivars(dev); + if (PCIR_IS_BIOS(&dinfo->cfg, pm->pm_reg) && + !(pm->pm_value & PCIM_BIOS_ENABLE)) + return (0); + cmd = pci_read_config(dev, PCIR_COMMAND, 2); + if (PCIR_IS_BIOS(&dinfo->cfg, pm->pm_reg) || PCI_BAR_MEM(pm->pm_value)) + return ((cmd & PCIM_CMD_MEMEN) != 0); + else + return ((cmd & PCIM_CMD_PORTEN) != 0); +} + +static struct pci_map * +pci_add_bar(device_t dev, int reg, pci_addr_t value, pci_addr_t size) +{ + struct pci_devinfo *dinfo; + struct pci_map *pm, *prev; + + dinfo = device_get_ivars(dev); + pm = malloc(sizeof(*pm), M_DEVBUF, M_WAITOK | M_ZERO); + pm->pm_reg = reg; + pm->pm_value = value; + pm->pm_size = size; + STAILQ_FOREACH(prev, &dinfo->cfg.maps, pm_link) { + KASSERT(prev->pm_reg != pm->pm_reg, ("duplicate map %02x", + reg)); + if (STAILQ_NEXT(prev, pm_link) == NULL || + STAILQ_NEXT(prev, pm_link)->pm_reg > pm->pm_reg) + break; + } + if (prev != NULL) + STAILQ_INSERT_AFTER(&dinfo->cfg.maps, prev, pm, pm_link); + else + STAILQ_INSERT_TAIL(&dinfo->cfg.maps, pm, pm_link); + return (pm); +} + +static void +pci_restore_bars(device_t dev) +{ + struct pci_devinfo *dinfo; + struct pci_map *pm; + int ln2range; + + dinfo = device_get_ivars(dev); + STAILQ_FOREACH(pm, &dinfo->cfg.maps, pm_link) { + if (PCIR_IS_BIOS(&dinfo->cfg, pm->pm_reg)) + ln2range = 32; + else + ln2range = pci_maprange(pm->pm_value); + pci_write_config(dev, pm->pm_reg, pm->pm_value, 4); + if (ln2range == 64) + pci_write_config(dev, pm->pm_reg + 4, + pm->pm_value >> 32, 4); + } } /* @@ -2477,6 +2568,7 @@ static int pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl, int force, int prefetch) { + struct pci_map *pm; pci_addr_t base, map, testval; pci_addr_t start, end, count; int barlen, basezero, maprange, mapsize, type; @@ -2513,6 +2605,8 @@ pci_add_map(device_t bus, device_t dev, (type == SYS_RES_IOPORT && mapsize < 2)) return (barlen); + /* Save a record of this BAR. */ + pm = pci_add_bar(dev, reg, map, mapsize); if (bootverbose) { printf("\tmap[%02x]: type %s, range %2d, base %#jx, size %2d", reg, pci_maptype(map), maprange, (uintmax_t)base, mapsize); @@ -2600,7 +2694,7 @@ pci_add_map(device_t bus, device_t dev, start = 0; } else start = rman_get_start(res); - pci_write_bar(dev, reg, start); + pci_write_bar(dev, pm, start); return (barlen); } @@ -3735,31 +3829,41 @@ pci_reserve_map(device_t dev, device_t c struct resource_list *rl = &dinfo->resources; struct resource_list_entry *rle; struct resource *res; + struct pci_map *pm; pci_addr_t map, testval; int mapsize; - /* - * Weed out the bogons, and figure out how large the BAR/map - * is. Bars that read back 0 here are bogus and unimplemented. - * Note: atapci in legacy mode are special and handled elsewhere - * in the code. If you have a atapci device in legacy mode and - * it fails here, that other code is broken. - */ res = NULL; - pci_read_bar(child, *rid, &map, &testval); + pm = pci_find_bar(child, *rid); + if (pm != NULL) { + /* This is a BAR that we failed to allocate earlier. */ + mapsize = pm->pm_size; + map = pm->pm_value; + } else { + /* + * Weed out the bogons, and figure out how large the + * BAR/map is. BARs that read back 0 here are bogus + * and unimplemented. Note: atapci in legacy mode are + * special and handled elsewhere in the code. If you + * have a atapci device in legacy mode and it fails + * here, that other code is broken. + */ + pci_read_bar(child, *rid, &map, &testval); - /* - * Determine the size of the BAR and ignore BARs with a size - * of 0. Device ROM BARs use a different mask value. - */ - if (*rid == PCIR_BIOS) - mapsize = pci_romsize(testval); - else - mapsize = pci_mapsize(testval); - if (mapsize == 0) - goto out; + /* + * Determine the size of the BAR and ignore BARs with a size + * of 0. Device ROM BARs use a different mask value. + */ + if (PCIR_IS_BIOS(&dinfo->cfg, *rid)) + mapsize = pci_romsize(testval); + else + mapsize = pci_mapsize(testval); + if (mapsize == 0) + goto out; + pm = pci_add_bar(child, *rid, map, mapsize); + } - if (PCI_BAR_MEM(testval) || *rid == PCIR_BIOS) { + if (PCI_BAR_MEM(map) || PCIR_IS_BIOS(&dinfo->cfg, *rid)) { if (type != SYS_RES_MEMORY) { if (bootverbose) device_printf(dev, @@ -3789,12 +3893,12 @@ pci_reserve_map(device_t dev, device_t c count = (pci_addr_t)1 << mapsize; if (RF_ALIGNMENT(flags) < mapsize) flags = (flags & ~RF_ALIGNMENT_MASK) | RF_ALIGNMENT_LOG2(mapsize); - if (PCI_BAR_MEM(testval) && (testval & PCIM_BAR_MEM_PREFETCH)) + if (PCI_BAR_MEM(map) && (map & PCIM_BAR_MEM_PREFETCH)) flags |= RF_PREFETCHABLE; /* * Allocate enough resource, and then write back the - * appropriate bar for that resource. + * appropriate BAR for that resource. */ res = BUS_ALLOC_RESOURCE(device_get_parent(dev), child, type, rid, start, end, count, flags & ~RF_ACTIVE); @@ -3818,7 +3922,7 @@ pci_reserve_map(device_t dev, device_t c "Lazy allocation of %#lx bytes rid %#x type %d at %#lx\n", count, *rid, type, rman_get_start(res)); map = rman_get_start(res); - pci_write_bar(child, *rid, map); + pci_write_bar(child, pm, map); out:; return (res); } @@ -3879,6 +3983,7 @@ int pci_activate_resource(device_t dev, device_t child, int type, int rid, struct resource *r) { + struct pci_devinfo *dinfo; int error; error = bus_generic_activate_resource(dev, child, type, rid, r); @@ -3888,9 +3993,10 @@ pci_activate_resource(device_t dev, devi /* Enable decoding in the command register when activating BARs. */ if (device_get_parent(child) == dev) { /* Device ROMs need their decoding explicitly enabled. */ - if (rid == PCIR_BIOS) - pci_write_config(child, rid, rman_get_start(r) | - PCIM_BIOS_ENABLE, 4); + dinfo = device_get_ivars(child); + if (PCIR_IS_BIOS(&dinfo->cfg, rid)) + pci_write_bar(child, pci_find_bar(child, rid), + rman_get_start(r) | PCIM_BIOS_ENABLE); switch (type) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: @@ -3905,15 +4011,20 @@ int pci_deactivate_resource(device_t dev, device_t child, int type, int rid, struct resource *r) { + struct pci_devinfo *dinfo; int error; error = bus_generic_deactivate_resource(dev, child, type, rid, r); if (error) return (error); - /* Disable decoding for device ROMs. */ - if (rid == PCIR_BIOS) - pci_write_config(child, rid, rman_get_start(r), 4); + /* Disable decoding for device ROMs. */ + if (device_get_parent(child) == dev) { + dinfo = device_get_ivars(child); + if (PCIR_IS_BIOS(&dinfo->cfg, rid)) + pci_write_bar(child, pci_find_bar(child, rid), + rman_get_start(r)); + } return (0); } @@ -3991,7 +4102,7 @@ pci_delete_resource(device_t dev, device switch (type) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: - pci_write_bar(child, rid, 0); + pci_write_bar(child, pci_find_bar(child, rid), 0); break; } #endif @@ -4090,7 +4201,6 @@ pci_modevent(module_t mod, int what, voi void pci_cfg_restore(device_t dev, struct pci_devinfo *dinfo) { - int i; /* * Only do header type 0 devices. Type 1 devices are bridges, @@ -4112,9 +4222,7 @@ pci_cfg_restore(device_t dev, struct pci */ if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) pci_set_powerstate(dev, PCI_POWERSTATE_D0); - for (i = 0; i < dinfo->cfg.nummaps; i++) - pci_write_config(dev, PCIR_BAR(i), dinfo->cfg.bar[i], 4); - pci_write_config(dev, PCIR_BIOS, dinfo->cfg.bios, 4); + pci_restore_bars(dev); pci_write_config(dev, PCIR_COMMAND, dinfo->cfg.cmdreg, 2); pci_write_config(dev, PCIR_INTLINE, dinfo->cfg.intline, 1); pci_write_config(dev, PCIR_INTPIN, dinfo->cfg.intpin, 1); @@ -4135,7 +4243,6 @@ pci_cfg_restore(device_t dev, struct pci void pci_cfg_save(device_t dev, struct pci_devinfo *dinfo, int setstate) { - int i; uint32_t cls; int ps; @@ -4148,9 +4255,6 @@ pci_cfg_save(device_t dev, struct pci_de */ if ((dinfo->cfg.hdrtype & PCIM_HDRTYPE) != PCIM_HDRTYPE_NORMAL) return; - for (i = 0; i < dinfo->cfg.nummaps; i++) - dinfo->cfg.bar[i] = pci_read_config(dev, PCIR_BAR(i), 4); - dinfo->cfg.bios = pci_read_config(dev, PCIR_BIOS, 4); /* * Some drivers apparently write to these registers w/o updating our Modified: head/sys/dev/pci/pci_user.c ============================================================================== --- head/sys/dev/pci/pci_user.c Thu Mar 31 13:14:24 2011 (r220194) +++ head/sys/dev/pci/pci_user.c Thu Mar 31 13:22:12 2011 (r220195) @@ -309,8 +309,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, struct pci_io *io; struct pci_bar_io *bio; struct pci_match_conf *pattern_buf; - struct resource_list_entry *rle; - uint32_t value; + struct pci_map *pm; size_t confsz, iolen, pbufsz; int error, ionum, i, num_patterns; #ifdef PRE7_COMPAT @@ -685,54 +684,14 @@ getconfexit: error = ENODEV; break; } - dinfo = device_get_ivars(pcidev); - - /* - * Look for a resource list entry matching the requested BAR. - * - * XXX: This will not find BARs that are not initialized, but - * maybe that is ok? - */ - rle = resource_list_find(&dinfo->resources, SYS_RES_MEMORY, - bio->pbi_reg); - if (rle == NULL) - rle = resource_list_find(&dinfo->resources, - SYS_RES_IOPORT, bio->pbi_reg); - if (rle == NULL || rle->res == NULL) { + pm = pci_find_bar(pcidev, bio->pbi_reg); + if (pm == NULL) { error = EINVAL; break; } - - /* - * Ok, we have a resource for this BAR. Read the lower - * 32 bits to get any flags. - */ - value = pci_read_config(pcidev, bio->pbi_reg, 4); - if (PCI_BAR_MEM(value)) { - if (rle->type != SYS_RES_MEMORY) { - error = EINVAL; - break; - } - value &= ~PCIM_BAR_MEM_BASE; - } else { - if (rle->type != SYS_RES_IOPORT) { - error = EINVAL; - break; - } - value &= ~PCIM_BAR_IO_BASE; - } - bio->pbi_base = rman_get_start(rle->res) | value; - bio->pbi_length = rman_get_size(rle->res); - - /* - * Check the command register to determine if this BAR - * is enabled. - */ - value = pci_read_config(pcidev, PCIR_COMMAND, 2); - if (rle->type == SYS_RES_MEMORY) - bio->pbi_enabled = (value & PCIM_CMD_MEMEN) != 0; - else - bio->pbi_enabled = (value & PCIM_CMD_PORTEN) != 0; + bio->pbi_base = pm->pm_value; + bio->pbi_length = (pci_addr_t)1 << pm->pm_size; + bio->pbi_enabled = pci_bar_enabled(pcidev, pm); error = 0; break; case PCIOCATTACHED: Modified: head/sys/dev/pci/pcireg.h ============================================================================== --- head/sys/dev/pci/pcireg.h Thu Mar 31 13:14:24 2011 (r220194) +++ head/sys/dev/pci/pcireg.h Thu Mar 31 13:22:12 2011 (r220195) @@ -212,6 +212,7 @@ #define PCIM_BRPM_64 0x1 #define PCIM_BRPM_MASK 0xf +#define PCIR_BIOS_1 0x38 #define PCIR_BRIDGECTL_1 0x3e /* config registers for header type 2 (CardBus) devices */ Modified: head/sys/dev/pci/pcivar.h ============================================================================== --- head/sys/dev/pci/pcivar.h Thu Mar 31 13:14:24 2011 (r220194) +++ head/sys/dev/pci/pcivar.h Thu Mar 31 13:22:12 2011 (r220195) @@ -46,7 +46,14 @@ struct pcicfg_pp { uint8_t pp_bse; /* conf. space addr. of PM BSE reg */ uint8_t pp_data; /* conf. space addr. of PM data reg */ }; - + +struct pci_map { + pci_addr_t pm_value; /* Raw BAR value */ + pci_addr_t pm_size; + uint8_t pm_reg; + STAILQ_ENTRY(pci_map) pm_link; +}; + struct vpd_readonly { char keyword[2]; char *value; @@ -120,8 +127,7 @@ struct pcicfg_ht { typedef struct pcicfg { struct device *dev; /* device which owns this */ - uint32_t bar[PCI_MAXMAPS_0]; /* BARs */ - uint32_t bios; /* BIOS mapping */ + STAILQ_HEAD(, pci_map) maps; /* BARs */ uint16_t subvendor; /* card vendor ID */ uint16_t subdevice; /* card device ID, assigned by card vendor */ @@ -477,4 +483,7 @@ STAILQ_HEAD(devlist, pci_devinfo); extern struct devlist pci_devq; extern uint32_t pci_generation; +struct pci_map *pci_find_bar(device_t dev, int reg); +int pci_bar_enabled(device_t dev, struct pci_map *pm); + #endif /* _PCIVAR_H_ */ From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 13:59:48 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4A5D2106566B; Thu, 31 Mar 2011 13:59:48 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3AC1D8FC16; Thu, 31 Mar 2011 13:59:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VDxm7P008486; Thu, 31 Mar 2011 13:59:48 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VDxmOI008483; Thu, 31 Mar 2011 13:59:48 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201103311359.p2VDxmOI008483@svn.freebsd.org> From: Fabien Thomas Date: Thu, 31 Mar 2011 13:59:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220198 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 13:59:48 -0000 Author: fabient Date: Thu Mar 31 13:59:47 2011 New Revision: 220198 URL: http://svn.freebsd.org/changeset/base/220198 Log: Clearing the flag when preempting will let the preempted thread run too much time. This can finish in a scheduler deadlock with ping-pong between two threads. One sample of this is: - device lapic (to have a preemption point on critical_exit()) - options DEVICE_POLLING with HZ>1499 (to have lapic freq = hardclock freq) - running a cpu intensive task (that does not enter the kernel) - only one CPU on SMP or no SMP. As requested by jhb@ 4BSD have received the same type of fix instead of propagating the flag to the new thread. Reviewed by: jhb, jeff MFC after: 1 month Modified: head/sys/kern/sched_4bsd.c head/sys/kern/sched_ule.c Modified: head/sys/kern/sched_4bsd.c ============================================================================== --- head/sys/kern/sched_4bsd.c Thu Mar 31 13:36:31 2011 (r220197) +++ head/sys/kern/sched_4bsd.c Thu Mar 31 13:59:47 2011 (r220198) @@ -940,13 +940,9 @@ sched_switch(struct thread *td, struct t if ((td->td_flags & TDF_NOLOAD) == 0) sched_load_rem(); - if (newtd) { - MPASS(newtd->td_lock == &sched_lock); - newtd->td_flags |= (td->td_flags & TDF_NEEDRESCHED); - } - td->td_lastcpu = td->td_oncpu; - td->td_flags &= ~TDF_NEEDRESCHED; + if (!(flags & SW_PREEMPT)) + td->td_flags &= ~TDF_NEEDRESCHED; td->td_owepreempt = 0; td->td_oncpu = NOCPU; Modified: head/sys/kern/sched_ule.c ============================================================================== --- head/sys/kern/sched_ule.c Thu Mar 31 13:36:31 2011 (r220197) +++ head/sys/kern/sched_ule.c Thu Mar 31 13:59:47 2011 (r220198) @@ -1783,7 +1783,8 @@ sched_switch(struct thread *td, struct t ts->ts_rltick = ticks; td->td_lastcpu = td->td_oncpu; td->td_oncpu = NOCPU; - td->td_flags &= ~TDF_NEEDRESCHED; + if (!(flags & SW_PREEMPT)) + td->td_flags &= ~TDF_NEEDRESCHED; td->td_owepreempt = 0; tdq->tdq_switchcnt++; /* From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 14:33:27 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CAA311065673; Thu, 31 Mar 2011 14:33:27 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BAEC68FC08; Thu, 31 Mar 2011 14:33:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VEXRZK009299; Thu, 31 Mar 2011 14:33:27 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VEXRHq009297; Thu, 31 Mar 2011 14:33:27 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201103311433.p2VEXRHq009297@svn.freebsd.org> From: Ed Maste Date: Thu, 31 Mar 2011 14:33:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220200 - head/usr.sbin/pkg_install X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 14:33:27 -0000 Author: emaste Date: Thu Mar 31 14:33:27 2011 New Revision: 220200 URL: http://svn.freebsd.org/changeset/base/220200 Log: Remove $Log$ keyword and associated history, which can cause annoyance in diffs in some cases. Revision control tools have a history command to obtain this information. Modified: head/usr.sbin/pkg_install/tkpkg Modified: head/usr.sbin/pkg_install/tkpkg ============================================================================== --- head/usr.sbin/pkg_install/tkpkg Thu Mar 31 14:16:56 2011 (r220199) +++ head/usr.sbin/pkg_install/tkpkg Thu Mar 31 14:33:27 2011 (r220200) @@ -1,31 +1,6 @@ #!/usr/local/bin/wish -f #$FreeBSD$ # -#$Log: tkpkg,v $ -#Revision 1.2 1994/12/06 00:51:21 jkh -#Many of John T. Kohl's patches from NetBSD. Thanks, John! -#Submitted by: jkohl -# -# Revision 1.1 1994/01/06 08:16:20 jkh -# Cleaning house. -# -# Revision 1.1 1993/09/04 17:06:09 jkh -# Added Rich's wish front-end. -# -# Revision 1.6 1993/09/03 23:37:22 rich -# warn user if no tar archives are found in the current directory. -# removed the revision string from the lower text frame. -# -# Revision 1.5 1993/09/03 15:48:04 rich -# glob for .tar.gz, .tar.z and .tar.Z looking for archives -# -# Revision 1.4 1993/08/28 15:53:59 rich -# added version and date info to lower text window. -# -# Revision 1.3 1993/08/28 15:47:12 rich -# filtered out ^Ls in pkg_* output. -# -# set pkgname "" wm title . "Package Installation" #-------------------------------------------------------------- From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 14:35:33 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D1411065670; Thu, 31 Mar 2011 14:35:33 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4D9EE8FC25; Thu, 31 Mar 2011 14:35:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VEZXx5009386; Thu, 31 Mar 2011 14:35:33 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VEZXmF009384; Thu, 31 Mar 2011 14:35:33 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201103311435.p2VEZXmF009384@svn.freebsd.org> From: Ed Maste Date: Thu, 31 Mar 2011 14:35:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220201 - head/usr.bin/compress/doc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 14:35:33 -0000 Author: emaste Date: Thu Mar 31 14:35:33 2011 New Revision: 220201 URL: http://svn.freebsd.org/changeset/base/220201 Log: Remove $Log$ keyword, which can cause annoyance in diffs in some cases. Revision control tools have a history command to obtain this information. Modified: head/usr.bin/compress/doc/revision.log Modified: head/usr.bin/compress/doc/revision.log ============================================================================== --- head/usr.bin/compress/doc/revision.log Thu Mar 31 14:33:27 2011 (r220200) +++ head/usr.bin/compress/doc/revision.log Thu Mar 31 14:35:33 2011 (r220201) @@ -2,7 +2,7 @@ /* * $Header: compress.c,v 4.0 85/07/30 12:50:00 joe Release $ - * $Log: compress.c,v $ + * * Revision 4.0 85/07/30 12:50:00 joe * Removed ferror() calls in output routine on every output except first. * Prepared for release to the world. From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 15:10:41 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E1684106566B; Thu, 31 Mar 2011 15:10:41 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D20888FC0A; Thu, 31 Mar 2011 15:10:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VFAfxp010177; Thu, 31 Mar 2011 15:10:41 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VFAfUj010175; Thu, 31 Mar 2011 15:10:41 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201103311510.p2VFAfUj010175@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 31 Mar 2011 15:10:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220203 - head/sys/netinet/ipfw X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 15:10:42 -0000 Author: ae Date: Thu Mar 31 15:10:41 2011 New Revision: 220203 URL: http://svn.freebsd.org/changeset/base/220203 Log: Fix a memory leak. Memory that is allocated for schedulers hash table was not freed. PR: kern/156083 MFC after: 1 week Modified: head/sys/netinet/ipfw/ip_dummynet.c Modified: head/sys/netinet/ipfw/ip_dummynet.c ============================================================================== --- head/sys/netinet/ipfw/ip_dummynet.c Thu Mar 31 14:44:00 2011 (r220202) +++ head/sys/netinet/ipfw/ip_dummynet.c Thu Mar 31 15:10:41 2011 (r220203) @@ -748,9 +748,10 @@ schk_delete_cb(void *obj, void *arg) #endif fsk_detach_list(&s->fsk_list, arg ? DN_DESTROY : 0); /* no more flowset pointing to us now */ - if (s->sch.flags & DN_HAVE_MASK) + if (s->sch.flags & DN_HAVE_MASK) { dn_ht_scan(s->siht, si_destroy, NULL); - else if (s->siht) + dn_ht_free(s->siht, 0); + } else if (s->siht) si_destroy(s->siht, NULL); if (s->profile) { free(s->profile, M_DUMMYNET); From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 15:11:12 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C3721065781; Thu, 31 Mar 2011 15:11:12 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8CD998FC08; Thu, 31 Mar 2011 15:11:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VFBCFF010239; Thu, 31 Mar 2011 15:11:12 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VFBCDo010237; Thu, 31 Mar 2011 15:11:12 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201103311511.p2VFBCDo010237@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 31 Mar 2011 15:11:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220204 - head/sys/netinet/ipfw X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 15:11:12 -0000 Author: ae Date: Thu Mar 31 15:11:12 2011 New Revision: 220204 URL: http://svn.freebsd.org/changeset/base/220204 Log: Fix malloc types. MFC after: 1 week Modified: head/sys/netinet/ipfw/ip_dn_glue.c Modified: head/sys/netinet/ipfw/ip_dn_glue.c ============================================================================== --- head/sys/netinet/ipfw/ip_dn_glue.c Thu Mar 31 15:10:41 2011 (r220203) +++ head/sys/netinet/ipfw/ip_dn_glue.c Thu Mar 31 15:11:12 2011 (r220204) @@ -807,7 +807,7 @@ ip_dummynet_compat(struct sockopt *sopt) if (error) break; error = dn_compat_del(v); - free(v, M_DUMMYNET); + free(v, M_TEMP); break; case IP_DUMMYNET_CONFIGURE: @@ -816,7 +816,7 @@ ip_dummynet_compat(struct sockopt *sopt) if (error) break; error = dn_compat_configure(v); - free(v, M_DUMMYNET); + free(v, M_TEMP); break; case IP_DUMMYNET_GET: { From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 15:12:40 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A1DFD106564A; Thu, 31 Mar 2011 15:12:40 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 923F88FC1C; Thu, 31 Mar 2011 15:12:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VFCedl010303; Thu, 31 Mar 2011 15:12:40 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VFCeEn010300; Thu, 31 Mar 2011 15:12:40 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201103311512.p2VFCeEn010300@svn.freebsd.org> From: Ed Maste Date: Thu, 31 Mar 2011 15:12:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220205 - head/share/examples/kld/firmware/fwimage X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 15:12:40 -0000 Author: emaste Date: Thu Mar 31 15:12:40 2011 New Revision: 220205 URL: http://svn.freebsd.org/changeset/base/220205 Log: Avoid having a binary file in our source tree and instead create it at build time, to avoid possible grief maintaining FreeBSD source in alternative version control tools. Added: head/share/examples/kld/firmware/fwimage/firmware.img.in - copied, changed from r220153, head/share/examples/kld/firmware/fwimage/firmware.img Deleted: head/share/examples/kld/firmware/fwimage/firmware.img Modified: head/share/examples/kld/firmware/fwimage/Makefile Modified: head/share/examples/kld/firmware/fwimage/Makefile ============================================================================== --- head/share/examples/kld/firmware/fwimage/Makefile Thu Mar 31 15:11:12 2011 (r220204) +++ head/share/examples/kld/firmware/fwimage/Makefile Thu Mar 31 15:12:40 2011 (r220205) @@ -3,4 +3,8 @@ KMOD= beastie FIRMWS= firmware.img:beastie +firmware.img: firmware.img.in + cp ${.ALLSRC} ${.TARGET} + printf '\0\0\0\0\0' >> ${.TARGET} + .include Copied and modified: head/share/examples/kld/firmware/fwimage/firmware.img.in (from r220153, head/share/examples/kld/firmware/fwimage/firmware.img) ============================================================================== Files head/share/examples/kld/firmware/fwimage/firmware.img Wed Mar 30 01:19:00 2011 (r220153, copy source) and head/share/examples/kld/firmware/fwimage/firmware.img.in Thu Mar 31 15:12:40 2011 (r220205) differ From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 15:23:32 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 76AB71065674; Thu, 31 Mar 2011 15:23:32 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6633D8FC12; Thu, 31 Mar 2011 15:23:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VFNWPk010562; Thu, 31 Mar 2011 15:23:32 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VFNWNf010554; Thu, 31 Mar 2011 15:23:32 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201103311523.p2VFNWNf010554@svn.freebsd.org> From: Fabien Thomas Date: Thu, 31 Mar 2011 15:23:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220206 - head/sys/netipsec X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 15:23:32 -0000 Author: fabient Date: Thu Mar 31 15:23:32 2011 New Revision: 220206 URL: http://svn.freebsd.org/changeset/base/220206 Log: Optimisation in IPSEC(4): - Remove contention on ISR during the crypto operation by using rwlock(9). - Remove a second lookup of the SA in the callback. Gain on 6 cores CPU with SHA1/AES128 can be up to 30%. Reviewed by: vanhu MFC after: 1 month Modified: head/sys/netipsec/ipsec.h head/sys/netipsec/key.c head/sys/netipsec/key.h head/sys/netipsec/xform.h head/sys/netipsec/xform_ah.c head/sys/netipsec/xform_esp.c head/sys/netipsec/xform_ipcomp.c Modified: head/sys/netipsec/ipsec.h ============================================================================== --- head/sys/netipsec/ipsec.h Thu Mar 31 15:12:40 2011 (r220205) +++ head/sys/netipsec/ipsec.h Thu Mar 31 15:23:32 2011 (r220206) @@ -123,7 +123,7 @@ struct ipsecrequest { struct secasvar *sav; /* place holder of SA for use */ struct secpolicy *sp; /* back pointer to SP */ - struct mtx lock; /* to interlock updates */ + struct rwlock lock; /* to interlock updates */ }; /* @@ -132,11 +132,15 @@ struct ipsecrequest { * hard it is to remove this... */ #define IPSECREQUEST_LOCK_INIT(_isr) \ - mtx_init(&(_isr)->lock, "ipsec request", NULL, MTX_DEF | MTX_RECURSE) -#define IPSECREQUEST_LOCK(_isr) mtx_lock(&(_isr)->lock) -#define IPSECREQUEST_UNLOCK(_isr) mtx_unlock(&(_isr)->lock) -#define IPSECREQUEST_LOCK_DESTROY(_isr) mtx_destroy(&(_isr)->lock) -#define IPSECREQUEST_LOCK_ASSERT(_isr) mtx_assert(&(_isr)->lock, MA_OWNED) + rw_init_flags(&(_isr)->lock, "ipsec request", RW_RECURSE) +#define IPSECREQUEST_LOCK(_isr) rw_rlock(&(_isr)->lock) +#define IPSECREQUEST_UNLOCK(_isr) rw_runlock(&(_isr)->lock) +#define IPSECREQUEST_WLOCK(_isr) rw_wlock(&(_isr)->lock) +#define IPSECREQUEST_WUNLOCK(_isr) rw_wunlock(&(_isr)->lock) +#define IPSECREQUEST_UPGRADE(_isr) rw_try_upgrade(&(_isr)->lock) +#define IPSECREQUEST_DOWNGRADE(_isr) rw_downgrade(&(_isr)->lock) +#define IPSECREQUEST_LOCK_DESTROY(_isr) rw_destroy(&(_isr)->lock) +#define IPSECREQUEST_LOCK_ASSERT(_isr) rw_assert(&(_isr)->lock, RA_LOCKED) /* security policy in PCB */ struct inpcbpolicy { Modified: head/sys/netipsec/key.c ============================================================================== --- head/sys/netipsec/key.c Thu Mar 31 15:12:40 2011 (r220205) +++ head/sys/netipsec/key.c Thu Mar 31 15:23:32 2011 (r220206) @@ -809,6 +809,7 @@ key_checkrequest(struct ipsecrequest *is { u_int level; int error; + struct secasvar *sav; IPSEC_ASSERT(isr != NULL, ("null isr")); IPSEC_ASSERT(saidx != NULL, ("null saidx")); @@ -826,45 +827,31 @@ key_checkrequest(struct ipsecrequest *is /* get current level */ level = ipsec_get_reqlevel(isr); -#if 0 - /* - * We do allocate new SA only if the state of SA in the holder is - * SADB_SASTATE_DEAD. The SA for outbound must be the oldest. - */ - if (isr->sav != NULL) { - if (isr->sav->sah == NULL) - panic("%s: sah is null.\n", __func__); - if (isr->sav == (struct secasvar *)LIST_FIRST( - &isr->sav->sah->savtree[SADB_SASTATE_DEAD])) { - KEY_FREESAV(&isr->sav); - isr->sav = NULL; - } - } -#else + /* - * we free any SA stashed in the IPsec request because a different + * We check new SA in the IPsec request because a different * SA may be involved each time this request is checked, either * because new SAs are being configured, or this request is * associated with an unconnected datagram socket, or this request * is associated with a system default policy. * - * The operation may have negative impact to performance. We may - * want to check cached SA carefully, rather than picking new SA - * every time. - */ - if (isr->sav != NULL) { - KEY_FREESAV(&isr->sav); - isr->sav = NULL; - } -#endif - - /* - * new SA allocation if no SA found. * key_allocsa_policy should allocate the oldest SA available. * See key_do_allocsa_policy(), and draft-jenkins-ipsec-rekeying-03.txt. */ - if (isr->sav == NULL) - isr->sav = key_allocsa_policy(saidx); + sav = key_allocsa_policy(saidx); + if (sav != isr->sav) { + /* SA need to be updated. */ + if (!IPSECREQUEST_UPGRADE(isr)) { + /* Kick everyone off. */ + IPSECREQUEST_UNLOCK(isr); + IPSECREQUEST_WLOCK(isr); + } + if (isr->sav != NULL) + KEY_FREESAV(&isr->sav); + isr->sav = sav; + IPSECREQUEST_DOWNGRADE(isr); + } else if (sav != NULL) + KEY_FREESAV(&sav); /* When there is SA. */ if (isr->sav != NULL) { @@ -1240,6 +1227,16 @@ key_freesp_so(struct secpolicy **sp) KEY_FREESP(sp); } +void +key_addrefsa(struct secasvar *sav, const char* where, int tag) +{ + + IPSEC_ASSERT(sav != NULL, ("null sav")); + IPSEC_ASSERT(sav->refcnt > 0, ("refcount must exist")); + + sa_addref(sav); +} + /* * Must be called after calling key_allocsa(). * This function is called by key_freesp() to free some SA allocated Modified: head/sys/netipsec/key.h ============================================================================== --- head/sys/netipsec/key.h Thu Mar 31 15:12:40 2011 (r220205) +++ head/sys/netipsec/key.h Thu Mar 31 15:23:32 2011 (r220206) @@ -76,10 +76,13 @@ extern void _key_freesp(struct secpolicy extern struct secasvar *key_allocsa(union sockaddr_union *, u_int, u_int32_t, const char*, int); +extern void key_addrefsa(struct secasvar *, const char*, int); extern void key_freesav(struct secasvar **, const char*, int); #define KEY_ALLOCSA(dst, proto, spi) \ key_allocsa(dst, proto, spi, __FILE__, __LINE__) +#define KEY_ADDREFSA(sav) \ + key_addrefsa(sav, __FILE__, __LINE__) #define KEY_FREESAV(psav) \ key_freesav(psav, __FILE__, __LINE__) Modified: head/sys/netipsec/xform.h ============================================================================== --- head/sys/netipsec/xform.h Thu Mar 31 15:12:40 2011 (r220205) +++ head/sys/netipsec/xform.h Thu Mar 31 15:23:32 2011 (r220206) @@ -75,6 +75,7 @@ struct tdb_crypto { int tc_protoff; /* current protocol offset */ int tc_skip; /* data offset */ caddr_t tc_ptr; /* associated crypto data */ + struct secasvar *tc_sav; /* related SA */ }; struct secasvar; Modified: head/sys/netipsec/xform_ah.c ============================================================================== --- head/sys/netipsec/xform_ah.c Thu Mar 31 15:12:40 2011 (r220205) +++ head/sys/netipsec/xform_ah.c Thu Mar 31 15:23:32 2011 (r220206) @@ -715,6 +715,8 @@ ah_input(struct mbuf *m, struct secasvar tc->tc_protoff = protoff; tc->tc_skip = skip; tc->tc_ptr = (caddr_t) mtag; /* Save the mtag we've identified. */ + KEY_ADDREFSA(sav); + tc->tc_sav = sav; if (mtag == NULL) return crypto_dispatch(crp); @@ -764,13 +766,8 @@ ah_input_cb(struct cryptop *crp) mtag = (struct m_tag *) tc->tc_ptr; m = (struct mbuf *) crp->crp_buf; - sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi); - if (sav == NULL) { - V_ahstat.ahs_notdb++; - DPRINTF(("%s: SA expired while in crypto\n", __func__)); - error = ENOBUFS; /*XXX*/ - goto bad; - } + sav = tc->tc_sav; + IPSEC_ASSERT(sav != NULL, ("null SA!")); saidx = &sav->sah->saidx; IPSEC_ASSERT(saidx->dst.sa.sa_family == AF_INET || @@ -785,7 +782,6 @@ ah_input_cb(struct cryptop *crp) sav->tdb_cryptoid = crp->crp_sid; if (crp->crp_etype == EAGAIN) { - KEY_FREESAV(&sav); error = crypto_dispatch(crp); return error; } @@ -1111,6 +1107,8 @@ ah_output( /* These are passed as-is to the callback. */ tc->tc_isr = isr; + KEY_ADDREFSA(sav); + tc->tc_sav = sav; tc->tc_spi = sav->spi; tc->tc_dst = sav->sah->saidx.dst; tc->tc_proto = sav->sah->saidx.proto; @@ -1147,14 +1145,14 @@ ah_output_cb(struct cryptop *crp) isr = tc->tc_isr; IPSECREQUEST_LOCK(isr); - sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi); - if (sav == NULL) { + sav = tc->tc_sav; + /* With the isr lock released SA pointer can be updated. */ + if (sav != isr->sav) { V_ahstat.ahs_notdb++; DPRINTF(("%s: SA expired while in crypto\n", __func__)); error = ENOBUFS; /*XXX*/ goto bad; } - IPSEC_ASSERT(isr->sav == sav, ("SA changed\n")); /* Check for crypto errors. */ if (crp->crp_etype) { @@ -1162,7 +1160,6 @@ ah_output_cb(struct cryptop *crp) sav->tdb_cryptoid = crp->crp_sid; if (crp->crp_etype == EAGAIN) { - KEY_FREESAV(&sav); IPSECREQUEST_UNLOCK(isr); error = crypto_dispatch(crp); return error; Modified: head/sys/netipsec/xform_esp.c ============================================================================== --- head/sys/netipsec/xform_esp.c Thu Mar 31 15:12:40 2011 (r220205) +++ head/sys/netipsec/xform_esp.c Thu Mar 31 15:23:32 2011 (r220206) @@ -429,6 +429,8 @@ esp_input(struct mbuf *m, struct secasva tc->tc_proto = sav->sah->saidx.proto; tc->tc_protoff = protoff; tc->tc_skip = skip; + KEY_ADDREFSA(sav); + tc->tc_sav = sav; /* Decryption descriptor */ if (espx) { @@ -490,15 +492,8 @@ esp_input_cb(struct cryptop *crp) mtag = (struct m_tag *) tc->tc_ptr; m = (struct mbuf *) crp->crp_buf; - sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi); - if (sav == NULL) { - V_espstat.esps_notdb++; - DPRINTF(("%s: SA gone during crypto (SA %s/%08lx proto %u)\n", - __func__, ipsec_address(&tc->tc_dst), - (u_long) ntohl(tc->tc_spi), tc->tc_proto)); - error = ENOBUFS; /*XXX*/ - goto bad; - } + sav = tc->tc_sav; + IPSEC_ASSERT(sav != NULL, ("null SA!")); saidx = &sav->sah->saidx; IPSEC_ASSERT(saidx->dst.sa.sa_family == AF_INET || @@ -515,7 +510,6 @@ esp_input_cb(struct cryptop *crp) sav->tdb_cryptoid = crp->crp_sid; if (crp->crp_etype == EAGAIN) { - KEY_FREESAV(&sav); error = crypto_dispatch(crp); return error; } @@ -883,6 +877,8 @@ esp_output( /* Callback parameters */ tc->tc_isr = isr; + KEY_ADDREFSA(sav); + tc->tc_sav = sav; tc->tc_spi = sav->spi; tc->tc_dst = saidx->dst; tc->tc_proto = saidx->proto; @@ -932,8 +928,9 @@ esp_output_cb(struct cryptop *crp) isr = tc->tc_isr; IPSECREQUEST_LOCK(isr); - sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi); - if (sav == NULL) { + sav = tc->tc_sav; + /* With the isr lock released SA pointer can be updated. */ + if (sav != isr->sav) { V_espstat.esps_notdb++; DPRINTF(("%s: SA gone during crypto (SA %s/%08lx proto %u)\n", __func__, ipsec_address(&tc->tc_dst), @@ -941,8 +938,6 @@ esp_output_cb(struct cryptop *crp) error = ENOBUFS; /*XXX*/ goto bad; } - IPSEC_ASSERT(isr->sav == sav, - ("SA changed was %p now %p\n", isr->sav, sav)); /* Check for crypto errors. */ if (crp->crp_etype) { @@ -951,7 +946,6 @@ esp_output_cb(struct cryptop *crp) sav->tdb_cryptoid = crp->crp_sid; if (crp->crp_etype == EAGAIN) { - KEY_FREESAV(&sav); IPSECREQUEST_UNLOCK(isr); error = crypto_dispatch(crp); return error; Modified: head/sys/netipsec/xform_ipcomp.c ============================================================================== --- head/sys/netipsec/xform_ipcomp.c Thu Mar 31 15:12:40 2011 (r220205) +++ head/sys/netipsec/xform_ipcomp.c Thu Mar 31 15:23:32 2011 (r220206) @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -185,6 +186,8 @@ ipcomp_input(struct mbuf *m, struct seca tc->tc_proto = sav->sah->saidx.proto; tc->tc_protoff = protoff; tc->tc_skip = skip; + KEY_ADDREFSA(sav); + tc->tc_sav = sav; return crypto_dispatch(crp); } @@ -228,13 +231,8 @@ ipcomp_input_cb(struct cryptop *crp) mtag = (struct mtag *) tc->tc_ptr; m = (struct mbuf *) crp->crp_buf; - sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi); - if (sav == NULL) { - V_ipcompstat.ipcomps_notdb++; - DPRINTF(("%s: SA expired while in crypto\n", __func__)); - error = ENOBUFS; /*XXX*/ - goto bad; - } + sav = tc->tc_sav; + IPSEC_ASSERT(sav != NULL, ("null SA!")); saidx = &sav->sah->saidx; IPSEC_ASSERT(saidx->dst.sa.sa_family == AF_INET || @@ -248,7 +246,6 @@ ipcomp_input_cb(struct cryptop *crp) sav->tdb_cryptoid = crp->crp_sid; if (crp->crp_etype == EAGAIN) { - KEY_FREESAV(&sav); return crypto_dispatch(crp); } V_ipcompstat.ipcomps_noxform++; @@ -431,6 +428,8 @@ ipcomp_output( } tc->tc_isr = isr; + KEY_ADDREFSA(sav); + tc->tc_sav = sav; tc->tc_spi = sav->spi; tc->tc_dst = sav->sah->saidx.dst; tc->tc_proto = sav->sah->saidx.proto; @@ -471,14 +470,14 @@ ipcomp_output_cb(struct cryptop *crp) isr = tc->tc_isr; IPSECREQUEST_LOCK(isr); - sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi); - if (sav == NULL) { + sav = tc->tc_sav; + /* With the isr lock released SA pointer can be updated. */ + if (sav != isr->sav) { V_ipcompstat.ipcomps_notdb++; DPRINTF(("%s: SA expired while in crypto\n", __func__)); error = ENOBUFS; /*XXX*/ goto bad; } - IPSEC_ASSERT(isr->sav == sav, ("SA changed\n")); /* Check for crypto errors */ if (crp->crp_etype) { @@ -487,7 +486,6 @@ ipcomp_output_cb(struct cryptop *crp) sav->tdb_cryptoid = crp->crp_sid; if (crp->crp_etype == EAGAIN) { - KEY_FREESAV(&sav); IPSECREQUEST_UNLOCK(isr); return crypto_dispatch(crp); } From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 15:40:14 2011 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 06A88106566B; Thu, 31 Mar 2011 15:40:14 +0000 (UTC) (envelope-from rrs@lakerest.net) Received: from lakerest.net (unknown [IPv6:2001:240:585:2:213:d4ff:fef3:2d8d]) by mx1.freebsd.org (Postfix) with ESMTP id 8A7A48FC13; Thu, 31 Mar 2011 15:40:13 +0000 (UTC) Received: from dhcp-54bc.meeting.ietf.org (dhcp-54bc.meeting.ietf.org [130.129.84.188]) (authenticated bits=0) by lakerest.net (8.14.4/8.14.3) with ESMTP id p2VFe9FU061476 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Thu, 31 Mar 2011 11:40:11 -0400 (EDT) (envelope-from rrs@lakerest.net) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Randall Stewart In-Reply-To: <201103291401.03565.jhb@freebsd.org> Date: Thu, 31 Mar 2011 11:40:08 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: <2BE17525-83AA-4255-B191-3429B5FF6F5E@lakerest.net> References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> To: John Baldwin X-Mailer: Apple Mail (2.1084) Cc: svn-src-head@FreeBSD.org, Daniel Eischen , svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r217592 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 15:40:14 -0000 John: So I caught up with Dave Thaler here at the IETF... He said that NO UDP socket that has NOT joined a multicast group should ever receive a packet sent to a multicast address. He also said this was part of the POSIX API and the way all Unix machines worked.=20 So.. no it is a bug and the fix is correct. R On Mar 29, 2011, at 2:01 PM, John Baldwin wrote: > On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: >> Author: rrs >> Date: Wed Jan 19 19:07:16 2011 >> New Revision: 217592 >> URL: http://svn.freebsd.org/changeset/base/217592 >>=20 >> Log: >> Fix a bug where Multicast packets sent from a >> udp endpoint may end up echoing back to the sender >> even with OUT joining the multi-cast group. >>=20 >> Reviewed by: gnn, bms, bz? >> Obtained from: deischen (with help from) >>=20 >> Modified: >> head/sys/netinet/udp_usrreq.c >>=20 >> Modified: head/sys/netinet/udp_usrreq.c >>=20 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- head/sys/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 = (r217591) >> +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 = (r217592) >> @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) >> * and source-specific multicast. [RFC3678] >> */ >> imo =3D inp->inp_moptions; >> - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && >> - imo !=3D NULL) { >> + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { >> struct sockaddr_in group; >> int blocked; >> - >> + if(imo =3D=3D NULL) { >> + INP_RUNLOCK(inp); >> + continue; >> + } >> bzero(&group, sizeof(struct = sockaddr_in)); >> group.sin_len =3D sizeof(struct = sockaddr_in); >> group.sin_family =3D AF_INET; >=20 > So it turns out that this is a feature, not a bug, and is how = multicast has=20 > always worked. Specifically, if you bind a UDP socket with a wildcard=20= > address, it should receive all traffic for the bound port, unicast or=20= > multicast. When you join a group, you have switched the socket into a = mode=20 > where it now has a whitelist of acceptable multicast groups, but if a = socket=20 > has no joined groups, it should receive all multicast traffic, not = none. This=20 > change breaks that. >=20 > I did not find this behavior intuitive at first, but it does seem to = be=20 > required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for=20= > example: >=20 > 3. Overview of APIs >=20 > There are a number of different APIs described in this document that > are appropriate for a number of different application types and IP > versions. Before providing detailed descriptions, this section > provides a "taxonomy" with a brief description of each. >=20 > There are two categories of source-filter APIs, both of which are > designed to allow multicast receiver applications to designate the > unicast address(es) of sender(s) along with the multicast group > (destination address) to receive. >=20 > o Basic (Delta-based): Some applications desire the simplicity = of > a delta-based API in which each function call specifies a > single source address which should be added to or removed from > the existing filter for a given multicast group address on > which to listen. Such applications typically fall into either > of two categories: >=20 > + Any-Source Multicast: By default, all sources are accepted. > Individual sources may be turned off and back on as needed > over time. This is also known as "exclude" mode, since the > source filter contains a list of excluded sources. >=20 > + Source-Specific Multicast: Only sources in a given list are > allowed. The list may change over time. This is also = known > as "include" mode, since the source filter contains a list > of included sources. >=20 > This API would be used, for example, by "single-source" > applications such as audio/video broadcasting. It would > also be used for logical multi-source sessions where each > source independently allocates its own Source-Specific > Multicast group address. >=20 >=20 > ..... >=20 > 4.1.1. IPv4 Any-Source Multicast API >=20 > The following socket options are defined in for > applications in the Any-Source Multicast category: >=20 > Socket option Argument type > IP_ADD_MEMBERSHIP struct ip_mreq > IP_BLOCK_SOURCE struct ip_mreq_source > IP_UNBLOCK_SOURCE struct ip_mreq_source > IP_DROP_MEMBERSHIP struct ip_mreq >=20 > IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on > most operating systems, and are used to join and leave an any-source > group. >=20 > IP_BLOCK_SOURCE can be used to block data from a given source to a > given group (e.g., if the user "mutes" that source), and > IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then > "unmutes" the source). >=20 > As to why the packets loop back to the receiver, I believe that is a = separate=20 > issue on the output side, not the receive side. >=20 > --=20 > John Baldwin >=20 ------------------------------ Randall Stewart 803-317-4952 (cell) From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 15:45:23 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 62419106564A; Thu, 31 Mar 2011 15:45:23 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 1E3A88FC12; Thu, 31 Mar 2011 15:45:22 +0000 (UTC) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.4/8.14.4/NETPLEX) with ESMTP id p2VFjMTh012910; Thu, 31 Mar 2011 11:45:22 -0400 X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.2.6 (mail.netplex.net [204.213.176.10]); Thu, 31 Mar 2011 11:45:22 -0400 (EDT) Date: Thu, 31 Mar 2011 11:45:22 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Randall Stewart In-Reply-To: <2BE17525-83AA-4255-B191-3429B5FF6F5E@lakerest.net> Message-ID: References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> <2BE17525-83AA-4255-B191-3429B5FF6F5E@lakerest.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, John Baldwin Subject: Re: svn commit: r217592 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 15:45:23 -0000 On Thu, 31 Mar 2011, Randall Stewart wrote: > John: > > So I caught up with Dave Thaler here at the IETF... > > He said that NO UDP socket that has NOT joined a multicast > group should ever receive a packet sent to a multicast address. > He also said this was part of the POSIX API and the way > all Unix machines worked. > > So.. no it is a bug and the fix is correct. Randall, thank you for following this up. If we ever meet, I owe you a beer (or drink of your choice) :-) -- DE From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 16:14:35 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BB5EE106564A; Thu, 31 Mar 2011 16:14:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A0EBF8FC08; Thu, 31 Mar 2011 16:14:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VGEZbQ011874; Thu, 31 Mar 2011 16:14:35 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VGEZZb011867; Thu, 31 Mar 2011 16:14:35 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201103311614.p2VGEZZb011867@svn.freebsd.org> From: Alexander Motin Date: Thu, 31 Mar 2011 16:14:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220209 - head/sys/geom/raid X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 16:14:35 -0000 Author: mav Date: Thu Mar 31 16:14:35 2011 New Revision: 220209 URL: http://svn.freebsd.org/changeset/base/220209 Log: Bunch of small bugfixes and cleanups. Found with: Coverity Prevent(tm) CID: 9656, 9658, 9693, 9705, 9706, 9707, 9808, 9809, 9810, 9711, 9712, 9713, 9714 Modified: head/sys/geom/raid/md_intel.c head/sys/geom/raid/md_jmicron.c head/sys/geom/raid/md_nvidia.c head/sys/geom/raid/md_promise.c head/sys/geom/raid/md_sii.c head/sys/geom/raid/tr_raid1.c Modified: head/sys/geom/raid/md_intel.c ============================================================================== --- head/sys/geom/raid/md_intel.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/md_intel.c Thu Mar 31 16:14:35 2011 (r220209) @@ -541,9 +541,9 @@ intel_meta_write_spare(struct g_consumer /* Fill anchor and single disk. */ meta = malloc(INTEL_MAX_MD_SIZE(1), M_MD_INTEL, M_WAITOK | M_ZERO); - memcpy(&meta->intel_id[0], INTEL_MAGIC, sizeof(INTEL_MAGIC)); + memcpy(&meta->intel_id[0], INTEL_MAGIC, sizeof(INTEL_MAGIC) - 1); memcpy(&meta->version[0], INTEL_VERSION_1000, - sizeof(INTEL_VERSION_1000)); + sizeof(INTEL_VERSION_1000) - 1); meta->config_size = INTEL_MAX_MD_SIZE(1); meta->config_id = arc4random(); meta->generation = 1; @@ -1881,10 +1881,8 @@ g_raid_md_ctl_intel(struct g_raid_md_obj /* If disk was assigned, just update statuses. */ if (pd->pd_disk_pos >= 0) { g_raid_change_disk_state(disk, G_RAID_DISK_S_OFFLINE); - if (disk->d_consumer) { - g_raid_kill_consumer(sc, disk->d_consumer); - disk->d_consumer = NULL; - } + g_raid_kill_consumer(sc, disk->d_consumer); + disk->d_consumer = NULL; TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { g_raid_change_subdisk_state(sd, G_RAID_SUBDISK_S_NONE); @@ -2049,7 +2047,7 @@ g_raid_md_write_intel(struct g_raid_md_o /* Fill anchor and disks. */ meta = malloc(INTEL_MAX_MD_SIZE(numdisks), M_MD_INTEL, M_WAITOK | M_ZERO); - memcpy(&meta->intel_id[0], INTEL_MAGIC, sizeof(INTEL_MAGIC)); + memcpy(&meta->intel_id[0], INTEL_MAGIC, sizeof(INTEL_MAGIC) - 1); meta->config_size = INTEL_MAX_MD_SIZE(numdisks); meta->config_id = mdi->mdio_config_id; meta->generation = mdi->mdio_generation; @@ -2214,7 +2212,7 @@ g_raid_md_write_intel(struct g_raid_md_o meta->total_volumes = vi; if (strcmp(version, INTEL_VERSION_1300) != 0) meta->attributes &= INTEL_ATTR_CHECKSUM; - memcpy(&meta->version[0], version, sizeof(INTEL_VERSION_1000)); + memcpy(&meta->version[0], version, sizeof(INTEL_VERSION_1000) - 1); /* We are done. Print meta data and store them to disks. */ g_raid_md_intel_print(meta); Modified: head/sys/geom/raid/md_jmicron.c ============================================================================== --- head/sys/geom/raid/md_jmicron.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/md_jmicron.c Thu Mar 31 16:14:35 2011 (r220209) @@ -431,7 +431,10 @@ g_raid_md_jmicron_start_disk(struct g_ra olddisk = NULL; /* Find disk position in metadata by it's serial. */ - disk_pos = jmicron_meta_find_disk(meta, pd->pd_disk_id); + if (pd->pd_meta != NULL) + disk_pos = jmicron_meta_find_disk(meta, pd->pd_disk_id); + else + disk_pos = -1; if (disk_pos < 0) { G_RAID_DEBUG1(1, sc, "Unknown, probably new or stale disk"); /* If we are in the start process, that's all for now. */ @@ -522,7 +525,7 @@ nofit: * Different disks may have different sizes/offsets, * especially in concat mode. Update. */ - if (pd->pd_meta != NULL && !resurrection) { + if (!resurrection) { sd->sd_offset = (off_t)pd->pd_meta->offset * 16 * 512; //ZZZ sd->sd_size = @@ -1300,10 +1303,8 @@ g_raid_md_ctl_jmicron(struct g_raid_md_o /* If disk was assigned, just update statuses. */ if (pd->pd_disk_pos >= 0) { g_raid_change_disk_state(disk, G_RAID_DISK_S_OFFLINE); - if (disk->d_consumer) { - g_raid_kill_consumer(sc, disk->d_consumer); - disk->d_consumer = NULL; - } + g_raid_kill_consumer(sc, disk->d_consumer); + disk->d_consumer = NULL; TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { g_raid_change_subdisk_state(sd, G_RAID_SUBDISK_S_NONE); Modified: head/sys/geom/raid/md_nvidia.c ============================================================================== --- head/sys/geom/raid/md_nvidia.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/md_nvidia.c Thu Mar 31 16:14:35 2011 (r220209) @@ -1311,10 +1311,8 @@ g_raid_md_ctl_nvidia(struct g_raid_md_ob /* If disk was assigned, just update statuses. */ if (pd->pd_disk_pos >= 0) { g_raid_change_disk_state(disk, G_RAID_DISK_S_OFFLINE); - if (disk->d_consumer) { - g_raid_kill_consumer(sc, disk->d_consumer); - disk->d_consumer = NULL; - } + g_raid_kill_consumer(sc, disk->d_consumer); + disk->d_consumer = NULL; TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { g_raid_change_subdisk_state(sd, G_RAID_SUBDISK_S_NONE); @@ -1435,7 +1433,7 @@ g_raid_md_write_nvidia(struct g_raid_md_ meta = malloc(sizeof(*meta), M_MD_NVIDIA, M_WAITOK | M_ZERO); if (mdi->mdio_meta) memcpy(meta, mdi->mdio_meta, sizeof(*meta)); - memcpy(meta->nvidia_id, NVIDIA_MAGIC, sizeof(NVIDIA_MAGIC)); + memcpy(meta->nvidia_id, NVIDIA_MAGIC, sizeof(NVIDIA_MAGIC) - 1); meta->config_size = 30; meta->version = 0x0064; meta->total_sectors = vol->v_mediasize / vol->v_sectorsize; Modified: head/sys/geom/raid/md_promise.c ============================================================================== --- head/sys/geom/raid/md_promise.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/md_promise.c Thu Mar 31 16:14:35 2011 (r220209) @@ -398,7 +398,8 @@ next: &off, &size)) { /* Optionally add record for unused space. */ meta = (struct promise_raid_conf *)buf; - memcpy(&meta->promise_id[0], PROMISE_MAGIC, sizeof(PROMISE_MAGIC)); + memcpy(&meta->promise_id[0], PROMISE_MAGIC, + sizeof(PROMISE_MAGIC) - 1); meta->dummy_0 = 0x00020000; meta->integrity = PROMISE_I_VALID; meta->disk.flags = PROMISE_F_ONLINE | PROMISE_F_VALID; @@ -462,7 +463,7 @@ promise_meta_write_spare(struct g_consum int error; meta = malloc(sizeof(*meta), M_MD_PROMISE, M_WAITOK | M_ZERO); - memcpy(&meta->promise_id[0], PROMISE_MAGIC, sizeof(PROMISE_MAGIC)); + memcpy(&meta->promise_id[0], PROMISE_MAGIC, sizeof(PROMISE_MAGIC) - 1); meta->dummy_0 = 0x00020000; meta->integrity = PROMISE_I_VALID; meta->disk.flags = PROMISE_F_SPARE | PROMISE_F_ONLINE | PROMISE_F_VALID; @@ -818,10 +819,10 @@ restart: } else update = 0; if (update) { + updated = 1; g_raid_md_write_promise(md, vol, NULL, disk); break; } - updated += update; } } if (updated) @@ -1684,7 +1685,8 @@ g_raid_md_write_promise(struct g_raid_md meta = malloc(sizeof(*meta), M_MD_PROMISE, M_WAITOK | M_ZERO); if (pv->pv_meta != NULL) memcpy(meta, pv->pv_meta, sizeof(*meta)); - memcpy(meta->promise_id, PROMISE_MAGIC, sizeof(PROMISE_MAGIC)); + memcpy(meta->promise_id, PROMISE_MAGIC, + sizeof(PROMISE_MAGIC) - 1); meta->dummy_0 = 0x00020000; meta->integrity = PROMISE_I_VALID; Modified: head/sys/geom/raid/md_sii.c ============================================================================== --- head/sys/geom/raid/md_sii.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/md_sii.c Thu Mar 31 16:14:35 2011 (r220209) @@ -1389,10 +1389,8 @@ g_raid_md_ctl_sii(struct g_raid_md_objec /* If disk was assigned, just update statuses. */ if (pd->pd_disk_pos >= 0) { g_raid_change_disk_state(disk, G_RAID_DISK_S_OFFLINE); - if (disk->d_consumer) { - g_raid_kill_consumer(sc, disk->d_consumer); - disk->d_consumer = NULL; - } + g_raid_kill_consumer(sc, disk->d_consumer); + disk->d_consumer = NULL; TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { g_raid_change_subdisk_state(sd, G_RAID_SUBDISK_S_NONE); Modified: head/sys/geom/raid/tr_raid1.c ============================================================================== --- head/sys/geom/raid/tr_raid1.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/tr_raid1.c Thu Mar 31 16:14:35 2011 (r220209) @@ -720,8 +720,6 @@ g_raid_tr_iodone_raid1(struct g_raid_tr_ bp->bio_error); bp->bio_cmd = BIO_WRITE; bp->bio_cflags = G_RAID_BIO_FLAG_SYNC; - bp->bio_offset = bp->bio_offset; - bp->bio_length = bp->bio_length; G_RAID_LOGREQ(4, bp, "Queueing rebuild write."); g_raid_subdisk_iostart(trs->trso_failed_sd, bp); } else { From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 16:19:53 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A79B71065672; Thu, 31 Mar 2011 16:19:53 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 96B728FC16; Thu, 31 Mar 2011 16:19:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VGJrkh012048; Thu, 31 Mar 2011 16:19:53 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VGJrqN012039; Thu, 31 Mar 2011 16:19:53 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201103311619.p2VGJrqN012039@svn.freebsd.org> From: Alexander Motin Date: Thu, 31 Mar 2011 16:19:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220210 - head/sys/geom/raid X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 16:19:53 -0000 Author: mav Date: Thu Mar 31 16:19:53 2011 New Revision: 220210 URL: http://svn.freebsd.org/changeset/base/220210 Log: Bunch of small bugfixes and cleanups. Found with: Clang Static Analyzer Modified: head/sys/geom/raid/g_raid.c head/sys/geom/raid/md_intel.c head/sys/geom/raid/md_jmicron.c head/sys/geom/raid/md_nvidia.c head/sys/geom/raid/md_promise.c head/sys/geom/raid/md_sii.c head/sys/geom/raid/tr_raid1.c head/sys/geom/raid/tr_raid1e.c Modified: head/sys/geom/raid/g_raid.c ============================================================================== --- head/sys/geom/raid/g_raid.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/g_raid.c Thu Mar 31 16:19:53 2011 (r220210) @@ -1608,7 +1608,7 @@ g_raid_access(struct g_provider *pp, int { struct g_raid_volume *vol; struct g_raid_softc *sc; - int dcr, dcw, dce, opens, error = 0; + int dcw, opens, error = 0; g_topology_assert(); sc = pp->geom->softc; @@ -1618,10 +1618,7 @@ g_raid_access(struct g_provider *pp, int G_RAID_DEBUG1(2, sc, "Access request for %s: r%dw%de%d.", pp->name, acr, acw, ace); - - dcr = pp->acr + acr; dcw = pp->acw + acw; - dce = pp->ace + ace; g_topology_unlock(); sx_xlock(&sc->sc_lock); Modified: head/sys/geom/raid/md_intel.c ============================================================================== --- head/sys/geom/raid/md_intel.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/md_intel.c Thu Mar 31 16:19:53 2011 (r220210) @@ -1153,7 +1153,6 @@ g_raid_md_taste_intel(struct g_raid_md_o /* Read metadata from device. */ meta = NULL; - spare = 0; vendor = 0xffff; disk_pos = 0; if (g_access(cp, 1, 0, 0) != 0) @@ -1431,7 +1430,7 @@ g_raid_md_ctl_intel(struct g_raid_md_obj gctl_error(req, "Can't open disk '%s'.", diskname); g_topology_unlock(); - error = -4; + error = -7; break; } pp = cp->provider; @@ -1481,6 +1480,11 @@ g_raid_md_ctl_intel(struct g_raid_md_obj if (error != 0) return (error); + if (sectorsize <= 0) { + gctl_error(req, "Can't get sector size."); + return (-8); + } + /* Reserve some space for metadata. */ size -= ((4096 + sectorsize - 1) / sectorsize) * sectorsize; @@ -1953,7 +1957,6 @@ g_raid_md_ctl_intel(struct g_raid_md_obj disk = g_raid_create_disk(sc); disk->d_consumer = cp; - disk->d_consumer->private = disk; disk->d_md_data = (void *)pd; cp->private = disk; Modified: head/sys/geom/raid/md_jmicron.c ============================================================================== --- head/sys/geom/raid/md_jmicron.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/md_jmicron.c Thu Mar 31 16:19:53 2011 (r220210) @@ -579,14 +579,12 @@ g_raid_md_jmicron_refill(struct g_raid_s { struct g_raid_md_object *md; struct g_raid_md_jmicron_object *mdi; - struct jmicron_raid_conf *meta; struct g_raid_disk *disk; struct task *task; int update, na; md = sc->sc_md; mdi = (struct g_raid_md_jmicron_object *)md; - meta = mdi->mdio_meta; update = 0; do { /* Make sure we miss anything. */ @@ -620,10 +618,8 @@ g_raid_md_jmicron_refill(struct g_raid_s } while (disk != NULL); /* Write new metadata if we changed something. */ - if (update) { + if (update) g_raid_md_write_jmicron(md, NULL, NULL, NULL); - meta = mdi->mdio_meta; - } /* Update status of our need for spare. */ mdi->mdio_incomplete = (g_raid_ndisks(sc, G_RAID_DISK_S_ACTIVE) < @@ -835,9 +831,7 @@ g_raid_md_taste_jmicron(struct g_raid_md /* Read metadata from device. */ meta = NULL; - spare = 0; vendor = 0xffff; - disk_pos = 0; if (g_access(cp, 1, 0, 0) != 0) return (G_RAID_MD_TASTE_FAIL); g_topology_unlock(); @@ -1133,6 +1127,11 @@ g_raid_md_ctl_jmicron(struct g_raid_md_o if (error != 0) return (error); + if (sectorsize <= 0) { + gctl_error(req, "Can't get sector size."); + return (-8); + } + /* Reserve space for metadata. */ size -= sectorsize; @@ -1364,7 +1363,6 @@ g_raid_md_ctl_jmicron(struct g_raid_md_o disk = g_raid_create_disk(sc); disk->d_consumer = cp; - disk->d_consumer->private = disk; disk->d_md_data = (void *)pd; cp->private = disk; g_topology_unlock(); @@ -1470,7 +1468,6 @@ g_raid_md_write_jmicron(struct g_raid_md if (mdi->mdio_meta != NULL) free(mdi->mdio_meta, M_MD_JMICRON); mdi->mdio_meta = meta; - i = 0; TAILQ_FOREACH(disk, &sc->sc_disks, d_next) { pd = (struct g_raid_md_jmicron_perdisk *)disk->d_md_data; if (disk->d_state != G_RAID_DISK_S_ACTIVE && @@ -1507,12 +1504,10 @@ g_raid_md_fail_disk_jmicron(struct g_rai struct g_raid_subdisk *tsd, struct g_raid_disk *tdisk) { struct g_raid_softc *sc; - struct g_raid_md_jmicron_object *mdi; struct g_raid_md_jmicron_perdisk *pd; struct g_raid_subdisk *sd; sc = md->mdo_softc; - mdi = (struct g_raid_md_jmicron_object *)md; pd = (struct g_raid_md_jmicron_perdisk *)tdisk->d_md_data; /* We can't fail disk that is not a part of array now. */ Modified: head/sys/geom/raid/md_nvidia.c ============================================================================== --- head/sys/geom/raid/md_nvidia.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/md_nvidia.c Thu Mar 31 16:19:53 2011 (r220210) @@ -584,14 +584,12 @@ g_raid_md_nvidia_refill(struct g_raid_so { struct g_raid_md_object *md; struct g_raid_md_nvidia_object *mdi; - struct nvidia_raid_conf *meta; struct g_raid_disk *disk; struct task *task; int update, na; md = sc->sc_md; mdi = (struct g_raid_md_nvidia_object *)md; - meta = mdi->mdio_meta; update = 0; do { /* Make sure we miss anything. */ @@ -625,10 +623,8 @@ g_raid_md_nvidia_refill(struct g_raid_so } while (disk != NULL); /* Write new metadata if we changed something. */ - if (update) { + if (update) g_raid_md_write_nvidia(md, NULL, NULL, NULL); - meta = mdi->mdio_meta; - } /* Update status of our need for spare. */ mdi->mdio_incomplete = (g_raid_ndisks(sc, G_RAID_DISK_S_ACTIVE) < @@ -828,7 +824,7 @@ g_raid_md_taste_nvidia(struct g_raid_md_ struct nvidia_raid_conf *meta; struct g_raid_md_nvidia_perdisk *pd; struct g_geom *geom; - int error, disk_pos, result, spare, len; + int error, result, spare, len; char name[32]; uint16_t vendor; @@ -838,9 +834,7 @@ g_raid_md_taste_nvidia(struct g_raid_md_ /* Read metadata from device. */ meta = NULL; - spare = 0; vendor = 0xffff; - disk_pos = 0; if (g_access(cp, 1, 0, 0) != 0) return (G_RAID_MD_TASTE_FAIL); g_topology_unlock(); @@ -866,16 +860,9 @@ g_raid_md_taste_nvidia(struct g_raid_md_ return (G_RAID_MD_TASTE_FAIL); } - /* Check this disk position in obtained metadata. */ - disk_pos = meta->disk_number; - if (disk_pos == -1) { - G_RAID_DEBUG(1, "NVIDIA disk position not found"); - goto fail1; - } - /* Metadata valid. Print it. */ g_raid_md_nvidia_print(meta); - G_RAID_DEBUG(1, "NVIDIA disk position %d", disk_pos); + G_RAID_DEBUG(1, "NVIDIA disk position %d", meta->disk_number); spare = 0;//(meta->type == NVIDIA_T_SPARE) ? 1 : 0; search: @@ -1141,6 +1128,11 @@ g_raid_md_ctl_nvidia(struct g_raid_md_ob if (error != 0) return (error); + if (sectorsize <= 0) { + gctl_error(req, "Can't get sector size."); + return (-8); + } + /* Reserve space for metadata. */ size -= 2 * sectorsize; @@ -1371,7 +1363,6 @@ g_raid_md_ctl_nvidia(struct g_raid_md_ob disk = g_raid_create_disk(sc); disk->d_consumer = cp; - disk->d_consumer->private = disk; disk->d_md_data = (void *)pd; cp->private = disk; g_topology_unlock(); @@ -1528,12 +1519,10 @@ g_raid_md_fail_disk_nvidia(struct g_raid struct g_raid_subdisk *tsd, struct g_raid_disk *tdisk) { struct g_raid_softc *sc; - struct g_raid_md_nvidia_object *mdi; struct g_raid_md_nvidia_perdisk *pd; struct g_raid_subdisk *sd; sc = md->mdo_softc; - mdi = (struct g_raid_md_nvidia_object *)md; pd = (struct g_raid_md_nvidia_perdisk *)tdisk->d_md_data; /* We can't fail disk that is not a part of array now. */ Modified: head/sys/geom/raid/md_promise.c ============================================================================== --- head/sys/geom/raid/md_promise.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/md_promise.c Thu Mar 31 16:19:53 2011 (r220210) @@ -1154,12 +1154,10 @@ g_raid_md_event_promise(struct g_raid_md struct g_raid_disk *disk, u_int event) { struct g_raid_softc *sc; - struct g_raid_md_promise_perdisk *pd; sc = md->mdo_softc; if (disk == NULL) return (-1); - pd = (struct g_raid_md_promise_perdisk *)disk->d_md_data; switch (event) { case G_RAID_DISK_E_DISCONNECTED: /* Delete disk. */ @@ -1184,10 +1182,8 @@ static int g_raid_md_volume_event_promise(struct g_raid_md_object *md, struct g_raid_volume *vol, u_int event) { - struct g_raid_softc *sc; struct g_raid_md_promise_pervolume *pv; - sc = md->mdo_softc; pv = (struct g_raid_md_promise_pervolume *)vol->v_md_data; switch (event) { case G_RAID_VOLUME_E_STARTMD: @@ -1345,6 +1341,11 @@ g_raid_md_ctl_promise(struct g_raid_md_o return (error); } + if (sectorsize <= 0) { + gctl_error(req, "Can't get sector size."); + return (-8); + } + /* Handle size argument. */ len = sizeof(*sizearg); sizearg = gctl_get_param(req, "size", &len); @@ -1567,8 +1568,6 @@ g_raid_md_ctl_promise(struct g_raid_md_o continue; } - pd = (struct g_raid_md_promise_perdisk *)disk->d_md_data; - /* Erase metadata on deleting disk and destroy it. */ promise_meta_erase(disk->d_consumer); g_raid_destroy_disk(disk); @@ -1610,14 +1609,12 @@ g_raid_md_ctl_promise(struct g_raid_md_o error = -4; break; } - pp = cp->provider; g_topology_unlock(); pd = malloc(sizeof(*pd), M_MD_PROMISE, M_WAITOK | M_ZERO); disk = g_raid_create_disk(sc); disk->d_consumer = cp; - disk->d_consumer->private = disk; disk->d_md_data = (void *)pd; cp->private = disk; Modified: head/sys/geom/raid/md_sii.c ============================================================================== --- head/sys/geom/raid/md_sii.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/md_sii.c Thu Mar 31 16:19:53 2011 (r220210) @@ -641,14 +641,12 @@ g_raid_md_sii_refill(struct g_raid_softc { struct g_raid_md_object *md; struct g_raid_md_sii_object *mdi; - struct sii_raid_conf *meta; struct g_raid_disk *disk; struct task *task; int update, na; md = sc->sc_md; mdi = (struct g_raid_md_sii_object *)md; - meta = mdi->mdio_meta; update = 0; do { /* Make sure we miss anything. */ @@ -682,10 +680,8 @@ g_raid_md_sii_refill(struct g_raid_softc } while (disk != NULL); /* Write new metadata if we changed something. */ - if (update) { + if (update) g_raid_md_write_sii(md, NULL, NULL, NULL); - meta = mdi->mdio_meta; - } /* Update status of our need for spare. */ mdi->mdio_incomplete = (g_raid_ndisks(sc, G_RAID_DISK_S_ACTIVE) < @@ -921,9 +917,7 @@ g_raid_md_taste_sii(struct g_raid_md_obj /* Read metadata from device. */ meta = NULL; - spare = 0; vendor = 0xffff; - disk_pos = 0; if (g_access(cp, 1, 0, 0) != 0) return (G_RAID_MD_TASTE_FAIL); g_topology_unlock(); @@ -1219,6 +1213,11 @@ g_raid_md_ctl_sii(struct g_raid_md_objec if (error != 0) return (error); + if (sectorsize <= 0) { + gctl_error(req, "Can't get sector size."); + return (-8); + } + /* Reserve space for metadata. */ size -= 0x800 * sectorsize; @@ -1449,7 +1448,6 @@ g_raid_md_ctl_sii(struct g_raid_md_objec disk = g_raid_create_disk(sc); disk->d_consumer = cp; - disk->d_consumer->private = disk; disk->d_md_data = (void *)pd; cp->private = disk; g_topology_unlock(); @@ -1559,7 +1557,6 @@ g_raid_md_write_sii(struct g_raid_md_obj if (mdi->mdio_meta != NULL) free(mdi->mdio_meta, M_MD_SII); mdi->mdio_meta = meta; - i = 0; TAILQ_FOREACH(disk, &sc->sc_disks, d_next) { pd = (struct g_raid_md_sii_perdisk *)disk->d_md_data; if (disk->d_state != G_RAID_DISK_S_ACTIVE) @@ -1605,12 +1602,10 @@ g_raid_md_fail_disk_sii(struct g_raid_md struct g_raid_subdisk *tsd, struct g_raid_disk *tdisk) { struct g_raid_softc *sc; - struct g_raid_md_sii_object *mdi; struct g_raid_md_sii_perdisk *pd; struct g_raid_subdisk *sd; sc = md->mdo_softc; - mdi = (struct g_raid_md_sii_object *)md; pd = (struct g_raid_md_sii_perdisk *)tdisk->d_md_data; /* We can't fail disk that is not a part of array now. */ Modified: head/sys/geom/raid/tr_raid1.c ============================================================================== --- head/sys/geom/raid/tr_raid1.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/tr_raid1.c Thu Mar 31 16:19:53 2011 (r220210) @@ -549,7 +549,6 @@ g_raid_tr_iostart_raid1_read(struct g_ra static void g_raid_tr_iostart_raid1_write(struct g_raid_tr_object *tr, struct bio *bp) { - struct g_raid_softc *sc; struct g_raid_volume *vol; struct g_raid_subdisk *sd; struct bio_queue_head queue; @@ -557,7 +556,6 @@ g_raid_tr_iostart_raid1_write(struct g_r int i; vol = tr->tro_volume; - sc = vol->v_softc; /* * Allocate all bios before sending any request, so we can return Modified: head/sys/geom/raid/tr_raid1e.c ============================================================================== --- head/sys/geom/raid/tr_raid1e.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/tr_raid1e.c Thu Mar 31 16:19:53 2011 (r220210) @@ -196,13 +196,11 @@ g_raid_tr_taste_raid1e(struct g_raid_tr_ static int g_raid_tr_update_state_raid1e_even(struct g_raid_volume *vol) { - struct g_raid_tr_raid1e_object *trs; struct g_raid_softc *sc; struct g_raid_subdisk *sd, *bestsd, *worstsd; int i, j, state, sstate; sc = vol->v_softc; - trs = (struct g_raid_tr_raid1e_object *)vol->v_tr; state = G_RAID_VOLUME_S_OPTIMAL; for (i = 0; i < vol->v_disks_count / N; i++) { bestsd = &vol->v_subdisks[i * N]; @@ -251,13 +249,11 @@ g_raid_tr_update_state_raid1e_even(struc static int g_raid_tr_update_state_raid1e_odd(struct g_raid_volume *vol) { - struct g_raid_tr_raid1e_object *trs; struct g_raid_softc *sc; struct g_raid_subdisk *sd, *bestsd, *worstsd; int i, j, state, sstate; sc = vol->v_softc; - trs = (struct g_raid_tr_raid1e_object *)vol->v_tr; if (g_raid_nsubdisks(vol, G_RAID_SUBDISK_S_ACTIVE) == vol->v_disks_count) return (G_RAID_VOLUME_S_OPTIMAL); From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 16:30:15 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27C731065670; Thu, 31 Mar 2011 16:30:15 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 180638FC0C; Thu, 31 Mar 2011 16:30:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VGUEos012293; Thu, 31 Mar 2011 16:30:14 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VGUEGn012291; Thu, 31 Mar 2011 16:30:14 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201103311630.p2VGUEGn012291@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 31 Mar 2011 16:30:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220211 - head/sys/netinet/ipfw X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 16:30:15 -0000 Author: ae Date: Thu Mar 31 16:30:14 2011 New Revision: 220211 URL: http://svn.freebsd.org/changeset/base/220211 Log: Fill up src_port and dst_port variables for SCTP over IPv4. PR: kern/153415 MFC after: 1 week Modified: head/sys/netinet/ipfw/ip_fw2.c Modified: head/sys/netinet/ipfw/ip_fw2.c ============================================================================== --- head/sys/netinet/ipfw/ip_fw2.c Thu Mar 31 16:19:53 2011 (r220210) +++ head/sys/netinet/ipfw/ip_fw2.c Thu Mar 31 16:30:14 2011 (r220211) @@ -1123,6 +1123,12 @@ do { \ args->f_id._flags = TCP(ulp)->th_flags; break; + case IPPROTO_SCTP: + PULLUP_TO(hlen, ulp, struct sctphdr); + src_port = SCTP(ulp)->src_port; + dst_port = SCTP(ulp)->dest_port; + break; + case IPPROTO_UDP: PULLUP_TO(hlen, ulp, struct udphdr); dst_port = UDP(ulp)->uh_dport; From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 18:12:04 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E34181065670; Thu, 31 Mar 2011 18:12:04 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D293A8FC0C; Thu, 31 Mar 2011 18:12:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VIC40J014445; Thu, 31 Mar 2011 18:12:04 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VIC4V5014443; Thu, 31 Mar 2011 18:12:04 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103311812.p2VIC4V5014443@svn.freebsd.org> From: Edward Tomasz Napierala Date: Thu, 31 Mar 2011 18:12:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220212 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 18:12:05 -0000 Author: trasz Date: Thu Mar 31 18:12:04 2011 New Revision: 220212 URL: http://svn.freebsd.org/changeset/base/220212 Log: Notify racct when process credentials change. Sponsored by: The FreeBSD Foundation Reviewed by: kib (earlier version) Modified: head/sys/kern/kern_prot.c Modified: head/sys/kern/kern_prot.c ============================================================================== --- head/sys/kern/kern_prot.c Thu Mar 31 16:30:14 2011 (r220211) +++ head/sys/kern/kern_prot.c Thu Mar 31 18:12:04 2011 (r220212) @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -584,6 +585,9 @@ setuid(struct thread *td, struct setuid_ } p->p_ucred = newcred; PROC_UNLOCK(p); +#ifdef RACCT + racct_proc_ucred_changed(p, oldcred, newcred); +#endif uifree(uip); crfree(oldcred); return (0); @@ -922,6 +926,9 @@ setreuid(register struct thread *td, str } p->p_ucred = newcred; PROC_UNLOCK(p); +#ifdef RACCT + racct_proc_ucred_changed(p, oldcred, newcred); +#endif uifree(ruip); uifree(euip); crfree(oldcred); @@ -1060,6 +1067,9 @@ setresuid(register struct thread *td, st } p->p_ucred = newcred; PROC_UNLOCK(p); +#ifdef RACCT + racct_proc_ucred_changed(p, oldcred, newcred); +#endif uifree(ruip); uifree(euip); crfree(oldcred); From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 18:18:33 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E8DFD10656DE; Thu, 31 Mar 2011 18:18:33 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id BC8C08FC27; Thu, 31 Mar 2011 18:18:33 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 34BFA46B1A; Thu, 31 Mar 2011 14:18:33 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 94B358A027; Thu, 31 Mar 2011 14:18:32 -0400 (EDT) From: John Baldwin To: Randall Stewart Date: Thu, 31 Mar 2011 14:17:27 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> <2BE17525-83AA-4255-B191-3429B5FF6F5E@lakerest.net> In-Reply-To: <2BE17525-83AA-4255-B191-3429B5FF6F5E@lakerest.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103311417.27360.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Thu, 31 Mar 2011 14:18:32 -0400 (EDT) Cc: svn-src-head@freebsd.org, Daniel Eischen , svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r217592 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 18:18:34 -0000 On Thursday, March 31, 2011 11:40:08 am Randall Stewart wrote: > John: > > So I caught up with Dave Thaler here at the IETF... > > He said that NO UDP socket that has NOT joined a multicast > group should ever receive a packet sent to a multicast address. > He also said this was part of the POSIX API and the way > all Unix machines worked. > > So.. no it is a bug and the fix is correct. That works for me. Can you please merge this fix to 7 and 8? > R > On Mar 29, 2011, at 2:01 PM, John Baldwin wrote: > > > On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: > >> Author: rrs > >> Date: Wed Jan 19 19:07:16 2011 > >> New Revision: 217592 > >> URL: http://svn.freebsd.org/changeset/base/217592 > >> > >> Log: > >> Fix a bug where Multicast packets sent from a > >> udp endpoint may end up echoing back to the sender > >> even with OUT joining the multi-cast group. > >> > >> Reviewed by: gnn, bms, bz? > >> Obtained from: deischen (with help from) > >> > >> Modified: > >> head/sys/netinet/udp_usrreq.c > >> > >> Modified: head/sys/netinet/udp_usrreq.c > >> > > ============================================================================== > >> --- head/sys/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 (r217591) > >> +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 (r217592) > >> @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) > >> * and source-specific multicast. [RFC3678] > >> */ > >> imo = inp->inp_moptions; > >> - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && > >> - imo != NULL) { > >> + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { > >> struct sockaddr_in group; > >> int blocked; > >> - > >> + if(imo == NULL) { > >> + INP_RUNLOCK(inp); > >> + continue; > >> + } > >> bzero(&group, sizeof(struct sockaddr_in)); > >> group.sin_len = sizeof(struct sockaddr_in); > >> group.sin_family = AF_INET; > > > > So it turns out that this is a feature, not a bug, and is how multicast has > > always worked. Specifically, if you bind a UDP socket with a wildcard > > address, it should receive all traffic for the bound port, unicast or > > multicast. When you join a group, you have switched the socket into a mode > > where it now has a whitelist of acceptable multicast groups, but if a socket > > has no joined groups, it should receive all multicast traffic, not none. This > > change breaks that. > > > > I did not find this behavior intuitive at first, but it does seem to be > > required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for > > example: > > > > 3. Overview of APIs > > > > There are a number of different APIs described in this document that > > are appropriate for a number of different application types and IP > > versions. Before providing detailed descriptions, this section > > provides a "taxonomy" with a brief description of each. > > > > There are two categories of source-filter APIs, both of which are > > designed to allow multicast receiver applications to designate the > > unicast address(es) of sender(s) along with the multicast group > > (destination address) to receive. > > > > o Basic (Delta-based): Some applications desire the simplicity of > > a delta-based API in which each function call specifies a > > single source address which should be added to or removed from > > the existing filter for a given multicast group address on > > which to listen. Such applications typically fall into either > > of two categories: > > > > + Any-Source Multicast: By default, all sources are accepted. > > Individual sources may be turned off and back on as needed > > over time. This is also known as "exclude" mode, since the > > source filter contains a list of excluded sources. > > > > + Source-Specific Multicast: Only sources in a given list are > > allowed. The list may change over time. This is also known > > as "include" mode, since the source filter contains a list > > of included sources. > > > > This API would be used, for example, by "single-source" > > applications such as audio/video broadcasting. It would > > also be used for logical multi-source sessions where each > > source independently allocates its own Source-Specific > > Multicast group address. > > > > > > ..... > > > > 4.1.1. IPv4 Any-Source Multicast API > > > > The following socket options are defined in for > > applications in the Any-Source Multicast category: > > > > Socket option Argument type > > IP_ADD_MEMBERSHIP struct ip_mreq > > IP_BLOCK_SOURCE struct ip_mreq_source > > IP_UNBLOCK_SOURCE struct ip_mreq_source > > IP_DROP_MEMBERSHIP struct ip_mreq > > > > IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on > > most operating systems, and are used to join and leave an any-source > > group. > > > > IP_BLOCK_SOURCE can be used to block data from a given source to a > > given group (e.g., if the user "mutes" that source), and > > IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then > > "unmutes" the source). > > > > As to why the packets loop back to the receiver, I believe that is a separate > > issue on the output side, not the receive side. > > > > -- > > John Baldwin > > > > ------------------------------ > Randall Stewart > 803-317-4952 (cell) > > -- John Baldwin From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 18:23:38 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C3647106564A; Thu, 31 Mar 2011 18:23:38 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B06658FC0A; Thu, 31 Mar 2011 18:23:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VINcEg014781; Thu, 31 Mar 2011 18:23:38 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VINcK5014767; Thu, 31 Mar 2011 18:23:38 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201103311823.p2VINcK5014767@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 31 Mar 2011 18:23:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220214 - vendor/NetBSD/libedit/dist X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 18:23:38 -0000 Author: obrien Date: Thu Mar 31 18:23:38 2011 New Revision: 220214 URL: http://svn.freebsd.org/changeset/base/220214 Log: Vendor import NetBSD's libedit of "2005/11/09 22:11:10 UTC". Obtained from: NetBSD Modified: vendor/NetBSD/libedit/dist/chared.c vendor/NetBSD/libedit/dist/chared.h vendor/NetBSD/libedit/dist/common.c vendor/NetBSD/libedit/dist/editline.3 vendor/NetBSD/libedit/dist/el.c vendor/NetBSD/libedit/dist/emacs.c vendor/NetBSD/libedit/dist/filecomplete.c vendor/NetBSD/libedit/dist/key.c vendor/NetBSD/libedit/dist/makelist vendor/NetBSD/libedit/dist/map.c vendor/NetBSD/libedit/dist/refresh.c vendor/NetBSD/libedit/dist/term.c vendor/NetBSD/libedit/dist/vi.c Modified: vendor/NetBSD/libedit/dist/chared.c ============================================================================== --- vendor/NetBSD/libedit/dist/chared.c Thu Mar 31 18:17:16 2011 (r220213) +++ vendor/NetBSD/libedit/dist/chared.c Thu Mar 31 18:23:38 2011 (r220214) @@ -1,4 +1,4 @@ -/* $NetBSD: chared.c,v 1.24 2005/08/01 23:00:15 christos Exp $ */ +/* $NetBSD: chared.c,v 1.25 2005/08/08 01:41:30 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: chared.c,v 1.24 2005/08/01 23:00:15 christos Exp $"); +__RCSID("$NetBSD: chared.c,v 1.25 2005/08/08 01:41:30 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -523,6 +523,8 @@ ch_reset(EditLine *el, int mclear) el->el_state.argument = 1; el->el_state.lastcmd = ED_UNASSIGNED; + el->el_history.eventno = 0; + if (mclear) ch__clearmacro(el); } Modified: vendor/NetBSD/libedit/dist/chared.h ============================================================================== --- vendor/NetBSD/libedit/dist/chared.h Thu Mar 31 18:17:16 2011 (r220213) +++ vendor/NetBSD/libedit/dist/chared.h Thu Mar 31 18:23:38 2011 (r220214) @@ -1,4 +1,4 @@ -/* $NetBSD: chared.h,v 1.15 2005/08/01 23:00:15 christos Exp $ */ +/* $NetBSD: chared.h,v 1.16 2005/08/08 14:05:37 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -48,7 +48,7 @@ #define EL_MAXMACRO 10 /* - * This is a issue of basic "vi" look-and-feel. Defining VI_MOVE works + * This is an issue of basic "vi" look-and-feel. Defining VI_MOVE works * like real vi: i.e. the transition from command<->insert modes moves * the cursor. * Modified: vendor/NetBSD/libedit/dist/common.c ============================================================================== --- vendor/NetBSD/libedit/dist/common.c Thu Mar 31 18:17:16 2011 (r220213) +++ vendor/NetBSD/libedit/dist/common.c Thu Mar 31 18:23:38 2011 (r220214) @@ -1,4 +1,4 @@ -/* $NetBSD: common.c,v 1.17 2005/08/01 23:00:15 christos Exp $ */ +/* $NetBSD: common.c,v 1.18 2005/08/08 14:05:37 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: common.c,v 1.17 2005/08/01 23:00:15 christos Exp $"); +__RCSID("$NetBSD: common.c,v 1.18 2005/08/08 14:05:37 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -155,7 +155,7 @@ ed_delete_next_char(EditLine *el, int c return (CC_ERROR); #else term_overwrite(el, STReof, 4); - /* then do a EOF */ + /* then do an EOF */ term__flush(); return (CC_EOF); #endif Modified: vendor/NetBSD/libedit/dist/editline.3 ============================================================================== --- vendor/NetBSD/libedit/dist/editline.3 Thu Mar 31 18:17:16 2011 (r220213) +++ vendor/NetBSD/libedit/dist/editline.3 Thu Mar 31 18:23:38 2011 (r220214) @@ -1,4 +1,4 @@ -.\" $NetBSD: editline.3,v 1.48 2005/07/14 15:02:37 wiz Exp $ +.\" $NetBSD: editline.3,v 1.50 2005/10/12 09:29:43 wiz Exp $ .\" .\" Copyright (c) 1997-2003 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -33,7 +33,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd July 14, 2005 +.Dd September 9, 2005 .Os .Dt EDITLINE 3 .Sh NAME @@ -46,6 +46,7 @@ .Nm el_push , .Nm el_parse , .Nm el_set , +.Nm el_get , .Nm el_source , .Nm el_resize , .Nm el_line , @@ -629,11 +630,11 @@ Load the history list stored in Save the history list to .Fa file . .It Dv H_SETUNIQUE , Fa "int unique" -Set if the adjacent identical event strings should not be entered into -the history. +Set flag that adjacent identical event strings should not be entered +into the history. .It Dv H_GETUNIQUE -Retrieve the current setting if if adjacent elements should be entered into -the history. +Retrieve the current setting if adjacent identical elements should +be entered into the history. .It Dv H_DEL , Fa "int num" Delete the event numbered .Fa e . Modified: vendor/NetBSD/libedit/dist/el.c ============================================================================== --- vendor/NetBSD/libedit/dist/el.c Thu Mar 31 18:17:16 2011 (r220213) +++ vendor/NetBSD/libedit/dist/el.c Thu Mar 31 18:23:38 2011 (r220214) @@ -1,4 +1,4 @@ -/* $NetBSD: el.c,v 1.40 2005/08/01 23:00:15 christos Exp $ */ +/* $NetBSD: el.c,v 1.41 2005/08/19 04:21:47 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94"; #else -__RCSID("$NetBSD: el.c,v 1.40 2005/08/01 23:00:15 christos Exp $"); +__RCSID("$NetBSD: el.c,v 1.41 2005/08/19 04:21:47 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -300,11 +300,11 @@ el_get(EditLine *el, int op, void *ret) switch (op) { case EL_PROMPT: case EL_RPROMPT: - rv = prompt_get(el, (void *) &ret, op); + rv = prompt_get(el, (el_pfunc_t *) ret, op); break; case EL_EDITOR: - rv = map_get_editor(el, (void *) &ret); + rv = map_get_editor(el, (const char **)ret); break; case EL_SIGNAL: Modified: vendor/NetBSD/libedit/dist/emacs.c ============================================================================== --- vendor/NetBSD/libedit/dist/emacs.c Thu Mar 31 18:17:16 2011 (r220213) +++ vendor/NetBSD/libedit/dist/emacs.c Thu Mar 31 18:23:38 2011 (r220214) @@ -1,4 +1,4 @@ -/* $NetBSD: emacs.c,v 1.19 2004/10/28 21:14:52 dsl Exp $ */ +/* $NetBSD: emacs.c,v 1.20 2005/08/08 14:05:37 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: emacs.c,v 1.19 2004/10/28 21:14:52 dsl Exp $"); +__RCSID("$NetBSD: emacs.c,v 1.20 2005/08/08 14:05:37 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -59,7 +59,7 @@ em_delete_or_list(EditLine *el, int c __ /* if I'm at the end */ if (el->el_line.cursor == el->el_line.buffer) { /* and the beginning */ - term_overwrite(el, STReof, 4); /* then do a EOF */ + term_overwrite(el, STReof, 4); /* then do an EOF */ term__flush(); return (CC_EOF); } else { Modified: vendor/NetBSD/libedit/dist/filecomplete.c ============================================================================== --- vendor/NetBSD/libedit/dist/filecomplete.c Thu Mar 31 18:17:16 2011 (r220213) +++ vendor/NetBSD/libedit/dist/filecomplete.c Thu Mar 31 18:23:38 2011 (r220214) @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.c,v 1.7 2005/06/11 18:18:59 christos Exp $ */ +/* $NetBSD: filecomplete.c,v 1.8 2005/08/03 13:41:38 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: filecomplete.c,v 1.7 2005/06/11 18:18:59 christos Exp $"); +__RCSID("$NetBSD: filecomplete.c,v 1.8 2005/08/03 13:41:38 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -438,7 +438,7 @@ fn_complete(EditLine *el, } else matches = 0; if (!attempted_completion_function || - (over != NULL && *over && !matches)) + (over != NULL && !*over && !matches)) matches = completion_matches(temp, complet_func); if (over != NULL) Modified: vendor/NetBSD/libedit/dist/key.c ============================================================================== --- vendor/NetBSD/libedit/dist/key.c Thu Mar 31 18:17:16 2011 (r220213) +++ vendor/NetBSD/libedit/dist/key.c Thu Mar 31 18:23:38 2011 (r220214) @@ -1,4 +1,4 @@ -/* $NetBSD: key.c,v 1.16 2005/07/06 21:13:02 christos Exp $ */ +/* $NetBSD: key.c,v 1.17 2005/08/08 14:05:37 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: key.c,v 1.16 2005/07/06 21:13:02 christos Exp $"); +__RCSID("$NetBSD: key.c,v 1.17 2005/08/08 14:05:37 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -46,7 +46,7 @@ __RCSID("$NetBSD: key.c,v 1.16 2005/07/0 * the extended-key map. * * An extended-key (key) is a sequence of keystrokes introduced - * with an sequence introducer and consisting of an arbitrary + * with a sequence introducer and consisting of an arbitrary * number of characters. This module maintains a map (the el->el_key.map) * to convert these extended-key sequences into input strs * (XK_STR), editor functions (XK_CMD), or unix commands (XK_EXE). @@ -449,7 +449,7 @@ node__put(EditLine *el, key_node_t *ptr) /* node__get(): - * Returns pointer to an key_node_t for ch. + * Returns pointer to a key_node_t for ch. */ private key_node_t * node__get(int ch) Modified: vendor/NetBSD/libedit/dist/makelist ============================================================================== --- vendor/NetBSD/libedit/dist/makelist Thu Mar 31 18:17:16 2011 (r220213) +++ vendor/NetBSD/libedit/dist/makelist Thu Mar 31 18:23:38 2011 (r220214) @@ -1,5 +1,5 @@ #!/bin/sh - -# $NetBSD: makelist,v 1.9 2005/05/16 13:14:43 lukem Exp $ +# $NetBSD: makelist,v 1.11 2005/10/22 16:45:03 christos Exp $ # # Copyright (c) 1992, 1993 # The Regents of the University of California. All rights reserved. @@ -118,7 +118,6 @@ case $FLAG in } } END { - printf(" { NULL, 0, NULL }\n"); printf("};\n"); printf("\nprotected const el_bindings_t* help__get()"); printf("{ return el_func_help; }\n"); @@ -141,7 +140,7 @@ case $FLAG in # -fh) cat $FILES | $AWK '/el_action_t/ { print $3 }' | \ - sort | tr '[a-z]' '[A-Z]' | $AWK ' + sort | tr '[:lower:]' '[:upper:]' | $AWK ' BEGIN { printf("/* Automatically generated file, do not edit */\n"); printf("#ifndef _h_fcns_c\n#define _h_fcns_c\n"); Modified: vendor/NetBSD/libedit/dist/map.c ============================================================================== --- vendor/NetBSD/libedit/dist/map.c Thu Mar 31 18:17:16 2011 (r220213) +++ vendor/NetBSD/libedit/dist/map.c Thu Mar 31 18:23:38 2011 (r220214) @@ -1,4 +1,4 @@ -/* $NetBSD: map.c,v 1.20 2004/08/13 12:10:39 mycroft Exp $ */ +/* $NetBSD: map.c,v 1.22 2005/08/09 13:58:44 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: map.c,v 1.20 2004/08/13 12:10:39 mycroft Exp $"); +__RCSID("$NetBSD: map.c,v 1.22 2005/08/09 13:58:44 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -1125,11 +1125,12 @@ private void map_print_key(EditLine *el, el_action_t *map, const char *in) { char outbuf[EL_BUFSIZ]; - el_bindings_t *bp; + el_bindings_t *bp, *ep; if (in[0] == '\0' || in[1] == '\0') { (void) key__decode_str(in, outbuf, ""); - for (bp = el->el_map.help; bp->name != NULL; bp++) + ep = &el->el_map.help[el->el_map.nfunc]; + for (bp = el->el_map.help; bp < ep; bp++) if (bp->func == map[(unsigned char) *in]) { (void) fprintf(el->el_outfile, "%s\t->\t%s\n", outbuf, bp->name); @@ -1146,7 +1147,7 @@ map_print_key(EditLine *el, el_action_t private void map_print_some_keys(EditLine *el, el_action_t *map, int first, int last) { - el_bindings_t *bp; + el_bindings_t *bp, *ep; char firstbuf[2], lastbuf[2]; char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ]; @@ -1161,7 +1162,8 @@ map_print_some_keys(EditLine *el, el_act key__decode_str(firstbuf, unparsbuf, STRQQ)); return; } - for (bp = el->el_map.help; bp->name != NULL; bp++) { + ep = &el->el_map.help[el->el_map.nfunc]; + for (bp = el->el_map.help; bp < ep; bp++) { if (bp->func == map[first]) { if (first == last) { (void) fprintf(el->el_outfile, "%-15s-> %s\n", @@ -1244,7 +1246,7 @@ map_bind(EditLine *el, int argc, const c char outbuf[EL_BUFSIZ]; const char *in = NULL; char *out = NULL; - el_bindings_t *bp; + el_bindings_t *bp, *ep; int cmd; int key; @@ -1286,8 +1288,8 @@ map_bind(EditLine *el, int argc, const c return (0); case 'l': - for (bp = el->el_map.help; bp->name != NULL; - bp++) + ep = &el->el_map.help[el->el_map.nfunc]; + for (bp = el->el_map.help; bp < ep; bp++) (void) fprintf(el->el_outfile, "%s\n\t%s\n", bp->name, bp->description); @@ -1388,7 +1390,7 @@ protected int map_addfunc(EditLine *el, const char *name, const char *help, el_func_t func) { void *p; - int nf = el->el_map.nfunc + 2; + int nf = el->el_map.nfunc + 1; if (name == NULL || help == NULL || func == NULL) return (-1); @@ -1407,7 +1409,6 @@ map_addfunc(EditLine *el, const char *na el->el_map.help[nf].name = name; el->el_map.help[nf].func = nf; el->el_map.help[nf].description = help; - el->el_map.help[++nf].name = NULL; el->el_map.nfunc++; return (0); Modified: vendor/NetBSD/libedit/dist/refresh.c ============================================================================== --- vendor/NetBSD/libedit/dist/refresh.c Thu Mar 31 18:17:16 2011 (r220213) +++ vendor/NetBSD/libedit/dist/refresh.c Thu Mar 31 18:23:38 2011 (r220214) @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.26 2003/08/07 16:44:33 agc Exp $ */ +/* $NetBSD: refresh.c,v 1.27 2005/11/09 22:11:10 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: refresh.c,v 1.26 2003/08/07 16:44:33 agc Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.27 2005/11/09 22:11:10 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -56,6 +56,7 @@ private void re_update_line(EditLine *, private void re_insert (EditLine *, char *, int, int, char *, int); private void re_delete(EditLine *, char *, int, int, int); private void re_fastputc(EditLine *, int); +private void re_clear_eol(EditLine *, int, int, int); private void re__strncopy(char *, char *, size_t); private void re__copy_and_pad(char *, const char *, size_t); @@ -347,7 +348,7 @@ re_insert(EditLine *el __attribute__((__ ELRE_DEBUG(1, (__F, "re_insert() starting: %d at %d max %d, d == \"%s\"\n", num, dat, dlen, d)); - ELRE_DEBUG(1, (__F, "s == \"%s\"n", s)); + ELRE_DEBUG(1, (__F, "s == \"%s\"\n", s)); /* open up the space for num chars */ if (num > 0) { @@ -360,7 +361,7 @@ re_insert(EditLine *el __attribute__((__ ELRE_DEBUG(1, (__F, "re_insert() after insert: %d at %d max %d, d == \"%s\"\n", num, dat, dlen, d)); - ELRE_DEBUG(1, (__F, "s == \"%s\"n", s)); + ELRE_DEBUG(1, (__F, "s == \"%s\"\n", s)); /* copy the characters */ for (a = d + dat; (a < d + dlen) && (num > 0); num--) @@ -369,7 +370,7 @@ re_insert(EditLine *el __attribute__((__ ELRE_DEBUG(1, (__F, "re_insert() after copy: %d at %d max %d, %s == \"%s\"\n", num, dat, dlen, d, s)); - ELRE_DEBUG(1, (__F, "s == \"%s\"n", s)); + ELRE_DEBUG(1, (__F, "s == \"%s\"\n", s)); } @@ -418,6 +419,32 @@ re__strncopy(char *a, char *b, size_t n) *a++ = *b++; } +/* re_clear_eol(): + * Find the number of characters we need to clear till the end of line + * in order to make sure that we have cleared the previous contents of + * the line. fx and sx is the number of characters inserted or deleted + * int the first or second diff, diff is the difference between the + * number of characters between the new and old line. + */ +private void +re_clear_eol(EditLine *el, int fx, int sx, int diff) +{ + + ELRE_DEBUG(1, (__F, "re_clear_eol sx %d, fx %d, diff %d\n", + sx, fx, diff)); + + if (fx < 0) + fx = -fx; + if (sx < 0) + sx = -sx; + if (fx > diff) + diff = fx; + if (sx > diff) + diff = sx; + + ELRE_DEBUG(1, (__F, "re_clear_eol %d\n", diff)); + term_clear_EOL(el, diff); +} /***************************************************************** re_update_line() is based on finding the middle difference of each line @@ -633,7 +660,7 @@ re_update_line(EditLine *el, char *old, fx = (nsb - nfd) - (osb - ofd); sx = (nls - nse) - (ols - ose); - ELRE_DEBUG(1, (__F, "\n")); + ELRE_DEBUG(1, (__F, "fx %d, sx %d\n", fx, sx)); ELRE_DEBUG(1, (__F, "ofd %d, osb %d, ose %d, ols %d, oe %d\n", ofd - old, osb - old, ose - old, ols - old, oe - old)); ELRE_DEBUG(1, (__F, "nfd %d, nsb %d, nse %d, nls %d, ne %d\n", @@ -782,9 +809,7 @@ re_update_line(EditLine *el, char *old, * write (nsb-nfd) chars of new starting at nfd */ term_overwrite(el, nfd, (nsb - nfd)); - ELRE_DEBUG(1, (__F, - "cleareol %d\n", (oe - old) - (ne - new))); - term_clear_EOL(el, (oe - old) - (ne - new)); + re_clear_eol(el, fx, sx, (oe - old) - (ne - new)); /* * Done */ @@ -825,10 +850,7 @@ re_update_line(EditLine *el, char *old, ELRE_DEBUG(1, (__F, "but with nothing left to save\r\n")); term_overwrite(el, nse, (nls - nse)); - ELRE_DEBUG(1, (__F, - "cleareol %d\n", (oe - old) - (ne - new))); - if ((oe - old) - (ne - new) != 0) - term_clear_EOL(el, (oe - old) - (ne - new)); + re_clear_eol(el, fx, sx, (oe - old) - (ne - new)); } } /* Modified: vendor/NetBSD/libedit/dist/term.c ============================================================================== --- vendor/NetBSD/libedit/dist/term.c Thu Mar 31 18:17:16 2011 (r220213) +++ vendor/NetBSD/libedit/dist/term.c Thu Mar 31 18:23:38 2011 (r220214) @@ -1,4 +1,4 @@ -/* $NetBSD: term.c,v 1.40 2004/05/22 23:21:28 christos Exp $ */ +/* $NetBSD: term.c,v 1.41 2005/08/08 14:05:37 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95"; #else -__RCSID("$NetBSD: term.c,v 1.40 2004/05/22 23:21:28 christos Exp $"); +__RCSID("$NetBSD: term.c,v 1.41 2005/08/08 14:05:37 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -944,7 +944,7 @@ term_set(EditLine *el, const char *term) Val(T_co) = tgetnum("co"); Val(T_li) = tgetnum("li"); for (t = tstr; t->name != NULL; t++) { - /* XXX: some systems tgetstr needs non const */ + /* XXX: some systems' tgetstr needs non const */ term_alloc(el, t, tgetstr(strchr(t->name, *t->name), &area)); } @@ -1449,7 +1449,7 @@ term_echotc(EditLine *el, int argc __att break; } if (t->name == NULL) { - /* XXX: some systems tgetstr needs non const */ + /* XXX: some systems' tgetstr needs non const */ scap = tgetstr(strchr(*argv, **argv), &area); } if (!scap || scap[0] == '\0') { Modified: vendor/NetBSD/libedit/dist/vi.c ============================================================================== --- vendor/NetBSD/libedit/dist/vi.c Thu Mar 31 18:17:16 2011 (r220213) +++ vendor/NetBSD/libedit/dist/vi.c Thu Mar 31 18:23:38 2011 (r220214) @@ -1,4 +1,4 @@ -/* $NetBSD: vi.c,v 1.21 2005/04/25 01:06:03 matt Exp $ */ +/* $NetBSD: vi.c,v 1.24 2005/08/10 12:46:24 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: vi.c,v 1.21 2005/04/25 01:06:03 matt Exp $"); +__RCSID("$NetBSD: vi.c,v 1.24 2005/08/10 12:46:24 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -71,8 +71,10 @@ cv_action(EditLine *el, int c) el->el_line.lastchar - el->el_line.buffer); el->el_chared.c_vcmd.action = NOP; el->el_chared.c_vcmd.pos = 0; - el->el_line.lastchar = el->el_line.buffer; - el->el_line.cursor = el->el_line.buffer; + if (!(c & YANK)) { + el->el_line.lastchar = el->el_line.buffer; + el->el_line.cursor = el->el_line.buffer; + } if (c & INSERT) el->el_map.current = el->el_map.key; @@ -89,7 +91,6 @@ cv_action(EditLine *el, int c) private el_action_t cv_paste(EditLine *el, int c) { - char *ptr; c_kill_t *k = &el->el_chared.c_kill; int len = k->last - k->buf; @@ -103,12 +104,12 @@ cv_paste(EditLine *el, int c) if (!c && el->el_line.cursor < el->el_line.lastchar) el->el_line.cursor++; - ptr = el->el_line.cursor; c_insert(el, len); if (el->el_line.cursor + len > el->el_line.lastchar) return (CC_ERROR); - (void) memcpy(ptr, k->buf, len +0u); + (void) memcpy(el->el_line.cursor, k->buf, len +0u); + return (CC_REFRESH); } @@ -895,7 +896,7 @@ vi_yank(EditLine *el, int c) /* vi_comment_out(): * Vi comment out current command - * [c] + * [#] */ protected el_action_t /*ARGSUSED*/ @@ -912,7 +913,7 @@ vi_comment_out(EditLine *el, int c) /* vi_alias(): * Vi include shell alias * [@] - * NB: posix impiles that we should enter insert mode, however + * NB: posix implies that we should enter insert mode, however * this is against historical precedent... */ protected el_action_t From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 18:28:10 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 21C9F1065782; Thu, 31 Mar 2011 18:28:10 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EA5208FC16; Thu, 31 Mar 2011 18:28:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VIS9HD014909; Thu, 31 Mar 2011 18:28:09 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VIS9gh014908; Thu, 31 Mar 2011 18:28:09 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201103311828.p2VIS9gh014908@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 31 Mar 2011 18:28:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220215 - vendor/NetBSD/libedit/2005-11-09 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 18:28:10 -0000 Author: obrien Date: Thu Mar 31 18:28:09 2011 New Revision: 220215 URL: http://svn.freebsd.org/changeset/base/220215 Log: "Tag" the "2005/11/09 22:11:10 UTC" import. Added: vendor/NetBSD/libedit/2005-11-09/ - copied from r220214, vendor/NetBSD/libedit/dist/ From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 18:28:46 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D80111065670; Thu, 31 Mar 2011 18:28:46 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C56F98FC0A; Thu, 31 Mar 2011 18:28:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VISkfS014969; Thu, 31 Mar 2011 18:28:46 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VISk4G014957; Thu, 31 Mar 2011 18:28:46 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201103311828.p2VISk4G014957@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 31 Mar 2011 18:28:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220216 - vendor/NetBSD/libedit/dist X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 18:28:46 -0000 Author: obrien Date: Thu Mar 31 18:28:46 2011 New Revision: 220216 URL: http://svn.freebsd.org/changeset/base/220216 Log: Vendor import NetBSD's libedit of "2006/03/23 20:22:51 UTC". Obtained from: NetBSD Modified: vendor/NetBSD/libedit/dist/chared.h vendor/NetBSD/libedit/dist/common.c vendor/NetBSD/libedit/dist/emacs.c vendor/NetBSD/libedit/dist/key.c vendor/NetBSD/libedit/dist/key.h vendor/NetBSD/libedit/dist/map.c vendor/NetBSD/libedit/dist/readline.c vendor/NetBSD/libedit/dist/term.c vendor/NetBSD/libedit/dist/term.h vendor/NetBSD/libedit/dist/tty.c vendor/NetBSD/libedit/dist/vi.c Modified: vendor/NetBSD/libedit/dist/chared.h ============================================================================== --- vendor/NetBSD/libedit/dist/chared.h Thu Mar 31 18:28:09 2011 (r220215) +++ vendor/NetBSD/libedit/dist/chared.h Thu Mar 31 18:28:46 2011 (r220216) @@ -1,4 +1,4 @@ -/* $NetBSD: chared.h,v 1.16 2005/08/08 14:05:37 christos Exp $ */ +/* $NetBSD: chared.h,v 1.17 2006/03/06 21:11:56 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -116,7 +116,6 @@ typedef struct el_chared_t { } el_chared_t; -#define STReof "^D\b\b" #define STRQQ "\"\"" #define isglob(a) (strchr("*[]?", (a)) != NULL) Modified: vendor/NetBSD/libedit/dist/common.c ============================================================================== --- vendor/NetBSD/libedit/dist/common.c Thu Mar 31 18:28:09 2011 (r220215) +++ vendor/NetBSD/libedit/dist/common.c Thu Mar 31 18:28:46 2011 (r220216) @@ -1,4 +1,4 @@ -/* $NetBSD: common.c,v 1.18 2005/08/08 14:05:37 christos Exp $ */ +/* $NetBSD: common.c,v 1.19 2006/03/06 21:11:56 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: common.c,v 1.18 2005/08/08 14:05:37 christos Exp $"); +__RCSID("$NetBSD: common.c,v 1.19 2006/03/06 21:11:56 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -137,7 +137,7 @@ ed_delete_prev_word(EditLine *el, int c */ protected el_action_t /*ARGSUSED*/ -ed_delete_next_char(EditLine *el, int c __attribute__((__unused__))) +ed_delete_next_char(EditLine *el, int c) { #ifdef notdef /* XXX */ #define EL el->el_line @@ -154,9 +154,8 @@ ed_delete_next_char(EditLine *el, int c #ifdef KSHVI return (CC_ERROR); #else - term_overwrite(el, STReof, 4); - /* then do an EOF */ - term__flush(); + /* then do an EOF */ + term_writechar(el, c); return (CC_EOF); #endif } else { Modified: vendor/NetBSD/libedit/dist/emacs.c ============================================================================== --- vendor/NetBSD/libedit/dist/emacs.c Thu Mar 31 18:28:09 2011 (r220215) +++ vendor/NetBSD/libedit/dist/emacs.c Thu Mar 31 18:28:46 2011 (r220216) @@ -1,4 +1,4 @@ -/* $NetBSD: emacs.c,v 1.20 2005/08/08 14:05:37 christos Exp $ */ +/* $NetBSD: emacs.c,v 1.21 2006/03/06 21:11:56 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: emacs.c,v 1.20 2005/08/08 14:05:37 christos Exp $"); +__RCSID("$NetBSD: emacs.c,v 1.21 2006/03/06 21:11:56 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -52,15 +52,14 @@ __RCSID("$NetBSD: emacs.c,v 1.20 2005/08 */ protected el_action_t /*ARGSUSED*/ -em_delete_or_list(EditLine *el, int c __attribute__((__unused__))) +em_delete_or_list(EditLine *el, int c) { if (el->el_line.cursor == el->el_line.lastchar) { /* if I'm at the end */ if (el->el_line.cursor == el->el_line.buffer) { /* and the beginning */ - term_overwrite(el, STReof, 4); /* then do an EOF */ - term__flush(); + term_writec(el, c); /* then do an EOF */ return (CC_EOF); } else { /* Modified: vendor/NetBSD/libedit/dist/key.c ============================================================================== --- vendor/NetBSD/libedit/dist/key.c Thu Mar 31 18:28:09 2011 (r220215) +++ vendor/NetBSD/libedit/dist/key.c Thu Mar 31 18:28:46 2011 (r220216) @@ -1,4 +1,4 @@ -/* $NetBSD: key.c,v 1.17 2005/08/08 14:05:37 christos Exp $ */ +/* $NetBSD: key.c,v 1.19 2006/03/23 20:22:51 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: key.c,v 1.17 2005/08/08 14:05:37 christos Exp $"); +__RCSID("$NetBSD: key.c,v 1.19 2006/03/23 20:22:51 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -91,7 +91,6 @@ private int node__delete(EditLine *, k private int node_lookup(EditLine *, const char *, key_node_t *, int); private int node_enum(EditLine *, key_node_t *, int); -private int key__decode_char(char *, int, int); #define KEY_BUFSIZ EL_BUFSIZ @@ -497,7 +496,7 @@ node_lookup(EditLine *el, const char *st /* If match put this char into el->el_key.buf. Recurse */ if (ptr->ch == *str) { /* match found */ - ncnt = key__decode_char(el->el_key.buf, cnt, + ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt, (unsigned char) ptr->ch); if (ptr->next != NULL) /* not yet at leaf */ @@ -551,7 +550,8 @@ node_enum(EditLine *el, key_node_t *ptr, return (-1); } /* put this char at end of str */ - ncnt = key__decode_char(el->el_key.buf, cnt, (unsigned char) ptr->ch); + ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt, + (unsigned char)ptr->ch); if (ptr->next == NULL) { /* print this key and function */ el->el_key.buf[ncnt + 1] = '"'; @@ -582,9 +582,10 @@ key_kprint(EditLine *el, const char *key switch (ntype) { case XK_STR: case XK_EXE: - (void) fprintf(el->el_outfile, fmt, key, - key__decode_str(val->str, unparsbuf, - ntype == XK_STR ? "\"\"" : "[]")); + (void) key__decode_str(val->str, unparsbuf, + sizeof(unparsbuf), + ntype == XK_STR ? "\"\"" : "[]"); + (void) fprintf(el->el_outfile, fmt, key, unparsbuf); break; case XK_CMD: for (fp = el->el_map.help; fp->name; fp++) @@ -609,83 +610,97 @@ key_kprint(EditLine *el, const char *key } +#define ADDC(c) \ + if (b < eb) \ + *b++ = c; \ + else \ + b++ /* key__decode_char(): * Put a printable form of char in buf. */ -private int -key__decode_char(char *buf, int cnt, int ch) +protected int +key__decode_char(char *buf, int cnt, int off, int ch) { + char *sb = buf + off; + char *eb = buf + cnt; + char *b = sb; if (ch == 0) { - buf[cnt++] = '^'; - buf[cnt] = '@'; - return (cnt); + ADDC('^'); + ADDC('@'); + return b - sb; } if (iscntrl(ch)) { - buf[cnt++] = '^'; + ADDC('^'); if (ch == '\177') - buf[cnt] = '?'; + ADDC('?'); else - buf[cnt] = ch | 0100; + ADDC(ch | 0100); } else if (ch == '^') { - buf[cnt++] = '\\'; - buf[cnt] = '^'; + ADDC('\\'); + ADDC('^'); } else if (ch == '\\') { - buf[cnt++] = '\\'; - buf[cnt] = '\\'; + ADDC('\\'); + ADDC('\\'); } else if (ch == ' ' || (isprint(ch) && !isspace(ch))) { - buf[cnt] = ch; + ADDC(ch); } else { - buf[cnt++] = '\\'; - buf[cnt++] = (((unsigned int) ch >> 6) & 7) + '0'; - buf[cnt++] = (((unsigned int) ch >> 3) & 7) + '0'; - buf[cnt] = (ch & 7) + '0'; + ADDC('\\'); + ADDC((((unsigned int) ch >> 6) & 7) + '0'); + ADDC((((unsigned int) ch >> 3) & 7) + '0'); + ADDC((ch & 7) + '0'); } - return (cnt); + return b - sb; } /* key__decode_str(): * Make a printable version of the ey */ -protected char * -key__decode_str(const char *str, char *buf, const char *sep) +protected int +key__decode_str(const char *str, char *buf, int len, const char *sep) { - char *b; + char *b = buf, *eb = b + len; const char *p; b = buf; - if (sep[0] != '\0') - *b++ = sep[0]; - if (*str == 0) { - *b++ = '^'; - *b++ = '@'; - if (sep[0] != '\0' && sep[1] != '\0') - *b++ = sep[1]; - *b++ = 0; - return (buf); + if (sep[0] != '\0') { + ADDC(sep[0]); + } + if (*str == '\0') { + ADDC('^'); + ADDC('@'); + if (sep[0] != '\0' && sep[1] != '\0') { + ADDC(sep[1]); + } + goto done; } for (p = str; *p != 0; p++) { if (iscntrl((unsigned char) *p)) { - *b++ = '^'; - if (*p == '\177') - *b++ = '?'; - else - *b++ = *p | 0100; + ADDC('^'); + if (*p == '\177') { + ADDC('?'); + } else { + ADDC(*p | 0100); + } } else if (*p == '^' || *p == '\\') { - *b++ = '\\'; - *b++ = *p; + ADDC('\\'); + ADDC(*p); } else if (*p == ' ' || (isprint((unsigned char) *p) && !isspace((unsigned char) *p))) { - *b++ = *p; + ADDC(*p); } else { - *b++ = '\\'; - *b++ = (((unsigned int) *p >> 6) & 7) + '0'; - *b++ = (((unsigned int) *p >> 3) & 7) + '0'; - *b++ = (*p & 7) + '0'; + ADDC('\\'); + ADDC((((unsigned int) *p >> 6) & 7) + '0'); + ADDC((((unsigned int) *p >> 3) & 7) + '0'); + ADDC((*p & 7) + '0'); } } - if (sep[0] != '\0' && sep[1] != '\0') - *b++ = sep[1]; - *b++ = 0; - return (buf); /* should check for overflow */ + if (sep[0] != '\0' && sep[1] != '\0') { + ADDC(sep[1]); + } +done: + ADDC('\0'); + if (b - buf >= len) + buf[len - 1] = '\0'; + return b - buf; } Modified: vendor/NetBSD/libedit/dist/key.h ============================================================================== --- vendor/NetBSD/libedit/dist/key.h Thu Mar 31 18:28:09 2011 (r220215) +++ vendor/NetBSD/libedit/dist/key.h Thu Mar 31 18:28:46 2011 (r220216) @@ -1,4 +1,4 @@ -/* $NetBSD: key.h,v 1.8 2003/08/07 16:44:32 agc Exp $ */ +/* $NetBSD: key.h,v 1.10 2006/03/23 20:22:51 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -74,6 +74,8 @@ protected int key_delete(EditLine *, c protected void key_print(EditLine *, const char *); protected void key_kprint(EditLine *, const char *, key_value_t *, int); -protected char *key__decode_str(const char *, char *, const char *); +protected int key__decode_str(const char *, char *, int, + const char *); +protected int key__decode_char(char *, int, int, int); #endif /* _h_el_key */ Modified: vendor/NetBSD/libedit/dist/map.c ============================================================================== --- vendor/NetBSD/libedit/dist/map.c Thu Mar 31 18:28:09 2011 (r220215) +++ vendor/NetBSD/libedit/dist/map.c Thu Mar 31 18:28:46 2011 (r220216) @@ -1,4 +1,4 @@ -/* $NetBSD: map.c,v 1.22 2005/08/09 13:58:44 christos Exp $ */ +/* $NetBSD: map.c,v 1.23 2006/03/06 21:11:56 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: map.c,v 1.22 2005/08/09 13:58:44 christos Exp $"); +__RCSID("$NetBSD: map.c,v 1.23 2006/03/06 21:11:56 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -1128,7 +1128,7 @@ map_print_key(EditLine *el, el_action_t el_bindings_t *bp, *ep; if (in[0] == '\0' || in[1] == '\0') { - (void) key__decode_str(in, outbuf, ""); + (void) key__decode_str(in, outbuf, sizeof(outbuf), ""); ep = &el->el_map.help[el->el_map.nfunc]; for (bp = el->el_map.help; bp < ep; bp++) if (bp->func == map[(unsigned char) *in]) { @@ -1156,40 +1156,47 @@ map_print_some_keys(EditLine *el, el_act lastbuf[0] = last; lastbuf[1] = 0; if (map[first] == ED_UNASSIGNED) { - if (first == last) + if (first == last) { + (void) key__decode_str(firstbuf, unparsbuf, + sizeof(unparsbuf), STRQQ); (void) fprintf(el->el_outfile, - "%-15s-> is undefined\n", - key__decode_str(firstbuf, unparsbuf, STRQQ)); + "%-15s-> is undefined\n", unparsbuf); + } return; } ep = &el->el_map.help[el->el_map.nfunc]; for (bp = el->el_map.help; bp < ep; bp++) { if (bp->func == map[first]) { if (first == last) { + (void) key__decode_str(firstbuf, unparsbuf, + sizeof(unparsbuf), STRQQ); (void) fprintf(el->el_outfile, "%-15s-> %s\n", - key__decode_str(firstbuf, unparsbuf, STRQQ), - bp->name); + unparsbuf, bp->name); } else { + (void) key__decode_str(firstbuf, unparsbuf, + sizeof(unparsbuf), STRQQ); + (void) key__decode_str(lastbuf, extrabuf, + sizeof(extrabuf), STRQQ); (void) fprintf(el->el_outfile, "%-4s to %-7s-> %s\n", - key__decode_str(firstbuf, unparsbuf, STRQQ), - key__decode_str(lastbuf, extrabuf, STRQQ), - bp->name); + unparsbuf, extrabuf, bp->name); } return; } } #ifdef MAP_DEBUG if (map == el->el_map.key) { + (void) key__decode_str(firstbuf, unparsbuf, + sizeof(unparsbuf), STRQQ); (void) fprintf(el->el_outfile, - "BUG!!! %s isn't bound to anything.\n", - key__decode_str(firstbuf, unparsbuf, STRQQ)); + "BUG!!! %s isn't bound to anything.\n", unparsbuf); (void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n", first, el->el_map.key[first]); } else { + (void) key__decode_str(firstbuf, unparsbuf, + sizeof(unparsbuf), STRQQ); (void) fprintf(el->el_outfile, - "BUG!!! %s isn't bound to anything.\n", - key__decode_str(firstbuf, unparsbuf, STRQQ)); + "BUG!!! %s isn't bound to anything.\n", unparsbuf); (void) fprintf(el->el_outfile, "el->el_map.alt[%d] == %d\n", first, el->el_map.alt[first]); } Modified: vendor/NetBSD/libedit/dist/readline.c ============================================================================== --- vendor/NetBSD/libedit/dist/readline.c Thu Mar 31 18:28:09 2011 (r220215) +++ vendor/NetBSD/libedit/dist/readline.c Thu Mar 31 18:28:46 2011 (r220216) @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.58 2005/07/14 15:00:58 christos Exp $ */ +/* $NetBSD: readline.c,v 1.66 2006/03/21 17:52:50 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.58 2005/07/14 15:00:58 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.66 2006/03/21 17:52:50 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -160,6 +160,7 @@ static Function *map[256]; static unsigned char _el_rl_complete(EditLine *, int); static unsigned char _el_rl_tstp(EditLine *, int); static char *_get_prompt(EditLine *); +static int _getc_function(EditLine *, char *); static HIST_ENTRY *_move_history(int); static int _history_expand_command(const char *, size_t, size_t, char **); @@ -198,6 +199,23 @@ _move_history(int op) /* + * read one key from user defined input function + */ +static int +/*ARGSUSED*/ +_getc_function(EditLine *el, char *c) +{ + int i; + + i = (*rl_getc_function)(NULL, 0); + if (i == -1) + return 0; + *c = i; + return 1; +} + + +/* * READLINE compatibility stuff */ @@ -242,6 +260,10 @@ rl_initialize(void) max_input_history = INT_MAX; el_set(e, EL_HIST, history, h); + /* setup getc function if valid */ + if (rl_getc_function) + el_set(e, EL_GETCFN, _getc_function); + /* for proper prompt printing in readline() */ rl_prompt = strdup(""); if (rl_prompt == NULL) { @@ -706,6 +728,7 @@ _history_expand_command(const char *comm what = realloc(from, size); if (what == NULL) { free(from); + free(tmp); return 0; } len = 0; @@ -718,6 +741,7 @@ _history_expand_command(const char *comm (size <<= 1)); if (nwhat == NULL) { free(what); + free(tmp); return 0; } what = nwhat; @@ -730,10 +754,13 @@ _history_expand_command(const char *comm free(what); if (search) { from = strdup(search); - if (from == NULL) + if (from == NULL) { + free(tmp); return 0; + } } else { from = NULL; + free(tmp); return (-1); } } @@ -745,6 +772,7 @@ _history_expand_command(const char *comm with = realloc(to, size); if (with == NULL) { free(to); + free(tmp); return -1; } len = 0; @@ -756,6 +784,7 @@ _history_expand_command(const char *comm nwith = realloc(with, size); if (nwith == NULL) { free(with); + free(tmp); return -1; } with = nwith; @@ -824,12 +853,14 @@ history_expand(char *str, char **output) return 0; } -#define ADD_STRING(what, len) \ +#define ADD_STRING(what, len, fr) \ { \ if (idx + len + 1 > size) { \ char *nresult = realloc(result, (size += len + 1));\ if (nresult == NULL) { \ free(*output); \ + if (/*CONSTCOND*/fr) \ + free(tmp); \ return 0; \ } \ result = nresult; \ @@ -841,6 +872,7 @@ history_expand(char *str, char **output) result = NULL; size = idx = 0; + tmp = NULL; for (i = 0; str[i];) { int qchar, loop_again; size_t len, start, j; @@ -878,24 +910,29 @@ loop: goto loop; } len = i - start; - tmp = &str[start]; - ADD_STRING(tmp, len); + ADD_STRING(&str[start], len, 0); if (str[i] == '\0' || str[i] != history_expansion_char) { len = j - i; - tmp = &str[i]; - ADD_STRING(tmp, len); + ADD_STRING(&str[i], len, 0); if (start == 0) ret = 0; else ret = 1; break; } + if (tmp) { + free(tmp); + tmp = NULL; + } ret = _history_expand_command (str, i, (j - i), &tmp); if (ret > 0 && tmp) { len = strlen(tmp); - ADD_STRING(tmp, len); + ADD_STRING(tmp, len, 1); + } + if (tmp) { free(tmp); + tmp = NULL; } i = j; } @@ -1083,7 +1120,7 @@ read_history(const char *filename) if (h == NULL || e == NULL) rl_initialize(); - return (history(h, &ev, H_LOAD, filename)); + return (history(h, &ev, H_LOAD, filename) == -1); } @@ -1097,7 +1134,7 @@ write_history(const char *filename) if (h == NULL || e == NULL) rl_initialize(); - return (history(h, &ev, H_SAVE, filename)); + return (history(h, &ev, H_SAVE, filename) == -1); } @@ -1614,7 +1651,7 @@ rl_callback_read_char() if (buf == NULL || count-- <= 0) return; - if (count == 0 && buf[0] == CTRL('d')) + if (count == 0 && buf[0] == e->el_tty.t_c[TS_IO][C_EOF]) done = 1; if (buf[count] == '\n' || buf[count] == '\r') done = 2; @@ -1654,7 +1691,7 @@ void rl_redisplay(void) { char a[2]; - a[0] = CTRL('r'); + a[0] = e->el_tty.t_c[TS_IO][C_REPRINT]; a[1] = '\0'; el_push(e, a); } Modified: vendor/NetBSD/libedit/dist/term.c ============================================================================== --- vendor/NetBSD/libedit/dist/term.c Thu Mar 31 18:28:09 2011 (r220215) +++ vendor/NetBSD/libedit/dist/term.c Thu Mar 31 18:28:46 2011 (r220216) @@ -1,4 +1,4 @@ -/* $NetBSD: term.c,v 1.41 2005/08/08 14:05:37 christos Exp $ */ +/* $NetBSD: term.c,v 1.45 2006/03/18 19:23:14 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95"; #else -__RCSID("$NetBSD: term.c,v 1.41 2005/08/08 14:05:37 christos Exp $"); +__RCSID("$NetBSD: term.c,v 1.45 2006/03/18 19:23:14 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -398,7 +398,8 @@ term_alloc(EditLine *el, const struct te * New string is shorter; no need to allocate space */ if (clen <= tlen) { - (void) strcpy(*str, cap); /* XXX strcpy is safe */ + if (*str) + (void) strcpy(*str, cap); /* XXX strcpy is safe */ return; } /* @@ -472,8 +473,12 @@ term_alloc_display(EditLine *el) return (-1); for (i = 0; i < c->v; i++) { b[i] = (char *) el_malloc((size_t) (sizeof(char) * (c->h + 1))); - if (b[i] == NULL) + if (b[i] == NULL) { + while (--i >= 0) + el_free((ptr_t) b[i]); + el_free((ptr_t) b); return (-1); + } } b[c->v] = NULL; el->el_display = b; @@ -483,8 +488,12 @@ term_alloc_display(EditLine *el) return (-1); for (i = 0; i < c->v; i++) { b[i] = (char *) el_malloc((size_t) (sizeof(char) * (c->h + 1))); - if (b[i] == NULL) + if (b[i] == NULL) { + while (--i >= 0) + el_free((ptr_t) b[i]); + el_free((ptr_t) b); return (-1); + } } b[c->v] = NULL; el->el_vdisplay = b; @@ -1250,6 +1259,19 @@ term__flush(void) (void) fflush(term_outfile); } +/* term_writec(): + * Write the given character out, in a human readable form + */ +protected void +term_writec(EditLine *el, int c) +{ + char buf[8]; + int cnt = key__decode_char(buf, sizeof(buf), 0, c); + buf[cnt] = '\0'; + term_overwrite(el, buf, cnt); + term__flush(); +} + /* term_telltc(): * Print the current termcap characteristics @@ -1277,11 +1299,17 @@ term_telltc(EditLine *el, int argc __att (void) fprintf(el->el_outfile, "\tIt %s magic margins\n", EL_HAS_MAGIC_MARGINS ? "has" : "does not have"); - for (t = tstr, ts = el->el_term.t_str; t->name != NULL; t++, ts++) + for (t = tstr, ts = el->el_term.t_str; t->name != NULL; t++, ts++) { + const char *ub; + if (*ts && **ts) { + (void) key__decode_str(*ts, upbuf, sizeof(upbuf), ""); + ub = upbuf; + } else { + ub = "(empty)"; + } (void) fprintf(el->el_outfile, "\t%25s (%s) == %s\n", - t->long_name, - t->name, *ts && **ts ? - key__decode_str(*ts, upbuf, "") : "(empty)"); + t->long_name, t->name, ub); + } (void) fputc('\n', el->el_outfile); return (0); } Modified: vendor/NetBSD/libedit/dist/term.h ============================================================================== --- vendor/NetBSD/libedit/dist/term.h Thu Mar 31 18:28:09 2011 (r220215) +++ vendor/NetBSD/libedit/dist/term.h Thu Mar 31 18:28:46 2011 (r220216) @@ -1,4 +1,4 @@ -/* $NetBSD: term.h,v 1.16 2005/03/15 00:10:40 christos Exp $ */ +/* $NetBSD: term.h,v 1.17 2006/03/06 21:11:56 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -102,6 +102,7 @@ protected int term_set(EditLine *, const protected int term_settc(EditLine *, int, const char **); protected int term_telltc(EditLine *, int, const char **); protected int term_echotc(EditLine *, int, const char **); +protected void term_writec(EditLine *, int); protected int term__putc(int); protected void term__flush(void); Modified: vendor/NetBSD/libedit/dist/tty.c ============================================================================== --- vendor/NetBSD/libedit/dist/tty.c Thu Mar 31 18:28:09 2011 (r220215) +++ vendor/NetBSD/libedit/dist/tty.c Thu Mar 31 18:28:46 2011 (r220216) @@ -1,4 +1,4 @@ -/* $NetBSD: tty.c,v 1.23 2005/06/01 11:37:52 lukem Exp $ */ +/* $NetBSD: tty.c,v 1.25 2006/03/18 09:09:41 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: tty.c,v 1.23 2005/06/01 11:37:52 lukem Exp $"); +__RCSID("$NetBSD: tty.c,v 1.25 2006/03/18 09:09:41 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -529,8 +529,11 @@ tty_setup(EditLine *el) #endif /* DEBUG_TTY */ return (-1); } - } else + } +#ifdef notdef + else tty__setchar(&el->el_tty.t_ex, el->el_tty.t_c[EX_IO]); +#endif el->el_tty.t_ed.c_iflag &= ~el->el_tty.t_t[ED_IO][MD_INP].t_clrmask; el->el_tty.t_ed.c_iflag |= el->el_tty.t_t[ED_IO][MD_INP].t_setmask; @@ -1200,10 +1203,14 @@ tty_stty(EditLine *el, int argc __attrib st = len = strlen(el->el_tty.t_t[z][m->m_type].t_name); } - x = (el->el_tty.t_t[z][i].t_setmask & m->m_value) - ? '+' : '\0'; - x = (el->el_tty.t_t[z][i].t_clrmask & m->m_value) - ? '-' : x; + if (i != -1) { + x = (el->el_tty.t_t[z][i].t_setmask & m->m_value) + ? '+' : '\0'; + x = (el->el_tty.t_t[z][i].t_clrmask & m->m_value) + ? '-' : x; + } else { + x = '\0'; + } if (x != '\0' || aflag) { Modified: vendor/NetBSD/libedit/dist/vi.c ============================================================================== --- vendor/NetBSD/libedit/dist/vi.c Thu Mar 31 18:28:09 2011 (r220215) +++ vendor/NetBSD/libedit/dist/vi.c Thu Mar 31 18:28:46 2011 (r220216) @@ -1,4 +1,4 @@ -/* $NetBSD: vi.c,v 1.24 2005/08/10 12:46:24 christos Exp $ */ +/* $NetBSD: vi.c,v 1.25 2006/03/06 21:11:56 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: vi.c,v 1.24 2005/08/10 12:46:24 christos Exp $"); +__RCSID("$NetBSD: vi.c,v 1.25 2006/03/06 21:11:56 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -600,13 +600,12 @@ vi_delete_prev_char(EditLine *el, int c */ protected el_action_t /*ARGSUSED*/ -vi_list_or_eof(EditLine *el, int c __attribute__((__unused__))) +vi_list_or_eof(EditLine *el, int c) { if (el->el_line.cursor == el->el_line.lastchar) { if (el->el_line.cursor == el->el_line.buffer) { - term_overwrite(el, STReof, 4); /* then do a EOF */ - term__flush(); + term_writec(el, c); /* then do a EOF */ return (CC_EOF); } else { /* From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 18:29:20 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D66951065673; Thu, 31 Mar 2011 18:29:20 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C32B08FC21; Thu, 31 Mar 2011 18:29:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VITK06015028; Thu, 31 Mar 2011 18:29:20 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VITKuS015024; Thu, 31 Mar 2011 18:29:20 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201103311829.p2VITKuS015024@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 31 Mar 2011 18:29:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220217 - vendor/NetBSD/libedit/2006-03-23 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 18:29:20 -0000 Author: obrien Date: Thu Mar 31 18:29:20 2011 New Revision: 220217 URL: http://svn.freebsd.org/changeset/base/220217 Log: "Tag" the "2006/03/23 20:22:51 UTC" import. Added: vendor/NetBSD/libedit/2006-03-23/ - copied from r220214, vendor/NetBSD/libedit/dist/ Replaced: vendor/NetBSD/libedit/2006-03-23/chared.h - copied unchanged from r220216, vendor/NetBSD/libedit/dist/chared.h vendor/NetBSD/libedit/2006-03-23/common.c - copied unchanged from r220216, vendor/NetBSD/libedit/dist/common.c vendor/NetBSD/libedit/2006-03-23/emacs.c - copied unchanged from r220216, vendor/NetBSD/libedit/dist/emacs.c vendor/NetBSD/libedit/2006-03-23/key.c - copied unchanged from r220216, vendor/NetBSD/libedit/dist/key.c vendor/NetBSD/libedit/2006-03-23/key.h - copied unchanged from r220216, vendor/NetBSD/libedit/dist/key.h vendor/NetBSD/libedit/2006-03-23/map.c - copied unchanged from r220216, vendor/NetBSD/libedit/dist/map.c vendor/NetBSD/libedit/2006-03-23/readline.c - copied unchanged from r220216, vendor/NetBSD/libedit/dist/readline.c vendor/NetBSD/libedit/2006-03-23/term.c - copied unchanged from r220216, vendor/NetBSD/libedit/dist/term.c vendor/NetBSD/libedit/2006-03-23/term.h - copied unchanged from r220216, vendor/NetBSD/libedit/dist/term.h vendor/NetBSD/libedit/2006-03-23/tty.c - copied unchanged from r220216, vendor/NetBSD/libedit/dist/tty.c vendor/NetBSD/libedit/2006-03-23/vi.c - copied unchanged from r220216, vendor/NetBSD/libedit/dist/vi.c Copied: vendor/NetBSD/libedit/2006-03-23/chared.h (from r220216, vendor/NetBSD/libedit/dist/chared.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/2006-03-23/chared.h Thu Mar 31 18:29:20 2011 (r220217, copy of r220216, vendor/NetBSD/libedit/dist/chared.h) @@ -0,0 +1,167 @@ +/* $NetBSD: chared.h,v 1.17 2006/03/06 21:11:56 christos Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Christos Zoulas of Cornell University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)chared.h 8.1 (Berkeley) 6/4/93 + */ + +/* + * el.chared.h: Character editor interface + */ +#ifndef _h_el_chared +#define _h_el_chared + +#include +#include + +#include "histedit.h" + +#define EL_MAXMACRO 10 + +/* + * This is an issue of basic "vi" look-and-feel. Defining VI_MOVE works + * like real vi: i.e. the transition from command<->insert modes moves + * the cursor. + * + * On the other hand we really don't want to move the cursor, because + * all the editing commands don't include the character under the cursor. + * Probably the best fix is to make all the editing commands aware of + * this fact. + */ +#define VI_MOVE + + +typedef struct c_macro_t { + int level; + int offset; + char **macro; +} c_macro_t; + +/* + * Undo information for vi - no undo in emacs (yet) + */ +typedef struct c_undo_t { + int len; /* length of saved line */ + int cursor; /* position of saved cursor */ + char *buf; /* full saved text */ +} c_undo_t; + +/* redo for vi */ +typedef struct c_redo_t { + char *buf; /* redo insert key sequence */ + char *pos; + char *lim; + el_action_t cmd; /* command to redo */ + char ch; /* char that invoked it */ + int count; + int action; /* from cv_action() */ +} c_redo_t; + +/* + * Current action information for vi + */ +typedef struct c_vcmd_t { + int action; + char *pos; +} c_vcmd_t; + +/* + * Kill buffer for emacs + */ +typedef struct c_kill_t { + char *buf; + char *last; + char *mark; +} c_kill_t; + +/* + * Note that we use both data structures because the user can bind + * commands from both editors! + */ +typedef struct el_chared_t { + c_undo_t c_undo; + c_kill_t c_kill; + c_redo_t c_redo; + c_vcmd_t c_vcmd; + c_macro_t c_macro; +} el_chared_t; + + +#define STRQQ "\"\"" + +#define isglob(a) (strchr("*[]?", (a)) != NULL) +#define isword(a) (isprint(a)) + +#define NOP 0x00 +#define DELETE 0x01 +#define INSERT 0x02 +#define YANK 0x04 + +#define CHAR_FWD (+1) +#define CHAR_BACK (-1) + +#define MODE_INSERT 0 +#define MODE_REPLACE 1 +#define MODE_REPLACE_1 2 + +#include "common.h" +#include "vi.h" +#include "emacs.h" +#include "search.h" +#include "fcns.h" + + +protected int cv__isword(int); +protected int cv__isWord(int); +protected void cv_delfini(EditLine *); +protected char *cv__endword(char *, char *, int, int (*)(int)); +protected int ce__isword(int); +protected void cv_undo(EditLine *); +protected void cv_yank(EditLine *, const char *, int); +protected char *cv_next_word(EditLine*, char *, char *, int, int (*)(int)); +protected char *cv_prev_word(char *, char *, int, int (*)(int)); +protected char *c__next_word(char *, char *, int, int (*)(int)); +protected char *c__prev_word(char *, char *, int, int (*)(int)); +protected void c_insert(EditLine *, int); +protected void c_delbefore(EditLine *, int); +protected void c_delbefore1(EditLine *); +protected void c_delafter(EditLine *, int); +protected void c_delafter1(EditLine *); +protected int c_gets(EditLine *, char *, const char *); +protected int c_hpos(EditLine *); + +protected int ch_init(EditLine *); +protected void ch_reset(EditLine *, int); +protected int ch_enlargebufs(EditLine *, size_t); +protected void ch_end(EditLine *); + +#endif /* _h_el_chared */ Copied: vendor/NetBSD/libedit/2006-03-23/common.c (from r220216, vendor/NetBSD/libedit/dist/common.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/2006-03-23/common.c Thu Mar 31 18:29:20 2011 (r220217, copy of r220216, vendor/NetBSD/libedit/dist/common.c) @@ -0,0 +1,921 @@ +/* $NetBSD: common.c,v 1.19 2006/03/06 21:11:56 christos Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Christos Zoulas of Cornell University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "config.h" +#if !defined(lint) && !defined(SCCSID) +#if 0 +static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: common.c,v 1.19 2006/03/06 21:11:56 christos Exp $"); +#endif +#endif /* not lint && not SCCSID */ + +/* + * common.c: Common Editor functions + */ +#include "el.h" + +/* ed_end_of_file(): + * Indicate end of file + * [^D] + */ +protected el_action_t +/*ARGSUSED*/ +ed_end_of_file(EditLine *el, int c __attribute__((__unused__))) +{ + + re_goto_bottom(el); + *el->el_line.lastchar = '\0'; + return (CC_EOF); +} + + +/* ed_insert(): + * Add character to the line + * Insert a character [bound to all insert keys] + */ +protected el_action_t +ed_insert(EditLine *el, int c) +{ + int count = el->el_state.argument; + + if (c == '\0') + return (CC_ERROR); + + if (el->el_line.lastchar + el->el_state.argument >= + el->el_line.limit) { + /* end of buffer space, try to allocate more */ + if (!ch_enlargebufs(el, (size_t) count)) + return CC_ERROR; /* error allocating more */ + } + + if (count == 1) { + if (el->el_state.inputmode == MODE_INSERT + || el->el_line.cursor >= el->el_line.lastchar) + c_insert(el, 1); + + *el->el_line.cursor++ = c; + re_fastaddc(el); /* fast refresh for one char. */ + } else { + if (el->el_state.inputmode != MODE_REPLACE_1) + c_insert(el, el->el_state.argument); + + while (count-- && el->el_line.cursor < el->el_line.lastchar) + *el->el_line.cursor++ = c; + re_refresh(el); + } + + if (el->el_state.inputmode == MODE_REPLACE_1) + return vi_command_mode(el, 0); + + return (CC_NORM); +} + + +/* ed_delete_prev_word(): + * Delete from beginning of current word to cursor + * [M-^?] [^W] + */ +protected el_action_t +/*ARGSUSED*/ +ed_delete_prev_word(EditLine *el, int c __attribute__((__unused__))) +{ + char *cp, *p, *kp; + + if (el->el_line.cursor == el->el_line.buffer) + return (CC_ERROR); + + cp = c__prev_word(el->el_line.cursor, el->el_line.buffer, + el->el_state.argument, ce__isword); + + for (p = cp, kp = el->el_chared.c_kill.buf; p < el->el_line.cursor; p++) + *kp++ = *p; + el->el_chared.c_kill.last = kp; + + c_delbefore(el, el->el_line.cursor - cp); /* delete before dot */ + el->el_line.cursor = cp; + if (el->el_line.cursor < el->el_line.buffer) + el->el_line.cursor = el->el_line.buffer; /* bounds check */ + return (CC_REFRESH); +} + + +/* ed_delete_next_char(): + * Delete character under cursor + * [^D] [x] + */ +protected el_action_t +/*ARGSUSED*/ +ed_delete_next_char(EditLine *el, int c) +{ +#ifdef notdef /* XXX */ +#define EL el->el_line + (void) fprintf(el->el_errlfile, + "\nD(b: %x(%s) c: %x(%s) last: %x(%s) limit: %x(%s)\n", + EL.buffer, EL.buffer, EL.cursor, EL.cursor, EL.lastchar, + EL.lastchar, EL.limit, EL.limit); +#endif + if (el->el_line.cursor == el->el_line.lastchar) { + /* if I'm at the end */ + if (el->el_map.type == MAP_VI) { + if (el->el_line.cursor == el->el_line.buffer) { + /* if I'm also at the beginning */ +#ifdef KSHVI + return (CC_ERROR); +#else + /* then do an EOF */ + term_writechar(el, c); + return (CC_EOF); +#endif + } else { +#ifdef KSHVI + el->el_line.cursor--; +#else + return (CC_ERROR); +#endif + } + } else { + if (el->el_line.cursor != el->el_line.buffer) + el->el_line.cursor--; + else + return (CC_ERROR); + } + } + c_delafter(el, el->el_state.argument); /* delete after dot */ + if (el->el_line.cursor >= el->el_line.lastchar && + el->el_line.cursor > el->el_line.buffer) + /* bounds check */ + el->el_line.cursor = el->el_line.lastchar - 1; + return (CC_REFRESH); +} + + +/* ed_kill_line(): + * Cut to the end of line + * [^K] [^K] + */ +protected el_action_t +/*ARGSUSED*/ +ed_kill_line(EditLine *el, int c __attribute__((__unused__))) +{ + char *kp, *cp; + + cp = el->el_line.cursor; + kp = el->el_chared.c_kill.buf; + while (cp < el->el_line.lastchar) + *kp++ = *cp++; /* copy it */ + el->el_chared.c_kill.last = kp; + /* zap! -- delete to end */ + el->el_line.lastchar = el->el_line.cursor; + return (CC_REFRESH); +} + + +/* ed_move_to_end(): + * Move cursor to the end of line + * [^E] [^E] + */ +protected el_action_t +/*ARGSUSED*/ +ed_move_to_end(EditLine *el, int c __attribute__((__unused__))) +{ + + el->el_line.cursor = el->el_line.lastchar; + if (el->el_map.type == MAP_VI) { +#ifdef VI_MOVE + el->el_line.cursor--; +#endif + if (el->el_chared.c_vcmd.action != NOP) { + cv_delfini(el); + return (CC_REFRESH); + } + } + return (CC_CURSOR); +} + + +/* ed_move_to_beg(): + * Move cursor to the beginning of line + * [^A] [^A] + */ +protected el_action_t +/*ARGSUSED*/ +ed_move_to_beg(EditLine *el, int c __attribute__((__unused__))) +{ + + el->el_line.cursor = el->el_line.buffer; + + if (el->el_map.type == MAP_VI) { + /* We want FIRST non space character */ + while (isspace((unsigned char) *el->el_line.cursor)) + el->el_line.cursor++; + if (el->el_chared.c_vcmd.action != NOP) { + cv_delfini(el); + return (CC_REFRESH); + } + } + return (CC_CURSOR); +} + + +/* ed_transpose_chars(): + * Exchange the character to the left of the cursor with the one under it + * [^T] [^T] + */ +protected el_action_t +ed_transpose_chars(EditLine *el, int c) +{ + + if (el->el_line.cursor < el->el_line.lastchar) { + if (el->el_line.lastchar <= &el->el_line.buffer[1]) + return (CC_ERROR); + else + el->el_line.cursor++; + } + if (el->el_line.cursor > &el->el_line.buffer[1]) { + /* must have at least two chars entered */ + c = el->el_line.cursor[-2]; + el->el_line.cursor[-2] = el->el_line.cursor[-1]; + el->el_line.cursor[-1] = c; + return (CC_REFRESH); + } else + return (CC_ERROR); +} + + +/* ed_next_char(): + * Move to the right one character + * [^F] [^F] + */ +protected el_action_t +/*ARGSUSED*/ +ed_next_char(EditLine *el, int c __attribute__((__unused__))) +{ + char *lim = el->el_line.lastchar; + + if (el->el_line.cursor >= lim || + (el->el_line.cursor == lim - 1 && + el->el_map.type == MAP_VI && + el->el_chared.c_vcmd.action == NOP)) + return (CC_ERROR); + + el->el_line.cursor += el->el_state.argument; + if (el->el_line.cursor > lim) + el->el_line.cursor = lim; + + if (el->el_map.type == MAP_VI) + if (el->el_chared.c_vcmd.action != NOP) { + cv_delfini(el); + return (CC_REFRESH); + } + return (CC_CURSOR); +} + + +/* ed_prev_word(): + * Move to the beginning of the current word + * [M-b] [b] + */ +protected el_action_t +/*ARGSUSED*/ +ed_prev_word(EditLine *el, int c __attribute__((__unused__))) +{ + + if (el->el_line.cursor == el->el_line.buffer) + return (CC_ERROR); + + el->el_line.cursor = c__prev_word(el->el_line.cursor, + el->el_line.buffer, + el->el_state.argument, + ce__isword); + + if (el->el_map.type == MAP_VI) + if (el->el_chared.c_vcmd.action != NOP) { + cv_delfini(el); + return (CC_REFRESH); + } + return (CC_CURSOR); +} + + +/* ed_prev_char(): + * Move to the left one character + * [^B] [^B] + */ +protected el_action_t +/*ARGSUSED*/ +ed_prev_char(EditLine *el, int c __attribute__((__unused__))) +{ + + if (el->el_line.cursor > el->el_line.buffer) { + el->el_line.cursor -= el->el_state.argument; + if (el->el_line.cursor < el->el_line.buffer) + el->el_line.cursor = el->el_line.buffer; + + if (el->el_map.type == MAP_VI) + if (el->el_chared.c_vcmd.action != NOP) { + cv_delfini(el); + return (CC_REFRESH); + } + return (CC_CURSOR); + } else + return (CC_ERROR); +} + + +/* ed_quoted_insert(): + * Add the next character typed verbatim + * [^V] [^V] + */ +protected el_action_t +ed_quoted_insert(EditLine *el, int c) +{ + int num; + char tc; + + tty_quotemode(el); + num = el_getc(el, &tc); + c = (unsigned char) tc; + tty_noquotemode(el); + if (num == 1) + return (ed_insert(el, c)); + else + return (ed_end_of_file(el, 0)); +} + + +/* ed_digit(): + * Adds to argument or enters a digit + */ +protected el_action_t +ed_digit(EditLine *el, int c) +{ + + if (!isdigit(c)) + return (CC_ERROR); + + if (el->el_state.doingarg) { + /* if doing an arg, add this in... */ + if (el->el_state.lastcmd == EM_UNIVERSAL_ARGUMENT) + el->el_state.argument = c - '0'; + else { + if (el->el_state.argument > 1000000) + return (CC_ERROR); + el->el_state.argument = + (el->el_state.argument * 10) + (c - '0'); + } + return (CC_ARGHACK); + } + + return ed_insert(el, c); +} + + +/* ed_argument_digit(): + * Digit that starts argument + * For ESC-n + */ +protected el_action_t +ed_argument_digit(EditLine *el, int c) +{ + + if (!isdigit(c)) + return (CC_ERROR); + + if (el->el_state.doingarg) { + if (el->el_state.argument > 1000000) + return (CC_ERROR); + el->el_state.argument = (el->el_state.argument * 10) + + (c - '0'); + } else { /* else starting an argument */ + el->el_state.argument = c - '0'; + el->el_state.doingarg = 1; + } + return (CC_ARGHACK); +} + + +/* ed_unassigned(): + * Indicates unbound character + * Bound to keys that are not assigned + */ +protected el_action_t +/*ARGSUSED*/ +ed_unassigned(EditLine *el, int c __attribute__((__unused__))) +{ + + return (CC_ERROR); +} + + +/** + ** TTY key handling. + **/ + +/* ed_tty_sigint(): + * Tty interrupt character + * [^C] + */ +protected el_action_t +/*ARGSUSED*/ +ed_tty_sigint(EditLine *el __attribute__((__unused__)), + int c __attribute__((__unused__))) +{ + + return (CC_NORM); +} + + +/* ed_tty_dsusp(): + * Tty delayed suspend character + * [^Y] + */ +protected el_action_t +/*ARGSUSED*/ +ed_tty_dsusp(EditLine *el __attribute__((__unused__)), + int c __attribute__((__unused__))) +{ + + return (CC_NORM); +} + + +/* ed_tty_flush_output(): + * Tty flush output characters + * [^O] + */ +protected el_action_t +/*ARGSUSED*/ +ed_tty_flush_output(EditLine *el __attribute__((__unused__)), + int c __attribute__((__unused__))) +{ + + return (CC_NORM); +} + + +/* ed_tty_sigquit(): + * Tty quit character + * [^\] + */ +protected el_action_t +/*ARGSUSED*/ +ed_tty_sigquit(EditLine *el __attribute__((__unused__)), + int c __attribute__((__unused__))) +{ + + return (CC_NORM); +} + + +/* ed_tty_sigtstp(): + * Tty suspend character + * [^Z] + */ +protected el_action_t +/*ARGSUSED*/ +ed_tty_sigtstp(EditLine *el __attribute__((__unused__)), + int c __attribute__((__unused__))) +{ + + return (CC_NORM); +} + + +/* ed_tty_stop_output(): + * Tty disallow output characters + * [^S] + */ +protected el_action_t +/*ARGSUSED*/ +ed_tty_stop_output(EditLine *el __attribute__((__unused__)), + int c __attribute__((__unused__))) +{ + + return (CC_NORM); +} + + +/* ed_tty_start_output(): + * Tty allow output characters + * [^Q] + */ +protected el_action_t +/*ARGSUSED*/ +ed_tty_start_output(EditLine *el __attribute__((__unused__)), + int c __attribute__((__unused__))) +{ + + return (CC_NORM); +} + + +/* ed_newline(): + * Execute command + * [^J] + */ +protected el_action_t +/*ARGSUSED*/ +ed_newline(EditLine *el, int c __attribute__((__unused__))) +{ + + re_goto_bottom(el); + *el->el_line.lastchar++ = '\n'; + *el->el_line.lastchar = '\0'; + return (CC_NEWLINE); +} + + +/* ed_delete_prev_char(): + * Delete the character to the left of the cursor + * [^?] + */ +protected el_action_t +/*ARGSUSED*/ +ed_delete_prev_char(EditLine *el, int c __attribute__((__unused__))) +{ + + if (el->el_line.cursor <= el->el_line.buffer) + return (CC_ERROR); + + c_delbefore(el, el->el_state.argument); + el->el_line.cursor -= el->el_state.argument; + if (el->el_line.cursor < el->el_line.buffer) + el->el_line.cursor = el->el_line.buffer; + return (CC_REFRESH); +} + + +/* ed_clear_screen(): + * Clear screen leaving current line at the top + * [^L] + */ +protected el_action_t +/*ARGSUSED*/ +ed_clear_screen(EditLine *el, int c __attribute__((__unused__))) +{ + + term_clear_screen(el); /* clear the whole real screen */ + re_clear_display(el); /* reset everything */ + return (CC_REFRESH); +} + + +/* ed_redisplay(): + * Redisplay everything + * ^R + */ +protected el_action_t +/*ARGSUSED*/ +ed_redisplay(EditLine *el __attribute__((__unused__)), + int c __attribute__((__unused__))) +{ + + return (CC_REDISPLAY); +} + + +/* ed_start_over(): + * Erase current line and start from scratch + * [^G] + */ +protected el_action_t +/*ARGSUSED*/ +ed_start_over(EditLine *el, int c __attribute__((__unused__))) +{ + + ch_reset(el, 0); + return (CC_REFRESH); +} + + +/* ed_sequence_lead_in(): + * First character in a bound sequence + * Placeholder for external keys + */ +protected el_action_t +/*ARGSUSED*/ +ed_sequence_lead_in(EditLine *el __attribute__((__unused__)), + int c __attribute__((__unused__))) +{ + + return (CC_NORM); +} + + +/* ed_prev_history(): + * Move to the previous history line + * [^P] [k] + */ +protected el_action_t +/*ARGSUSED*/ +ed_prev_history(EditLine *el, int c __attribute__((__unused__))) +{ + char beep = 0; + int sv_event = el->el_history.eventno; + + el->el_chared.c_undo.len = -1; + *el->el_line.lastchar = '\0'; /* just in case */ + + if (el->el_history.eventno == 0) { /* save the current buffer + * away */ + (void) strncpy(el->el_history.buf, el->el_line.buffer, + EL_BUFSIZ); + el->el_history.last = el->el_history.buf + + (el->el_line.lastchar - el->el_line.buffer); + } + el->el_history.eventno += el->el_state.argument; + + if (hist_get(el) == CC_ERROR) { + if (el->el_map.type == MAP_VI) { + el->el_history.eventno = sv_event; + return CC_ERROR; + } + beep = 1; + /* el->el_history.eventno was fixed by first call */ + (void) hist_get(el); + } + if (beep) + return CC_REFRESH_BEEP; + return CC_REFRESH; +} + + +/* ed_next_history(): + * Move to the next history line + * [^N] [j] + */ +protected el_action_t +/*ARGSUSED*/ +ed_next_history(EditLine *el, int c __attribute__((__unused__))) +{ + el_action_t beep = CC_REFRESH, rval; + + el->el_chared.c_undo.len = -1; + *el->el_line.lastchar = '\0'; /* just in case */ + + el->el_history.eventno -= el->el_state.argument; + + if (el->el_history.eventno < 0) { + el->el_history.eventno = 0; + beep = CC_REFRESH_BEEP; + } + rval = hist_get(el); + if (rval == CC_REFRESH) + return beep; + return rval; + +} + + +/* ed_search_prev_history(): + * Search previous in history for a line matching the current + * next search history [M-P] [K] + */ +protected el_action_t +/*ARGSUSED*/ +ed_search_prev_history(EditLine *el, int c __attribute__((__unused__))) +{ + const char *hp; + int h; + bool_t found = 0; + + el->el_chared.c_vcmd.action = NOP; + el->el_chared.c_undo.len = -1; + *el->el_line.lastchar = '\0'; /* just in case */ + if (el->el_history.eventno < 0) { +#ifdef DEBUG_EDIT + (void) fprintf(el->el_errfile, + "e_prev_search_hist(): eventno < 0;\n"); +#endif + el->el_history.eventno = 0; + return (CC_ERROR); + } + if (el->el_history.eventno == 0) { + (void) strncpy(el->el_history.buf, el->el_line.buffer, + EL_BUFSIZ); + el->el_history.last = el->el_history.buf + + (el->el_line.lastchar - el->el_line.buffer); + } + if (el->el_history.ref == NULL) + return (CC_ERROR); + + hp = HIST_FIRST(el); + if (hp == NULL) + return (CC_ERROR); + + c_setpat(el); /* Set search pattern !! */ + + for (h = 1; h <= el->el_history.eventno; h++) + hp = HIST_NEXT(el); + + while (hp != NULL) { +#ifdef SDEBUG + (void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp); +#endif + if ((strncmp(hp, el->el_line.buffer, (size_t) + (el->el_line.lastchar - el->el_line.buffer)) || + hp[el->el_line.lastchar - el->el_line.buffer]) && + c_hmatch(el, hp)) { + found++; + break; + } + h++; + hp = HIST_NEXT(el); + } + + if (!found) { +#ifdef SDEBUG + (void) fprintf(el->el_errfile, "not found\n"); +#endif + return (CC_ERROR); + } + el->el_history.eventno = h; + + return (hist_get(el)); +} + + +/* ed_search_next_history(): + * Search next in history for a line matching the current + * [M-N] [J] + */ +protected el_action_t +/*ARGSUSED*/ +ed_search_next_history(EditLine *el, int c __attribute__((__unused__))) +{ + const char *hp; + int h; + bool_t found = 0; + + el->el_chared.c_vcmd.action = NOP; + el->el_chared.c_undo.len = -1; + *el->el_line.lastchar = '\0'; /* just in case */ + + if (el->el_history.eventno == 0) + return (CC_ERROR); + + if (el->el_history.ref == NULL) + return (CC_ERROR); + + hp = HIST_FIRST(el); + if (hp == NULL) + return (CC_ERROR); + + c_setpat(el); /* Set search pattern !! */ + + for (h = 1; h < el->el_history.eventno && hp; h++) { +#ifdef SDEBUG + (void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp); +#endif + if ((strncmp(hp, el->el_line.buffer, (size_t) + (el->el_line.lastchar - el->el_line.buffer)) || + hp[el->el_line.lastchar - el->el_line.buffer]) && + c_hmatch(el, hp)) + found = h; + hp = HIST_NEXT(el); + } + + if (!found) { /* is it the current history number? */ + if (!c_hmatch(el, el->el_history.buf)) { +#ifdef SDEBUG + (void) fprintf(el->el_errfile, "not found\n"); +#endif + return (CC_ERROR); + } + } + el->el_history.eventno = found; + + return (hist_get(el)); +} + + +/* ed_prev_line(): + * Move up one line + * Could be [k] [^p] + */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 18:31:27 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 94F3F1065674; Thu, 31 Mar 2011 18:31:27 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 817A38FC08; Thu, 31 Mar 2011 18:31:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VIVRs7015120; Thu, 31 Mar 2011 18:31:27 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VIVRBR015109; Thu, 31 Mar 2011 18:31:27 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201103311831.p2VIVRBR015109@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 31 Mar 2011 18:31:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220218 - in vendor/NetBSD/libedit/dist: . TEST readline X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 18:31:27 -0000 Author: obrien Date: Thu Mar 31 18:31:27 2011 New Revision: 220218 URL: http://svn.freebsd.org/changeset/base/220218 Log: Vendor import NetBSD's libedit of "2007/01/12 16:31:13 UTC". Obtained from: NetBSD Added: vendor/NetBSD/libedit/dist/TEST/tc1.c (contents, props changed) Deleted: vendor/NetBSD/libedit/dist/TEST/test.c Modified: vendor/NetBSD/libedit/dist/Makefile vendor/NetBSD/libedit/dist/TEST/Makefile vendor/NetBSD/libedit/dist/editline.3 vendor/NetBSD/libedit/dist/editrc.5 vendor/NetBSD/libedit/dist/el.c vendor/NetBSD/libedit/dist/el.h vendor/NetBSD/libedit/dist/filecomplete.c vendor/NetBSD/libedit/dist/filecomplete.h vendor/NetBSD/libedit/dist/histedit.h vendor/NetBSD/libedit/dist/history.c vendor/NetBSD/libedit/dist/map.c vendor/NetBSD/libedit/dist/read.h vendor/NetBSD/libedit/dist/readline.c vendor/NetBSD/libedit/dist/readline/readline.h vendor/NetBSD/libedit/dist/shlib_version vendor/NetBSD/libedit/dist/term.c vendor/NetBSD/libedit/dist/term.h vendor/NetBSD/libedit/dist/vi.c Modified: vendor/NetBSD/libedit/dist/Makefile ============================================================================== --- vendor/NetBSD/libedit/dist/Makefile Thu Mar 31 18:29:20 2011 (r220217) +++ vendor/NetBSD/libedit/dist/Makefile Thu Mar 31 18:31:27 2011 (r220218) @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.34 2005/05/28 12:02:53 lukem Exp $ +# $NetBSD: Makefile,v 1.35 2006/08/31 20:20:38 rpaulo Exp $ # @(#)Makefile 8.1 (Berkeley) 6/4/93 USE_SHLIBDIR= yes @@ -37,7 +37,7 @@ INCSDIR=/usr/include CLEANFILES+=editline.c CLEANFILES+=common.h.tmp editline.c.tmp emacs.h.tmp fcns.c.tmp fcns.h.tmp CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp -CLEANFILES+=test.o test +CLEANFILES+=tc1.o tc1 CPPFLAGS+=-I. -I${LIBEDITDIR} CPPFLAGS+=-I. -I${.CURDIR} CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH @@ -94,9 +94,9 @@ editline.c: ${OSRCS} makelist Makefile ${HOST_SH} ${LIBEDITDIR}/makelist -e ${OSRCS:T} > ${.TARGET}.tmp && \ mv ${.TARGET}.tmp ${.TARGET} -test.o: ${LIBEDITDIR}/TEST/test.c +tc1.o: ${LIBEDITDIR}/TEST/tc1.c -test: libedit.a test.o +tc1: libedit.a tc1.o ${_MKTARGET_LINK} ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermcap Modified: vendor/NetBSD/libedit/dist/TEST/Makefile ============================================================================== --- vendor/NetBSD/libedit/dist/TEST/Makefile Thu Mar 31 18:29:20 2011 (r220217) +++ vendor/NetBSD/libedit/dist/TEST/Makefile Thu Mar 31 18:31:27 2011 (r220218) @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.2 2003/12/05 13:37:48 lukem Exp $ +# $NetBSD: Makefile,v 1.3 2006/08/31 20:20:38 rpaulo Exp $ NOMAN=1 -PROG=test +PROG=tc1 CPPFLAGS=-I${.CURDIR}/.. LDADD+=-ledit -ltermcap DPADD+=${LIBEDIT} ${LIBTERMCAP} Added: vendor/NetBSD/libedit/dist/TEST/tc1.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/dist/TEST/tc1.c Thu Mar 31 18:31:27 2011 (r220218) @@ -0,0 +1,301 @@ +/* $NetBSD: tc1.c,v 1.1 2006/08/31 20:20:38 rpaulo Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Christos Zoulas of Cornell University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "config.h" +#ifndef lint +__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\ + The Regents of the University of California. All rights reserved.\n"); +#endif /* not lint */ + +#if !defined(lint) && !defined(SCCSID) +#if 0 +static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: tc1.c,v 1.1 2006/08/31 20:20:38 rpaulo Exp $"); +#endif +#endif /* not lint && not SCCSID */ + +/* + * test.c: A little test program + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "histedit.h" + +static int continuation = 0; +volatile sig_atomic_t gotsig = 0; + +static unsigned char complete(EditLine *, int); + int main(int, char **); +static char *prompt(EditLine *); +static void sig(int); + +static char * +prompt(EditLine *el) +{ + static char a[] = "Edit$ "; + static char b[] = "Edit> "; + + return (continuation ? b : a); +} + +static void +sig(int i) +{ + gotsig = i; +} + +static unsigned char +complete(EditLine *el, int ch) +{ + DIR *dd = opendir("."); + struct dirent *dp; + const char* ptr; + const LineInfo *lf = el_line(el); + int len; + + /* + * Find the last word + */ + for (ptr = lf->cursor - 1; + !isspace((unsigned char)*ptr) && ptr > lf->buffer; ptr--) + continue; + len = lf->cursor - ++ptr; + + for (dp = readdir(dd); dp != NULL; dp = readdir(dd)) { + if (len > strlen(dp->d_name)) + continue; + if (strncmp(dp->d_name, ptr, len) == 0) { + closedir(dd); + if (el_insertstr(el, &dp->d_name[len]) == -1) + return (CC_ERROR); + else + return (CC_REFRESH); + } + } + + closedir(dd); + return (CC_ERROR); +} + +int +main(int argc, char *argv[]) +{ + EditLine *el = NULL; + int num; + const char *buf; + Tokenizer *tok; +#if 0 + int lastevent = 0; +#endif + int ncontinuation; + History *hist; + HistEvent ev; + + (void) signal(SIGINT, sig); + (void) signal(SIGQUIT, sig); + (void) signal(SIGHUP, sig); + (void) signal(SIGTERM, sig); + + hist = history_init(); /* Init the builtin history */ + /* Remember 100 events */ + history(hist, &ev, H_SETSIZE, 100); + + tok = tok_init(NULL); /* Initialize the tokenizer */ + + /* Initialize editline */ + el = el_init(*argv, stdin, stdout, stderr); + + el_set(el, EL_EDITOR, "vi"); /* Default editor is vi */ + el_set(el, EL_SIGNAL, 1); /* Handle signals gracefully */ + el_set(el, EL_PROMPT, prompt); /* Set the prompt function */ + + /* Tell editline to use this history interface */ + el_set(el, EL_HIST, history, hist); + + /* Add a user-defined function */ + el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete); + + /* Bind tab to it */ + el_set(el, EL_BIND, "^I", "ed-complete", NULL); + + /* + * Bind j, k in vi command mode to previous and next line, instead + * of previous and next history. + */ + el_set(el, EL_BIND, "-a", "k", "ed-prev-line", NULL); + el_set(el, EL_BIND, "-a", "j", "ed-next-line", NULL); + + /* + * Source the user's defaults file. + */ + el_source(el, NULL); + + while ((buf = el_gets(el, &num)) != NULL && num != 0) { + int ac, cc, co; +#ifdef DEBUG + int i; +#endif + const char **av; + const LineInfo *li; + li = el_line(el); +#ifdef DEBUG + (void) fprintf(stderr, "==> got %d %s", num, buf); + (void) fprintf(stderr, " > li `%.*s_%.*s'\n", + (li->cursor - li->buffer), li->buffer, + (li->lastchar - 1 - li->cursor), + (li->cursor >= li->lastchar) ? "" : li->cursor); + +#endif + if (gotsig) { + (void) fprintf(stderr, "Got signal %d.\n", gotsig); + gotsig = 0; + el_reset(el); + } + + if (!continuation && num == 1) + continue; + + ac = cc = co = 0; + ncontinuation = tok_line(tok, li, &ac, &av, &cc, &co); + if (ncontinuation < 0) { + (void) fprintf(stderr, "Internal error\n"); + continuation = 0; + continue; + } +#ifdef DEBUG + (void) fprintf(stderr, " > nc %d ac %d cc %d co %d\n", + ncontinuation, ac, cc, co); +#endif +#if 0 + if (continuation) { + /* + * Append to the right event in case the user + * moved around in history. + */ + if (history(hist, &ev, H_SET, lastevent) == -1) + err(1, "%d: %s", lastevent, ev.str); + history(hist, &ev, H_ADD , buf); + } else { + history(hist, &ev, H_ENTER, buf); + lastevent = ev.num; + } +#else + /* Simpler */ + history(hist, &ev, continuation ? H_APPEND : H_ENTER, buf); +#endif + + continuation = ncontinuation; + ncontinuation = 0; + if (continuation) + continue; +#ifdef DEBUG + for (i = 0; i < ac; i++) { + (void) fprintf(stderr, " > arg# %2d ", i); + if (i != cc) + (void) fprintf(stderr, "`%s'\n", av[i]); + else + (void) fprintf(stderr, "`%.*s_%s'\n", + co, av[i], av[i] + co); + } +#endif + + if (strcmp(av[0], "history") == 0) { + int rv; + + switch (ac) { + case 1: + for (rv = history(hist, &ev, H_LAST); rv != -1; + rv = history(hist, &ev, H_PREV)) + (void) fprintf(stdout, "%4d %s", + ev.num, ev.str); + break; + + case 2: + if (strcmp(av[1], "clear") == 0) + history(hist, &ev, H_CLEAR); + else + goto badhist; + break; + + case 3: + if (strcmp(av[1], "load") == 0) + history(hist, &ev, H_LOAD, av[2]); + else if (strcmp(av[1], "save") == 0) + history(hist, &ev, H_SAVE, av[2]); + break; + + badhist: + default: + (void) fprintf(stderr, + "Bad history arguments\n"); + break; + } + } else if (el_parse(el, ac, av) == -1) { + switch (fork()) { + case 0: + execvp(av[0], (char *const *)__UNCONST(av)); + perror(av[0]); + _exit(1); + /*NOTREACHED*/ + break; + + case -1: + perror("fork"); + break; + + default: + if (wait(&num) == -1) + perror("wait"); + (void) fprintf(stderr, "Exit %x\n", num); + break; + } + } + + tok_reset(tok); + } + + el_end(el); + tok_end(tok); + history_end(hist); + + return (0); +} Modified: vendor/NetBSD/libedit/dist/editline.3 ============================================================================== --- vendor/NetBSD/libedit/dist/editline.3 Thu Mar 31 18:29:20 2011 (r220217) +++ vendor/NetBSD/libedit/dist/editline.3 Thu Mar 31 18:31:27 2011 (r220218) @@ -1,4 +1,4 @@ -.\" $NetBSD: editline.3,v 1.50 2005/10/12 09:29:43 wiz Exp $ +.\" $NetBSD: editline.3,v 1.55 2007/01/12 16:31:13 christos Exp $ .\" .\" Copyright (c) 1997-2003 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -13,11 +13,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the NetBSD -.\" Foundation, Inc. and its contributors. -.\" 4. Neither the name of The NetBSD Foundation nor the names of its +.\" 3. Neither the name of The NetBSD Foundation nor the names of its .\" contributors may be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" @@ -33,7 +29,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd September 9, 2005 +.Dd January 12, 2007 .Os .Dt EDITLINE 3 .Sh NAME @@ -82,7 +78,7 @@ .Ft int .Fn el_set "EditLine *e" "int op" "..." .Ft int -.Fn el_get "EditLine *e" "int op" "void *result" +.Fn el_get "EditLine *e" "int op" "..." .Ft int .Fn el_source "EditLine *e" "const char *file" .Ft void @@ -402,6 +398,25 @@ to be associated with this EditLine stru It can be retrieved with the corresponding .Fn el_get call. +.It Dv EL_SETFP , Fa "int fd" , Fa "FILE *fp" +Set the current +.Nm editline +file pointer for +.Dq input +.Fa fd += +.Dv 0 , +.Dq output +.Fa fd += +.Dv 1 , +or +.Dq error +.Fa fd += +.Dv 2 +from +.Fa fp . .El .It Fn el_get Get @@ -426,15 +441,24 @@ Return the name of the editor, which wil .Dq emacs or .Dq vi . +.It Dv EL_GETTC , Fa "const char *name" , Fa "void *value" +Return non-zero if +.Fa name +is a valid +.Xr termcap 5 +capability +and set +.Fa value +to the current value of that capability. .It Dv EL_SIGNAL , Fa "int *" Return non-zero if .Nm has installed private signal handlers (see .Fn el_get above). -.It Dv EL_EDITMODE, Fa "int *" +.It Dv EL_EDITMODE , Fa "int *" Return non-zero if editing is enabled. -.It Dv EL_GETCFN, Fa "int (**f)(EditLine *, char *)" +.It Dv EL_GETCFN , Fa "int (**f)(EditLine *, char *)" Return a pointer to the function that read characters, which is equal to ``EL_BUILTIN_GETCFN'' in the case of the default builtin function. .It Dv EL_CLIENTDATA , Fa "void **data" @@ -443,13 +467,32 @@ Retrieve previously registered with the corresponding .Fn el_set call. -.It Dv EL_UNBUFFERED, Fa "int" +.It Dv EL_UNBUFFERED , Fa "int" Sets or clears unbuffered mode. In this mode, .Fn el_gets will return immediately after processing a single character. -.It Dv EL_PREP_TERM, Fa "int" +.It Dv EL_PREP_TERM , Fa "int" Sets or clears terminal editing mode. +.It Dv EL_GETFP , Fa "int fd", Fa "FILE **fp" +Return in +.Fa fp +the current +.Nm editline +file pointer for +.Dq input +.Fa fd += +.Dv 0 , +.Dq output +.Fa fd += +.Dv 1 , +or +.Dq error +.Fa fd += +.Dv 2 . .El .It Fn el_source Initialise @@ -511,7 +554,7 @@ Returns \-1 if is empty or won't fit, and 0 otherwise. .It Fn el_deletestr Delete -.Fa num +.Fa count characters before the cursor. .El .Sh HISTORY LIST FUNCTIONS @@ -635,7 +678,7 @@ into the history. .It Dv H_GETUNIQUE Retrieve the current setting if adjacent identical elements should be entered into the history. -.It Dv H_DEL , Fa "int num" +.It Dv H_DEL , Fa "int e" Delete the event numbered .Fa e . This function is only provided for @@ -731,7 +774,8 @@ is a NUL terminated string to tokenize. .Xr sh 1 , .Xr signal 3 , .Xr termcap 3 , -.Xr editrc 5 +.Xr editrc 5 , +.Xr termcap 5 .Sh HISTORY The .Nm Modified: vendor/NetBSD/libedit/dist/editrc.5 ============================================================================== --- vendor/NetBSD/libedit/dist/editrc.5 Thu Mar 31 18:29:20 2011 (r220217) +++ vendor/NetBSD/libedit/dist/editrc.5 Thu Mar 31 18:31:27 2011 (r220218) @@ -1,4 +1,4 @@ -.\" $NetBSD: editrc.5,v 1.19 2003/11/01 23:35:33 christos Exp $ +.\" $NetBSD: editrc.5,v 1.20 2006/08/21 12:45:30 christos Exp $ .\" .\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -13,11 +13,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the NetBSD -.\" Foundation, Inc. and its contributors. -.\" 4. Neither the name of The NetBSD Foundation nor the names of its +.\" 3. Neither the name of The NetBSD Foundation nor the names of its .\" contributors may be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" Modified: vendor/NetBSD/libedit/dist/el.c ============================================================================== --- vendor/NetBSD/libedit/dist/el.c Thu Mar 31 18:29:20 2011 (r220217) +++ vendor/NetBSD/libedit/dist/el.c Thu Mar 31 18:31:27 2011 (r220218) @@ -1,4 +1,4 @@ -/* $NetBSD: el.c,v 1.41 2005/08/19 04:21:47 christos Exp $ */ +/* $NetBSD: el.c,v 1.44 2006/12/15 22:13:33 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94"; #else -__RCSID("$NetBSD: el.c,v 1.41 2005/08/19 04:21:47 christos Exp $"); +__RCSID("$NetBSD: el.c,v 1.44 2006/12/15 22:13:33 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -65,9 +65,12 @@ el_init(const char *prog, FILE *fin, FIL memset(el, 0, sizeof(EditLine)); - el->el_infd = fileno(fin); + el->el_infile = fin; el->el_outfile = fout; el->el_errfile = ferr; + + el->el_infd = fileno(fin); + if ((el->el_prog = el_strdup(prog)) == NULL) { el_free(el); return NULL; @@ -143,29 +146,29 @@ el_reset(EditLine *el) public int el_set(EditLine *el, int op, ...) { - va_list va; + va_list ap; int rv = 0; if (el == NULL) return (-1); - va_start(va, op); + va_start(ap, op); switch (op) { case EL_PROMPT: case EL_RPROMPT: - rv = prompt_set(el, va_arg(va, el_pfunc_t), op); + rv = prompt_set(el, va_arg(ap, el_pfunc_t), op); break; case EL_TERMINAL: - rv = term_set(el, va_arg(va, char *)); + rv = term_set(el, va_arg(ap, char *)); break; case EL_EDITOR: - rv = map_set_editor(el, va_arg(va, char *)); + rv = map_set_editor(el, va_arg(ap, char *)); break; case EL_SIGNAL: - if (va_arg(va, int)) + if (va_arg(ap, int)) el->el_flags |= HANDLE_SIGNALS; else el->el_flags &= ~HANDLE_SIGNALS; @@ -174,6 +177,7 @@ el_set(EditLine *el, int op, ...) case EL_BIND: case EL_TELLTC: case EL_SETTC: + case EL_GETTC: case EL_ECHOTC: case EL_SETTY: { @@ -181,7 +185,7 @@ el_set(EditLine *el, int op, ...) int i; for (i = 1; i < 20; i++) - if ((argv[i] = va_arg(va, char *)) == NULL) + if ((argv[i] = va_arg(ap, char *)) == NULL) break; switch (op) { @@ -220,9 +224,9 @@ el_set(EditLine *el, int op, ...) case EL_ADDFN: { - char *name = va_arg(va, char *); - char *help = va_arg(va, char *); - el_func_t func = va_arg(va, el_func_t); + char *name = va_arg(ap, char *); + char *help = va_arg(ap, char *); + el_func_t func = va_arg(ap, el_func_t); rv = map_addfunc(el, name, help, func); break; @@ -230,15 +234,15 @@ el_set(EditLine *el, int op, ...) case EL_HIST: { - hist_fun_t func = va_arg(va, hist_fun_t); - ptr_t ptr = va_arg(va, char *); + hist_fun_t func = va_arg(ap, hist_fun_t); + ptr_t ptr = va_arg(ap, char *); rv = hist_set(el, func, ptr); break; } case EL_EDITMODE: - if (va_arg(va, int)) + if (va_arg(ap, int)) el->el_flags &= ~EDIT_DISABLED; else el->el_flags |= EDIT_DISABLED; @@ -247,17 +251,17 @@ el_set(EditLine *el, int op, ...) case EL_GETCFN: { - el_rfunc_t rc = va_arg(va, el_rfunc_t); + el_rfunc_t rc = va_arg(ap, el_rfunc_t); rv = el_read_setfn(el, rc); break; } case EL_CLIENTDATA: - el->el_data = va_arg(va, void *); + el->el_data = va_arg(ap, void *); break; case EL_UNBUFFERED: - rv = va_arg(va, int); + rv = va_arg(ap, int); if (rv && !(el->el_flags & UNBUFFERED)) { el->el_flags |= UNBUFFERED; read_prepare(el); @@ -269,7 +273,7 @@ el_set(EditLine *el, int op, ...) break; case EL_PREP_TERM: - rv = va_arg(va, int); + rv = va_arg(ap, int); if (rv) (void) tty_rawmode(el); else @@ -277,12 +281,39 @@ el_set(EditLine *el, int op, ...) rv = 0; break; + case EL_SETFP: + { + FILE *fp; + int what; + + what = va_arg(ap, int); + fp = va_arg(ap, FILE *); + + rv = 0; + switch (what) { + case 0: + el->el_infile = fp; + el->el_infd = fileno(fp); + break; + case 1: + el->el_outfile = fp; + break; + case 2: + el->el_errfile = fp; + break; + default: + rv = -1; + break; + } + break; + } + default: rv = -1; break; } - va_end(va); + va_end(ap); return (rv); } @@ -291,90 +322,71 @@ el_set(EditLine *el, int op, ...) * retrieve the editline parameters */ public int -el_get(EditLine *el, int op, void *ret) +el_get(EditLine *el, int op, ...) { + va_list ap; int rv; - if (el == NULL || ret == NULL) - return (-1); + if (el == NULL) + return -1; + + va_start(ap, op); + switch (op) { case EL_PROMPT: case EL_RPROMPT: - rv = prompt_get(el, (el_pfunc_t *) ret, op); + rv = prompt_get(el, va_arg(ap, el_pfunc_t *), op); break; case EL_EDITOR: - rv = map_get_editor(el, (const char **)ret); + rv = map_get_editor(el, va_arg(ap, const char **)); break; case EL_SIGNAL: - *((int *) ret) = (el->el_flags & HANDLE_SIGNALS); + *va_arg(ap, int *) = (el->el_flags & HANDLE_SIGNALS); rv = 0; break; case EL_EDITMODE: - *((int *) ret) = (!(el->el_flags & EDIT_DISABLED)); + *va_arg(ap, int *) = !(el->el_flags & EDIT_DISABLED); rv = 0; break; case EL_TERMINAL: - term_get(el, (const char **)ret); + term_get(el, va_arg(ap, const char **)); rv = 0; break; -#if 0 /* XXX */ - case EL_BIND: - case EL_TELLTC: - case EL_SETTC: - case EL_ECHOTC: - case EL_SETTY: + case EL_GETTC: { - const char *argv[20]; + static char name[] = "gettc"; + char *argv[20]; int i; for (i = 1; i < sizeof(argv) / sizeof(argv[0]); i++) - if ((argv[i] = va_arg(va, char *)) == NULL) + if ((argv[i] = va_arg(ap, char *)) == NULL) break; switch (op) { - case EL_BIND: - argv[0] = "bind"; - rv = map_bind(el, i, argv); - break; - - case EL_TELLTC: - argv[0] = "telltc"; - rv = term_telltc(el, i, argv); - break; - - case EL_SETTC: - argv[0] = "settc"; - rv = term_settc(el, i, argv); - break; - - case EL_ECHOTC: - argv[0] = "echotc"; - rv = term_echotc(el, i, argv); - break; - - case EL_SETTY: - argv[0] = "setty"; - rv = tty_stty(el, i, argv); + case EL_GETTC: + argv[0] = name; + rv = term_gettc(el, i, argv); break; default: rv = -1; - EL_ABORT((el->errfile, "Bad op %d\n", op)); + EL_ABORT((el->el_errfile, "Bad op %d\n", op)); break; } break; } +#if 0 /* XXX */ case EL_ADDFN: { - char *name = va_arg(va, char *); - char *help = va_arg(va, char *); - el_func_t func = va_arg(va, el_func_t); + char *name = va_arg(ap, char *); + char *help = va_arg(ap, char *); + el_func_t func = va_arg(ap, el_func_t); rv = map_addfunc(el, name, help, func); break; @@ -382,31 +394,57 @@ el_get(EditLine *el, int op, void *ret) case EL_HIST: { - hist_fun_t func = va_arg(va, hist_fun_t); - ptr_t ptr = va_arg(va, char *); + hist_fun_t func = va_arg(ap, hist_fun_t); + ptr_t ptr = va_arg(ap, char *); rv = hist_set(el, func, ptr); } break; #endif /* XXX */ case EL_GETCFN: - *((el_rfunc_t *)ret) = el_read_getfn(el); + *va_arg(ap, el_rfunc_t *) = el_read_getfn(el); rv = 0; break; case EL_CLIENTDATA: - *((void **)ret) = el->el_data; + *va_arg(ap, void **) = el->el_data; rv = 0; break; case EL_UNBUFFERED: - *((int *) ret) = (!(el->el_flags & UNBUFFERED)); + *va_arg(ap, int *) = (!(el->el_flags & UNBUFFERED)); rv = 0; break; + case EL_GETFP: + { + int what; + FILE **fpp; + + what = va_arg(ap, int); + fpp = va_arg(ap, FILE **); + rv = 0; + switch (what) { + case 0: + *fpp = el->el_infile; + break; + case 1: + *fpp = el->el_outfile; + break; + case 2: + *fpp = el->el_errfile; + break; + default: + rv = -1; + break; + } + break; + } default: rv = -1; + break; } + va_end(ap); return (rv); } Modified: vendor/NetBSD/libedit/dist/el.h ============================================================================== --- vendor/NetBSD/libedit/dist/el.h Thu Mar 31 18:29:20 2011 (r220217) +++ vendor/NetBSD/libedit/dist/el.h Thu Mar 31 18:31:27 2011 (r220218) @@ -1,4 +1,4 @@ -/* $NetBSD: el.h,v 1.16 2003/10/18 23:48:42 christos Exp $ */ +/* $NetBSD: el.h,v 1.17 2006/12/15 22:13:33 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -110,6 +110,7 @@ typedef struct el_state_t { struct editline { char *el_prog; /* the program name */ + FILE *el_infile; /* Stdio stuff */ FILE *el_outfile; /* Stdio stuff */ FILE *el_errfile; /* Stdio stuff */ int el_infd; /* Input file descriptor */ Modified: vendor/NetBSD/libedit/dist/filecomplete.c ============================================================================== --- vendor/NetBSD/libedit/dist/filecomplete.c Thu Mar 31 18:29:20 2011 (r220217) +++ vendor/NetBSD/libedit/dist/filecomplete.c Thu Mar 31 18:31:27 2011 (r220218) @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.c,v 1.8 2005/08/03 13:41:38 christos Exp $ */ +/* $NetBSD: filecomplete.c,v 1.10 2006/11/09 16:58:38 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -15,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its + * 3. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -38,7 +34,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: filecomplete.c,v 1.8 2005/08/03 13:41:38 christos Exp $"); +__RCSID("$NetBSD: filecomplete.c,v 1.10 2006/11/09 16:58:38 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -398,6 +394,7 @@ fn_complete(EditLine *el, const char *ctemp; size_t len; int what_to_do = '\t'; + int retval = CC_NORM; if (el->el_state.lastcmd == el->el_state.thiscmd) what_to_do = '?'; @@ -420,7 +417,11 @@ fn_complete(EditLine *el, ctemp--; len = li->cursor - ctemp; +#if defined(__SSP__) || defined(__SSP_ALL__) + temp = malloc(len + 1); +#else temp = alloca(len + 1); +#endif (void)strncpy(temp, ctemp, len); temp[len] = '\0'; @@ -445,9 +446,10 @@ fn_complete(EditLine *el, *over = 0; if (matches) { - int i, retval = CC_REFRESH; + int i; int matches_num, maxlen, match_len, match_display=1; + retval = CC_REFRESH; /* * Only replace the completed string with common part of * possible matches if there is possible completion. @@ -519,11 +521,13 @@ fn_complete(EditLine *el, /* free elements of array and the array itself */ for (i = 0; matches[i]; i++) free(matches[i]); - free(matches), matches = NULL; - - return (retval); + free(matches); + matches = NULL; } - return (CC_NORM); +#if defined(__SSP__) || defined(__SSP_ALL__) + free(temp); +#endif + return retval; } /* Modified: vendor/NetBSD/libedit/dist/filecomplete.h ============================================================================== --- vendor/NetBSD/libedit/dist/filecomplete.h Thu Mar 31 18:29:20 2011 (r220217) +++ vendor/NetBSD/libedit/dist/filecomplete.h Thu Mar 31 18:31:27 2011 (r220218) @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.h,v 1.4 2005/06/11 18:18:59 christos Exp $ */ +/* $NetBSD: filecomplete.h,v 1.5 2006/08/21 12:45:30 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -15,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its + * 3. Neither the name of The NetBSD Foundation nor the names of its *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 18:32:01 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6D047106564A; Thu, 31 Mar 2011 18:32:01 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 547CF8FC20; Thu, 31 Mar 2011 18:32:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VIW1w1015179; Thu, 31 Mar 2011 18:32:01 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VIW1n6015173; Thu, 31 Mar 2011 18:32:01 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201103311832.p2VIW1n6015173@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 31 Mar 2011 18:32:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220219 - in vendor/NetBSD/libedit/2007-01-12: . TEST readline X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 18:32:01 -0000 Author: obrien Date: Thu Mar 31 18:32:01 2011 New Revision: 220219 URL: http://svn.freebsd.org/changeset/base/220219 Log: "Tag" the "2007/01/12 16:31:13 UTC" import. Added: vendor/NetBSD/libedit/2007-01-12/ - copied from r220217, vendor/NetBSD/libedit/dist/ vendor/NetBSD/libedit/2007-01-12/TEST/tc1.c - copied unchanged from r220218, vendor/NetBSD/libedit/dist/TEST/tc1.c Replaced: vendor/NetBSD/libedit/2007-01-12/Makefile - copied unchanged from r220218, vendor/NetBSD/libedit/dist/Makefile vendor/NetBSD/libedit/2007-01-12/TEST/Makefile - copied unchanged from r220218, vendor/NetBSD/libedit/dist/TEST/Makefile vendor/NetBSD/libedit/2007-01-12/editline.3 - copied unchanged from r220218, vendor/NetBSD/libedit/dist/editline.3 vendor/NetBSD/libedit/2007-01-12/editrc.5 - copied unchanged from r220218, vendor/NetBSD/libedit/dist/editrc.5 vendor/NetBSD/libedit/2007-01-12/el.c - copied unchanged from r220218, vendor/NetBSD/libedit/dist/el.c vendor/NetBSD/libedit/2007-01-12/el.h - copied unchanged from r220218, vendor/NetBSD/libedit/dist/el.h vendor/NetBSD/libedit/2007-01-12/filecomplete.c - copied unchanged from r220218, vendor/NetBSD/libedit/dist/filecomplete.c vendor/NetBSD/libedit/2007-01-12/filecomplete.h - copied unchanged from r220218, vendor/NetBSD/libedit/dist/filecomplete.h vendor/NetBSD/libedit/2007-01-12/histedit.h - copied unchanged from r220218, vendor/NetBSD/libedit/dist/histedit.h vendor/NetBSD/libedit/2007-01-12/history.c - copied unchanged from r220218, vendor/NetBSD/libedit/dist/history.c vendor/NetBSD/libedit/2007-01-12/map.c - copied unchanged from r220218, vendor/NetBSD/libedit/dist/map.c vendor/NetBSD/libedit/2007-01-12/read.h - copied unchanged from r220218, vendor/NetBSD/libedit/dist/read.h vendor/NetBSD/libedit/2007-01-12/readline.c - copied unchanged from r220218, vendor/NetBSD/libedit/dist/readline.c vendor/NetBSD/libedit/2007-01-12/readline/readline.h - copied unchanged from r220218, vendor/NetBSD/libedit/dist/readline/readline.h vendor/NetBSD/libedit/2007-01-12/shlib_version - copied unchanged from r220218, vendor/NetBSD/libedit/dist/shlib_version vendor/NetBSD/libedit/2007-01-12/term.c - copied unchanged from r220218, vendor/NetBSD/libedit/dist/term.c vendor/NetBSD/libedit/2007-01-12/term.h - copied unchanged from r220218, vendor/NetBSD/libedit/dist/term.h vendor/NetBSD/libedit/2007-01-12/vi.c - copied unchanged from r220218, vendor/NetBSD/libedit/dist/vi.c Deleted: vendor/NetBSD/libedit/2007-01-12/TEST/test.c Copied: vendor/NetBSD/libedit/2007-01-12/Makefile (from r220218, vendor/NetBSD/libedit/dist/Makefile) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/2007-01-12/Makefile Thu Mar 31 18:32:01 2011 (r220219, copy of r220218, vendor/NetBSD/libedit/dist/Makefile) @@ -0,0 +1,104 @@ +# $NetBSD: Makefile,v 1.35 2006/08/31 20:20:38 rpaulo Exp $ +# @(#)Makefile 8.1 (Berkeley) 6/4/93 + +USE_SHLIBDIR= yes + +WARNS= 3 +LIB= edit + +LIBDPLIBS= termcap ${.CURDIR}/../libterm + +OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c hist.c \ + key.c map.c \ + parse.c prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c + +MAN= editline.3 editrc.5 + +MLINKS= editline.3 el_init.3 editline.3 el_end.3 editline.3 el_reset.3 \ + editline.3 el_gets.3 editline.3 el_getc.3 editline.3 el_push.3 \ + editline.3 el_parse.3 editline.3 el_set.3 editline.3 el_get.3 \ + editline.3 el_source.3 editline.3 el_resize.3 editline.3 el_line.3 \ + editline.3 el_insertstr.3 editline.3 el_deletestr.3 \ + editline.3 history_init.3 editline.3 history_end.3 \ + editline.3 history.3 \ + editline.3 tok_init.3 editline.3 tok_end.3 editline.3 tok_reset.3 \ + editline.3 tok_line.3 editline.3 tok_str.3 + +# For speed and debugging +#SRCS= ${OSRCS} tokenizer.c history.c readline.c +# For protection +SRCS= editline.c tokenizer.c history.c readline.c + +LIBEDITDIR?=${.CURDIR} + +INCS= histedit.h +INCSDIR=/usr/include + +CLEANFILES+=editline.c +CLEANFILES+=common.h.tmp editline.c.tmp emacs.h.tmp fcns.c.tmp fcns.h.tmp +CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp +CLEANFILES+=tc1.o tc1 +CPPFLAGS+=-I. -I${LIBEDITDIR} +CPPFLAGS+=-I. -I${.CURDIR} +CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH +CPPFLAGS+=#-DDEBUG_PASTE -DDEBUG_EDIT + +AHDR=vi.h emacs.h common.h +ASRC=${LIBEDITDIR}/vi.c ${LIBEDITDIR}/emacs.c ${LIBEDITDIR}/common.c + +DPSRCS+= ${AHDR} fcns.h help.h fcns.c help.c +CLEANFILES+= ${AHDR} fcns.h help.h fcns.c help.c + +SUBDIR= readline + +vi.h: vi.c makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/vi.c \ + > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +emacs.h: emacs.c makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/emacs.c \ + > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +common.h: common.c makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/common.c \ + > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +fcns.h: ${AHDR} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -fh ${AHDR} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +fcns.c: ${AHDR} fcns.h help.h makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -fc ${AHDR} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +help.c: ${ASRC} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -bc ${ASRC} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +help.h: ${ASRC} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -bh ${ASRC} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +editline.c: ${OSRCS} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -e ${OSRCS:T} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +tc1.o: ${LIBEDITDIR}/TEST/tc1.c + +tc1: libedit.a tc1.o + ${_MKTARGET_LINK} + ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermcap + +.include +.include Copied: vendor/NetBSD/libedit/2007-01-12/TEST/Makefile (from r220218, vendor/NetBSD/libedit/dist/TEST/Makefile) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/2007-01-12/TEST/Makefile Thu Mar 31 18:32:01 2011 (r220219, copy of r220218, vendor/NetBSD/libedit/dist/TEST/Makefile) @@ -0,0 +1,13 @@ +# $NetBSD: Makefile,v 1.3 2006/08/31 20:20:38 rpaulo Exp $ + +NOMAN=1 +PROG=tc1 +CPPFLAGS=-I${.CURDIR}/.. +LDADD+=-ledit -ltermcap +DPADD+=${LIBEDIT} ${LIBTERMCAP} + +.ifdef DEBUG +CPPFLAGS+=-DDEBUG +.endif + +.include Copied: vendor/NetBSD/libedit/2007-01-12/TEST/tc1.c (from r220218, vendor/NetBSD/libedit/dist/TEST/tc1.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/2007-01-12/TEST/tc1.c Thu Mar 31 18:32:01 2011 (r220219, copy of r220218, vendor/NetBSD/libedit/dist/TEST/tc1.c) @@ -0,0 +1,301 @@ +/* $NetBSD: tc1.c,v 1.1 2006/08/31 20:20:38 rpaulo Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Christos Zoulas of Cornell University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "config.h" +#ifndef lint +__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\ + The Regents of the University of California. All rights reserved.\n"); +#endif /* not lint */ + +#if !defined(lint) && !defined(SCCSID) +#if 0 +static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: tc1.c,v 1.1 2006/08/31 20:20:38 rpaulo Exp $"); +#endif +#endif /* not lint && not SCCSID */ + +/* + * test.c: A little test program + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "histedit.h" + +static int continuation = 0; +volatile sig_atomic_t gotsig = 0; + +static unsigned char complete(EditLine *, int); + int main(int, char **); +static char *prompt(EditLine *); +static void sig(int); + +static char * +prompt(EditLine *el) +{ + static char a[] = "Edit$ "; + static char b[] = "Edit> "; + + return (continuation ? b : a); +} + +static void +sig(int i) +{ + gotsig = i; +} + +static unsigned char +complete(EditLine *el, int ch) +{ + DIR *dd = opendir("."); + struct dirent *dp; + const char* ptr; + const LineInfo *lf = el_line(el); + int len; + + /* + * Find the last word + */ + for (ptr = lf->cursor - 1; + !isspace((unsigned char)*ptr) && ptr > lf->buffer; ptr--) + continue; + len = lf->cursor - ++ptr; + + for (dp = readdir(dd); dp != NULL; dp = readdir(dd)) { + if (len > strlen(dp->d_name)) + continue; + if (strncmp(dp->d_name, ptr, len) == 0) { + closedir(dd); + if (el_insertstr(el, &dp->d_name[len]) == -1) + return (CC_ERROR); + else + return (CC_REFRESH); + } + } + + closedir(dd); + return (CC_ERROR); +} + +int +main(int argc, char *argv[]) +{ + EditLine *el = NULL; + int num; + const char *buf; + Tokenizer *tok; +#if 0 + int lastevent = 0; +#endif + int ncontinuation; + History *hist; + HistEvent ev; + + (void) signal(SIGINT, sig); + (void) signal(SIGQUIT, sig); + (void) signal(SIGHUP, sig); + (void) signal(SIGTERM, sig); + + hist = history_init(); /* Init the builtin history */ + /* Remember 100 events */ + history(hist, &ev, H_SETSIZE, 100); + + tok = tok_init(NULL); /* Initialize the tokenizer */ + + /* Initialize editline */ + el = el_init(*argv, stdin, stdout, stderr); + + el_set(el, EL_EDITOR, "vi"); /* Default editor is vi */ + el_set(el, EL_SIGNAL, 1); /* Handle signals gracefully */ + el_set(el, EL_PROMPT, prompt); /* Set the prompt function */ + + /* Tell editline to use this history interface */ + el_set(el, EL_HIST, history, hist); + + /* Add a user-defined function */ + el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete); + + /* Bind tab to it */ + el_set(el, EL_BIND, "^I", "ed-complete", NULL); + + /* + * Bind j, k in vi command mode to previous and next line, instead + * of previous and next history. + */ + el_set(el, EL_BIND, "-a", "k", "ed-prev-line", NULL); + el_set(el, EL_BIND, "-a", "j", "ed-next-line", NULL); + + /* + * Source the user's defaults file. + */ + el_source(el, NULL); + + while ((buf = el_gets(el, &num)) != NULL && num != 0) { + int ac, cc, co; +#ifdef DEBUG + int i; +#endif + const char **av; + const LineInfo *li; + li = el_line(el); +#ifdef DEBUG + (void) fprintf(stderr, "==> got %d %s", num, buf); + (void) fprintf(stderr, " > li `%.*s_%.*s'\n", + (li->cursor - li->buffer), li->buffer, + (li->lastchar - 1 - li->cursor), + (li->cursor >= li->lastchar) ? "" : li->cursor); + +#endif + if (gotsig) { + (void) fprintf(stderr, "Got signal %d.\n", gotsig); + gotsig = 0; + el_reset(el); + } + + if (!continuation && num == 1) + continue; + + ac = cc = co = 0; + ncontinuation = tok_line(tok, li, &ac, &av, &cc, &co); + if (ncontinuation < 0) { + (void) fprintf(stderr, "Internal error\n"); + continuation = 0; + continue; + } +#ifdef DEBUG + (void) fprintf(stderr, " > nc %d ac %d cc %d co %d\n", + ncontinuation, ac, cc, co); +#endif +#if 0 + if (continuation) { + /* + * Append to the right event in case the user + * moved around in history. + */ + if (history(hist, &ev, H_SET, lastevent) == -1) + err(1, "%d: %s", lastevent, ev.str); + history(hist, &ev, H_ADD , buf); + } else { + history(hist, &ev, H_ENTER, buf); + lastevent = ev.num; + } +#else + /* Simpler */ + history(hist, &ev, continuation ? H_APPEND : H_ENTER, buf); +#endif + + continuation = ncontinuation; + ncontinuation = 0; + if (continuation) + continue; +#ifdef DEBUG + for (i = 0; i < ac; i++) { + (void) fprintf(stderr, " > arg# %2d ", i); + if (i != cc) + (void) fprintf(stderr, "`%s'\n", av[i]); + else + (void) fprintf(stderr, "`%.*s_%s'\n", + co, av[i], av[i] + co); + } +#endif + + if (strcmp(av[0], "history") == 0) { + int rv; + + switch (ac) { + case 1: + for (rv = history(hist, &ev, H_LAST); rv != -1; + rv = history(hist, &ev, H_PREV)) + (void) fprintf(stdout, "%4d %s", + ev.num, ev.str); + break; + + case 2: + if (strcmp(av[1], "clear") == 0) + history(hist, &ev, H_CLEAR); + else + goto badhist; + break; + + case 3: + if (strcmp(av[1], "load") == 0) + history(hist, &ev, H_LOAD, av[2]); + else if (strcmp(av[1], "save") == 0) + history(hist, &ev, H_SAVE, av[2]); + break; + + badhist: + default: + (void) fprintf(stderr, + "Bad history arguments\n"); + break; + } + } else if (el_parse(el, ac, av) == -1) { + switch (fork()) { + case 0: + execvp(av[0], (char *const *)__UNCONST(av)); + perror(av[0]); + _exit(1); + /*NOTREACHED*/ + break; + + case -1: + perror("fork"); + break; + + default: + if (wait(&num) == -1) + perror("wait"); + (void) fprintf(stderr, "Exit %x\n", num); + break; + } + } + + tok_reset(tok); + } + + el_end(el); + tok_end(tok); + history_end(hist); + + return (0); +} Copied: vendor/NetBSD/libedit/2007-01-12/editline.3 (from r220218, vendor/NetBSD/libedit/dist/editline.3) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/2007-01-12/editline.3 Thu Mar 31 18:32:01 2011 (r220219, copy of r220218, vendor/NetBSD/libedit/dist/editline.3) @@ -0,0 +1,823 @@ +.\" $NetBSD: editline.3,v 1.55 2007/01/12 16:31:13 christos Exp $ +.\" +.\" Copyright (c) 1997-2003 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This file was contributed to The NetBSD Foundation by Luke Mewburn. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of The NetBSD Foundation nor the names of its +.\" contributors may be used to endorse or promote products derived +.\" from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd January 12, 2007 +.Os +.Dt EDITLINE 3 +.Sh NAME +.Nm editline , +.Nm el_init , +.Nm el_end , +.Nm el_reset , +.Nm el_gets , +.Nm el_getc , +.Nm el_push , +.Nm el_parse , +.Nm el_set , +.Nm el_get , +.Nm el_source , +.Nm el_resize , +.Nm el_line , +.Nm el_insertstr , +.Nm el_deletestr , +.Nm history_init , +.Nm history_end , +.Nm history , +.Nm tok_init , +.Nm tok_end , +.Nm tok_reset , +.Nm tok_line , +.Nm tok_str +.Nd line editor, history and tokenization functions +.Sh LIBRARY +.Lb libedit +.Sh SYNOPSIS +.In histedit.h +.Ft EditLine * +.Fn el_init "const char *prog" "FILE *fin" "FILE *fout" "FILE *ferr" +.Ft void +.Fn el_end "EditLine *e" +.Ft void +.Fn el_reset "EditLine *e" +.Ft const char * +.Fn el_gets "EditLine *e" "int *count" +.Ft int +.Fn el_getc "EditLine *e" "char *ch" +.Ft void +.Fn el_push "EditLine *e" "const char *str" +.Ft int +.Fn el_parse "EditLine *e" "int argc" "const char *argv[]" +.Ft int +.Fn el_set "EditLine *e" "int op" "..." +.Ft int +.Fn el_get "EditLine *e" "int op" "..." +.Ft int +.Fn el_source "EditLine *e" "const char *file" +.Ft void +.Fn el_resize "EditLine *e" +.Ft const LineInfo * +.Fn el_line "EditLine *e" +.Ft int +.Fn el_insertstr "EditLine *e" "const char *str" +.Ft void +.Fn el_deletestr "EditLine *e" "int count" +.Ft History * +.Fn history_init +.Ft void +.Fn history_end "History *h" +.Ft int +.Fn history "History *h" "HistEvent *ev" "int op" "..." +.Ft Tokenizer * +.Fn tok_init "const char *IFS" +.Ft void +.Fn tok_end "Tokenizer *t" +.Ft void +.Fn tok_reset "Tokenizer *t" +.Ft int +.Fn tok_line "Tokenizer *t" "const LineInfo *li" "int *argc" "const char **argv[]" "int *cursorc" "int *cursoro" +.Ft int +.Fn tok_str "Tokenizer *t" "const char *str" "int *argc" "const char **argv[]" +.Sh DESCRIPTION +The +.Nm +library provides generic line editing, history and tokenization functions, +similar to those found in +.Xr sh 1 . +.Pp +These functions are available in the +.Nm libedit +library (which needs the +.Nm libtermcap +library). +Programs should be linked with +.Fl ledit ltermcap . +.Sh LINE EDITING FUNCTIONS +The line editing functions use a common data structure, +.Fa EditLine , +which is created by +.Fn el_init +and freed by +.Fn el_end . +.Pp +The following functions are available: +.Bl -tag -width 4n +.It Fn el_init +Initialise the line editor, and return a data structure +to be used by all other line editing functions. +.Fa prog +is the name of the invoking program, used when reading the +.Xr editrc 5 +file to determine which settings to use. +.Fa fin , +.Fa fout +and +.Fa ferr +are the input, output, and error streams (respectively) to use. +In this documentation, references to +.Dq the tty +are actually to this input/output stream combination. +.It Fn el_end +Clean up and finish with +.Fa e , +assumed to have been created with +.Fn el_init . +.It Fn el_reset +Reset the tty and the parser. +This should be called after an error which may have upset the tty's +state. +.It Fn el_gets +Read a line from the tty. +.Fa count +is modified to contain the number of characters read. +Returns the line read if successful, or +.Dv NULL +if no characters were read or if an error occurred. +.It Fn el_getc +Read a character from the tty. +.Fa ch +is modified to contain the character read. +Returns the number of characters read if successful, \-1 otherwise. +.It Fn el_push +Pushes +.Fa str +back onto the input stream. +This is used by the macro expansion mechanism. +Refer to the description of +.Ic bind +.Fl s +in +.Xr editrc 5 +for more information. +.It Fn el_parse +Parses the +.Fa argv +array (which is +.Fa argc +elements in size) +to execute builtin +.Nm +commands. +If the command is prefixed with +.Dq prog : +then +.Fn el_parse +will only execute the command if +.Dq prog +matches the +.Fa prog +argument supplied to +.Fn el_init . +The return value is +\-1 if the command is unknown, +0 if there was no error or +.Dq prog +didn't match, or +1 if the command returned an error. +Refer to +.Xr editrc 5 +for more information. +.It Fn el_set +Set +.Nm +parameters. +.Fa op +determines which parameter to set, and each operation has its +own parameter list. +.Pp +The following values for +.Fa op +are supported, along with the required argument list: +.Bl -tag -width 4n +.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)" +Define prompt printing function as +.Fa f , +which is to return a string that contains the prompt. +.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)" +Define right side prompt printing function as +.Fa f , +which is to return a string that contains the prompt. +.It Dv EL_TERMINAL , Fa "const char *type" +Define terminal type of the tty to be +.Fa type , +or to +.Ev TERM +if +.Fa type +is +.Dv NULL . +.It Dv EL_EDITOR , Fa "const char *mode" +Set editing mode to +.Fa mode , +which must be one of +.Dq emacs +or +.Dq vi . +.It Dv EL_SIGNAL , Fa "int flag" +If +.Fa flag +is non-zero, +.Nm +will install its own signal handler for the following signals when +reading command input: +.Dv SIGCONT , +.Dv SIGHUP , +.Dv SIGINT , +.Dv SIGQUIT , +.Dv SIGSTOP , +.Dv SIGTERM , +.Dv SIGTSTP , +and +.Dv SIGWINCH . +Otherwise, the current signal handlers will be used. +.It Dv EL_BIND , Xo +.Fa "const char *" , +.Fa "..." , +.Dv NULL +.Xc +Perform the +.Ic bind +builtin command. +Refer to +.Xr editrc 5 +for more information. +.It Dv EL_ECHOTC , Xo +.Fa "const char *" , +.Fa "..." , +.Dv NULL +.Xc +Perform the +.Ic echotc +builtin command. +Refer to +.Xr editrc 5 +for more information. +.It Dv EL_SETTC , Xo +.Fa "const char *" , +.Fa "..." , +.Dv NULL +.Xc +Perform the +.Ic settc +builtin command. +Refer to +.Xr editrc 5 +for more information. +.It Dv EL_SETTY , Xo +.Fa "const char *" , +.Fa "..." , +.Dv NULL +.Xc +Perform the +.Ic setty +builtin command. +Refer to +.Xr editrc 5 +for more information. +.It Dv EL_TELLTC , Xo +.Fa "const char *" , +.Fa "..." , +.Dv NULL +.Xc +Perform the +.Ic telltc +builtin command. +Refer to +.Xr editrc 5 +for more information. +.It Dv EL_ADDFN , Xo +.Fa "const char *name" , +.Fa "const char *help" , +.Fa "unsigned char (*func)(EditLine *e, int ch)" +.Xc +Add a user defined function, +.Fn func , +referred to as +.Fa name +which is invoked when a key which is bound to +.Fa name +is entered. +.Fa help +is a description of +.Fa name . +At invocation time, +.Fa ch +is the key which caused the invocation. +The return value of +.Fn func +should be one of: +.Bl -tag -width "CC_REDISPLAY" +.It Dv CC_NORM +Add a normal character. +.It Dv CC_NEWLINE +End of line was entered. +.It Dv CC_EOF +EOF was entered. +.It Dv CC_ARGHACK +Expecting further command input as arguments, do nothing visually. +.It Dv CC_REFRESH +Refresh display. +.It Dv CC_REFRESH_BEEP +Refresh display, and beep. +.It Dv CC_CURSOR +Cursor moved, so update and perform +.Dv CC_REFRESH . +.It Dv CC_REDISPLAY +Redisplay entire input line. +This is useful if a key binding outputs extra information. +.It Dv CC_ERROR +An error occurred. +Beep, and flush tty. +.It Dv CC_FATAL +Fatal error, reset tty to known state. +.El +.It Dv EL_HIST , Xo +.Fa "History *(*func)(History *, int op, ...)" , +.Fa "const char *ptr" +.Xc +Defines which history function to use, which is usually +.Fn history . +.Fa ptr +should be the value returned by +.Fn history_init . +.It Dv EL_EDITMODE , Fa "int flag" +If +.Fa flag +is non-zero, +editing is enabled (the default). +Note that this is only an indication, and does not +affect the operation of +.Nm . +At this time, it is the caller's responsibility to +check this +(using +.Fn el_get ) +to determine if editing should be enabled or not. +.It Dv EL_GETCFN , Fa "int (*f)(EditLine *, char *c)" +Define the character reading function as +.Fa f , +which is to return the number of characters read and store them in +.Fa c . +This function is called internally by +.Fn el_gets +and +.Fn el_getc . +The builtin function can be set or restored with the special function +name ``EL_BUILTIN_GETCFN''. +.It Dv EL_CLIENTDATA , Fa "void *data" +Register +.Fa data +to be associated with this EditLine structure. +It can be retrieved with the corresponding +.Fn el_get +call. +.It Dv EL_SETFP , Fa "int fd" , Fa "FILE *fp" +Set the current +.Nm editline +file pointer for +.Dq input +.Fa fd += +.Dv 0 , +.Dq output +.Fa fd += +.Dv 1 , +or +.Dq error +.Fa fd += +.Dv 2 +from +.Fa fp . +.El +.It Fn el_get +Get +.Nm +parameters. +.Fa op +determines which parameter to retrieve into +.Fa result . +Returns 0 if successful, \-1 otherwise. +.Pp +The following values for +.Fa op +are supported, along with actual type of +.Fa result : +.Bl -tag -width 4n +.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)" +Return a pointer to the function that displays the prompt. +.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)" +Return a pointer to the function that displays the rightside prompt. +.It Dv EL_EDITOR , Fa "const char *" +Return the name of the editor, which will be one of +.Dq emacs +or +.Dq vi . +.It Dv EL_GETTC , Fa "const char *name" , Fa "void *value" +Return non-zero if +.Fa name +is a valid +.Xr termcap 5 +capability +and set +.Fa value +to the current value of that capability. +.It Dv EL_SIGNAL , Fa "int *" +Return non-zero if +.Nm +has installed private signal handlers (see +.Fn el_get +above). +.It Dv EL_EDITMODE , Fa "int *" +Return non-zero if editing is enabled. +.It Dv EL_GETCFN , Fa "int (**f)(EditLine *, char *)" +Return a pointer to the function that read characters, which is equal to +``EL_BUILTIN_GETCFN'' in the case of the default builtin function. +.It Dv EL_CLIENTDATA , Fa "void **data" +Retrieve +.Fa data +previously registered with the corresponding +.Fn el_set +call. +.It Dv EL_UNBUFFERED , Fa "int" +Sets or clears unbuffered mode. +In this mode, +.Fn el_gets +will return immediately after processing a single character. +.It Dv EL_PREP_TERM , Fa "int" +Sets or clears terminal editing mode. +.It Dv EL_GETFP , Fa "int fd", Fa "FILE **fp" +Return in +.Fa fp +the current +.Nm editline +file pointer for +.Dq input +.Fa fd += +.Dv 0 , +.Dq output +.Fa fd += +.Dv 1 , +or +.Dq error +.Fa fd += +.Dv 2 . +.El +.It Fn el_source +Initialise +.Nm +by reading the contents of +.Fa file . +.Fn el_parse +is called for each line in +.Fa file . +If +.Fa file +is +.Dv NULL , +try +.Pa $PWD/.editrc +then +.Pa $HOME/.editrc . +Refer to +.Xr editrc 5 +for details on the format of +.Fa file . +.It Fn el_resize +Must be called if the terminal size changes. +If +.Dv EL_SIGNAL +has been set with +.Fn el_set , +then this is done automatically. +Otherwise, it's the responsibility of the application to call +.Fn el_resize +on the appropriate occasions. +.It Fn el_line +Return the editing information for the current line in a +.Fa LineInfo +structure, which is defined as follows: +.Bd -literal +typedef struct lineinfo { + const char *buffer; /* address of buffer */ + const char *cursor; /* address of cursor */ + const char *lastchar; /* address of last character */ +} LineInfo; +.Ed +.Pp +.Fa buffer +is not NUL terminated. +This function may be called after +.Fn el_gets +to obtain the +.Fa LineInfo +structure pertaining to line returned by that function, +and from within user defined functions added with +.Dv EL_ADDFN . +.It Fn el_insertstr +Insert +.Fa str +into the line at the cursor. +Returns \-1 if +.Fa str +is empty or won't fit, and 0 otherwise. +.It Fn el_deletestr +Delete +.Fa count +characters before the cursor. +.El +.Sh HISTORY LIST FUNCTIONS +The history functions use a common data structure, +.Fa History , +which is created by +.Fn history_init +and freed by +.Fn history_end . +.Pp +The following functions are available: +.Bl -tag -width 4n +.It Fn history_init *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 18:34:50 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 64AF8106564A; Thu, 31 Mar 2011 18:34:50 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 50A848FC1A; Thu, 31 Mar 2011 18:34:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VIYoOM015299; Thu, 31 Mar 2011 18:34:50 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VIYolV015291; Thu, 31 Mar 2011 18:34:50 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201103311834.p2VIYolV015291@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 31 Mar 2011 18:34:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220220 - in vendor/NetBSD/libedit/dist: . TEST readline X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 18:34:50 -0000 Author: obrien Date: Thu Mar 31 18:34:50 2011 New Revision: 220220 URL: http://svn.freebsd.org/changeset/base/220220 Log: Vendor import NetBSD's libedit of "2010/06/01 18:20:26 UTC". Obtained from: NetBSD Added: vendor/NetBSD/libedit/dist/TEST/wtc1.c (contents, props changed) vendor/NetBSD/libedit/dist/chartype.c (contents, props changed) vendor/NetBSD/libedit/dist/chartype.h (contents, props changed) vendor/NetBSD/libedit/dist/eln.c (contents, props changed) Modified: vendor/NetBSD/libedit/dist/Makefile vendor/NetBSD/libedit/dist/TEST/Makefile vendor/NetBSD/libedit/dist/TEST/tc1.c vendor/NetBSD/libedit/dist/chared.c vendor/NetBSD/libedit/dist/chared.h vendor/NetBSD/libedit/dist/common.c vendor/NetBSD/libedit/dist/config.h vendor/NetBSD/libedit/dist/editline.3 vendor/NetBSD/libedit/dist/editrc.5 vendor/NetBSD/libedit/dist/el.c vendor/NetBSD/libedit/dist/el.h vendor/NetBSD/libedit/dist/emacs.c vendor/NetBSD/libedit/dist/filecomplete.c vendor/NetBSD/libedit/dist/filecomplete.h vendor/NetBSD/libedit/dist/hist.c vendor/NetBSD/libedit/dist/hist.h vendor/NetBSD/libedit/dist/histedit.h vendor/NetBSD/libedit/dist/history.c vendor/NetBSD/libedit/dist/key.c vendor/NetBSD/libedit/dist/key.h vendor/NetBSD/libedit/dist/makelist vendor/NetBSD/libedit/dist/map.c vendor/NetBSD/libedit/dist/map.h vendor/NetBSD/libedit/dist/parse.c vendor/NetBSD/libedit/dist/parse.h vendor/NetBSD/libedit/dist/prompt.c vendor/NetBSD/libedit/dist/prompt.h vendor/NetBSD/libedit/dist/read.c vendor/NetBSD/libedit/dist/read.h vendor/NetBSD/libedit/dist/readline.c vendor/NetBSD/libedit/dist/readline/readline.h vendor/NetBSD/libedit/dist/refresh.c vendor/NetBSD/libedit/dist/refresh.h vendor/NetBSD/libedit/dist/search.c vendor/NetBSD/libedit/dist/search.h vendor/NetBSD/libedit/dist/shlib_version vendor/NetBSD/libedit/dist/sig.c vendor/NetBSD/libedit/dist/sig.h vendor/NetBSD/libedit/dist/sys.h vendor/NetBSD/libedit/dist/term.c vendor/NetBSD/libedit/dist/term.h vendor/NetBSD/libedit/dist/tokenizer.c vendor/NetBSD/libedit/dist/tty.c vendor/NetBSD/libedit/dist/tty.h vendor/NetBSD/libedit/dist/vi.c Modified: vendor/NetBSD/libedit/dist/Makefile ============================================================================== --- vendor/NetBSD/libedit/dist/Makefile Thu Mar 31 18:32:01 2011 (r220219) +++ vendor/NetBSD/libedit/dist/Makefile Thu Mar 31 18:34:50 2011 (r220220) @@ -1,15 +1,16 @@ -# $NetBSD: Makefile,v 1.35 2006/08/31 20:20:38 rpaulo Exp $ +# $NetBSD: Makefile,v 1.41 2010/02/03 15:34:43 roy Exp $ # @(#)Makefile 8.1 (Berkeley) 6/4/93 USE_SHLIBDIR= yes -WARNS= 3 +WIDECHAR ?= yes +WARNS= 4 LIB= edit -LIBDPLIBS= termcap ${.CURDIR}/../libterm +LIBDPLIBS+= terminfo ${.CURDIR}/../libterminfo -OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c hist.c \ - key.c map.c \ +OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \ + hist.c key.c map.c chartype.c \ parse.c prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c MAN= editline.3 editrc.5 @@ -25,9 +26,16 @@ MLINKS= editline.3 el_init.3 editline.3 editline.3 tok_line.3 editline.3 tok_str.3 # For speed and debugging -#SRCS= ${OSRCS} tokenizer.c history.c readline.c +#SRCS= ${OSRCS} readline.c tokenizer.c history.c # For protection -SRCS= editline.c tokenizer.c history.c readline.c +SRCS= editline.c readline.c tokenizer.c history.c + +.if ${WIDECHAR} == "yes" +OSRCS += eln.c +SRCS += tokenizern.c historyn.c +CLEANFILES+=tokenizern.c.tmp tokenizern.c historyn.c.tmp historyn.c +CPPFLAGS+=-DWIDECHAR +.endif LIBEDITDIR?=${.CURDIR} @@ -36,8 +44,8 @@ INCSDIR=/usr/include CLEANFILES+=editline.c CLEANFILES+=common.h.tmp editline.c.tmp emacs.h.tmp fcns.c.tmp fcns.h.tmp -CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp -CLEANFILES+=tc1.o tc1 +CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp tc1.o tc1 +CLEANFILES+=tokenizern.c.tmp tokenizern.c tokenizerw.c.tmp tokenizerw.c CPPFLAGS+=-I. -I${LIBEDITDIR} CPPFLAGS+=-I. -I${.CURDIR} CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH @@ -94,11 +102,21 @@ editline.c: ${OSRCS} makelist Makefile ${HOST_SH} ${LIBEDITDIR}/makelist -e ${OSRCS:T} > ${.TARGET}.tmp && \ mv ${.TARGET}.tmp ${.TARGET} +tokenizern.c: makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -n tokenizer.c > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +historyn.c: makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -n history.c > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + tc1.o: ${LIBEDITDIR}/TEST/tc1.c tc1: libedit.a tc1.o ${_MKTARGET_LINK} - ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermcap + ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermlib .include .include Modified: vendor/NetBSD/libedit/dist/TEST/Makefile ============================================================================== --- vendor/NetBSD/libedit/dist/TEST/Makefile Thu Mar 31 18:32:01 2011 (r220219) +++ vendor/NetBSD/libedit/dist/TEST/Makefile Thu Mar 31 18:34:50 2011 (r220220) @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.3 2006/08/31 20:20:38 rpaulo Exp $ +# $NetBSD: Makefile,v 1.5 2010/02/03 15:34:43 roy Exp $ NOMAN=1 -PROG=tc1 +PROG=wtc1 CPPFLAGS=-I${.CURDIR}/.. -LDADD+=-ledit -ltermcap -DPADD+=${LIBEDIT} ${LIBTERMCAP} +LDADD+=-ledit -ltermlib +DPADD+=${LIBEDIT} ${LIBTERMLIB} .ifdef DEBUG CPPFLAGS+=-DDEBUG Modified: vendor/NetBSD/libedit/dist/TEST/tc1.c ============================================================================== --- vendor/NetBSD/libedit/dist/TEST/tc1.c Thu Mar 31 18:32:01 2011 (r220219) +++ vendor/NetBSD/libedit/dist/TEST/tc1.c Thu Mar 31 18:34:50 2011 (r220220) @@ -1,4 +1,4 @@ -/* $NetBSD: tc1.c,v 1.1 2006/08/31 20:20:38 rpaulo Exp $ */ +/* $NetBSD: tc1.c,v 1.5 2010/04/18 21:17:47 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19 #if 0 static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: tc1.c,v 1.1 2006/08/31 20:20:38 rpaulo Exp $"); +__RCSID("$NetBSD: tc1.c,v 1.5 2010/04/18 21:17:47 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -57,6 +57,7 @@ __RCSID("$NetBSD: tc1.c,v 1.1 2006/08/31 #include #include #include +#include #include "histedit.h" @@ -71,7 +72,7 @@ static void sig(int); static char * prompt(EditLine *el) { - static char a[] = "Edit$ "; + static char a[] = "\1\033[7m\1Edit$\1\033[0m\1 "; static char b[] = "Edit> "; return (continuation ? b : a); @@ -91,6 +92,7 @@ complete(EditLine *el, int ch) const char* ptr; const LineInfo *lf = el_line(el); int len; + int res = CC_ERROR; /* * Find the last word @@ -104,16 +106,16 @@ complete(EditLine *el, int ch) if (len > strlen(dp->d_name)) continue; if (strncmp(dp->d_name, ptr, len) == 0) { - closedir(dd); if (el_insertstr(el, &dp->d_name[len]) == -1) - return (CC_ERROR); + res = CC_ERROR; else - return (CC_REFRESH); + res = CC_REFRESH; + break; } } closedir(dd); - return (CC_ERROR); + return res; } int @@ -130,6 +132,7 @@ main(int argc, char *argv[]) History *hist; HistEvent ev; + (void) setlocale(LC_CTYPE, ""); (void) signal(SIGINT, sig); (void) signal(SIGQUIT, sig); (void) signal(SIGHUP, sig); @@ -146,7 +149,7 @@ main(int argc, char *argv[]) el_set(el, EL_EDITOR, "vi"); /* Default editor is vi */ el_set(el, EL_SIGNAL, 1); /* Handle signals gracefully */ - el_set(el, EL_PROMPT, prompt); /* Set the prompt function */ + el_set(el, EL_PROMPT_ESC, prompt, '\1');/* Set the prompt function */ /* Tell editline to use this history interface */ el_set(el, EL_HIST, history, hist); Added: vendor/NetBSD/libedit/dist/TEST/wtc1.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/dist/TEST/wtc1.c Thu Mar 31 18:34:50 2011 (r220220) @@ -0,0 +1,269 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../histedit.h" + + +static int continuation; +volatile sig_atomic_t gotsig; + +static wchar_t * +prompt(EditLine *el) +{ + static wchar_t a[] = L"\1\033[7m\1Edit$\1\033[0m\1 "; + static wchar_t b[] = L"Edit> "; + + return continuation ? b : a; +} + + +static void +sig(int i) +{ + gotsig = i; +} + +const char * +my_wcstombs(const wchar_t *wstr) +{ + static struct { + char *str; + int len; + } buf; + + int needed = wcstombs(0, wstr, 0) + 1; + if (needed > buf.len) { + buf.str = malloc(needed); + buf.len = needed; + } + wcstombs(buf.str, wstr, needed); + buf.str[needed - 1] = 0; + + return buf.str; +} + + +static unsigned char +complete(EditLine *el, int ch) +{ + DIR *dd = opendir("."); + struct dirent *dp; + const wchar_t *ptr; + char *buf, *bptr; + const LineInfoW *lf = el_wline(el); + int len, mblen, i; + unsigned char res; + + /* Find the last word */ + for (ptr = lf->cursor -1; !iswspace(*ptr) && ptr > lf->buffer; --ptr) + continue; + len = lf->cursor - ++ptr; + + /* Convert last word to multibyte encoding, so we can compare to it */ + wctomb(NULL, 0); /* Reset shift state */ + mblen = MB_LEN_MAX * len + 1; + buf = bptr =(char *)malloc(mblen); + for (i = 0; i < len; ++i) { + /* Note: really should test for -1 return from wctomb */ + bptr += wctomb(bptr, ptr[i]); + } + *bptr = 0; /* Terminate multibyte string */ + mblen = bptr - buf; + + /* Scan directory for matching name */ + for (dp = readdir(dd); dp != NULL; dp = readdir(dd)) { + if (mblen > strlen(dp->d_name)) + continue; + if (strncmp(dp->d_name, buf, mblen) == 0) { + if (el_insertstr(el, &dp->d_name[mblen]) == -1) + res = CC_ERROR; + else + res = CC_REFRESH; + break; + } + } + + closedir(dd); + free(buf); + return res; +} + + +int +main(int argc, char *argv[]) +{ + EditLine *el = NULL; + int numc, ncontinuation; + const wchar_t *line; + TokenizerW *tok; + HistoryW *hist; + HistEventW ev; +#ifdef DEBUG + int i; +#endif + + setlocale(LC_ALL, ""); + + (void)signal(SIGINT, sig); + (void)signal(SIGQUIT, sig); + (void)signal(SIGHUP, sig); + (void)signal(SIGTERM, sig); + + hist = history_winit(); /* Init built-in history */ + history_w(hist, &ev, H_SETSIZE, 100); /* Remember 100 events */ + + tok = tok_winit(NULL); /* Init the tokenizer */ + + el = el_init(argv[0], stdin, stdout, stderr); + + el_wset(el, EL_EDITOR, L"vi"); /* Default editor is vi */ + el_wset(el, EL_SIGNAL, 1); /* Handle signals gracefully */ + el_wset(el, EL_PROMPT_ESC, prompt, '\1'); /* Set the prompt function */ + + el_wset(el, EL_HIST, history_w, hist); /* FIXME - history_w? */ + + /* Add a user-defined function */ + el_wset(el, EL_ADDFN, L"ed-complete", L"Complete argument", complete); + + /* Bind to it */ + el_wset(el, EL_BIND, L"^I", L"ed-complete", NULL); + + /* + * Bind j, k in vi command mode to previous and next line, instead + * of previous and next history. + */ + el_wset(el, EL_BIND, L"-a", L"k", L"ed-prev-line", NULL); + el_wset(el, EL_BIND, L"-a", L"j", L"ed-next-line", NULL); + + /* Source the user's defaults file. */ + el_source(el, NULL); + + while((line = el_wgets(el, &numc)) != NULL && numc != 0) { + int ac, cc, co, rc; + const wchar_t **av; + + const LineInfoW *li; + li = el_wline(el); + +#ifdef DEBUG + (void)fwprintf(stderr, L"==> got %d %ls", numc, line); + (void)fwprintf(stderr, L" > li `%.*ls_%.*ls'\n", + (li->cursor - li->buffer), li->buffer, + (li->lastchar - 1 - li->cursor), + (li->cursor >= li->lastchar) ? L"" : li->cursor); +#endif + + if (gotsig) { + (void)fprintf(stderr, "Got signal %d.\n", gotsig); + gotsig = 0; + el_reset(el); + } + + if(!continuation && numc == 1) + continue; /* Only got a linefeed */ + + ac = cc = co = 0; + ncontinuation = tok_wline(tok, li, &ac, &av, &cc, &co); + if (ncontinuation < 0) { + (void) fprintf(stderr, "Internal error\n"); + continuation = 0; + continue; + } + +#ifdef DEBUG + (void)fprintf(stderr, " > nc %d ac %d cc %d co %d\n", + ncontinuation, ac, cc, co); +#endif + history_w(hist, &ev, continuation ? H_APPEND : H_ENTER, line); + + continuation = ncontinuation; + ncontinuation = 0; + if(continuation) + continue; + +#ifdef DEBUG + for (i = 0; i < ac; ++i) { + (void)fwprintf(stderr, L" > arg# %2d ", i); + if (i != cc) + (void)fwprintf(stderr, L"`%ls'\n", av[i]); + else + (void)fwprintf(stderr, L"`%.*ls_%ls'\n", + co, av[i], av[i] + co); + } +#endif + + if (wcscmp (av[0], L"history") == 0) { + switch(ac) { + case 1: + for(rc = history_w(hist, &ev, H_LAST); + rc != -1; + rc = history_w(hist, &ev, H_PREV)) + (void)fwprintf(stdout, L"%4d %ls", + ev.num, ev.str); + break; + case 2: + if (wcscmp(av[1], L"clear") == 0) + history_w(hist, &ev, H_CLEAR); + else + goto badhist; + break; + case 3: + if (wcscmp(av[1], L"load") == 0) + history_w(hist, &ev, H_LOAD, + my_wcstombs(av[2])); + else if (wcscmp(av[1], L"save") == 0) + history_w(hist, &ev, H_SAVE, + my_wcstombs(av[2])); + else + goto badhist; + break; + badhist: + default: + (void)fprintf(stderr, + "Bad history arguments\n"); + break; + } + } else if (el_wparse(el, ac, av) == -1) { + switch (fork()) { + case 0: { + Tokenizer *ntok = tok_init(NULL); + int nargc; + const char **nav; + tok_str(ntok, my_wcstombs(line), &nargc, &nav); + execvp(nav[0],(char **)nav); + perror(nav[0]); + _exit(1); + /* NOTREACHED */ + break; + } + case -1: + perror("fork"); + break; + default: + if (wait(&rc) == -1) + perror("wait"); + (void)fprintf(stderr, "Exit %x\n", rc); + break; + } + } + + tok_wreset(tok); + } + + el_end(el); + tok_wend(tok); + history_wend(hist); + + fprintf(stdout, "\n"); + return 0; +} + + Modified: vendor/NetBSD/libedit/dist/chared.c ============================================================================== --- vendor/NetBSD/libedit/dist/chared.c Thu Mar 31 18:32:01 2011 (r220219) +++ vendor/NetBSD/libedit/dist/chared.c Thu Mar 31 18:34:50 2011 (r220220) @@ -1,4 +1,4 @@ -/* $NetBSD: chared.c,v 1.25 2005/08/08 01:41:30 christos Exp $ */ +/* $NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: chared.c,v 1.25 2005/08/08 01:41:30 christos Exp $"); +__RCSID("$NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -47,7 +47,7 @@ __RCSID("$NetBSD: chared.c,v 1.25 2005/0 #include #include "el.h" -private void ch__clearmacro __P((EditLine *)); +private void ch__clearmacro (EditLine *); /* value to leave unused in line buffer */ #define EL_LEAVE 2 @@ -60,13 +60,13 @@ cv_undo(EditLine *el) { c_undo_t *vu = &el->el_chared.c_undo; c_redo_t *r = &el->el_chared.c_redo; - unsigned int size; + size_t size; /* Save entire line for undo */ size = el->el_line.lastchar - el->el_line.buffer; vu->len = size; - vu->cursor = el->el_line.cursor - el->el_line.buffer; - memcpy(vu->buf, el->el_line.buffer, size); + vu->cursor = (int)(el->el_line.cursor - el->el_line.buffer); + (void)memcpy(vu->buf, el->el_line.buffer, size * sizeof(*vu->buf)); /* save command info for redo */ r->count = el->el_state.doingarg ? el->el_state.argument : 0; @@ -80,11 +80,11 @@ cv_undo(EditLine *el) * Save yank/delete data for paste */ protected void -cv_yank(EditLine *el, const char *ptr, int size) +cv_yank(EditLine *el, const Char *ptr, int size) { c_kill_t *k = &el->el_chared.c_kill; - memcpy(k->buf, ptr, size +0u); + (void)memcpy(k->buf, ptr, size * sizeof(*k->buf)); k->last = k->buf + size; } @@ -95,10 +95,10 @@ cv_yank(EditLine *el, const char *ptr, i protected void c_insert(EditLine *el, int num) { - char *cp; + Char *cp; if (el->el_line.lastchar + num >= el->el_line.limit) { - if (!ch_enlargebufs(el, num +0u)) + if (!ch_enlargebufs(el, (size_t)num)) return; /* can't go past end of buffer */ } @@ -119,7 +119,7 @@ c_delafter(EditLine *el, int num) { if (el->el_line.cursor + num > el->el_line.lastchar) - num = el->el_line.lastchar - el->el_line.cursor; + num = (int)(el->el_line.lastchar - el->el_line.cursor); if (el->el_map.current != el->el_map.emacs) { cv_undo(el); @@ -127,7 +127,7 @@ c_delafter(EditLine *el, int num) } if (num > 0) { - char *cp; + Char *cp; for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) *cp = cp[num]; @@ -143,7 +143,7 @@ c_delafter(EditLine *el, int num) protected void c_delafter1(EditLine *el) { - char *cp; + Char *cp; for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) *cp = cp[1]; @@ -160,7 +160,7 @@ c_delbefore(EditLine *el, int num) { if (el->el_line.cursor - num < el->el_line.buffer) - num = el->el_line.cursor - el->el_line.buffer; + num = (int)(el->el_line.cursor - el->el_line.buffer); if (el->el_map.current != el->el_map.emacs) { cv_undo(el); @@ -168,7 +168,7 @@ c_delbefore(EditLine *el, int num) } if (num > 0) { - char *cp; + Char *cp; for (cp = el->el_line.cursor - num; cp <= el->el_line.lastchar; @@ -186,7 +186,7 @@ c_delbefore(EditLine *el, int num) protected void c_delbefore1(EditLine *el) { - char *cp; + Char *cp; for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++) *cp = cp[1]; @@ -199,9 +199,9 @@ c_delbefore1(EditLine *el) * Return if p is part of a word according to emacs */ protected int -ce__isword(int p) +ce__isword(Int p) { - return (isalnum(p) || strchr("*?_-.[]~=", p) != NULL); + return (Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL); } @@ -209,11 +209,11 @@ ce__isword(int p) * Return if p is part of a word according to vi */ protected int -cv__isword(int p) +cv__isword(Int p) { - if (isalnum(p) || p == '_') + if (Isalnum(p) || p == '_') return 1; - if (isgraph(p)) + if (Isgraph(p)) return 2; return 0; } @@ -223,24 +223,24 @@ cv__isword(int p) * Return if p is part of a big word according to vi */ protected int -cv__isWord(int p) +cv__isWord(Int p) { - return (!isspace(p)); + return (!Isspace(p)); } /* c__prev_word(): * Find the previous word */ -protected char * -c__prev_word(char *p, char *low, int n, int (*wtest)(int)) +protected Char * +c__prev_word(Char *p, Char *low, int n, int (*wtest)(Int)) { p--; while (n--) { - while ((p >= low) && !(*wtest)((unsigned char) *p)) + while ((p >= low) && !(*wtest)(*p)) p--; - while ((p >= low) && (*wtest)((unsigned char) *p)) + while ((p >= low) && (*wtest)(*p)) p--; } @@ -256,13 +256,13 @@ c__prev_word(char *p, char *low, int n, /* c__next_word(): * Find the next word */ -protected char * -c__next_word(char *p, char *high, int n, int (*wtest)(int)) +protected Char * +c__next_word(Char *p, Char *high, int n, int (*wtest)(Int)) { while (n--) { - while ((p < high) && !(*wtest)((unsigned char) *p)) + while ((p < high) && !(*wtest)(*p)) p++; - while ((p < high) && (*wtest)((unsigned char) *p)) + while ((p < high) && (*wtest)(*p)) p++; } if (p > high) @@ -274,21 +274,21 @@ c__next_word(char *p, char *high, int n, /* cv_next_word(): * Find the next word vi style */ -protected char * -cv_next_word(EditLine *el, char *p, char *high, int n, int (*wtest)(int)) +protected Char * +cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(Int)) { int test; while (n--) { - test = (*wtest)((unsigned char) *p); - while ((p < high) && (*wtest)((unsigned char) *p) == test) + test = (*wtest)(*p); + while ((p < high) && (*wtest)(*p) == test) p++; /* * vi historically deletes with cw only the word preserving the * trailing whitespace! This is not what 'w' does.. */ if (n || el->el_chared.c_vcmd.action != (DELETE|INSERT)) - while ((p < high) && isspace((unsigned char) *p)) + while ((p < high) && Isspace(*p)) p++; } @@ -303,17 +303,17 @@ cv_next_word(EditLine *el, char *p, char /* cv_prev_word(): * Find the previous word vi style */ -protected char * -cv_prev_word(char *p, char *low, int n, int (*wtest)(int)) +protected Char * +cv_prev_word(Char *p, Char *low, int n, int (*wtest)(Int)) { int test; p--; while (n--) { - while ((p > low) && isspace((unsigned char) *p)) + while ((p > low) && Isspace(*p)) p--; - test = (*wtest)((unsigned char) *p); - while ((p >= low) && (*wtest)((unsigned char) *p) == test) + test = (*wtest)(*p); + while ((p >= low) && (*wtest)(*p) == test) p--; } p++; @@ -332,9 +332,9 @@ cv_prev_word(char *p, char *low, int n, * A '$' by itself means a big number; "$-" is for negative; '^' means 1. * Return p pointing to last char used. */ -protected char * +protected Char * c__number( - char *p, /* character position */ + Char *p, /* character position */ int *num, /* Return value */ int dval) /* dval is the number to subtract from like $-3 */ { @@ -353,7 +353,8 @@ c__number( sign = -1; /* Handle $- */ ++p; } - for (i = 0; isdigit((unsigned char) *p); i = 10 * i + *p++ - '0') + /* XXX: this assumes ASCII compatible digits */ + for (i = 0; Isdigit(*p); i = 10 * i + *p++ - '0') continue; *num = (sign < 0 ? dval - i : i); return (--p); @@ -376,7 +377,7 @@ cv_delfini(EditLine *el) /* sanity */ return; - size = el->el_line.cursor - el->el_chared.c_vcmd.pos; + size = (int)(el->el_line.cursor - el->el_chared.c_vcmd.pos); if (size == 0) size = 1; el->el_line.cursor = el->el_chared.c_vcmd.pos; @@ -402,15 +403,15 @@ cv_delfini(EditLine *el) /* ce__endword(): * Go to the end of this word according to emacs */ -protected char * -ce__endword(char *p, char *high, int n) +protected Char * +ce__endword(Char *p, Char *high, int n) { p++; while (n--) { - while ((p < high) && isspace((unsigned char) *p)) + while ((p < high) && Isspace(*p)) p++; - while ((p < high) && !isspace((unsigned char) *p)) + while ((p < high) && !Isspace(*p)) p++; } @@ -423,19 +424,19 @@ ce__endword(char *p, char *high, int n) /* cv__endword(): * Go to the end of this word according to vi */ -protected char * -cv__endword(char *p, char *high, int n, int (*wtest)(int)) +protected Char * +cv__endword(Char *p, Char *high, int n, int (*wtest)(Int)) { int test; p++; while (n--) { - while ((p < high) && isspace((unsigned char) *p)) + while ((p < high) && Isspace(*p)) p++; - test = (*wtest)((unsigned char) *p); - while ((p < high) && (*wtest)((unsigned char) *p) == test) + test = (*wtest)(*p); + while ((p < high) && (*wtest)(*p) == test) p++; } p--; @@ -450,22 +451,27 @@ ch_init(EditLine *el) { c_macro_t *ma = &el->el_chared.c_macro; - el->el_line.buffer = (char *) el_malloc(EL_BUFSIZ); + el->el_line.buffer = el_malloc(EL_BUFSIZ * + sizeof(*el->el_line.buffer)); if (el->el_line.buffer == NULL) return (-1); - (void) memset(el->el_line.buffer, 0, EL_BUFSIZ); + (void) memset(el->el_line.buffer, 0, EL_BUFSIZ * + sizeof(*el->el_line.buffer)); el->el_line.cursor = el->el_line.buffer; el->el_line.lastchar = el->el_line.buffer; el->el_line.limit = &el->el_line.buffer[EL_BUFSIZ - EL_LEAVE]; - el->el_chared.c_undo.buf = (char *) el_malloc(EL_BUFSIZ); + el->el_chared.c_undo.buf = el_malloc(EL_BUFSIZ * + sizeof(*el->el_chared.c_undo.buf)); if (el->el_chared.c_undo.buf == NULL) return (-1); - (void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ); + (void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ * + sizeof(*el->el_chared.c_undo.buf)); el->el_chared.c_undo.len = -1; el->el_chared.c_undo.cursor = 0; - el->el_chared.c_redo.buf = (char *) el_malloc(EL_BUFSIZ); + el->el_chared.c_redo.buf = el_malloc(EL_BUFSIZ * + sizeof(*el->el_chared.c_redo.buf)); if (el->el_chared.c_redo.buf == NULL) return (-1); el->el_chared.c_redo.pos = el->el_chared.c_redo.buf; @@ -475,10 +481,12 @@ ch_init(EditLine *el) el->el_chared.c_vcmd.action = NOP; el->el_chared.c_vcmd.pos = el->el_line.buffer; - el->el_chared.c_kill.buf = (char *) el_malloc(EL_BUFSIZ); + el->el_chared.c_kill.buf = el_malloc(EL_BUFSIZ * + sizeof(*el->el_chared.c_kill.buf)); if (el->el_chared.c_kill.buf == NULL) return (-1); - (void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ); + (void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ * + sizeof(*el->el_chared.c_kill.buf)); el->el_chared.c_kill.mark = el->el_line.buffer; el->el_chared.c_kill.last = el->el_chared.c_kill.buf; @@ -492,7 +500,7 @@ ch_init(EditLine *el) ma->level = -1; ma->offset = 0; - ma->macro = (char **) el_malloc(EL_MAXMACRO * sizeof(char *)); + ma->macro = el_malloc(EL_MAXMACRO * sizeof(*ma->macro)); if (ma->macro == NULL) return (-1); return (0); @@ -530,8 +538,7 @@ ch_reset(EditLine *el, int mclear) } private void -ch__clearmacro(el) - EditLine *el; +ch__clearmacro(EditLine *el) { c_macro_t *ma = &el->el_chared.c_macro; while (ma->level >= 0) @@ -543,12 +550,10 @@ ch__clearmacro(el) * Returns 1 if successful, 0 if not. */ protected int -ch_enlargebufs(el, addlen) - EditLine *el; - size_t addlen; +ch_enlargebufs(EditLine *el, size_t addlen) { size_t sz, newsz; - char *newbuffer, *oldbuf, *oldkbuf; + Char *newbuffer, *oldbuf, *oldkbuf; sz = el->el_line.limit - el->el_line.buffer + EL_LEAVE; newsz = sz * 2; @@ -564,12 +569,12 @@ ch_enlargebufs(el, addlen) /* * Reallocate line buffer. */ - newbuffer = el_realloc(el->el_line.buffer, newsz); + newbuffer = el_realloc(el->el_line.buffer, newsz * sizeof(*newbuffer)); if (!newbuffer) return 0; /* zero the newly added memory, leave old data in */ - (void) memset(&newbuffer[sz], 0, newsz - sz); + (void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer)); oldbuf = el->el_line.buffer; @@ -582,12 +587,12 @@ ch_enlargebufs(el, addlen) /* * Reallocate kill buffer. */ - newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz); + newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz * sizeof(*newbuffer)); if (!newbuffer) return 0; /* zero the newly added memory, leave old data in */ - (void) memset(&newbuffer[sz], 0, newsz - sz); + (void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer)); oldkbuf = el->el_chared.c_kill.buf; @@ -600,15 +605,17 @@ ch_enlargebufs(el, addlen) /* * Reallocate undo buffer. */ - newbuffer = el_realloc(el->el_chared.c_undo.buf, newsz); + newbuffer = el_realloc(el->el_chared.c_undo.buf, + newsz * sizeof(*newbuffer)); if (!newbuffer) return 0; /* zero the newly added memory, leave old data in */ - (void) memset(&newbuffer[sz], 0, newsz - sz); + (void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer)); el->el_chared.c_undo.buf = newbuffer; - newbuffer = el_realloc(el->el_chared.c_redo.buf, newsz); + newbuffer = el_realloc(el->el_chared.c_redo.buf, + newsz * sizeof(*newbuffer)); if (!newbuffer) return 0; el->el_chared.c_redo.pos = newbuffer + @@ -653,11 +660,11 @@ ch_end(EditLine *el) * Insert string at cursorI */ public int -el_insertstr(EditLine *el, const char *s) +FUN(el,insertstr)(EditLine *el, const Char *s) { size_t len; - if ((len = strlen(s)) == 0) + if ((len = Strlen(s)) == 0) return (-1); if (el->el_line.lastchar + len >= el->el_line.limit) { if (!ch_enlargebufs(el, len)) @@ -693,15 +700,15 @@ el_deletestr(EditLine *el, int n) * Get a string */ protected int -c_gets(EditLine *el, char *buf, const char *prompt) +c_gets(EditLine *el, Char *buf, const Char *prompt) { - char ch; - int len; - char *cp = el->el_line.buffer; + Char ch; + ssize_t len; + Char *cp = el->el_line.buffer; if (prompt) { - len = strlen(prompt); - memcpy(cp, prompt, len + 0u); + len = Strlen(prompt); + (void)memcpy(cp, prompt, len * sizeof(*cp)); cp += len; } len = 0; @@ -712,7 +719,7 @@ c_gets(EditLine *el, char *buf, const ch el->el_line.lastchar = cp + 1; re_refresh(el); - if (el_getc(el, &ch) != 1) { + if (FUN(el,getc)(el, &ch) != 1) { ed_end_of_file(el, 0); len = -1; break; @@ -722,7 +729,7 @@ c_gets(EditLine *el, char *buf, const ch case 0010: /* Delete and backspace */ case 0177: - if (len <= 0) { + if (len == 0) { len = -1; break; } @@ -750,7 +757,7 @@ c_gets(EditLine *el, char *buf, const ch el->el_line.buffer[0] = '\0'; el->el_line.lastchar = el->el_line.buffer; el->el_line.cursor = el->el_line.buffer; - return len; + return (int)len; } @@ -760,7 +767,7 @@ c_gets(EditLine *el, char *buf, const ch protected int c_hpos(EditLine *el) { - char *ptr; + Char *ptr; /* * Find how many characters till the beginning of this line. @@ -772,6 +779,6 @@ c_hpos(EditLine *el) ptr >= el->el_line.buffer && *ptr != '\n'; ptr--) continue; - return (el->el_line.cursor - ptr - 1); + return (int)(el->el_line.cursor - ptr - 1); } } Modified: vendor/NetBSD/libedit/dist/chared.h ============================================================================== --- vendor/NetBSD/libedit/dist/chared.h Thu Mar 31 18:32:01 2011 (r220219) +++ vendor/NetBSD/libedit/dist/chared.h Thu Mar 31 18:34:50 2011 (r220220) @@ -1,4 +1,4 @@ -/* $NetBSD: chared.h,v 1.17 2006/03/06 21:11:56 christos Exp $ */ +/* $NetBSD: chared.h,v 1.20 2010/04/15 00:57:33 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -63,25 +63,25 @@ typedef struct c_macro_t { int level; int offset; - char **macro; + Char **macro; } c_macro_t; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 18:35:44 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E2E4B1065677; Thu, 31 Mar 2011 18:35:44 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CE7768FC28; Thu, 31 Mar 2011 18:35:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VIZi7J015374; Thu, 31 Mar 2011 18:35:44 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VIZim5015367; Thu, 31 Mar 2011 18:35:44 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201103311835.p2VIZim5015367@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 31 Mar 2011 18:35:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220221 - in vendor/NetBSD/libedit/2010-06-01: . TEST readline X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 18:35:45 -0000 Author: obrien Date: Thu Mar 31 18:35:44 2011 New Revision: 220221 URL: http://svn.freebsd.org/changeset/base/220221 Log: "Tag" the "2010/06/01 18:20:26 UTC" import. Added: vendor/NetBSD/libedit/2010-06-01/ - copied from r220218, vendor/NetBSD/libedit/dist/ vendor/NetBSD/libedit/2010-06-01/TEST/wtc1.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/TEST/wtc1.c vendor/NetBSD/libedit/2010-06-01/chartype.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/chartype.c vendor/NetBSD/libedit/2010-06-01/chartype.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/chartype.h vendor/NetBSD/libedit/2010-06-01/eln.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/eln.c Replaced: vendor/NetBSD/libedit/2010-06-01/Makefile - copied unchanged from r220220, vendor/NetBSD/libedit/dist/Makefile vendor/NetBSD/libedit/2010-06-01/TEST/Makefile - copied unchanged from r220220, vendor/NetBSD/libedit/dist/TEST/Makefile vendor/NetBSD/libedit/2010-06-01/TEST/tc1.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/TEST/tc1.c vendor/NetBSD/libedit/2010-06-01/chared.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/chared.c vendor/NetBSD/libedit/2010-06-01/chared.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/chared.h vendor/NetBSD/libedit/2010-06-01/common.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/common.c vendor/NetBSD/libedit/2010-06-01/config.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/config.h vendor/NetBSD/libedit/2010-06-01/editline.3 - copied unchanged from r220220, vendor/NetBSD/libedit/dist/editline.3 vendor/NetBSD/libedit/2010-06-01/editrc.5 - copied unchanged from r220220, vendor/NetBSD/libedit/dist/editrc.5 vendor/NetBSD/libedit/2010-06-01/el.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/el.c vendor/NetBSD/libedit/2010-06-01/el.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/el.h vendor/NetBSD/libedit/2010-06-01/emacs.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/emacs.c vendor/NetBSD/libedit/2010-06-01/filecomplete.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/filecomplete.c vendor/NetBSD/libedit/2010-06-01/filecomplete.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/filecomplete.h vendor/NetBSD/libedit/2010-06-01/hist.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/hist.c vendor/NetBSD/libedit/2010-06-01/hist.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/hist.h vendor/NetBSD/libedit/2010-06-01/histedit.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/histedit.h vendor/NetBSD/libedit/2010-06-01/history.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/history.c vendor/NetBSD/libedit/2010-06-01/key.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/key.c vendor/NetBSD/libedit/2010-06-01/key.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/key.h vendor/NetBSD/libedit/2010-06-01/makelist - copied unchanged from r220220, vendor/NetBSD/libedit/dist/makelist vendor/NetBSD/libedit/2010-06-01/map.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/map.c vendor/NetBSD/libedit/2010-06-01/map.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/map.h vendor/NetBSD/libedit/2010-06-01/parse.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/parse.c vendor/NetBSD/libedit/2010-06-01/parse.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/parse.h vendor/NetBSD/libedit/2010-06-01/prompt.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/prompt.c vendor/NetBSD/libedit/2010-06-01/prompt.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/prompt.h vendor/NetBSD/libedit/2010-06-01/read.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/read.c vendor/NetBSD/libedit/2010-06-01/read.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/read.h vendor/NetBSD/libedit/2010-06-01/readline.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/readline.c vendor/NetBSD/libedit/2010-06-01/readline/readline.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/readline/readline.h vendor/NetBSD/libedit/2010-06-01/refresh.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/refresh.c vendor/NetBSD/libedit/2010-06-01/refresh.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/refresh.h vendor/NetBSD/libedit/2010-06-01/search.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/search.c vendor/NetBSD/libedit/2010-06-01/search.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/search.h vendor/NetBSD/libedit/2010-06-01/shlib_version - copied unchanged from r220220, vendor/NetBSD/libedit/dist/shlib_version vendor/NetBSD/libedit/2010-06-01/sig.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/sig.c vendor/NetBSD/libedit/2010-06-01/sig.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/sig.h vendor/NetBSD/libedit/2010-06-01/sys.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/sys.h vendor/NetBSD/libedit/2010-06-01/term.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/term.c vendor/NetBSD/libedit/2010-06-01/term.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/term.h vendor/NetBSD/libedit/2010-06-01/tokenizer.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/tokenizer.c vendor/NetBSD/libedit/2010-06-01/tty.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/tty.c vendor/NetBSD/libedit/2010-06-01/tty.h - copied unchanged from r220220, vendor/NetBSD/libedit/dist/tty.h vendor/NetBSD/libedit/2010-06-01/vi.c - copied unchanged from r220220, vendor/NetBSD/libedit/dist/vi.c Copied: vendor/NetBSD/libedit/2010-06-01/Makefile (from r220220, vendor/NetBSD/libedit/dist/Makefile) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/2010-06-01/Makefile Thu Mar 31 18:35:44 2011 (r220221, copy of r220220, vendor/NetBSD/libedit/dist/Makefile) @@ -0,0 +1,122 @@ +# $NetBSD: Makefile,v 1.41 2010/02/03 15:34:43 roy Exp $ +# @(#)Makefile 8.1 (Berkeley) 6/4/93 + +USE_SHLIBDIR= yes + +WIDECHAR ?= yes +WARNS= 4 +LIB= edit + +LIBDPLIBS+= terminfo ${.CURDIR}/../libterminfo + +OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \ + hist.c key.c map.c chartype.c \ + parse.c prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c + +MAN= editline.3 editrc.5 + +MLINKS= editline.3 el_init.3 editline.3 el_end.3 editline.3 el_reset.3 \ + editline.3 el_gets.3 editline.3 el_getc.3 editline.3 el_push.3 \ + editline.3 el_parse.3 editline.3 el_set.3 editline.3 el_get.3 \ + editline.3 el_source.3 editline.3 el_resize.3 editline.3 el_line.3 \ + editline.3 el_insertstr.3 editline.3 el_deletestr.3 \ + editline.3 history_init.3 editline.3 history_end.3 \ + editline.3 history.3 \ + editline.3 tok_init.3 editline.3 tok_end.3 editline.3 tok_reset.3 \ + editline.3 tok_line.3 editline.3 tok_str.3 + +# For speed and debugging +#SRCS= ${OSRCS} readline.c tokenizer.c history.c +# For protection +SRCS= editline.c readline.c tokenizer.c history.c + +.if ${WIDECHAR} == "yes" +OSRCS += eln.c +SRCS += tokenizern.c historyn.c +CLEANFILES+=tokenizern.c.tmp tokenizern.c historyn.c.tmp historyn.c +CPPFLAGS+=-DWIDECHAR +.endif + +LIBEDITDIR?=${.CURDIR} + +INCS= histedit.h +INCSDIR=/usr/include + +CLEANFILES+=editline.c +CLEANFILES+=common.h.tmp editline.c.tmp emacs.h.tmp fcns.c.tmp fcns.h.tmp +CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp tc1.o tc1 +CLEANFILES+=tokenizern.c.tmp tokenizern.c tokenizerw.c.tmp tokenizerw.c +CPPFLAGS+=-I. -I${LIBEDITDIR} +CPPFLAGS+=-I. -I${.CURDIR} +CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH +CPPFLAGS+=#-DDEBUG_PASTE -DDEBUG_EDIT + +AHDR=vi.h emacs.h common.h +ASRC=${LIBEDITDIR}/vi.c ${LIBEDITDIR}/emacs.c ${LIBEDITDIR}/common.c + +DPSRCS+= ${AHDR} fcns.h help.h fcns.c help.c +CLEANFILES+= ${AHDR} fcns.h help.h fcns.c help.c + +SUBDIR= readline + +vi.h: vi.c makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/vi.c \ + > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +emacs.h: emacs.c makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/emacs.c \ + > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +common.h: common.c makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/common.c \ + > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +fcns.h: ${AHDR} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -fh ${AHDR} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +fcns.c: ${AHDR} fcns.h help.h makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -fc ${AHDR} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +help.c: ${ASRC} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -bc ${ASRC} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +help.h: ${ASRC} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -bh ${ASRC} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +editline.c: ${OSRCS} makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -e ${OSRCS:T} > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +tokenizern.c: makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -n tokenizer.c > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +historyn.c: makelist Makefile + ${_MKTARGET_CREATE} + ${HOST_SH} ${LIBEDITDIR}/makelist -n history.c > ${.TARGET}.tmp && \ + mv ${.TARGET}.tmp ${.TARGET} + +tc1.o: ${LIBEDITDIR}/TEST/tc1.c + +tc1: libedit.a tc1.o + ${_MKTARGET_LINK} + ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermlib + +.include +.include Copied: vendor/NetBSD/libedit/2010-06-01/TEST/Makefile (from r220220, vendor/NetBSD/libedit/dist/TEST/Makefile) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/2010-06-01/TEST/Makefile Thu Mar 31 18:35:44 2011 (r220221, copy of r220220, vendor/NetBSD/libedit/dist/TEST/Makefile) @@ -0,0 +1,13 @@ +# $NetBSD: Makefile,v 1.5 2010/02/03 15:34:43 roy Exp $ + +NOMAN=1 +PROG=wtc1 +CPPFLAGS=-I${.CURDIR}/.. +LDADD+=-ledit -ltermlib +DPADD+=${LIBEDIT} ${LIBTERMLIB} + +.ifdef DEBUG +CPPFLAGS+=-DDEBUG +.endif + +.include Copied: vendor/NetBSD/libedit/2010-06-01/TEST/tc1.c (from r220220, vendor/NetBSD/libedit/dist/TEST/tc1.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/2010-06-01/TEST/tc1.c Thu Mar 31 18:35:44 2011 (r220221, copy of r220220, vendor/NetBSD/libedit/dist/TEST/tc1.c) @@ -0,0 +1,304 @@ +/* $NetBSD: tc1.c,v 1.5 2010/04/18 21:17:47 christos Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Christos Zoulas of Cornell University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "config.h" +#ifndef lint +__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\ + The Regents of the University of California. All rights reserved.\n"); +#endif /* not lint */ + +#if !defined(lint) && !defined(SCCSID) +#if 0 +static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: tc1.c,v 1.5 2010/04/18 21:17:47 christos Exp $"); +#endif +#endif /* not lint && not SCCSID */ + +/* + * test.c: A little test program + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "histedit.h" + +static int continuation = 0; +volatile sig_atomic_t gotsig = 0; + +static unsigned char complete(EditLine *, int); + int main(int, char **); +static char *prompt(EditLine *); +static void sig(int); + +static char * +prompt(EditLine *el) +{ + static char a[] = "\1\033[7m\1Edit$\1\033[0m\1 "; + static char b[] = "Edit> "; + + return (continuation ? b : a); +} + +static void +sig(int i) +{ + gotsig = i; +} + +static unsigned char +complete(EditLine *el, int ch) +{ + DIR *dd = opendir("."); + struct dirent *dp; + const char* ptr; + const LineInfo *lf = el_line(el); + int len; + int res = CC_ERROR; + + /* + * Find the last word + */ + for (ptr = lf->cursor - 1; + !isspace((unsigned char)*ptr) && ptr > lf->buffer; ptr--) + continue; + len = lf->cursor - ++ptr; + + for (dp = readdir(dd); dp != NULL; dp = readdir(dd)) { + if (len > strlen(dp->d_name)) + continue; + if (strncmp(dp->d_name, ptr, len) == 0) { + if (el_insertstr(el, &dp->d_name[len]) == -1) + res = CC_ERROR; + else + res = CC_REFRESH; + break; + } + } + + closedir(dd); + return res; +} + +int +main(int argc, char *argv[]) +{ + EditLine *el = NULL; + int num; + const char *buf; + Tokenizer *tok; +#if 0 + int lastevent = 0; +#endif + int ncontinuation; + History *hist; + HistEvent ev; + + (void) setlocale(LC_CTYPE, ""); + (void) signal(SIGINT, sig); + (void) signal(SIGQUIT, sig); + (void) signal(SIGHUP, sig); + (void) signal(SIGTERM, sig); + + hist = history_init(); /* Init the builtin history */ + /* Remember 100 events */ + history(hist, &ev, H_SETSIZE, 100); + + tok = tok_init(NULL); /* Initialize the tokenizer */ + + /* Initialize editline */ + el = el_init(*argv, stdin, stdout, stderr); + + el_set(el, EL_EDITOR, "vi"); /* Default editor is vi */ + el_set(el, EL_SIGNAL, 1); /* Handle signals gracefully */ + el_set(el, EL_PROMPT_ESC, prompt, '\1');/* Set the prompt function */ + + /* Tell editline to use this history interface */ + el_set(el, EL_HIST, history, hist); + + /* Add a user-defined function */ + el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete); + + /* Bind tab to it */ + el_set(el, EL_BIND, "^I", "ed-complete", NULL); + + /* + * Bind j, k in vi command mode to previous and next line, instead + * of previous and next history. + */ + el_set(el, EL_BIND, "-a", "k", "ed-prev-line", NULL); + el_set(el, EL_BIND, "-a", "j", "ed-next-line", NULL); + + /* + * Source the user's defaults file. + */ + el_source(el, NULL); + + while ((buf = el_gets(el, &num)) != NULL && num != 0) { + int ac, cc, co; +#ifdef DEBUG + int i; +#endif + const char **av; + const LineInfo *li; + li = el_line(el); +#ifdef DEBUG + (void) fprintf(stderr, "==> got %d %s", num, buf); + (void) fprintf(stderr, " > li `%.*s_%.*s'\n", + (li->cursor - li->buffer), li->buffer, + (li->lastchar - 1 - li->cursor), + (li->cursor >= li->lastchar) ? "" : li->cursor); + +#endif + if (gotsig) { + (void) fprintf(stderr, "Got signal %d.\n", gotsig); + gotsig = 0; + el_reset(el); + } + + if (!continuation && num == 1) + continue; + + ac = cc = co = 0; + ncontinuation = tok_line(tok, li, &ac, &av, &cc, &co); + if (ncontinuation < 0) { + (void) fprintf(stderr, "Internal error\n"); + continuation = 0; + continue; + } +#ifdef DEBUG + (void) fprintf(stderr, " > nc %d ac %d cc %d co %d\n", + ncontinuation, ac, cc, co); +#endif +#if 0 + if (continuation) { + /* + * Append to the right event in case the user + * moved around in history. + */ + if (history(hist, &ev, H_SET, lastevent) == -1) + err(1, "%d: %s", lastevent, ev.str); + history(hist, &ev, H_ADD , buf); + } else { + history(hist, &ev, H_ENTER, buf); + lastevent = ev.num; + } +#else + /* Simpler */ + history(hist, &ev, continuation ? H_APPEND : H_ENTER, buf); +#endif + + continuation = ncontinuation; + ncontinuation = 0; + if (continuation) + continue; +#ifdef DEBUG + for (i = 0; i < ac; i++) { + (void) fprintf(stderr, " > arg# %2d ", i); + if (i != cc) + (void) fprintf(stderr, "`%s'\n", av[i]); + else + (void) fprintf(stderr, "`%.*s_%s'\n", + co, av[i], av[i] + co); + } +#endif + + if (strcmp(av[0], "history") == 0) { + int rv; + + switch (ac) { + case 1: + for (rv = history(hist, &ev, H_LAST); rv != -1; + rv = history(hist, &ev, H_PREV)) + (void) fprintf(stdout, "%4d %s", + ev.num, ev.str); + break; + + case 2: + if (strcmp(av[1], "clear") == 0) + history(hist, &ev, H_CLEAR); + else + goto badhist; + break; + + case 3: + if (strcmp(av[1], "load") == 0) + history(hist, &ev, H_LOAD, av[2]); + else if (strcmp(av[1], "save") == 0) + history(hist, &ev, H_SAVE, av[2]); + break; + + badhist: + default: + (void) fprintf(stderr, + "Bad history arguments\n"); + break; + } + } else if (el_parse(el, ac, av) == -1) { + switch (fork()) { + case 0: + execvp(av[0], (char *const *)__UNCONST(av)); + perror(av[0]); + _exit(1); + /*NOTREACHED*/ + break; + + case -1: + perror("fork"); + break; + + default: + if (wait(&num) == -1) + perror("wait"); + (void) fprintf(stderr, "Exit %x\n", num); + break; + } + } + + tok_reset(tok); + } + + el_end(el); + tok_end(tok); + history_end(hist); + + return (0); +} Copied: vendor/NetBSD/libedit/2010-06-01/TEST/wtc1.c (from r220220, vendor/NetBSD/libedit/dist/TEST/wtc1.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/2010-06-01/TEST/wtc1.c Thu Mar 31 18:35:44 2011 (r220221, copy of r220220, vendor/NetBSD/libedit/dist/TEST/wtc1.c) @@ -0,0 +1,269 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../histedit.h" + + +static int continuation; +volatile sig_atomic_t gotsig; + +static wchar_t * +prompt(EditLine *el) +{ + static wchar_t a[] = L"\1\033[7m\1Edit$\1\033[0m\1 "; + static wchar_t b[] = L"Edit> "; + + return continuation ? b : a; +} + + +static void +sig(int i) +{ + gotsig = i; +} + +const char * +my_wcstombs(const wchar_t *wstr) +{ + static struct { + char *str; + int len; + } buf; + + int needed = wcstombs(0, wstr, 0) + 1; + if (needed > buf.len) { + buf.str = malloc(needed); + buf.len = needed; + } + wcstombs(buf.str, wstr, needed); + buf.str[needed - 1] = 0; + + return buf.str; +} + + +static unsigned char +complete(EditLine *el, int ch) +{ + DIR *dd = opendir("."); + struct dirent *dp; + const wchar_t *ptr; + char *buf, *bptr; + const LineInfoW *lf = el_wline(el); + int len, mblen, i; + unsigned char res; + + /* Find the last word */ + for (ptr = lf->cursor -1; !iswspace(*ptr) && ptr > lf->buffer; --ptr) + continue; + len = lf->cursor - ++ptr; + + /* Convert last word to multibyte encoding, so we can compare to it */ + wctomb(NULL, 0); /* Reset shift state */ + mblen = MB_LEN_MAX * len + 1; + buf = bptr =(char *)malloc(mblen); + for (i = 0; i < len; ++i) { + /* Note: really should test for -1 return from wctomb */ + bptr += wctomb(bptr, ptr[i]); + } + *bptr = 0; /* Terminate multibyte string */ + mblen = bptr - buf; + + /* Scan directory for matching name */ + for (dp = readdir(dd); dp != NULL; dp = readdir(dd)) { + if (mblen > strlen(dp->d_name)) + continue; + if (strncmp(dp->d_name, buf, mblen) == 0) { + if (el_insertstr(el, &dp->d_name[mblen]) == -1) + res = CC_ERROR; + else + res = CC_REFRESH; + break; + } + } + + closedir(dd); + free(buf); + return res; +} + + +int +main(int argc, char *argv[]) +{ + EditLine *el = NULL; + int numc, ncontinuation; + const wchar_t *line; + TokenizerW *tok; + HistoryW *hist; + HistEventW ev; +#ifdef DEBUG + int i; +#endif + + setlocale(LC_ALL, ""); + + (void)signal(SIGINT, sig); + (void)signal(SIGQUIT, sig); + (void)signal(SIGHUP, sig); + (void)signal(SIGTERM, sig); + + hist = history_winit(); /* Init built-in history */ + history_w(hist, &ev, H_SETSIZE, 100); /* Remember 100 events */ + + tok = tok_winit(NULL); /* Init the tokenizer */ + + el = el_init(argv[0], stdin, stdout, stderr); + + el_wset(el, EL_EDITOR, L"vi"); /* Default editor is vi */ + el_wset(el, EL_SIGNAL, 1); /* Handle signals gracefully */ + el_wset(el, EL_PROMPT_ESC, prompt, '\1'); /* Set the prompt function */ + + el_wset(el, EL_HIST, history_w, hist); /* FIXME - history_w? */ + + /* Add a user-defined function */ + el_wset(el, EL_ADDFN, L"ed-complete", L"Complete argument", complete); + + /* Bind to it */ + el_wset(el, EL_BIND, L"^I", L"ed-complete", NULL); + + /* + * Bind j, k in vi command mode to previous and next line, instead + * of previous and next history. + */ + el_wset(el, EL_BIND, L"-a", L"k", L"ed-prev-line", NULL); + el_wset(el, EL_BIND, L"-a", L"j", L"ed-next-line", NULL); + + /* Source the user's defaults file. */ + el_source(el, NULL); + + while((line = el_wgets(el, &numc)) != NULL && numc != 0) { + int ac, cc, co, rc; + const wchar_t **av; + + const LineInfoW *li; + li = el_wline(el); + +#ifdef DEBUG + (void)fwprintf(stderr, L"==> got %d %ls", numc, line); + (void)fwprintf(stderr, L" > li `%.*ls_%.*ls'\n", + (li->cursor - li->buffer), li->buffer, + (li->lastchar - 1 - li->cursor), + (li->cursor >= li->lastchar) ? L"" : li->cursor); +#endif + + if (gotsig) { + (void)fprintf(stderr, "Got signal %d.\n", gotsig); + gotsig = 0; + el_reset(el); + } + + if(!continuation && numc == 1) + continue; /* Only got a linefeed */ + + ac = cc = co = 0; + ncontinuation = tok_wline(tok, li, &ac, &av, &cc, &co); + if (ncontinuation < 0) { + (void) fprintf(stderr, "Internal error\n"); + continuation = 0; + continue; + } + +#ifdef DEBUG + (void)fprintf(stderr, " > nc %d ac %d cc %d co %d\n", + ncontinuation, ac, cc, co); +#endif + history_w(hist, &ev, continuation ? H_APPEND : H_ENTER, line); + + continuation = ncontinuation; + ncontinuation = 0; + if(continuation) + continue; + +#ifdef DEBUG + for (i = 0; i < ac; ++i) { + (void)fwprintf(stderr, L" > arg# %2d ", i); + if (i != cc) + (void)fwprintf(stderr, L"`%ls'\n", av[i]); + else + (void)fwprintf(stderr, L"`%.*ls_%ls'\n", + co, av[i], av[i] + co); + } +#endif + + if (wcscmp (av[0], L"history") == 0) { + switch(ac) { + case 1: + for(rc = history_w(hist, &ev, H_LAST); + rc != -1; + rc = history_w(hist, &ev, H_PREV)) + (void)fwprintf(stdout, L"%4d %ls", + ev.num, ev.str); + break; + case 2: + if (wcscmp(av[1], L"clear") == 0) + history_w(hist, &ev, H_CLEAR); + else + goto badhist; + break; + case 3: + if (wcscmp(av[1], L"load") == 0) + history_w(hist, &ev, H_LOAD, + my_wcstombs(av[2])); + else if (wcscmp(av[1], L"save") == 0) + history_w(hist, &ev, H_SAVE, + my_wcstombs(av[2])); + else + goto badhist; + break; + badhist: + default: + (void)fprintf(stderr, + "Bad history arguments\n"); + break; + } + } else if (el_wparse(el, ac, av) == -1) { + switch (fork()) { + case 0: { + Tokenizer *ntok = tok_init(NULL); + int nargc; + const char **nav; + tok_str(ntok, my_wcstombs(line), &nargc, &nav); + execvp(nav[0],(char **)nav); + perror(nav[0]); + _exit(1); + /* NOTREACHED */ + break; + } + case -1: + perror("fork"); + break; + default: + if (wait(&rc) == -1) + perror("wait"); + (void)fprintf(stderr, "Exit %x\n", rc); + break; + } + } + + tok_wreset(tok); + } + + el_end(el); + tok_wend(tok); + history_wend(hist); + + fprintf(stdout, "\n"); + return 0; +} + + Copied: vendor/NetBSD/libedit/2010-06-01/chared.c (from r220220, vendor/NetBSD/libedit/dist/chared.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/2010-06-01/chared.c Thu Mar 31 18:35:44 2011 (r220221, copy of r220220, vendor/NetBSD/libedit/dist/chared.c) @@ -0,0 +1,784 @@ +/* $NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Christos Zoulas of Cornell University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "config.h" +#if !defined(lint) && !defined(SCCSID) +#if 0 +static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $"); +#endif +#endif /* not lint && not SCCSID */ + +/* + * chared.c: Character editor utilities + */ +#include +#include "el.h" + +private void ch__clearmacro (EditLine *); + +/* value to leave unused in line buffer */ +#define EL_LEAVE 2 + +/* cv_undo(): + * Handle state for the vi undo command + */ +protected void +cv_undo(EditLine *el) +{ + c_undo_t *vu = &el->el_chared.c_undo; + c_redo_t *r = &el->el_chared.c_redo; + size_t size; + + /* Save entire line for undo */ + size = el->el_line.lastchar - el->el_line.buffer; + vu->len = size; + vu->cursor = (int)(el->el_line.cursor - el->el_line.buffer); + (void)memcpy(vu->buf, el->el_line.buffer, size * sizeof(*vu->buf)); + + /* save command info for redo */ + r->count = el->el_state.doingarg ? el->el_state.argument : 0; + r->action = el->el_chared.c_vcmd.action; + r->pos = r->buf; + r->cmd = el->el_state.thiscmd; + r->ch = el->el_state.thisch; +} + +/* cv_yank(): + * Save yank/delete data for paste + */ +protected void +cv_yank(EditLine *el, const Char *ptr, int size) +{ + c_kill_t *k = &el->el_chared.c_kill; + + (void)memcpy(k->buf, ptr, size * sizeof(*k->buf)); + k->last = k->buf + size; +} + + +/* c_insert(): + * Insert num characters + */ +protected void +c_insert(EditLine *el, int num) +{ + Char *cp; + + if (el->el_line.lastchar + num >= el->el_line.limit) { + if (!ch_enlargebufs(el, (size_t)num)) + return; /* can't go past end of buffer */ + } + + if (el->el_line.cursor < el->el_line.lastchar) { + /* if I must move chars */ + for (cp = el->el_line.lastchar; cp >= el->el_line.cursor; cp--) + cp[num] = *cp; + } + el->el_line.lastchar += num; +} + + +/* c_delafter(): + * Delete num characters after the cursor + */ +protected void +c_delafter(EditLine *el, int num) +{ + + if (el->el_line.cursor + num > el->el_line.lastchar) + num = (int)(el->el_line.lastchar - el->el_line.cursor); + + if (el->el_map.current != el->el_map.emacs) { + cv_undo(el); + cv_yank(el, el->el_line.cursor, num); + } + + if (num > 0) { + Char *cp; + + for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) + *cp = cp[num]; + + el->el_line.lastchar -= num; + } +} + + +/* c_delafter1(): + * Delete the character after the cursor, do not yank + */ +protected void +c_delafter1(EditLine *el) +{ + Char *cp; + + for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) + *cp = cp[1]; + + el->el_line.lastchar--; +} + + +/* c_delbefore(): + * Delete num characters before the cursor + */ +protected void +c_delbefore(EditLine *el, int num) +{ + + if (el->el_line.cursor - num < el->el_line.buffer) + num = (int)(el->el_line.cursor - el->el_line.buffer); + + if (el->el_map.current != el->el_map.emacs) { + cv_undo(el); + cv_yank(el, el->el_line.cursor - num, num); + } + + if (num > 0) { + Char *cp; + + for (cp = el->el_line.cursor - num; + cp <= el->el_line.lastchar; + cp++) + *cp = cp[num]; + + el->el_line.lastchar -= num; + } +} + + +/* c_delbefore1(): + * Delete the character before the cursor, do not yank + */ +protected void +c_delbefore1(EditLine *el) +{ + Char *cp; + + for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++) + *cp = cp[1]; + + el->el_line.lastchar--; +} + + +/* ce__isword(): + * Return if p is part of a word according to emacs + */ +protected int +ce__isword(Int p) +{ + return (Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL); +} + + +/* cv__isword(): + * Return if p is part of a word according to vi + */ +protected int +cv__isword(Int p) +{ + if (Isalnum(p) || p == '_') + return 1; + if (Isgraph(p)) + return 2; + return 0; +} + + +/* cv__isWord(): + * Return if p is part of a big word according to vi + */ +protected int +cv__isWord(Int p) +{ + return (!Isspace(p)); +} + + +/* c__prev_word(): + * Find the previous word + */ +protected Char * +c__prev_word(Char *p, Char *low, int n, int (*wtest)(Int)) +{ + p--; + + while (n--) { + while ((p >= low) && !(*wtest)(*p)) + p--; + while ((p >= low) && (*wtest)(*p)) + p--; + } + + /* cp now points to one character before the word */ + p++; + if (p < low) + p = low; + /* cp now points where we want it */ + return (p); +} + + +/* c__next_word(): + * Find the next word + */ +protected Char * +c__next_word(Char *p, Char *high, int n, int (*wtest)(Int)) +{ + while (n--) { + while ((p < high) && !(*wtest)(*p)) + p++; + while ((p < high) && (*wtest)(*p)) + p++; + } + if (p > high) + p = high; + /* p now points where we want it */ + return (p); +} + +/* cv_next_word(): + * Find the next word vi style + */ +protected Char * *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 19:22:11 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C8EC1106566C; Thu, 31 Mar 2011 19:22:11 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B59818FC15; Thu, 31 Mar 2011 19:22:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VJMBBd016500; Thu, 31 Mar 2011 19:22:11 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VJMBVM016495; Thu, 31 Mar 2011 19:22:11 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103311922.p2VJMBVM016495@svn.freebsd.org> From: Edward Tomasz Napierala Date: Thu, 31 Mar 2011 19:22:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220222 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 19:22:11 -0000 Author: trasz Date: Thu Mar 31 19:22:11 2011 New Revision: 220222 URL: http://svn.freebsd.org/changeset/base/220222 Log: Enable accounting for RACCT_NPROC and RACCT_NTHR. Sponsored by: The FreeBSD Foundation Reviewed by: kib (earlier version) Modified: head/sys/kern/init_main.c head/sys/kern/kern_exit.c head/sys/kern/kern_fork.c head/sys/kern/kern_thr.c Modified: head/sys/kern/init_main.c ============================================================================== --- head/sys/kern/init_main.c Thu Mar 31 18:35:44 2011 (r220221) +++ head/sys/kern/init_main.c Thu Mar 31 19:22:11 2011 (r220222) @@ -557,6 +557,9 @@ proc0_init(void *dummy __unused) * Charge root for one process. */ (void)chgproccnt(p->p_ucred->cr_ruidinfo, 1, 0); + PROC_LOCK(p); + racct_add_force(p, RACCT_NPROC, 1); + PROC_UNLOCK(p); } SYSINIT(p0init, SI_SUB_INTRINSIC, SI_ORDER_FIRST, proc0_init, NULL); Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Thu Mar 31 18:35:44 2011 (r220221) +++ head/sys/kern/kern_exit.c Thu Mar 31 19:22:11 2011 (r220222) @@ -177,6 +177,7 @@ exit1(struct thread *td, int rv) } KASSERT(p->p_numthreads == 1, ("exit1: proc %p exiting with %d threads", p, p->p_numthreads)); + racct_sub(p, RACCT_NTHR, 1); /* * Wakeup anyone in procfs' PIOCWAIT. They should have a hold * on our vmspace, so we should block below until they have @@ -745,6 +746,9 @@ proc_reap(struct thread *td, struct proc * Destroy resource accounting information associated with the process. */ racct_proc_exit(p); + PROC_LOCK(p->p_pptr); + racct_sub(p->p_pptr, RACCT_NPROC, 1); + PROC_UNLOCK(p->p_pptr); /* * Free credentials, arguments, and sigacts. @@ -905,7 +909,11 @@ proc_reparent(struct proc *child, struct if (child->p_pptr == parent) return; + PROC_LOCK(parent); + racct_add_force(parent, RACCT_NPROC, 1); + PROC_UNLOCK(parent); PROC_LOCK(child->p_pptr); + racct_sub(child->p_pptr, RACCT_NPROC, 1); sigqueue_take(child->p_ksi); PROC_UNLOCK(child->p_pptr); LIST_REMOVE(child, p_sibling); Modified: head/sys/kern/kern_fork.c ============================================================================== --- head/sys/kern/kern_fork.c Thu Mar 31 18:35:44 2011 (r220221) +++ head/sys/kern/kern_fork.c Thu Mar 31 19:22:11 2011 (r220222) @@ -734,6 +734,12 @@ fork1(struct thread *td, int flags, int return (fork_norfproc(td, flags)); } + PROC_LOCK(p1); + error = racct_add(p1, RACCT_NPROC, 1); + PROC_UNLOCK(p1); + if (error != 0) + return (EAGAIN); + mem_charged = 0; vm2 = NULL; if (pages == 0) @@ -817,6 +823,17 @@ fork1(struct thread *td, int flags, int } /* + * After fork, there is exactly one thread running. + */ + PROC_LOCK(newproc); + error = racct_set(newproc, RACCT_NTHR, 1); + PROC_UNLOCK(newproc); + if (error != 0) { + error = EAGAIN; + goto fail; + } + + /* * Increment the count of procs running with this uid. Don't allow * a nonprivileged user to exceed their current limit. * @@ -857,6 +874,9 @@ fail1: vmspace_free(vm2); uma_zfree(proc_zone, newproc); pause("fork", hz / 2); + PROC_LOCK(p1); + racct_sub(p1, RACCT_NPROC, 1); + PROC_UNLOCK(p1); return (error); } Modified: head/sys/kern/kern_thr.c ============================================================================== --- head/sys/kern/kern_thr.c Thu Mar 31 18:35:44 2011 (r220221) +++ head/sys/kern/kern_thr.c Thu Mar 31 19:22:11 2011 (r220222) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -184,10 +185,18 @@ create_thread(struct thread *td, mcontex } } + PROC_LOCK(td->td_proc); + error = racct_add(p, RACCT_NTHR, 1); + PROC_UNLOCK(td->td_proc); + if (error != 0) + return (EPROCLIM); + /* Initialize our td */ newtd = thread_alloc(0); - if (newtd == NULL) - return (ENOMEM); + if (newtd == NULL) { + error = ENOMEM; + goto fail; + } /* * Try the copyout as soon as we allocate the td so we don't @@ -203,7 +212,8 @@ create_thread(struct thread *td, mcontex (parent_tid != NULL && suword_lwpid(parent_tid, newtd->td_tid))) { thread_free(newtd); - return (EFAULT); + error = EFAULT; + goto fail; } bzero(&newtd->td_startzero, @@ -220,7 +230,7 @@ create_thread(struct thread *td, mcontex if (error != 0) { thread_free(newtd); crfree(td->td_ucred); - return (error); + goto fail; } } else { /* Set up our machine context. */ @@ -233,7 +243,7 @@ create_thread(struct thread *td, mcontex if (error != 0) { thread_free(newtd); crfree(td->td_ucred); - return (error); + goto fail; } } @@ -265,6 +275,12 @@ create_thread(struct thread *td, mcontex thread_unlock(newtd); return (0); + +fail: + PROC_LOCK(p); + racct_sub(p, RACCT_NTHR, 1); + PROC_UNLOCK(p); + return (error); } int @@ -294,7 +310,10 @@ thr_exit(struct thread *td, struct thr_e } rw_wlock(&tidhash_lock); + PROC_LOCK(p); + racct_sub(p, RACCT_NTHR, 1); + /* * Shutting down last thread in the proc. This will actually * call exit() in the trampoline when it returns. From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 19:34:38 2011 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 02BA11065670; Thu, 31 Mar 2011 19:34:38 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id AD2B18FC18; Thu, 31 Mar 2011 19:34:37 +0000 (UTC) Received: from [10.30.101.54] ([209.117.142.2]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id p2VJTHQp010763 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Thu, 31 Mar 2011 13:29:19 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <201103310740.20265.jhb@freebsd.org> Date: Thu, 31 Mar 2011 13:29:11 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <73CB36BD-1C9E-4992-A3C7-B540ABB7F11E@bsdimp.com> References: <201103310807.p2V87DHV096049@svn.freebsd.org> <201103310740.20265.jhb@freebsd.org> To: John Baldwin X-Mailer: Apple Mail (2.1082) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Thu, 31 Mar 2011 13:29:19 -0600 (MDT) Cc: svn-src-head@FreeBSD.org, Adrian Chadd , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org Subject: Re: svn commit: r220185 - in head/sys: amd64/conf arm/conf conf dev/ath i386/conf mips/conf modules modules/ath modules/ath_ahb modules/ath_pci pc98/conf sparc64/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 19:34:38 -0000 On Mar 31, 2011, at 5:40 AM, John Baldwin wrote: > On Thursday, March 31, 2011 4:07:13 am Adrian Chadd wrote: >> Author: adrian >> Date: Thu Mar 31 08:07:13 2011 >> New Revision: 220185 >> URL: http://svn.freebsd.org/changeset/base/220185 >>=20 >> Log: >> Break out the ath PCI logic into a separate device/module. >>=20 >> Introduce the AHB glue for Atheros embedded systems. Right now it's >> hard-coded for the AR9130 chip whose support isn't yet in this HAL; >> it'll be added in a subsequent commit. >>=20 >> Kernel configuration files now need both 'ath' and 'ath_pci' = devices; both >> modules need to be loaded for the ath device to work. >=20 > Err, there's no need to break the kernel config. Just have the kernel = DTRT if=20 > both ath and pci are enabled using something like: >=20 > sys/dev/ath/if_ath_pci.c ath pci >=20 > in sys/conf/files. >=20 > You can still have an if_ath_pci.ko module with this arrangement. = This is=20 > what almost all other drivers due that have multiple bus backends. Well, most drivers with multiple back ends compile all the relevant ones = for the platform in. There's very few that call out individual ones = (ata and its kin being the big exception). Personally, I'd not bother having a if_ath_pci.ko, and instead bundle it = in with if_ath.ko and omitting if_ath_ahb.c from the x86 builds, but I = understand why this might be important in the embedded builds. Warner= From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 19:58:52 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B87F1065674; Thu, 31 Mar 2011 19:58:52 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 1BA148FC1D; Thu, 31 Mar 2011 19:58:52 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id AFE3346B09; Thu, 31 Mar 2011 15:58:51 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 3F6928A01B; Thu, 31 Mar 2011 15:58:51 -0400 (EDT) From: John Baldwin To: Warner Losh Date: Thu, 31 Mar 2011 15:58:50 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201103310807.p2V87DHV096049@svn.freebsd.org> <201103310740.20265.jhb@freebsd.org> <73CB36BD-1C9E-4992-A3C7-B540ABB7F11E@bsdimp.com> In-Reply-To: <73CB36BD-1C9E-4992-A3C7-B540ABB7F11E@bsdimp.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103311558.50709.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Thu, 31 Mar 2011 15:58:51 -0400 (EDT) Cc: svn-src-head@freebsd.org, Adrian Chadd , src-committers@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r220185 - in head/sys: amd64/conf arm/conf conf dev/ath i386/conf mips/conf modules modules/ath modules/ath_ahb modules/ath_pci pc98/conf sparc64/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 19:58:52 -0000 On Thursday, March 31, 2011 3:29:11 pm Warner Losh wrote: > > On Mar 31, 2011, at 5:40 AM, John Baldwin wrote: > > > On Thursday, March 31, 2011 4:07:13 am Adrian Chadd wrote: > >> Author: adrian > >> Date: Thu Mar 31 08:07:13 2011 > >> New Revision: 220185 > >> URL: http://svn.freebsd.org/changeset/base/220185 > >> > >> Log: > >> Break out the ath PCI logic into a separate device/module. > >> > >> Introduce the AHB glue for Atheros embedded systems. Right now it's > >> hard-coded for the AR9130 chip whose support isn't yet in this HAL; > >> it'll be added in a subsequent commit. > >> > >> Kernel configuration files now need both 'ath' and 'ath_pci' devices; both > >> modules need to be loaded for the ath device to work. > > > > Err, there's no need to break the kernel config. Just have the kernel DTRT if > > both ath and pci are enabled using something like: > > > > sys/dev/ath/if_ath_pci.c ath pci > > > > in sys/conf/files. > > > > You can still have an if_ath_pci.ko module with this arrangement. This is > > what almost all other drivers due that have multiple bus backends. > > Well, most drivers with multiple back ends compile all the relevant ones for the platform in. There's very few that call out individual ones (ata and its kin being the big exception). Yes, that is true for modules, and I agree that the module build for if_ath.ko should just include all the relevant bus attachments for each platform. There's certainly no reason to not use the method above for sys/conf/files and remove 'device ath_pci', etc. -- John Baldwin From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 20:16:12 2011 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 93F3B106564A; Thu, 31 Mar 2011 20:16:12 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 2CC3C8FC13; Thu, 31 Mar 2011 20:16:12 +0000 (UTC) Received: from [10.30.101.54] ([209.117.142.2]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id p2VKCxMe011231 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Thu, 31 Mar 2011 14:13:01 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <201103311558.50709.jhb@freebsd.org> Date: Thu, 31 Mar 2011 14:12:54 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <4DEF8A5E-6ADE-4B27-8E1C-82188DB1244D@bsdimp.com> References: <201103310807.p2V87DHV096049@svn.freebsd.org> <201103310740.20265.jhb@freebsd.org> <73CB36BD-1C9E-4992-A3C7-B540ABB7F11E@bsdimp.com> <201103311558.50709.jhb@freebsd.org> To: John Baldwin X-Mailer: Apple Mail (2.1082) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Thu, 31 Mar 2011 14:13:02 -0600 (MDT) Cc: svn-src-head@FreeBSD.org, Adrian Chadd , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org Subject: Re: svn commit: r220185 - in head/sys: amd64/conf arm/conf conf dev/ath i386/conf mips/conf modules modules/ath modules/ath_ahb modules/ath_pci pc98/conf sparc64/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 20:16:12 -0000 On Mar 31, 2011, at 1:58 PM, John Baldwin wrote: > On Thursday, March 31, 2011 3:29:11 pm Warner Losh wrote: >>=20 >> On Mar 31, 2011, at 5:40 AM, John Baldwin wrote: >>=20 >>> On Thursday, March 31, 2011 4:07:13 am Adrian Chadd wrote: >>>> Author: adrian >>>> Date: Thu Mar 31 08:07:13 2011 >>>> New Revision: 220185 >>>> URL: http://svn.freebsd.org/changeset/base/220185 >>>>=20 >>>> Log: >>>> Break out the ath PCI logic into a separate device/module. >>>>=20 >>>> Introduce the AHB glue for Atheros embedded systems. Right now it's >>>> hard-coded for the AR9130 chip whose support isn't yet in this HAL; >>>> it'll be added in a subsequent commit. >>>>=20 >>>> Kernel configuration files now need both 'ath' and 'ath_pci' = devices; both >>>> modules need to be loaded for the ath device to work. >>>=20 >>> Err, there's no need to break the kernel config. Just have the = kernel DTRT if=20 >>> both ath and pci are enabled using something like: >>>=20 >>> sys/dev/ath/if_ath_pci.c ath pci >>>=20 >>> in sys/conf/files. >>>=20 >>> You can still have an if_ath_pci.ko module with this arrangement. = This is=20 >>> what almost all other drivers due that have multiple bus backends. >>=20 >> Well, most drivers with multiple back ends compile all the relevant = ones for the platform in. There's very few that call out individual = ones (ata=20 > and its kin being the big exception). >=20 > Yes, that is true for modules, and I agree that the module build for = if_ath.ko > should just include all the relevant bus attachments for each = platform. >=20 > There's certainly no reason to not use the method above for = sys/conf/files > and remove 'device ath_pci', etc. Agreed. Wasn't trying to disagree with you there. Warner= From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 20:46:51 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 310E81065674; Thu, 31 Mar 2011 20:46:51 +0000 (UTC) (envelope-from davidch@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1C6AA8FC15; Thu, 31 Mar 2011 20:46:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VKkpOU022043; Thu, 31 Mar 2011 20:46:51 GMT (envelope-from davidch@svn.freebsd.org) Received: (from davidch@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VKkoMJ022040; Thu, 31 Mar 2011 20:46:50 GMT (envelope-from davidch@svn.freebsd.org) Message-Id: <201103312046.p2VKkoMJ022040@svn.freebsd.org> From: David Christensen Date: Thu, 31 Mar 2011 20:46:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220223 - head/sys/dev/bxe X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 20:46:51 -0000 Author: davidch Date: Thu Mar 31 20:46:50 2011 New Revision: 220223 URL: http://svn.freebsd.org/changeset/base/220223 Log: - Fixed a problem where the stack passed a TSO frame larger than the 64K size allowed by the DMA descriptor for TSO frames. MFC after: One week Modified: head/sys/dev/bxe/if_bxe.c head/sys/dev/bxe/if_bxe.h Modified: head/sys/dev/bxe/if_bxe.c ============================================================================== --- head/sys/dev/bxe/if_bxe.c Thu Mar 31 19:22:11 2011 (r220222) +++ head/sys/dev/bxe/if_bxe.c Thu Mar 31 20:46:50 2011 (r220223) @@ -68,7 +68,7 @@ __FBSDID("$FreeBSD$"); /* BXE Debug Options */ #ifdef BXE_DEBUG - uint32_t bxe_debug = BXE_WARN; + uint32_t bxe_debug = BXE_INFO; /* 0 = Never */ /* 1 = 1 in 2,147,483,648 */ @@ -382,7 +382,7 @@ static void bxe_breakpoint(struct bxe_so #endif -#define BXE_DRIVER_VERSION "1.5.52_preliminary" +#define BXE_DRIVER_VERSION "1.5.52" static void bxe_init_e1_firmware(struct bxe_softc *sc); static void bxe_init_e1h_firmware(struct bxe_softc *sc); @@ -13042,10 +13042,20 @@ bxe_dma_alloc(device_t dev) * address of the block. */ - if (bus_dma_tag_create(sc->parent_tag, BCM_PAGE_SIZE, - BXE_DMA_BOUNDARY, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, - NULL, NULL, BXE_STATUS_BLK_SZ, 1, BXE_STATUS_BLK_SZ, - 0, NULL, NULL, &fp->status_block_tag)) { + if (bus_dma_tag_create(sc->parent_tag, + BCM_PAGE_SIZE, /* alignment for segs */ + BXE_DMA_BOUNDARY, /* cannot cross */ + BUS_SPACE_MAXADDR, /* restricted low */ + BUS_SPACE_MAXADDR, /* restricted hi */ + NULL, /* filter f() */ + NULL, /* filter f() arg */ + BXE_STATUS_BLK_SZ, /* max map for this tag */ + 1, /* # of discontinuities */ + BXE_STATUS_BLK_SZ, /* max seg size */ + 0, /* flags */ + NULL, /* lock f() */ + NULL, /* lock f() arg */ + &fp->status_block_tag)) { BXE_PRINTF("%s(%d): Could not allocate fp[%d] " "status block DMA tag!\n", __FILE__, __LINE__, i); rc = ENOMEM; @@ -13086,10 +13096,20 @@ bxe_dma_alloc(device_t dev) * allocate and clear the memory, and fetch the * physical address of the block. */ - if (bus_dma_tag_create(sc->parent_tag, BCM_PAGE_SIZE, - BXE_DMA_BOUNDARY, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, - NULL, NULL, BXE_TX_CHAIN_PAGE_SZ, 1, BXE_TX_CHAIN_PAGE_SZ, - 0, NULL, NULL, &fp->tx_bd_chain_tag)) { + if (bus_dma_tag_create(sc->parent_tag, + BCM_PAGE_SIZE, /* alignment for segs */ + BXE_DMA_BOUNDARY, /* cannot cross */ + BUS_SPACE_MAXADDR, /* restricted low */ + BUS_SPACE_MAXADDR, /* restricted hi */ + NULL, /* filter f() */ + NULL, /* filter f() arg */ + BXE_TX_CHAIN_PAGE_SZ,/* max map for this tag */ + 1, /* # of discontinuities */ + BXE_TX_CHAIN_PAGE_SZ,/* max seg size */ + 0, /* flags */ + NULL, /* lock f() */ + NULL, /* lock f() arg */ + &fp->tx_bd_chain_tag)) { BXE_PRINTF( "%s(%d): Could not allocate fp[%d] TX descriptor " "chain DMA tag!\n", __FILE__, __LINE__, i); @@ -13132,23 +13152,33 @@ bxe_dma_alloc(device_t dev) } /* - * Check the required size before mapping to conserve resources. + * Check required size before mapping to conserve resources. */ if (bxe_tso_enable) { - max_size = BXE_TSO_MAX_SIZE; - max_segments = 32; /* BXE_MAX_SEGMENTS; */ + max_size = BXE_TSO_MAX_SIZE; + max_segments = BXE_TSO_MAX_SEGMENTS; max_seg_size = BXE_TSO_MAX_SEG_SIZE; } else { - max_size = MCLBYTES * BXE_MAX_SEGMENTS; + max_size = MCLBYTES * BXE_MAX_SEGMENTS; max_segments = BXE_MAX_SEGMENTS; max_seg_size = MCLBYTES; } /* Create a DMA tag for TX mbufs. */ - if (bus_dma_tag_create(sc->parent_tag, 1, BXE_DMA_BOUNDARY, - BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, - max_size, max_segments, max_seg_size, - 0, NULL, NULL, &fp->tx_mbuf_tag)) { + if (bus_dma_tag_create(sc->parent_tag, + 1, /* alignment for segs */ + BXE_DMA_BOUNDARY, /* cannot cross */ + BUS_SPACE_MAXADDR, /* restricted low */ + BUS_SPACE_MAXADDR, /* restricted hi */ + NULL, /* filter f() */ + NULL, /* filter f() arg */ + max_size, /* max map for this tag */ + max_segments, /* # of discontinuities */ + max_seg_size, /* max seg size */ + 0, /* flags */ + NULL, /* lock f() */ + NULL, /* lock f() arg */ + &fp->tx_mbuf_tag)) { BXE_PRINTF( "%s(%d): Could not allocate fp[%d] TX mbuf DMA tag!\n", __FILE__, __LINE__, i); @@ -13174,12 +13204,22 @@ bxe_dma_alloc(device_t dev) * the memory, and fetch the physical * address of the blocks. */ - if (bus_dma_tag_create(sc->parent_tag, BCM_PAGE_SIZE, - BXE_DMA_BOUNDARY, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, - NULL, NULL, BXE_RX_CHAIN_PAGE_SZ, 1, BXE_RX_CHAIN_PAGE_SZ, - 0, NULL, NULL, &fp->rx_bd_chain_tag)) { - BXE_PRINTF( - "%s(%d): Could not allocate fp[%d] RX BD chain DMA tag!\n", + if (bus_dma_tag_create(sc->parent_tag, + BCM_PAGE_SIZE, /* alignment for segs */ + BXE_DMA_BOUNDARY, /* cannot cross */ + BUS_SPACE_MAXADDR, /* restricted low */ + BUS_SPACE_MAXADDR, /* restricted hi */ + NULL, /* filter f() */ + NULL, /* filter f() arg */ + BXE_RX_CHAIN_PAGE_SZ,/* max map for this tag */ + 1, /* # of discontinuities */ + BXE_RX_CHAIN_PAGE_SZ,/* max seg size */ + 0, /* flags */ + NULL, /* lock f() */ + NULL, /* lock f() arg */ + &fp->rx_bd_chain_tag)) { + BXE_PRINTF("%s(%d): Could not allocate fp[%d] " + "RX BD chain DMA tag!\n", __FILE__, __LINE__, i); rc = ENOMEM; goto bxe_dma_alloc_exit; @@ -13222,9 +13262,19 @@ bxe_dma_alloc(device_t dev) /* * Create a DMA tag for RX mbufs. */ - if (bus_dma_tag_create(sc->parent_tag, 1, BXE_DMA_BOUNDARY, - BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, - MJUM9BYTES, 1, MJUM9BYTES, 0, NULL, NULL, + if (bus_dma_tag_create(sc->parent_tag, + 1, /* alignment for segs */ + BXE_DMA_BOUNDARY, /* cannot cross */ + BUS_SPACE_MAXADDR, /* restricted low */ + BUS_SPACE_MAXADDR, /* restricted hi */ + NULL, /* filter f() */ + NULL, /* filter f() arg */ + MJUM9BYTES, /* max map for this tag */ + 1, /* # of discontinuities */ + MJUM9BYTES, /* max seg size */ + 0, /* flags */ + NULL, /* lock f() */ + NULL, /* lock f() arg */ &fp->rx_mbuf_tag)) { BXE_PRINTF( "%s(%d): Could not allocate fp[%d] RX mbuf DMA tag!\n", @@ -13251,10 +13301,20 @@ bxe_dma_alloc(device_t dev) * map the memory into DMA space, and fetch * the physical address of the block. */ - if (bus_dma_tag_create(sc->parent_tag, BCM_PAGE_SIZE, - BXE_DMA_BOUNDARY, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, - NULL, NULL, BXE_RX_CHAIN_PAGE_SZ, 1, BXE_RX_CHAIN_PAGE_SZ, - 0, NULL, NULL, &fp->rx_comp_chain_tag)) { + if (bus_dma_tag_create(sc->parent_tag, + BCM_PAGE_SIZE, /* alignment for segs */ + BXE_DMA_BOUNDARY, /* cannot cross */ + BUS_SPACE_MAXADDR, /* restricted low */ + BUS_SPACE_MAXADDR, /* restricted hi */ + NULL, /* filter f() */ + NULL, /* filter f() arg */ + BXE_RX_CHAIN_PAGE_SZ,/* max map for this tag */ + 1, /* # of discontinuities */ + BXE_RX_CHAIN_PAGE_SZ,/* max seg size */ + 0, /* flags */ + NULL, /* lock f() */ + NULL, /* lock f() arg */ + &fp->rx_comp_chain_tag)) { BXE_PRINTF( "%s(%d): Could not allocate fp[%d] RX Completion Queue DMA tag!\n", __FILE__, __LINE__, i); @@ -13311,10 +13371,19 @@ bxe_dma_alloc(device_t dev) * memory into DMA space, and fetch the * physical address of the block. */ - if (bus_dma_tag_create(sc->parent_tag, BCM_PAGE_SIZE, - BXE_DMA_BOUNDARY, BUS_SPACE_MAXADDR, - BUS_SPACE_MAXADDR, NULL, NULL, BXE_RX_CHAIN_PAGE_SZ, - 1, BXE_RX_CHAIN_PAGE_SZ, 0, NULL, NULL, + if (bus_dma_tag_create(sc->parent_tag, + BCM_PAGE_SIZE, /* alignment for segs */ + BXE_DMA_BOUNDARY, /* cannot cross */ + BUS_SPACE_MAXADDR, /* restricted low */ + BUS_SPACE_MAXADDR, /* restricted hi */ + NULL, /* filter f() */ + NULL, /* filter f() arg */ + BXE_RX_CHAIN_PAGE_SZ,/* max map for this tag */ + 1, /* # of discontinuities */ + BXE_RX_CHAIN_PAGE_SZ,/* max seg size */ + 0, /* flags */ + NULL, /* lock f() */ + NULL, /* lock f() arg */ &fp->rx_sge_chain_tag)) { BXE_PRINTF( "%s(%d): Could not allocate fp[%d] RX SGE descriptor chain DMA tag!\n", Modified: head/sys/dev/bxe/if_bxe.h ============================================================================== --- head/sys/dev/bxe/if_bxe.h Thu Mar 31 19:22:11 2011 (r220222) +++ head/sys/dev/bxe/if_bxe.h Thu Mar 31 20:46:50 2011 (r220223) @@ -388,8 +388,9 @@ struct bxe_type { /* Reduce from 13 to leave room for the parsing buffer. */ #define BXE_MAX_SEGMENTS 12 -#define BXE_TSO_MAX_SIZE 65536 -#define BXE_TSO_MAX_SEG_SIZE 4096 +#define BXE_TSO_MAX_SEGMENTS 32 +#define BXE_TSO_MAX_SIZE (65535 + sizeof(struct ether_vlan_header)) +#define BXE_TSO_MAX_SEG_SIZE 4096 /* * Hardware Support For IP and TCP checksum. From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 21:01:10 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A6B1E10656DA; Thu, 31 Mar 2011 21:01:10 +0000 (UTC) (envelope-from davidch@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 92CC08FC2A; Thu, 31 Mar 2011 21:01:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VL1ADI022619; Thu, 31 Mar 2011 21:01:10 GMT (envelope-from davidch@svn.freebsd.org) Received: (from davidch@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VL1AJN022616; Thu, 31 Mar 2011 21:01:10 GMT (envelope-from davidch@svn.freebsd.org) Message-Id: <201103312101.p2VL1AJN022616@svn.freebsd.org> From: David Christensen Date: Thu, 31 Mar 2011 21:01:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220224 - head/sys/dev/bxe X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 21:01:10 -0000 Author: davidch Date: Thu Mar 31 21:01:10 2011 New Revision: 220224 URL: http://svn.freebsd.org/changeset/base/220224 Log: - Print number of queues when RSS is enabled. - Improve reporting of media type (not always 10GBase-CX4). MFC after: One week Modified: head/sys/dev/bxe/if_bxe.c head/sys/dev/bxe/if_bxe.h Modified: head/sys/dev/bxe/if_bxe.c ============================================================================== --- head/sys/dev/bxe/if_bxe.c Thu Mar 31 20:46:50 2011 (r220223) +++ head/sys/dev/bxe/if_bxe.c Thu Mar 31 21:01:10 2011 (r220224) @@ -1036,7 +1036,7 @@ bxe_print_adapter_info(struct bxe_softc printf("None"); break; case ETH_RSS_MODE_REGULAR: - printf("RSS"); + printf("RSS:%d", sc->num_queues); break; default: printf("Unknown"); @@ -1717,14 +1717,6 @@ bxe_attach(device_t dev) /* Prepare the tick routine. */ callout_init(&sc->bxe_tick_callout, CALLOUT_MPSAFE); - ifmedia_init(&sc->bxe_ifmedia, IFM_IMASK, bxe_ifmedia_upd, - bxe_ifmedia_status); - ifmedia_add(&sc->bxe_ifmedia, IFM_ETHER | IFM_10G_CX4, 0, NULL); - ifmedia_add(&sc->bxe_ifmedia, IFM_ETHER | IFM_10G_CX4 | IFM_FDX, 0, - NULL); - ifmedia_add(&sc->bxe_ifmedia, IFM_ETHER | IFM_AUTO, 0, NULL); - ifmedia_set(&sc->bxe_ifmedia, IFM_ETHER | IFM_AUTO); - sc->bxe_ifmedia.ifm_media = sc->bxe_ifmedia.ifm_cur->ifm_media; /* Enable bus master capability */ pci_enable_busmaster(dev); @@ -1778,12 +1770,62 @@ bxe_attach(device_t dev) /* Get hardware info from shared memory and validate data. */ if (bxe_get_function_hwinfo(sc)) { - DBPRINT(sc, BXE_WARN, "%s(): Failed to get hardware info!\n", - __FUNCTION__); + DBPRINT(sc, BXE_WARN, + "%s(): Failed to get hardware info!\n", __FUNCTION__); rc = ENODEV; goto bxe_attach_fail; } + /* Identify supported media based on the PHY type. */ + switch (XGXS_EXT_PHY_TYPE(sc->link_params.ext_phy_config)) { + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: + DBPRINT(sc, BXE_INFO_LOAD, + "%s(): Found 10GBase-CX4 media.\n", __FUNCTION__); + sc->media = IFM_10G_CX4; + break; +#if 0 + /* ToDo: Configure correct media types for these PHYs. */ + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8071 + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072 + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073 + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705 + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706 + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726 +#endif + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: + DBPRINT(sc, BXE_INFO_LOAD, + "%s(): Found 10GBase-SR media.\n", __FUNCTION__); + sc->media = IFM_10G_SR; + break; + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481: + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101: + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823: + DBPRINT(sc, BXE_INFO_LOAD, + "%s(): Found 10GBase-T media.\n", __FUNCTION__); + sc->media = IFM_10G_T; + break; + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN: + default: + BXE_PRINTF("%s(%d): PHY not supported by driver!\n", + __FILE__, __LINE__); + sc->media = 0; + rc = ENODEV; + goto bxe_attach_fail; + } + + /* Setup supported media options. */ + ifmedia_init(&sc->bxe_ifmedia, + IFM_IMASK, bxe_ifmedia_upd, bxe_ifmedia_status); + ifmedia_add(&sc->bxe_ifmedia, + IFM_ETHER | sc->media | IFM_FDX, 0, NULL); + ifmedia_add(&sc->bxe_ifmedia, + IFM_ETHER | IFM_AUTO, 0, NULL); + ifmedia_set(&sc->bxe_ifmedia, + IFM_ETHER | IFM_AUTO); + sc->bxe_ifmedia.ifm_media = sc->bxe_ifmedia.ifm_cur->ifm_media; + /* Set init arrays */ rc = bxe_init_firmware(sc); if (rc) { @@ -14153,6 +14195,18 @@ bxe_ifmedia_upd(struct ifnet *ifp) DBPRINT(sc, BXE_VERBOSE_PHY, "%s(): Media set to IFM_10G_CX4, forced mode.\n", __FUNCTION__); break; + case IFM_10G_SR: + DBPRINT(sc, BXE_VERBOSE_PHY, + "%s(): Media set to IFM_10G_SR, forced mode.\n", __FUNCTION__); + break; + case IFM_10G_T: + DBPRINT(sc, BXE_VERBOSE_PHY, + "%s(): Media set to IFM_10G_T, forced mode.\n", __FUNCTION__); + break; + case IFM_10G_TWINAX: + DBPRINT(sc, BXE_VERBOSE_PHY, + "%s(): Media set to IFM_10G_TWINAX, forced mode.\n", __FUNCTION__); + break; default: DBPRINT(sc, BXE_WARN, "%s(): Invalid media type!\n", __FUNCTION__); @@ -14198,7 +14252,7 @@ bxe_ifmedia_status(struct ifnet *ifp, st goto bxe_ifmedia_status_exit; } - ifmr->ifm_active |= IFM_10G_CX4; + ifmr->ifm_active |= sc->media; if (sc->link_vars.duplex == MEDIUM_FULL_DUPLEX) ifmr->ifm_active |= IFM_FDX; Modified: head/sys/dev/bxe/if_bxe.h ============================================================================== --- head/sys/dev/bxe/if_bxe.h Thu Mar 31 20:46:50 2011 (r220223) +++ head/sys/dev/bxe/if_bxe.h Thu Mar 31 21:01:10 2011 (r220224) @@ -1119,6 +1119,7 @@ struct bxe_softc { * MUST start with ifnet pointer (see definition of miibus_statchg()). */ struct ifnet *bxe_ifp; + int media; /* Parent device handle. */ device_t bxe_dev; From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 21:30:00 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8A06B1065670; Thu, 31 Mar 2011 21:30:00 +0000 (UTC) (envelope-from davidch@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7237B8FC12; Thu, 31 Mar 2011 21:30:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VLU0ii023274; Thu, 31 Mar 2011 21:30:00 GMT (envelope-from davidch@svn.freebsd.org) Received: (from davidch@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VLU0fG023271; Thu, 31 Mar 2011 21:30:00 GMT (envelope-from davidch@svn.freebsd.org) Message-Id: <201103312130.p2VLU0fG023271@svn.freebsd.org> From: David Christensen Date: Thu, 31 Mar 2011 21:30:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220226 - head/sys/dev/bxe X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 21:30:00 -0000 Author: davidch Date: Thu Mar 31 21:30:00 2011 New Revision: 220226 URL: http://svn.freebsd.org/changeset/base/220226 Log: - Added debug support to monitor mbuf defrag attempts/failures. MFC after: One week. Modified: head/sys/dev/bxe/if_bxe.c head/sys/dev/bxe/if_bxe.h Modified: head/sys/dev/bxe/if_bxe.c ============================================================================== --- head/sys/dev/bxe/if_bxe.c Thu Mar 31 21:21:07 2011 (r220225) +++ head/sys/dev/bxe/if_bxe.c Thu Mar 31 21:30:00 2011 (r220226) @@ -352,7 +352,7 @@ static int bxe_sysctl_reg_read(SYSCTL_HA static int bxe_sysctl_breakpoint(SYSCTL_HANDLER_ARGS); static void bxe_validate_rx_packet(struct bxe_fastpath *, uint16_t, union eth_rx_cqe *, struct mbuf *); -static void bxe_dump_grc(struct bxe_softc *, int); +static void bxe_grcdump(struct bxe_softc *, int); static void bxe_dump_enet(struct bxe_softc *,struct mbuf *); static void bxe_dump_mbuf (struct bxe_softc *, struct mbuf *); static void bxe_dump_tx_mbuf_chain(struct bxe_softc *, int, int); @@ -8585,16 +8585,22 @@ bxe_tx_encap(struct bxe_fastpath *fp, st error = bus_dmamap_load_mbuf_sg(fp->tx_mbuf_tag, map, m0, segs, &nsegs, BUS_DMA_NOWAIT); do{ - /* Handle any mapping errors. */ + /* Handle any mapping errors. */ if(__predict_false(error)){ if (error == ENOMEM) { + /* Temporary OS resource issue. */ rc = ENOMEM; }else if (error == EFBIG) { + /* Possibly recoverable. */ + DBRUN(fp->mbuf_defrag_attempts++); m0 = m_defrag(*m_head, M_DONTWAIT); if (m0 == NULL) { + BXE_PRINTF("%s(%d): Can't defrag TX frame!\n", + __FILE__, __LINE__); rc = ENOBUFS; } else { /* Defrag was successful, try mapping again.*/ + DBRUN(fp->mbuf_defrag_successes++); *m_head = m0; error = bus_dmamap_load_mbuf_sg( @@ -8602,10 +8608,15 @@ bxe_tx_encap(struct bxe_fastpath *fp, st segs, &nsegs, BUS_DMA_NOWAIT); } }else { + /* Unrecoverable. */ + BXE_PRINTF("%s(%d): Unknown TX mapping error! " + "rc = %d.\n", __FILE__, __LINE__, error); + DBRUN(bxe_dump_mbuf(sc, m0)); rc = error; } break; } + /* * Now that we know how many buffer descriptors are required to * send the frame, check whether we have enough transmit BD's @@ -8615,29 +8626,39 @@ bxe_tx_encap(struct bxe_fastpath *fp, st if (__predict_false((nsegs + 2) > (USABLE_TX_BD - fp->used_tx_bd))) { bus_dmamap_unload(fp->tx_mbuf_tag, map); + BXE_PRINTF("%s(%d): Insufficient TX queue space!\n", + __FILE__, __LINE__); + /* DRC - Should we drop a frame with this error? */ rc = ENOBUFS; break; } + /* Now make sure it fits in the pkt window */ - if (nsegs > 12) { - /* The mbuf has more segments than the controller can handle. - * Try to defrag the mbuf if there are too many - * segments. If it can't be defragged then - * drop the frame, log an error, and exit. - * An alternative would be to use a bounce buffer. - */ + if (__predict_false(nsegs > 12)) { + /* The mbuf has more segments than the controller can + * handle. Try to defrag the mbuf if there are too many + * segments. If it can't be defragged then + * drop the frame, log an error, and exit. + * An alternative would be to use a bounce buffer. + */ if(m0->m_pkthdr.csum_flags & CSUM_TSO){ if (! bxe_chktso_window(sc,nsegs,segs,m0)) /* Send it */ break; } + /* Defrag for non tso and if tso needs it */ + DBRUN(fp->mbuf_defrag_attempts++); m0 = m_defrag(*m_head, M_DONTWAIT); if (m0 == NULL) { + BXE_PRINTF("%s(%d): Can't defrag TX frame!\n", + __FILE__, __LINE__); rc = ENOBUFS; break; } + /* Defrag was successful, try mapping again. */ + DBRUN(fp->mbuf_defrag_successes++); *m_head = m0; error = bus_dmamap_load_mbuf_sg( @@ -8654,6 +8675,8 @@ bxe_tx_encap(struct bxe_fastpath *fp, st /* The frame can't be defragged, * drop it. */ + BXE_PRINTF("%s(%d): Can't map TX frame!\n", + __FILE__, __LINE__); rc = error; } break; @@ -8663,6 +8686,8 @@ bxe_tx_encap(struct bxe_fastpath *fp, st if (bxe_chktso_window(sc,nsegs,segs,m0)) rc = ENOBUFS; } else if (nsegs > 12 ){ + BXE_PRINTF("%s(%d): Too many fragments for a TSO " + "frame!\n", __FILE__, __LINE__); rc = ENOBUFS; } } @@ -8672,15 +8697,13 @@ bxe_tx_encap(struct bxe_fastpath *fp, st if (rc){ if(rc == ENOMEM){ /* Recoverable try again later */ - BXE_PRINTF("%s(%d): Error mapping mbuf into TX chain" - "returning pkt to queue\n",__FILE__, __LINE__); + BXE_PRINTF("%s(%d): Error mapping mbuf into TX chain, " + "returning pkt to queue!\n",__FILE__, __LINE__); }else{ fp->soft_tx_errors++; DBRUN(fp->tx_mbuf_alloc--); m_freem(*m_head); *m_head = NULL; - BXE_PRINTF("%s(%d): Error mapping mbuf into TX chain" - "Frame dropped \n",__FILE__, __LINE__); } return (rc); } @@ -14838,7 +14861,7 @@ bxe_rxeof(struct bxe_fastpath *fp) /* * The high level logic used here is to - * immediatley replace each receive buffer + * immediatley replace each receive buffer * as it is used so that the receive chain * is full at all times. First we try to * allocate a new receive buffer, but if @@ -15497,7 +15520,7 @@ bxe_sysctl_reg_read(SYSCTL_HANDLER_ARGS) * 0 for success, positive value for failure. */ static int -bxe_sysctl_dump_grc(SYSCTL_HANDLER_ARGS) +bxe_sysctl_grcdump(SYSCTL_HANDLER_ARGS) { struct bxe_softc *sc; int error, result; @@ -15510,10 +15533,10 @@ bxe_sysctl_dump_grc(SYSCTL_HANDLER_ARGS) if (result == 1) { /* Generate a grcdump and log the contents.*/ - bxe_dump_grc(sc, 1); + bxe_grcdump(sc, 1); } else { /* Generate a grcdump and don't log the contents. */ - bxe_dump_grc(sc, 0); + bxe_grcdump(sc, 0); } return (error); @@ -15555,13 +15578,18 @@ bxe_sysctl_breakpoint(SYSCTL_HANDLER_ARG static void bxe_add_sysctls(struct bxe_softc *sc) { - struct sysctl_ctx_list *ctx; - struct sysctl_oid_list *children; - struct bxe_eth_stats *estats; + struct sysctl_ctx_list *ctx = + device_get_sysctl_ctx(sc->bxe_dev); + struct sysctl_oid_list *children = + SYSCTL_CHILDREN(device_get_sysctl_tree(sc->bxe_dev)); + struct bxe_eth_stats *estats = &sc->eth_stats; + + struct sysctl_oid *queue_node; + struct sysctl_oid_list *queue_list; + +#define QUEUE_NAME_LEN 32 + char namebuf[QUEUE_NAME_LEN]; - estats = &sc->eth_stats; - ctx = device_get_sysctl_ctx(sc->bxe_dev); - children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->bxe_dev)); SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "estats_total_bytes_received_hi", @@ -15676,36 +15704,60 @@ bxe_add_sysctls(struct bxe_softc *sc) CTLFLAG_RD, &sc->mbuf_alloc_failed, 0, "mbuf cluster allocation failures"); + for (int i = 0; i < sc->num_queues; i++) { + struct bxe_fastpath *fp = &sc->fp[i]; + snprintf(namebuf, QUEUE_NAME_LEN, "fp[%02d]", i); + + queue_node = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, + namebuf, CTLFLAG_RD, NULL, "Queue Name"); + queue_list = SYSCTL_CHILDREN(queue_node); + + SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, + "mbuf_alloc_failed", + CTLFLAG_RD, &fp->mbuf_alloc_failed, + "Mbuf allocation failures"); + + SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, + "mbuf_defrag_attempts", + CTLFLAG_RD, &fp->mbuf_defrag_attempts, + "Mbuf defrag attempts"); + + SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, + "mbuf_defrag_successes", + CTLFLAG_RD, &fp->mbuf_defrag_successes, + "Mbuf defrag successes"); + } + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "driver_state", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_driver_state, - "I", "Drive state information"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_driver_state, "I", "Drive state information"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "hw_state", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_hw_state, - "I", "Hardware state information"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_hw_state, "I", "Hardware state information"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dump_fw", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_dump_fw, - "I", "Dump MCP firmware"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_dump_fw, "I", "Dump MCP firmware"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dump_rx_chain", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_dump_rx_chain, - "I", "Dump rx_bd chain"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_dump_rx_chain, "I", "Dump rx_bd chain"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dump_cqe_chain", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_dump_cqe_chain, - "I", "Dump cqe chain"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_dump_cqe_chain, "I", "Dump cqe chain"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dump_tx_chain", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_dump_tx_chain, - "I", "Dump tx_bd chain"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_dump_tx_chain, "I", "Dump tx_bd chain"); /* * Generates a GRCdump (run sysctl dev.bxe.0.grcdump=0 - * before access buffer below). + * before accessing buffer below). */ SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "grcdump", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_dump_grc, + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_grcdump, "I", "Initiate a grcdump operation"); /* @@ -15713,16 +15765,17 @@ bxe_add_sysctls(struct bxe_softc *sc) * Use "sysctl -b dev.bxe.0.grcdump_buffer > buf.bin". */ SYSCTL_ADD_OPAQUE(ctx, children, OID_AUTO, "grcdump_buffer", - CTLFLAG_RD | CTLFLAG_SKIP, sc->grcdump_buffer, BXE_GRCDUMP_BUF_SIZE, - "IU", "Grcdump buffer"); + CTLFLAG_RD | CTLFLAG_SKIP, sc->grcdump_buffer, + BXE_GRCDUMP_BUF_SIZE, "IU", "Access grcdump buffer"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "breakpoint", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_breakpoint, - "I", "Driver breakpoint"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_breakpoint, "I", "Driver breakpoint"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "reg_read", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_reg_read, - "I", "Register read"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_reg_read, "I", "Register read"); + #endif /* BXE_DEBUG */ } @@ -15886,7 +15939,7 @@ bxe_dump_debug_reg_wread(struct bxe_soft * None. */ static void -bxe_dump_grc(struct bxe_softc *sc, int log) +bxe_grcdump(struct bxe_softc *sc, int log) { uint32_t *buf, i, index; Modified: head/sys/dev/bxe/if_bxe.h ============================================================================== --- head/sys/dev/bxe/if_bxe.h Thu Mar 31 21:21:07 2011 (r220225) +++ head/sys/dev/bxe/if_bxe.h Thu Mar 31 21:30:00 2011 (r220226) @@ -1084,6 +1084,8 @@ struct bxe_fastpath { /* Memory buffer allocation failure counter. */ unsigned long mbuf_alloc_failed; + unsigned long mbuf_defrag_attempts; + unsigned long mbuf_defrag_successes; /* Track the number of enqueued mbufs. */ int tx_mbuf_alloc; From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 21:33:33 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA4F4106566B; Thu, 31 Mar 2011 21:33:33 +0000 (UTC) (envelope-from rstone@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D758E8FC17; Thu, 31 Mar 2011 21:33:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VLXXv0023396; Thu, 31 Mar 2011 21:33:33 GMT (envelope-from rstone@svn.freebsd.org) Received: (from rstone@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VLXXLA023394; Thu, 31 Mar 2011 21:33:33 GMT (envelope-from rstone@svn.freebsd.org) Message-Id: <201103312133.p2VLXXLA023394@svn.freebsd.org> From: Ryan Stone Date: Thu, 31 Mar 2011 21:33:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220227 - head/sys/tools X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 21:33:34 -0000 Author: rstone Date: Thu Mar 31 21:33:33 2011 New Revision: 220227 URL: http://svn.freebsd.org/changeset/base/220227 Log: GNU awk does not output escaped newlines in multi-line printc statements. This leads to compile errors when trying to compile firmware(9) stubs created with gawk, as multiple #include statements end up on the same line. Replace the multi-line printc statement that outputs all of the #includes with one printc per #include. This allows modules compatible with firmware(9) to be cross-built from a Linux machine without requiring the one true awk to be installed. I've intentionally done the minimal set of changes necessary to make gawk produce valid (but not pretty) C code, to reduce the churn and keep fw_stubs.awk as readable as possible. Approved by: emaste (mentor) MFC after: 2 weeks Modified: head/sys/tools/fw_stub.awk Modified: head/sys/tools/fw_stub.awk ============================================================================== --- head/sys/tools/fw_stub.awk Thu Mar 31 21:30:00 2011 (r220226) +++ head/sys/tools/fw_stub.awk Thu Mar 31 21:33:33 2011 (r220227) @@ -124,14 +124,14 @@ gsub(/[-\.]/, "_", modname); printc("/*\ * Automatically generated by:\ * $FreeBSD$\ - */\ -#include \ -#include \ -#include \ -#include \ -#include \ -#include \ -#include \n"); + */"); +printc("#include "); +printc("#include "); +printc("#include "); +printc("#include "); +printc("#include "); +printc("#include "); +printc("#include \n"); if (opt_l) { printc("static long " opt_l "_license_ack = 0;"); From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 22:04:01 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 42C8F106566B; Thu, 31 Mar 2011 22:04:01 +0000 (UTC) (envelope-from davidch@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2F06F8FC08; Thu, 31 Mar 2011 22:04:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VM41gW024056; Thu, 31 Mar 2011 22:04:01 GMT (envelope-from davidch@svn.freebsd.org) Received: (from davidch@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VM41fm024054; Thu, 31 Mar 2011 22:04:01 GMT (envelope-from davidch@svn.freebsd.org) Message-Id: <201103312204.p2VM41fm024054@svn.freebsd.org> From: David Christensen Date: Thu, 31 Mar 2011 22:04:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220228 - head/sys/dev/bxe X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 22:04:01 -0000 Author: davidch Date: Thu Mar 31 22:04:00 2011 New Revision: 220228 URL: http://svn.freebsd.org/changeset/base/220228 Log: - Fixed DMA engine errors by increasing timeouts to 200ms for reads/writes. - Improved some error reporting calls to include file name/line number. - Various style(9) fixes. MFC after: One week. Modified: head/sys/dev/bxe/if_bxe.c Modified: head/sys/dev/bxe/if_bxe.c ============================================================================== --- head/sys/dev/bxe/if_bxe.c Thu Mar 31 21:33:33 2011 (r220227) +++ head/sys/dev/bxe/if_bxe.c Thu Mar 31 22:04:00 2011 (r220228) @@ -458,9 +458,7 @@ SYSCTL_UINT(_hw_bxe, OID_AUTO, tpa_enabl /* * Specifies the number of queues that will be used when a multi-queue - * RSS mode is selected using bxe_multi_mode below. Some RSS modes - * require additional queue configuration which may conflict with this - * setting. In that case this value will be overriden. + * RSS mode is selected using bxe_multi_mode below. * * Allowable values are 0 (Auto) or 1 to MAX_CONTEXT (fixed queue number). */ @@ -1145,7 +1143,7 @@ bxe_interrupt_allocate(struct bxe_softc break; } } else { - /* User has forced INTx mode. */ + /* User has forced INTx mode. */ sc->multi_mode = ETH_RSS_MODE_DISABLED; sc->num_queues = 1; } @@ -1451,7 +1449,7 @@ bxe_interrupt_attach(struct bxe_softc *s "%s(): Enabling slowpath MSI[0] vector.\n", __FUNCTION__); /* - * Setup the interrupt handler. Note that we pass the driver + * Setup the interrupt handler. Note that we pass the driver * instance to the interrupt handler for the slowpath. */ rc = bus_setup_intr(sc->bxe_dev,sc->bxe_msi_res[0], @@ -1477,7 +1475,7 @@ bxe_interrupt_attach(struct bxe_softc *s "%s(): Enabling MSI[%d] vector.\n", __FUNCTION__, i + 1); /* - * Setup the interrupt handler. Note that we pass the + * Setup the interrupt handler. Note that we pass the * fastpath context to the interrupt handler in this * case. */ @@ -1762,7 +1760,7 @@ bxe_attach(device_t dev) /* Put indirect address registers into a sane state. */ pci_write_config(sc->bxe_dev, PCICFG_GRC_ADDRESS, - PCICFG_VENDOR_ID_OFFSET, 4); + PCICFG_VENDOR_ID_OFFSET, 4); REG_WR(sc, PXP2_REG_PGL_ADDR_88_F0 + BP_PORT(sc) * 16, 0); REG_WR(sc, PXP2_REG_PGL_ADDR_8C_F0 + BP_PORT(sc) * 16, 0); REG_WR(sc, PXP2_REG_PGL_ADDR_90_F0 + BP_PORT(sc) * 16, 0); @@ -1829,7 +1827,8 @@ bxe_attach(device_t dev) /* Set init arrays */ rc = bxe_init_firmware(sc); if (rc) { - BXE_PRINTF("Error loading firmware\n"); + BXE_PRINTF("%s(%d): Error loading firmware\n", + __FILE__, __LINE__); goto bxe_attach_fail; } @@ -1846,8 +1845,8 @@ bxe_attach(device_t dev) /* Check that NVRAM contents are valid.*/ if (bxe_nvram_test(sc)) { - DBPRINT(sc, BXE_WARN, "%s(): Failed NVRAM test!\n", - __FUNCTION__); + BXE_PRINTF("%s(%d): Failed NVRAM test!\n", + __FILE__, __LINE__); rc = ENODEV; goto bxe_attach_fail; } @@ -1855,7 +1854,7 @@ bxe_attach(device_t dev) /* Allocate the appropriate interrupts.*/ if (bxe_interrupt_allocate(sc)) { BXE_PRINTF("%s(%d): Interrupt allocation failed!\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENODEV; goto bxe_attach_fail; } @@ -1902,10 +1901,13 @@ bxe_attach(device_t dev) /* Disable WoL. */ sc->wol = 0; + /* Assume a standard 1500 byte MTU size for mbuf allocations. */ + sc->mbuf_alloc_size = MCLBYTES; + /* Allocate DMA memory resources. */ if (bxe_dma_alloc(sc->bxe_dev)) { BXE_PRINTF("%s(%d): DMA allocation failed!\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENOMEM; goto bxe_attach_fail; } @@ -1914,7 +1916,7 @@ bxe_attach(device_t dev) ifp = sc->bxe_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { BXE_PRINTF("%s(%d): Interface allocation failed!\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENXIO; goto bxe_attach_fail; } @@ -1935,8 +1937,6 @@ bxe_attach(device_t dev) ifp->if_capenable = ifp->if_capabilities; ifp->if_baudrate = IF_Gbps(10UL); - /* Assume a standard 1500 byte MTU size for mbuf allocations. */ - sc->mbuf_alloc_size = MCLBYTES; ifp->if_snd.ifq_drv_maxlen = sc->tx_ring_size; IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen); @@ -1947,8 +1947,8 @@ bxe_attach(device_t dev) /* Attach the interrupts to the interrupt handlers. */ if (bxe_interrupt_attach(sc)) { - BXE_PRINTF("%s(%d): Interrupt allocation failed!\n", __FILE__, - __LINE__); + BXE_PRINTF("%s(%d): Interrupt allocation failed!\n", + __FILE__, __LINE__); goto bxe_attach_fail; } @@ -2901,6 +2901,9 @@ bxe_setup_leading(struct bxe_softc *sc) DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET | BXE_VERBOSE_RAMROD); + DBPRINT(sc, BXE_INFO_LOAD, "%s(): Setup leading connection " + "on fp[00].\n", __FUNCTION__); + /* Reset IGU state for the leading connection. */ bxe_ack_sb(sc, sc->fp[0].sb_id, CSTORM_ID, 0, IGU_INT_ENABLE, 0); @@ -2929,6 +2932,9 @@ bxe_stop_leading(struct bxe_softc *sc) DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET | BXE_VERBOSE_RAMROD); + DBPRINT(sc, BXE_INFO_LOAD, "%s(): Stop client connection " + "on fp[00].\n", __FUNCTION__); + /* Send the ETH_HALT ramrod. */ sc->fp[0].state = BXE_FP_STATE_HALTING; bxe_sp_post(sc,RAMROD_CMD_ID_ETH_HALT, 0, 0, sc->fp[0].cl_id, 0); @@ -2987,6 +2993,9 @@ bxe_setup_multi(struct bxe_softc *sc, in DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET | BXE_VERBOSE_RAMROD); + DBPRINT(sc, BXE_INFO_LOAD, "%s(): Setup client connection " + "on fp[%02d].\n", __FUNCTION__, index); + fp = &sc->fp[index]; /* Reset IGU state. */ bxe_ack_sb(sc, fp->sb_id, CSTORM_ID, 0, IGU_INT_ENABLE, 0); @@ -3019,7 +3028,11 @@ bxe_stop_multi(struct bxe_softc *sc, int DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET | BXE_VERBOSE_RAMROD); + DBPRINT(sc, BXE_INFO_LOAD, "%s(): Stop client connection " + "on fp[%02d].\n", __FUNCTION__, index); + fp = &sc->fp[index]; + /* Halt the client connection. */ fp->state = BXE_FP_STATE_HALTING; bxe_sp_post(sc, RAMROD_CMD_ID_ETH_HALT, index, 0, fp->cl_id, 0); @@ -4398,7 +4411,7 @@ bxe_write_dmae(struct bxe_softc *sc, bus bxe_post_dmae(sc, &dmae, INIT_DMAE_C(sc)); - DELAY(5); + DELAY(50); timeout = 4000; while (*wb_comp != BXE_WB_COMP_VAL) { @@ -4409,7 +4422,7 @@ bxe_write_dmae(struct bxe_softc *sc, bus break; } timeout--; - DELAY(5); + DELAY(50); } BXE_DMAE_UNLOCK(sc); @@ -4485,9 +4498,9 @@ bxe_read_dmae(struct bxe_softc *sc, uint bxe_post_dmae(sc, &dmae, INIT_DMAE_C(sc)); - DELAY(5); + DELAY(50); - timeout = 200; + timeout = 4000; while (*wb_comp != BXE_WB_COMP_VAL) { if (!timeout) { DBPRINT(sc, 1, @@ -4496,7 +4509,7 @@ bxe_read_dmae(struct bxe_softc *sc, uint break; } timeout--; - DELAY(5); + DELAY(50); } BXE_DMAE_UNLOCK(sc); @@ -8527,8 +8540,7 @@ bxe_chktso_window(struct bxe_softc* sc, } /* - * bxe_tx_encap() - * Encapsultes an mbuf cluster into the bxe tx_bd chain structure and + * Encapsultes an mbuf cluster into the tx_bd chain structure and * makes the memory visible to the controller. * * If an mbuf is submitted to this routine and cannot be given to the @@ -10769,6 +10781,7 @@ bxe_init_context(struct bxe_softc *sc) U64_HI(fp->rx_bd_chain_paddr[0]); context->ustorm_st_context.common.bd_page_base_lo = U64_LO(fp->rx_bd_chain_paddr[0]); + if (TPA_ENABLED(sc) && !(fp->disable_tpa)) { /* Enable TPA and SGE chain support. */ context->ustorm_st_context.common.flags |= @@ -11333,7 +11346,7 @@ bxe_init_nic(struct bxe_softc *sc, uint3 fp->sb_id = fp->cl_id; DBPRINT(sc, (BXE_INFO_LOAD | BXE_INFO_RESET), - "%s(): fp[%d]: cl_id = %d, sb_id = %d,\n", + "%s(): fp[%d]: cl_id = %d, sb_id = %d\n", __FUNCTION__, fp->index, fp->cl_id, fp->sb_id); /* Initialize the fastpath status block. */ @@ -14761,7 +14774,8 @@ bxe_rxeof(struct bxe_fastpath *fp) __FUNCTION__)); /* Check the CQE type for slowpath or fastpath completion. */ - if (__predict_false(CQE_TYPE(cqe_fp_flags) == 1)) { + if (__predict_false(CQE_TYPE(cqe_fp_flags) == + RX_ETH_CQE_TYPE_ETH_RAMROD)) { /* This is a slowpath completion. */ bxe_sp_event(fp, cqe); goto bxe_rxeof_next_cqe; @@ -14891,6 +14905,7 @@ bxe_rxeof(struct bxe_fastpath *fp) DBRUN(bxe_breakpoint(sc)); + /* ToDo: Find alterntive to panic(). */ panic( "bxe%d: Double mbuf allocation failure!\n", sc->bxe_unit); @@ -15352,6 +15367,7 @@ bxe_sysctl_driver_state(SYSCTL_HANDLER_A fp = &sc->fp[i]; bxe_dump_fp_state(fp); } + bxe_dump_status_block(sc); } return (error); From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 22:40:44 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8E4B5106566B; Thu, 31 Mar 2011 22:40:44 +0000 (UTC) (envelope-from davidch@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7B0388FC0A; Thu, 31 Mar 2011 22:40:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VMeic2024874; Thu, 31 Mar 2011 22:40:44 GMT (envelope-from davidch@svn.freebsd.org) Received: (from davidch@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VMeiEb024871; Thu, 31 Mar 2011 22:40:44 GMT (envelope-from davidch@svn.freebsd.org) Message-Id: <201103312240.p2VMeiEb024871@svn.freebsd.org> From: David Christensen Date: Thu, 31 Mar 2011 22:40:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220229 - head/sys/dev/bxe X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 22:40:44 -0000 Author: davidch Date: Thu Mar 31 22:40:44 2011 New Revision: 220229 URL: http://svn.freebsd.org/changeset/base/220229 Log: - Freshened debug support code. - Renamed several RX variable for more consistent usage. - Fixed a potential problem when masking RX CQ producer value. MFC after: One week. Modified: head/sys/dev/bxe/if_bxe.c head/sys/dev/bxe/if_bxe.h Modified: head/sys/dev/bxe/if_bxe.c ============================================================================== --- head/sys/dev/bxe/if_bxe.c Thu Mar 31 22:04:00 2011 (r220228) +++ head/sys/dev/bxe/if_bxe.c Thu Mar 31 22:40:44 2011 (r220229) @@ -68,7 +68,8 @@ __FBSDID("$FreeBSD$"); /* BXE Debug Options */ #ifdef BXE_DEBUG - uint32_t bxe_debug = BXE_INFO; +uint32_t bxe_debug = BXE_INFO; + /* 0 = Never */ /* 1 = 1 in 2,147,483,648 */ @@ -345,8 +346,8 @@ int bxe_set_gpio_int(struct bxe_softc * static int bxe_sysctl_driver_state(SYSCTL_HANDLER_ARGS); static int bxe_sysctl_hw_state(SYSCTL_HANDLER_ARGS); static int bxe_sysctl_dump_fw(SYSCTL_HANDLER_ARGS); -static int bxe_sysctl_dump_cqe_chain(SYSCTL_HANDLER_ARGS); -static int bxe_sysctl_dump_rx_chain(SYSCTL_HANDLER_ARGS); +static int bxe_sysctl_dump_rx_cq_chain(SYSCTL_HANDLER_ARGS); +static int bxe_sysctl_dump_rx_bd_chain(SYSCTL_HANDLER_ARGS); static int bxe_sysctl_dump_tx_chain(SYSCTL_HANDLER_ARGS); static int bxe_sysctl_reg_read(SYSCTL_HANDLER_ARGS); static int bxe_sysctl_breakpoint(SYSCTL_HANDLER_ARGS); @@ -357,16 +358,16 @@ static void bxe_dump_enet(struct bxe_sof static void bxe_dump_mbuf (struct bxe_softc *, struct mbuf *); static void bxe_dump_tx_mbuf_chain(struct bxe_softc *, int, int); static void bxe_dump_rx_mbuf_chain(struct bxe_softc *, int, int); -static void bxe_dump_pbd_locked(struct bxe_softc *,int, +static void bxe_dump_tx_parsing_bd(struct bxe_fastpath *,int, struct eth_tx_parse_bd *); -static void bxe_dump_txbd_locked(struct bxe_fastpath *, int, - struct eth_tx_bd *); -static void bxe_dump_rxbd_locked(struct bxe_fastpath *, int, +static void bxe_dump_txbd(struct bxe_fastpath *, int, + union eth_tx_bd_types *); +static void bxe_dump_rxbd(struct bxe_fastpath *, int, struct eth_rx_bd *); -static void bxe_dump_cqe_locked(struct bxe_fastpath *, int, union eth_rx_cqe *); +static void bxe_dump_cqe(struct bxe_fastpath *, int, union eth_rx_cqe *); static void bxe_dump_tx_chain(struct bxe_fastpath *, int, int); -static void bxe_dump_cqe_chain(struct bxe_fastpath *, int, int); -static void bxe_dump_rx_chain(struct bxe_fastpath *, int, int); +static void bxe_dump_rx_cq_chain(struct bxe_fastpath *, int, int); +static void bxe_dump_rx_bd_chain(struct bxe_fastpath *, int, int); static void bxe_dump_status_block(struct bxe_softc *); static void bxe_dump_stats_block(struct bxe_softc *); static void bxe_dump_fp_state(struct bxe_fastpath *); @@ -404,6 +405,7 @@ static device_method_t bxe_methods[] = { KOBJMETHOD_END }; + static driver_t bxe_driver = { "bxe", bxe_methods, @@ -1725,11 +1727,11 @@ bxe_attach(device_t dev) * processor memory. */ rid = PCIR_BAR(0); - sc->bxe_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &rid, RF_ACTIVE); + sc->bxe_res = bus_alloc_resource_any(dev, + SYS_RES_MEMORY, &rid, RF_ACTIVE); if (sc->bxe_res == NULL) { BXE_PRINTF("%s(%d):PCI BAR0 memory allocation failed\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENXIO; goto bxe_attach_fail; } @@ -1744,11 +1746,11 @@ bxe_attach(device_t dev) * Doorbell (DB) memory. */ rid = PCIR_BAR(2); - sc->bxe_db_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &rid, RF_ACTIVE); + sc->bxe_db_res = bus_alloc_resource_any(dev, + SYS_RES_MEMORY, &rid, RF_ACTIVE); if (sc->bxe_db_res == NULL) { BXE_PRINTF("%s(%d): PCI BAR2 memory allocation failed\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENXIO; goto bxe_attach_fail; } @@ -1834,7 +1836,6 @@ bxe_attach(device_t dev) #ifdef BXE_DEBUG - /* Allocate a memory buffer for grcdump output.*/ sc->grcdump_buffer = malloc(BXE_GRCDUMP_BUF_SIZE, M_TEMP, M_NOWAIT); if (sc->grcdump_buffer == NULL) { @@ -3738,8 +3739,8 @@ bxe_init_locked(struct bxe_softc *sc, in callout_reset(&sc->bxe_tick_callout, hz, bxe_tick, sc); /* Everything went OK, go ahead and exit. */ goto bxe_init_locked_exit; + /* Try and gracefully shutdown the device because of a failure. */ -/* Try and gracefully shutdown the device because of a failure. */ bxe_init_locked_failed4: for (i = 1; i < sc->num_queues; i++) @@ -4413,6 +4414,7 @@ bxe_write_dmae(struct bxe_softc *sc, bus DELAY(50); + /* Wait up to 200ms. */ timeout = 4000; while (*wb_comp != BXE_WB_COMP_VAL) { if (!timeout) { @@ -4433,18 +4435,18 @@ bxe_write_dmae_exit: /* -* Perform a DMAE read from to device memory. -* + * Perform a DMAE read from to device memory. + * * Some of the registers on the 577XX controller are 128bits wide. It is * required that when accessing those registers that they be read * atomically and that no intervening bus acceses to the device occur. * This could be handled by a lock held across all driver instances for * the device or it can be handled by performing a DMA operation when * reading from the device. This code implements the latter. -* -* Returns: -* None. -*/ + * + * Returns: + * None. + */ void bxe_read_dmae(struct bxe_softc *sc, uint32_t src_addr, uint32_t len32) @@ -7244,7 +7246,8 @@ bxe_stats_init(struct bxe_softc *sc) sizeof(struct ustorm_per_client_stats)); memset(&fp->old_xclient, 0, sizeof(struct xstorm_per_client_stats)); - memset(&fp->eth_q_stats, 0, sizeof(struct bxe_q_stats)); + memset(&fp->eth_q_stats, 0, + sizeof(struct bxe_q_stats)); } sc->stats_state = STATS_STATE_DISABLED; @@ -8539,6 +8542,7 @@ bxe_chktso_window(struct bxe_softc* sc, return (defrag); } + /* * Encapsultes an mbuf cluster into the tx_bd chain structure and * makes the memory visible to the controller. @@ -8557,7 +8561,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st bus_dma_segment_t segs[32]; bus_dmamap_t map; struct mbuf *m0; - struct eth_tx_parse_bd *pbd; + struct eth_tx_parse_bd *tx_parse_bd; struct eth_tx_bd *tx_data_bd; struct eth_tx_bd *tx_total_pkt_size_bd; struct eth_tx_start_bd *tx_start_bd; @@ -8580,7 +8584,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st tx_total_pkt_size_bd = NULL; tx_start_bd = NULL; tx_data_bd = NULL; - pbd = NULL; + tx_parse_bd = NULL; pkt_prod = fp->tx_pkt_prod; bd_prod = TX_BD(fp->tx_bd_prod); @@ -8693,6 +8697,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st } break; } + /* Last try */ if (m0->m_pkthdr.csum_flags & CSUM_TSO){ if (bxe_chktso_window(sc,nsegs,segs,m0)) @@ -8765,11 +8770,11 @@ bxe_tx_encap(struct bxe_fastpath *fp, st * however, it is only used for tso & chksum. */ bd_prod = TX_BD(NEXT_TX_BD(bd_prod)); - pbd = (struct eth_tx_parse_bd *) + tx_parse_bd = (struct eth_tx_parse_bd *) &fp->tx_bd_chain[TX_PAGE(bd_prod)][TX_IDX(bd_prod)].parse_bd; - memset(pbd, 0, sizeof(struct eth_tx_parse_bd)); + memset(tx_parse_bd, 0, sizeof(struct eth_tx_parse_bd)); - /* Gather all info about the packet and add to pbd */ + /* Gather all info about the packet and add to tx_parse_bd */ if (m0->m_pkthdr.csum_flags) { struct ether_vlan_header *eh; struct ip *ip = NULL; @@ -8790,8 +8795,9 @@ bxe_tx_encap(struct bxe_fastpath *fp, st } /* Set the Ethernet header length in 16 bit words. */ - pbd->global_data = (e_hlen + ovlan) >> 1; - pbd->global_data |= ((m0->m_flags & M_VLANTAG) << ETH_TX_PARSE_BD_LLC_SNAP_EN_SHIFT); + tx_parse_bd->global_data = (e_hlen + ovlan) >> 1; + tx_parse_bd->global_data |= ((m0->m_flags & M_VLANTAG) << + ETH_TX_PARSE_BD_LLC_SNAP_EN_SHIFT); switch (etype) { case ETHERTYPE_IP:{ @@ -8802,10 +8808,10 @@ bxe_tx_encap(struct bxe_fastpath *fp, st ip = (struct ip *)(m0->m_data + e_hlen); /* Calculate IP header length (16 bit words). */ - pbd->ip_hlen = (ip->ip_hl << 1); + tx_parse_bd->ip_hlen = (ip->ip_hl << 1); /* Calculate enet + IP header length (16 bit words). */ - pbd->total_hlen = pbd->ip_hlen + (e_hlen >> 1); + tx_parse_bd->total_hlen = tx_parse_bd->ip_hlen + (e_hlen >> 1); if (m0->m_pkthdr.csum_flags & CSUM_IP) { DBPRINT(sc, BXE_EXTREME_SEND, "%s(): IP checksum " @@ -8816,7 +8822,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st /* Handle any checksums requested by the stack. */ if ((m0->m_pkthdr.csum_flags & CSUM_TCP)|| - (m0->m_pkthdr.csum_flags & CSUM_TSO)){ + (m0->m_pkthdr.csum_flags & CSUM_TSO)){ /* Perform TCP checksum offload. */ DBPRINT(sc, BXE_EXTREME_SEND, "%s(): TCP checksum " @@ -8830,10 +8836,10 @@ bxe_tx_encap(struct bxe_fastpath *fp, st DBRUN(sc->debug_tcp_csum_offload_frames++); /* Update the enet + IP + TCP header length. */ - pbd->total_hlen += (uint16_t)(th->th_off << 1); + tx_parse_bd->total_hlen += (uint16_t)(th->th_off << 1); /* Get the pseudo header checksum. */ - pbd->tcp_pseudo_csum = ntohs(th->th_sum); + tx_parse_bd->tcp_pseudo_csum = ntohs(th->th_sum); } else if (m0->m_pkthdr.csum_flags & CSUM_UDP) { /* * The hardware doesn't actually support UDP checksum @@ -8861,7 +8867,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st /* Add the TCP checksum offload flag for UDP frames too. */ flags |= ETH_TX_BD_FLAGS_L4_CSUM; DBRUN(sc->debug_udp_csum_offload_frames++); - pbd->global_data |= ETH_TX_PARSE_BD_UDP_CS_FLG; + tx_parse_bd->global_data |= ETH_TX_PARSE_BD_UDP_CS_FLG; /* Get a pointer to the UDP header. */ uh = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2)); @@ -8878,8 +8884,8 @@ bxe_tx_encap(struct bxe_fastpath *fp, st ntohl((*(tmp_uh + 2)) & 0x0000FFFF)); /* Update the enet + IP + UDP header length. */ - pbd->total_hlen += (sizeof(struct udphdr) >> 1); - pbd->tcp_pseudo_csum = ~in_addword(uh->uh_sum, ~tmp_csum); + tx_parse_bd->total_hlen += (sizeof(struct udphdr) >> 1); + tx_parse_bd->tcp_pseudo_csum = ~in_addword(uh->uh_sum, ~tmp_csum); } /* Update the flags settings for VLAN/Offload. */ @@ -8900,9 +8906,10 @@ bxe_tx_encap(struct bxe_fastpath *fp, st /* Setup the Parsing BD with TSO specific info */ if (m0->m_pkthdr.csum_flags & CSUM_TSO) { - uint16_t hdr_len = pbd->total_hlen << 1; + uint16_t hdr_len = tx_parse_bd->total_hlen << 1; - DBPRINT(sc, BXE_EXTREME_SEND, "%s(): TSO is enabled.\n",__FUNCTION__); + DBPRINT(sc, BXE_EXTREME_SEND, "%s(): TSO is enabled.\n", + __FUNCTION__); tx_start_bd->bd_flags.as_bitfield |= ETH_TX_BD_FLAGS_SW_LSO; @@ -8918,9 +8925,9 @@ bxe_tx_encap(struct bxe_fastpath *fp, st __FUNCTION__, tx_start_bd->nbytes, tx_start_bd->addr_hi, tx_start_bd->addr_lo, nbds); - bd_prod = TX_BD(NEXT_TX_BD(bd_prod)); + bd_prod = TX_BD(NEXT_TX_BD(bd_prod)); - /* Get a new transmit BD (after the pbd) and fill it. */ + /* Get a new transmit BD (after the tx_parse_bd) and fill it. */ tx_data_bd = &fp->tx_bd_chain[TX_PAGE(bd_prod)][TX_IDX(bd_prod)].reg_bd; tx_data_bd->addr_hi = htole32(U64_HI(segs[0].ds_addr + hdr_len)); tx_data_bd->addr_lo = htole32(U64_LO(segs[0].ds_addr + hdr_len)); @@ -8934,23 +8941,26 @@ bxe_tx_encap(struct bxe_fastpath *fp, st */ DBPRINT(sc, BXE_EXTREME_SEND, "%s(): TSO split data " - "size is %d (%x:%x)\n", __FUNCTION__, - tx_data_bd->nbytes, tx_data_bd->addr_hi, tx_data_bd->addr_lo); + "size is %d (%x:%x)\n", __FUNCTION__, + tx_data_bd->nbytes, tx_data_bd->addr_hi, + tx_data_bd->addr_lo); } /* * For TSO the controller needs the following info: * MSS, tcp_send_seq, ip_id, and tcp_pseudo_csum. */ - pbd->lso_mss = htole16(m0->m_pkthdr.tso_segsz); - pbd->tcp_send_seq = ntohl(th->th_seq); - pbd->tcp_flags = th->th_flags; - pbd->ip_id = ntohs(ip->ip_id); + tx_parse_bd->lso_mss = htole16(m0->m_pkthdr.tso_segsz); + tx_parse_bd->tcp_send_seq = ntohl(th->th_seq); + tx_parse_bd->tcp_flags = th->th_flags; + tx_parse_bd->ip_id = ntohs(ip->ip_id); + + tx_parse_bd->tcp_pseudo_csum = + ntohs(in_pseudo(ip->ip_src.s_addr, + ip->ip_dst.s_addr, htons(IPPROTO_TCP))); - pbd->tcp_pseudo_csum = ntohs(in_pseudo(ip->ip_src.s_addr, - ip->ip_dst.s_addr, htons(IPPROTO_TCP))); - - pbd->global_data |= ETH_TX_PARSE_BD_PSEUDO_CS_WITHOUT_LEN; + tx_parse_bd->global_data |= + ETH_TX_PARSE_BD_PSEUDO_CS_WITHOUT_LEN; } } @@ -8971,17 +8981,6 @@ bxe_tx_encap(struct bxe_fastpath *fp, st /* Update bd producer index value for next tx */ bd_prod = TX_BD(NEXT_TX_BD(bd_prod)); -/* -BXE_PRINTF("tx_start_bd: addrlo:0x%x, addrhi:0x%x, nbytes:0x%x, bitfield:0x%x, gendata:0x%x, nbd:0x%x\n", -tx_start_bd->addr_lo, -tx_start_bd->addr_hi, -tx_start_bd->nbytes, -tx_start_bd->bd_flags.as_bitfield, -tx_start_bd->general_data, -tx_start_bd->nbd ); - -bxe_dump_mbuf(sc, m0); -*/ DBRUNMSG(BXE_EXTREME_SEND, bxe_dump_tx_chain(fp, debug_prod, nbds)); /* @@ -9391,12 +9390,12 @@ bxe_ioctl(struct ifnet *ifp, u_long comm * The adjusted value of *fp->rx_cons_sb. */ static __inline uint16_t -bxe_rx_comp_cons(struct bxe_fastpath *fp) +bxe_rx_cq_cons(struct bxe_fastpath *fp) { volatile uint16_t rx_cons_sb = 0; rmb(); - rx_cons_sb = (volatile uint16_t)le16toh(*fp->rx_cons_sb); + rx_cons_sb = (volatile uint16_t) le16toh(*fp->rx_cons_sb); /* * It is valid for the hardware's copy of the completion @@ -9405,8 +9404,8 @@ bxe_rx_comp_cons(struct bxe_fastpath *fp * that it is pointing at the next available CQE so we * need to adjust the value accordingly. */ - if ((rx_cons_sb & TOTAL_RCQ_ENTRIES_PER_PAGE) == - TOTAL_RCQ_ENTRIES_PER_PAGE) + if ((rx_cons_sb & USABLE_RCQ_ENTRIES_PER_PAGE) == + USABLE_RCQ_ENTRIES_PER_PAGE) rx_cons_sb++; return (rx_cons_sb); @@ -9434,7 +9433,7 @@ bxe_has_rx_work(struct bxe_fastpath *fp) { rmb(); - return (bxe_rx_comp_cons(fp) != fp->rx_comp_cons); + return (bxe_rx_cq_cons(fp) != fp->rx_cq_cons); } /* @@ -10306,7 +10305,7 @@ bxe_init_rx_chains(struct bxe_softc *sc) struct eth_rx_bd *rx_bd; struct eth_rx_cqe_next_page *nextpg; uint16_t ring_prod, cqe_ring_prod; - int func, i, j, max_agg_queues; + int func, i, j, rcq_idx, rx_idx, rx_sge_idx, max_agg_queues; DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET); @@ -10374,16 +10373,19 @@ bxe_init_rx_chains(struct bxe_softc *sc) /* Link the SGE Ring Pages to form SGE chain */ for (j = 0; j < NUM_RX_SGE_PAGES; j++) { - DBPRINT(sc, - (BXE_INSANE_LOAD | BXE_INSANE_RESET), - "%s(): Linking fp[%d] SGE ring[%d].\n", - __FUNCTION__, i, j); - + rx_sge_idx = ((j + 1) % NUM_RX_SGE_PAGES); sge = &fp->rx_sge_chain[j][MAX_RX_SGE_CNT]; + + DBPRINT(sc, (BXE_EXTREME_LOAD | BXE_EXTREME_RESET), + "%s(): fp[%02d].rx_sge_chain[%02d][0x%04X]=0x%jX\n", + __FUNCTION__, i, j, + (uint16_t) MAX_RX_SGE_CNT, + (uintmax_t) fp->rx_sge_chain_paddr[rx_sge_idx]); + sge->addr_hi = - htole32(U64_HI(fp->rx_sge_chain_paddr[(j + 1) % NUM_RX_SGE_PAGES])); + htole32(U64_HI(fp->rx_sge_chain_paddr[rx_sge_idx])); sge->addr_lo = - htole32(U64_LO(fp->rx_sge_chain_paddr[(j + 1) % NUM_RX_SGE_PAGES])); + htole32(U64_LO(fp->rx_sge_chain_paddr[rx_sge_idx])); } bxe_init_sge_ring_bit_mask(fp); @@ -10394,16 +10396,19 @@ bxe_init_rx_chains(struct bxe_softc *sc) /* Link the pages to form the RX BD Chain. */ for (j = 0; j < NUM_RX_PAGES; j++) { + rx_idx = ((j + 1) % NUM_RX_PAGES); rx_bd = &fp->rx_bd_chain[j][USABLE_RX_BD_PER_PAGE]; - DBPRINT(sc, (BXE_INSANE_LOAD | BXE_INSANE_RESET), - "%s(): Linking fp[%d] RX BD chain page[%d].\n", - __FUNCTION__, i, j); + DBPRINT(sc, (BXE_INFO_LOAD), + "%s(): fp[%02d].rx_bd_chain[%02d][0x%04X]=0x%jX\n", + __FUNCTION__, i, j, + (uint16_t) USABLE_RX_BD_PER_PAGE, + (uintmax_t) fp->rx_bd_chain_paddr[rx_idx]); rx_bd->addr_hi = - htole32(U64_HI(fp->rx_bd_chain_paddr[(j + 1) % NUM_RX_PAGES])); + htole32(U64_HI(fp->rx_bd_chain_paddr[rx_idx])); rx_bd->addr_lo = - htole32(U64_LO(fp->rx_bd_chain_paddr[(j + 1) % NUM_RX_PAGES])); + htole32(U64_LO(fp->rx_bd_chain_paddr[rx_idx])); } DBPRINT(sc, (BXE_INSANE_LOAD | BXE_INSANE_RESET), @@ -10412,17 +10417,20 @@ bxe_init_rx_chains(struct bxe_softc *sc) /* Link the pages to form the RX Completion Queue.*/ for (j = 0; j < NUM_RCQ_PAGES; j++) { + rcq_idx = ((j + 1) % NUM_RCQ_PAGES); nextpg = (struct eth_rx_cqe_next_page *) - &fp->rx_comp_chain[j][USABLE_RCQ_ENTRIES_PER_PAGE]; + &fp->rx_cq_chain[j][USABLE_RCQ_ENTRIES_PER_PAGE]; - DBPRINT(sc, (BXE_INSANE_LOAD | BXE_INSANE_RESET), - "%s(): Linking fp[%d] RX completion chain page[%d].\n", - __FUNCTION__, i, j); + DBPRINT(sc, (BXE_INFO_LOAD), + "%s(): fp[%02d].rx_cq_chain[%02d][0x%04X]=0x%jX\n", + __FUNCTION__, i, j, + (uint16_t) USABLE_RCQ_ENTRIES_PER_PAGE, + (uintmax_t) fp->rx_cq_chain_paddr[rcq_idx]); nextpg->addr_hi = - htole32(U64_HI(fp->rx_comp_chain_paddr[(j + 1) % NUM_RCQ_PAGES])); + htole32(U64_HI(fp->rx_cq_chain_paddr[rcq_idx])); nextpg->addr_lo = - htole32(U64_LO(fp->rx_comp_chain_paddr[(j + 1) % NUM_RCQ_PAGES])); + htole32(U64_LO(fp->rx_cq_chain_paddr[rcq_idx])); } if (TPA_ENABLED(sc)) { @@ -10432,7 +10440,8 @@ bxe_init_rx_chains(struct bxe_softc *sc) while (ring_prod < sc->rx_ring_size) { if (bxe_alloc_rx_sge(sc, fp, ring_prod) != 0) { BXE_PRINTF( - "%s(%d): Memory allocation failure! Disabling TPA for fp[%d].\n", + "%s(%d): Memory allocation failure! " + "Disabling TPA for fp[%d].\n", __FILE__, __LINE__, i); /* Cleanup already allocated elements */ @@ -10452,7 +10461,7 @@ bxe_init_rx_chains(struct bxe_softc *sc) * Allocate buffers for all the RX BDs in RX BD Chain. * Add completion queue entries at the same time. */ - fp->rx_comp_cons = ring_prod = cqe_ring_prod = 0; + fp->rx_cq_cons = ring_prod = cqe_ring_prod = 0; DBRUN(fp->free_rx_bd = USABLE_RX_BD); while (ring_prod < sc->rx_ring_size) { @@ -10469,9 +10478,9 @@ bxe_init_rx_chains(struct bxe_softc *sc) /* Update the driver's copy of the producer indices. */ fp->rx_bd_prod = ring_prod; - fp->rx_comp_prod = cqe_ring_prod; + fp->rx_cq_prod = cqe_ring_prod; /* - * fp->rx_comp_prod = + * fp->rx_cq_prod = * (uint16_t)min(NUM_RCQ_PAGES*TOTAL_RCQ_ENTRIES_PER_PAGE, * cqe_ring_prod); */ @@ -10485,8 +10494,8 @@ bxe_init_rx_chains(struct bxe_softc *sc) BUS_DMASYNC_PREWRITE); for (j = 0; j < NUM_RCQ_PAGES; j++) - bus_dmamap_sync(fp->rx_comp_chain_tag, - fp->rx_comp_chain_map[j], BUS_DMASYNC_PREREAD | + bus_dmamap_sync(fp->rx_cq_chain_tag, + fp->rx_cq_chain_map[j], BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); /* @@ -10494,7 +10503,7 @@ bxe_init_rx_chains(struct bxe_softc *sc) * Warning! this will generate an interrupt (to the TSTORM). * This must only be done when the controller is initialized. */ - bxe_update_rx_prod(sc, fp, ring_prod, fp->rx_comp_prod, + bxe_update_rx_prod(sc, fp, ring_prod, fp->rx_cq_prod, fp->rx_sge_prod); if (i != 0) @@ -10502,10 +10511,10 @@ bxe_init_rx_chains(struct bxe_softc *sc) REG_WR(sc, BAR_USTORM_INTMEM + USTORM_MEM_WORKAROUND_ADDRESS_OFFSET(func), - U64_LO(fp->rx_comp_chain_paddr[0])); + U64_LO(fp->rx_cq_chain_paddr[0])); REG_WR(sc, BAR_USTORM_INTMEM + USTORM_MEM_WORKAROUND_ADDRESS_OFFSET(func) + 4, - U64_HI(fp->rx_comp_chain_paddr[0])); + U64_HI(fp->rx_cq_chain_paddr[0])); } DBEXIT(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET); @@ -10521,7 +10530,7 @@ static void bxe_init_tx_chains(struct bxe_softc *sc) { struct bxe_fastpath *fp; - struct eth_tx_next_bd *tx_bd; + struct eth_tx_next_bd *tx_n_bd; int i, j; DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET); @@ -10532,17 +10541,17 @@ bxe_init_tx_chains(struct bxe_softc *sc) "%s(): Linking fp[%d] TX chain pages.\n", __FUNCTION__, i); for (j = 0; j < NUM_TX_PAGES; j++) { - tx_bd = + tx_n_bd = &fp->tx_bd_chain[j][USABLE_TX_BD_PER_PAGE].next_bd; DBPRINT(sc, (BXE_INSANE_LOAD | BXE_INSANE_RESET), "%s(): Linking fp[%d] TX BD chain page[%d].\n", __FUNCTION__, i, j); - tx_bd->addr_hi = + tx_n_bd->addr_hi = htole32(U64_HI(fp->tx_bd_chain_paddr[(j + 1) % NUM_TX_PAGES])); - tx_bd->addr_lo = + tx_n_bd->addr_lo = htole32(U64_LO(fp->tx_bd_chain_paddr[(j + 1) % NUM_TX_PAGES])); } @@ -10609,8 +10618,8 @@ bxe_free_rx_chains(struct bxe_softc *sc) /* Clear each RX completion queue page. */ for (j = 0; j < NUM_RCQ_PAGES; j++) { - if (fp->rx_comp_chain[j] != NULL) - bzero((char *)fp->rx_comp_chain[j], + if (fp->rx_cq_chain[j] != NULL) + bzero((char *)fp->rx_cq_chain[j], BXE_RX_CHAIN_PAGE_SZ); } @@ -11190,14 +11199,14 @@ bxe_init_internal_func(struct bxe_softc for (i = 0; i < sc->num_queues; i++) { fp = &sc->fp[i]; nextpg = (struct eth_rx_cqe_next_page *) - &fp->rx_comp_chain[i][USABLE_RCQ_ENTRIES_PER_PAGE]; + &fp->rx_cq_chain[i][USABLE_RCQ_ENTRIES_PER_PAGE]; /* Program the completion queue address. */ REG_WR(sc, BAR_USTORM_INTMEM + USTORM_CQE_PAGE_BASE_OFFSET(port, fp->cl_id), - U64_LO(fp->rx_comp_chain_paddr[0])); + U64_LO(fp->rx_cq_chain_paddr[0])); REG_WR(sc, BAR_USTORM_INTMEM + USTORM_CQE_PAGE_BASE_OFFSET(port, fp->cl_id) + 4, - U64_HI(fp->rx_comp_chain_paddr[0])); + U64_HI(fp->rx_cq_chain_paddr[0])); /* Next page */ REG_WR(sc, BAR_USTORM_INTMEM + USTORM_CQE_PAGE_NEXT_OFFSET(port, @@ -12806,22 +12815,22 @@ bxe_dma_free(struct bxe_softc *sc) * Free, unmap and destroy all RX CQ * chain pages. */ - if (fp->rx_comp_chain_tag != NULL) { + if (fp->rx_cq_chain_tag != NULL) { for (j = 0; j < NUM_RCQ_PAGES; j++ ) { - if (fp->rx_comp_chain_map[j] != NULL) { - if (fp->rx_comp_chain[j] != NULL) - bus_dmamem_free(fp->rx_comp_chain_tag, - fp->rx_comp_chain[j], - fp->rx_comp_chain_map[j]); - - bus_dmamap_unload(fp->rx_comp_chain_tag, - fp->rx_comp_chain_map[j]); - bus_dmamap_destroy(fp->rx_comp_chain_tag, - fp->rx_comp_chain_map[j]); + if (fp->rx_cq_chain_map[j] != NULL) { + if (fp->rx_cq_chain[j] != NULL) + bus_dmamem_free(fp->rx_cq_chain_tag, + fp->rx_cq_chain[j], + fp->rx_cq_chain_map[j]); + + bus_dmamap_unload(fp->rx_cq_chain_tag, + fp->rx_cq_chain_map[j]); + bus_dmamap_destroy(fp->rx_cq_chain_tag, + fp->rx_cq_chain_map[j]); } } - bus_dma_tag_destroy(fp->rx_comp_chain_tag); + bus_dma_tag_destroy(fp->rx_cq_chain_tag); } /* Unload and destroy the TX mbuf maps. */ @@ -13093,7 +13102,7 @@ bxe_dma_alloc(device_t dev) NULL, /* filter f() */ NULL, /* filter f() arg */ MAXBSIZE, /* max map for this tag */ - BUS_SPACE_UNRESTRICTED, /* #of discontinuities */ + BUS_SPACE_UNRESTRICTED, /* # of discontinuities */ BUS_SPACE_MAXSIZE_32BIT, /* max seg size */ 0, /* flags */ NULL, /* lock f() */ @@ -13115,9 +13124,9 @@ bxe_dma_alloc(device_t dev) (long unsigned int)sizeof(struct bxe_fastpath)); /* - * Create a DMA tag for the status block, allocate and clear the - * memory, map the memory into DMA space, and fetch the physical - * address of the block. + * Create a DMA tag for the status block, allocate and + * clear the memory, map the memory into DMA space, and + * fetch the physical address of the block. */ if (bus_dma_tag_create(sc->parent_tag, @@ -13266,10 +13275,11 @@ bxe_dma_alloc(device_t dev) /* Create DMA maps for each the TX mbuf cluster(ext buf). */ for (j = 0; j < TOTAL_TX_BD; j++) { - if (bus_dmamap_create(fp->tx_mbuf_tag, BUS_DMA_NOWAIT, + if (bus_dmamap_create(fp->tx_mbuf_tag, + BUS_DMA_NOWAIT, &(fp->tx_mbuf_map[j]))) { - BXE_PRINTF( - "%s(%d): Unable to create fp[%d] TX mbuf DMA map!\n", + BXE_PRINTF("%s(%d): Unable to create fp[%d] " + "TX mbuf DMA map!\n", __FILE__, __LINE__, i); rc = ENOMEM; goto bxe_dma_alloc_exit; @@ -13363,8 +13373,8 @@ bxe_dma_alloc(device_t dev) /* Create DMA maps for the RX mbuf clusters. */ for (j = 0; j < TOTAL_RX_BD; j++) { - if (bus_dmamap_create(fp->rx_mbuf_tag, BUS_DMA_NOWAIT, - &(fp->rx_mbuf_map[j]))) { + if (bus_dmamap_create(fp->rx_mbuf_tag, + BUS_DMA_NOWAIT, &(fp->rx_mbuf_map[j]))) { BXE_PRINTF( "%s(%d): Unable to create fp[%d] RX mbuf DMA map!\n", __FILE__, __LINE__, i); @@ -13392,7 +13402,7 @@ bxe_dma_alloc(device_t dev) 0, /* flags */ NULL, /* lock f() */ NULL, /* lock f() arg */ - &fp->rx_comp_chain_tag)) { + &fp->rx_cq_chain_tag)) { BXE_PRINTF( "%s(%d): Could not allocate fp[%d] RX Completion Queue DMA tag!\n", __FILE__, __LINE__, i); @@ -13401,9 +13411,9 @@ bxe_dma_alloc(device_t dev) } for (j = 0; j < NUM_RCQ_PAGES; j++) { - if (bus_dmamem_alloc(fp->rx_comp_chain_tag, - (void **)&fp->rx_comp_chain[j], BUS_DMA_NOWAIT, - &fp->rx_comp_chain_map[j])) { + if (bus_dmamem_alloc(fp->rx_cq_chain_tag, + (void **)&fp->rx_cq_chain[j], BUS_DMA_NOWAIT, + &fp->rx_cq_chain_map[j])) { BXE_PRINTF( "%s(%d): Could not allocate fp[%d] RX Completion Queue DMA memory!\n", __FILE__, __LINE__, i); @@ -13411,11 +13421,11 @@ bxe_dma_alloc(device_t dev) goto bxe_dma_alloc_exit; } - bzero((char *)fp->rx_comp_chain[j], + bzero((char *)fp->rx_cq_chain[j], BXE_RX_CHAIN_PAGE_SZ); - error = bus_dmamap_load(fp->rx_comp_chain_tag, - fp->rx_comp_chain_map[j], fp->rx_comp_chain[j], + error = bus_dmamap_load(fp->rx_cq_chain_tag, + fp->rx_cq_chain_map[j], fp->rx_cq_chain[j], BXE_RX_CHAIN_PAGE_SZ, bxe_dma_map_addr, &busaddr, BUS_DMA_NOWAIT); @@ -13431,17 +13441,17 @@ bxe_dma_alloc(device_t dev) * Physical address of each page in the RX * Completion Chain. */ - fp->rx_comp_chain_paddr[j] = busaddr; + fp->rx_cq_chain_paddr[j] = busaddr; DBPRINT(sc, (BXE_EXTREME_LOAD | BXE_EXTREME_RESET), - "%s(): fp[%d]->rx_comp_chain_paddr[%d] = 0x%jX\n", + "%s(): fp[%d]->rx_cq_chain_paddr[%d] = 0x%jX\n", __FUNCTION__, i, j, (uintmax_t)busaddr); } if (TPA_ENABLED(sc)) { int tpa_pool_max = CHIP_IS_E1H(sc) ? - ETH_MAX_AGGREGATION_QUEUES_E1H : - ETH_MAX_AGGREGATION_QUEUES_E1; + ETH_MAX_AGGREGATION_QUEUES_E1H : + ETH_MAX_AGGREGATION_QUEUES_E1; /* * Create a DMA tag for the RX SGE Ring, @@ -14213,6 +14223,7 @@ bxe_ifmedia_upd(struct ifnet *ifp) ifm = &sc->bxe_ifmedia; rc = 0; + /* This is an Ethernet controller. */ if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) { rc = EINVAL; @@ -14672,27 +14683,27 @@ bxe_tpa_stop_exit: */ static __inline void bxe_update_rx_prod(struct bxe_softc *sc, struct bxe_fastpath *fp, - uint16_t bd_prod, uint16_t rx_comp_prod, uint16_t rx_sge_prod) + uint16_t bd_prod, uint16_t rx_cq_prod, uint16_t sge_prod) { volatile struct ustorm_eth_rx_producers rx_prods = {0}; int i; /* Update producers. */ - rx_prods.bd_prod = bd_prod;/* htole16(bd_prod);*/ - rx_prods.cqe_prod = rx_comp_prod;/*htole16(rx_comp_prod);*/ - rx_prods.sge_prod = rx_sge_prod;/*htole16(rx_sge_prod);*/ + rx_prods.bd_prod = bd_prod; + rx_prods.cqe_prod = rx_cq_prod; + rx_prods.sge_prod = sge_prod; wmb(); for (i = 0; i < sizeof(struct ustorm_eth_rx_producers) / 4; i++){ REG_WR(sc, BAR_USTORM_INTMEM + USTORM_RX_PRODS_OFFSET(BP_PORT(sc), fp->cl_id) + i * 4, - ((volatile uint32_t *)&rx_prods)[i]); + ((volatile uint32_t *) &rx_prods)[i]); } - DBPRINT(sc, BXE_EXTREME_RECV, "%s(): Wrote fp[%d] bd_prod = 0x%04X, " - "cqe_prod = 0x%04X, sge_prod = 0x%04X\n", __FUNCTION__, fp->index, - bd_prod, rx_comp_prod, rx_sge_prod); + DBPRINT(sc, BXE_EXTREME_RECV, "%s(%d): Wrote fp[%02d] bd_prod = 0x%04X, " + "rx_cq_prod = 0x%04X, sge_prod = 0x%04X\n", __FUNCTION__, curcpu, + fp->index, bd_prod, rx_cq_prod, sge_prod); } /* @@ -14706,32 +14717,38 @@ bxe_rxeof(struct bxe_fastpath *fp) { struct bxe_softc *sc; struct ifnet *ifp; - uint16_t bd_cons, bd_prod, bd_prod_fw; - uint16_t hw_comp_cons_idx, sw_comp_cons_idx, sw_comp_prod; - uint16_t comp_ring_cons; + uint16_t rx_bd_cons, rx_bd_cons_idx; + uint16_t rx_bd_prod, rx_bd_prod_idx; + uint16_t rx_cq_cons, rx_cq_cons_idx; + uint16_t rx_cq_prod, rx_cq_cons_sb; #ifdef BXE_DEBUG unsigned long rx_pkts = 0; #endif + sc = fp->sc; ifp = sc->bxe_ifp; DBENTER(BXE_EXTREME_RECV); - /* Get the sb's view of the RX completion consumer index. */ - hw_comp_cons_idx = le16toh(*fp->rx_cons_sb); - if ((hw_comp_cons_idx & USABLE_RCQ_ENTRIES_PER_PAGE) == - USABLE_RCQ_ENTRIES_PER_PAGE) - hw_comp_cons_idx++; - /* Get working copies of the driver's view of the RX indices. */ - bd_cons = fp->rx_bd_cons; - bd_prod = bd_prod_fw = fp->rx_bd_prod; - sw_comp_cons_idx = fp->rx_comp_cons; - sw_comp_prod = fp->rx_comp_prod; + + /* Get the status block's view of the RX completion consumer index. */ + rx_cq_cons_sb = bxe_rx_cq_cons(fp); + + /* + * Get working copies of the driver's view of the + * RX indices. These are 16 bit values that are + * expected to increment from from 0 to 65535 + * and then wrap-around to 0 again. + */ + rx_bd_cons = fp->rx_bd_cons; + rx_bd_prod = fp->rx_bd_prod; + rx_cq_cons = fp->rx_cq_cons; + rx_cq_prod = fp->rx_cq_prod; DBPRINT(sc, (BXE_EXTREME_RECV), - "%s(): fp[%d], bd_cons = 0x%04X, bd_prod = 0x%04X, " - "sw_comp_cons = 0x%04X, sw_comp_prod = 0x%04X\n", __FUNCTION__, - fp->index, bd_cons, bd_prod, sw_comp_cons_idx, sw_comp_prod); + "%s(%d): BEFORE: fp[%d], rx_bd_cons = 0x%04X, rx_bd_prod = 0x%04X, " + "rx_cq_cons_sw = 0x%04X, rx_cq_prod_sw = 0x%04X\n", __FUNCTION__, + curcpu, fp->index, rx_bd_cons, rx_bd_prod, rx_cq_cons, rx_cq_prod); /* * Memory barrier to prevent speculative reads of the RX buffer @@ -14743,20 +14760,25 @@ bxe_rxeof(struct bxe_fastpath *fp) * Scan through the receive chain as long * as there is work to do. */ - while (sw_comp_cons_idx != hw_comp_cons_idx) { + while (rx_cq_cons != rx_cq_cons_sb) { struct mbuf *m; union eth_rx_cqe *cqe; uint8_t cqe_fp_flags; uint16_t len, pad; - /* Convert the indices to an actual rx_bd index. */ - comp_ring_cons = RCQ_ENTRY(sw_comp_cons_idx); - bd_prod = RX_BD(bd_prod); - bd_cons = RX_BD(bd_cons); + /* + * Convert the 16 bit indices used by hardware + * into values that map to the arrays used by + * the driver (i.e. an index). + */ + rx_cq_cons_idx = RCQ_ENTRY(rx_cq_cons); + rx_bd_prod_idx = RX_BD(rx_bd_prod); + rx_bd_cons_idx = RX_BD(rx_bd_cons); wmb(); + /* Fetch the cookie. */ - cqe = (union eth_rx_cqe*) - &fp->rx_comp_chain[RCQ_PAGE(comp_ring_cons)][RCQ_IDX(comp_ring_cons)]; + cqe = (union eth_rx_cqe *) + &fp->rx_cq_chain[RCQ_PAGE(rx_cq_cons_idx)][RCQ_IDX(rx_cq_cons_idx)]; cqe_fp_flags = cqe->fast_path_cqe.type_error_flags; #ifdef BXE_DEBUG @@ -14769,9 +14791,10 @@ bxe_rxeof(struct bxe_fastpath *fp) } #endif - DBRUNIF((cqe_fp_flags == 0), BXE_PRINTF( - "%s(): CQE received with null type/error flags!\n", - __FUNCTION__)); + DBRUNIF((cqe_fp_flags == 0), + BXE_PRINTF("%s(): CQE received with null " + "type/error flags!\n", __FUNCTION__); + bxe_dump_cqe(fp, rx_cq_cons_idx, cqe)); /* Check the CQE type for slowpath or fastpath completion. */ if (__predict_false(CQE_TYPE(cqe_fp_flags) == @@ -14803,8 +14826,8 @@ bxe_rxeof(struct bxe_fastpath *fp) * Check if a TPA aggregation has been started. */ if (TPA_TYPE(cqe_fp_flags) == TPA_TYPE_START) { - bxe_tpa_start(fp, queue, bd_cons, - bd_prod); + bxe_tpa_start(fp, queue, + rx_bd_cons_idx, rx_bd_prod_idx); goto bxe_rxeof_next_rx; } @@ -14826,7 +14849,7 @@ bxe_rxeof(struct bxe_fastpath *fp) * the frame up. */ bxe_tpa_stop(sc, fp, queue, pad, len, - cqe, comp_ring_cons); + cqe, rx_cq_cons_idx); bxe_update_sge_prod(fp, &cqe->fast_path_cqe); goto bxe_rxeof_next_cqe; @@ -14834,8 +14857,8 @@ bxe_rxeof(struct bxe_fastpath *fp) } /* Remove the mbuf from the RX chain. */ - m = fp->rx_mbuf_ptr[bd_cons]; - fp->rx_mbuf_ptr[bd_cons] = NULL; + m = fp->rx_mbuf_ptr[rx_bd_cons_idx]; + fp->rx_mbuf_ptr[rx_bd_cons_idx] = NULL; DBRUN(fp->free_rx_bd++); DBRUNIF((fp->free_rx_bd > USABLE_RX_BD), @@ -14845,9 +14868,10 @@ bxe_rxeof(struct bxe_fastpath *fp) /* Unmap the mbuf from DMA space. */ bus_dmamap_sync(fp->rx_mbuf_tag, - fp->rx_mbuf_map[bd_cons], BUS_DMASYNC_POSTREAD); + fp->rx_mbuf_map[rx_bd_cons_idx], + BUS_DMASYNC_POSTREAD); bus_dmamap_unload(fp->rx_mbuf_tag, - fp->rx_mbuf_map[bd_cons]); + fp->rx_mbuf_map[rx_bd_cons_idx]); /* Check if the received frame has any errors. */ if (__predict_false(cqe_fp_flags & @@ -14860,11 +14884,13 @@ bxe_rxeof(struct bxe_fastpath *fp) fp->soft_rx_errors++; /* Reuse the mbuf for a new frame. */ - if (bxe_get_buf(fp, m, bd_prod)) { + if (bxe_get_buf(fp, m, rx_bd_prod_idx)) { DBPRINT(sc, BXE_FATAL, "%s(): Can't reuse RX mbuf!\n", __FUNCTION__); DBRUN(bxe_breakpoint(sc)); + + /* ToDo: Find alterntive to panic(). */ panic("bxe%d: Can't reuse RX mbuf!\n", sc->bxe_unit); } @@ -14885,7 +14911,8 @@ bxe_rxeof(struct bxe_fastpath *fp) */ /* Allocate a new mbuf for the receive chain. */ - if (__predict_false(bxe_get_buf(fp, NULL, bd_prod))) { + if (__predict_false(bxe_get_buf(fp, + NULL, rx_bd_prod_idx))) { /* * Drop the current frame if we can't get * a new mbuf. @@ -14897,12 +14924,11 @@ bxe_rxeof(struct bxe_fastpath *fp) * receive chain. */ if (__predict_false(bxe_get_buf(fp, m, - bd_prod))) { + rx_bd_prod_idx))) { /* This is really bad! */ DBPRINT(sc, BXE_FATAL, "%s(): Can't reuse RX mbuf!\n", __FUNCTION__); - DBRUN(bxe_breakpoint(sc)); /* ToDo: Find alterntive to panic(). */ @@ -14980,12 +15006,12 @@ bxe_rxeof(struct bxe_fastpath *fp) } /* Last chance to check for problems. */ - DBRUN(bxe_validate_rx_packet(fp, comp_ring_cons, cqe, - m)); + DBRUN(bxe_validate_rx_packet(fp, rx_cq_cons, cqe, m)); /* Pass the mbuf off to the upper layers. */ ifp->if_ipackets++; + /* ToDo: Any potential locking issues here? */ /* Pass the frame to the stack. */ (*ifp->if_input)(ifp, m); @@ -14993,14 +15019,13 @@ bxe_rxeof(struct bxe_fastpath *fp) } bxe_rxeof_next_rx: - bd_prod = NEXT_RX_BD(bd_prod); - bd_prod_fw = NEXT_RX_BD(bd_prod_fw); - bd_cons = NEXT_RX_BD(bd_cons); + rx_bd_prod = NEXT_RX_BD(rx_bd_prod); + rx_bd_cons = NEXT_RX_BD(rx_bd_cons); DBRUN(rx_pkts++); bxe_rxeof_next_cqe: - sw_comp_prod = NEXT_RCQ_IDX(sw_comp_prod); - sw_comp_cons_idx = NEXT_RCQ_IDX(sw_comp_cons_idx); + rx_cq_prod = NEXT_RCQ_IDX(rx_cq_prod); + rx_cq_cons = NEXT_RCQ_IDX(rx_cq_cons); /* * Memory barrier to prevent speculative reads of the RX buffer @@ -15010,18 +15035,19 @@ bxe_rxeof_next_cqe: } /* Update the driver copy of the fastpath indices. */ - fp->rx_bd_cons = bd_cons; - fp->rx_bd_prod = bd_prod_fw; - fp->rx_comp_cons = sw_comp_cons_idx; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@FreeBSD.ORG Thu Mar 31 22:50:56 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3655E106566B; Thu, 31 Mar 2011 22:50:56 +0000 (UTC) (envelope-from davidch@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 09E518FC0A; Thu, 31 Mar 2011 22:50:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VMotXr025178; Thu, 31 Mar 2011 22:50:55 GMT (envelope-from davidch@svn.freebsd.org) Received: (from davidch@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VMotq8025176; Thu, 31 Mar 2011 22:50:55 GMT (envelope-from davidch@svn.freebsd.org) Message-Id: <201103312250.p2VMotq8025176@svn.freebsd.org> From: David Christensen Date: Thu, 31 Mar 2011 22:50:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220230 - head/sys/dev/bxe X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 22:50:56 -0000 Author: davidch Date: Thu Mar 31 22:50:55 2011 New Revision: 220230 URL: http://svn.freebsd.org/changeset/base/220230 Log: - Fixed build problem when not useing BXE_DEBUG. MFC after: One week. Modified: head/sys/dev/bxe/if_bxe.c Modified: head/sys/dev/bxe/if_bxe.c ============================================================================== --- head/sys/dev/bxe/if_bxe.c Thu Mar 31 22:40:44 2011 (r220229) +++ head/sys/dev/bxe/if_bxe.c Thu Mar 31 22:50:55 2011 (r220230) @@ -15627,13 +15627,6 @@ bxe_add_sysctls(struct bxe_softc *sc) SYSCTL_CHILDREN(device_get_sysctl_tree(sc->bxe_dev)); struct bxe_eth_stats *estats = &sc->eth_stats; - struct sysctl_oid *queue_node; - struct sysctl_oid_list *queue_list; - -#define QUEUE_NAME_LEN 32 - char namebuf[QUEUE_NAME_LEN]; - - SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "estats_total_bytes_received_hi", CTLFLAG_RD, &estats->total_bytes_received_hi, @@ -15747,28 +15740,36 @@ bxe_add_sysctls(struct bxe_softc *sc) CTLFLAG_RD, &sc->mbuf_alloc_failed, 0, "mbuf cluster allocation failures"); - for (int i = 0; i < sc->num_queues; i++) { - struct bxe_fastpath *fp = &sc->fp[i]; - snprintf(namebuf, QUEUE_NAME_LEN, "fp[%02d]", i); - - queue_node = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, - namebuf, CTLFLAG_RD, NULL, "Queue Name"); - queue_list = SYSCTL_CHILDREN(queue_node); - - SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, - "mbuf_alloc_failed", - CTLFLAG_RD, &fp->mbuf_alloc_failed, - "Mbuf allocation failures"); - - SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, - "mbuf_defrag_attempts", - CTLFLAG_RD, &fp->mbuf_defrag_attempts, - "Mbuf defrag attempts"); - - SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, - "mbuf_defrag_successes", - CTLFLAG_RD, &fp->mbuf_defrag_successes, - "Mbuf defrag successes"); + do() { +#define QUEUE_NAME_LEN 32 + char namebuf[QUEUE_NAME_LEN]; + struct sysctl_oid *queue_node; + struct sysctl_oid_list *queue_list; + + for (int i = 0; i < sc->num_queues; i++) { + struct bxe_fastpath *fp = &sc->fp[i]; + snprintf(namebuf, QUEUE_NAME_LEN, "fp[%02d]", i); + + queue_node = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, + namebuf, CTLFLAG_RD, NULL, "Queue Name"); + queue_list = SYSCTL_CHILDREN(queue_node); + + SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, + "mbuf_alloc_failed", + CTLFLAG_RD, &fp->mbuf_alloc_failed, + "Mbuf allocation failures"); + + SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, + "mbuf_defrag_attempts", + CTLFLAG_RD, &fp->mbuf_defrag_attempts, + "Mbuf defrag attempts"); + + SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, + "mbuf_defrag_successes", + CTLFLAG_RD, &fp->mbuf_defrag_successes, + "Mbuf defrag successes"); + } + } SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "driver_state", From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 00:25:32 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BEC95106566B; Fri, 1 Apr 2011 00:25:32 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AE9D68FC13; Fri, 1 Apr 2011 00:25:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p310PWHq027053; Fri, 1 Apr 2011 00:25:32 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p310PWmC027051; Fri, 1 Apr 2011 00:25:32 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201104010025.p310PWmC027051@svn.freebsd.org> From: Navdeep Parhar Date: Fri, 1 Apr 2011 00:25:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220231 - in head/sys/modules/cxgbe: . if_cxgbe X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 00:25:32 -0000 Author: np Date: Fri Apr 1 00:25:32 2011 New Revision: 220231 URL: http://svn.freebsd.org/changeset/base/220231 Log: Allow multiple modules within sys/modules/cxgbe. The first one is if_cxgbe. MFC after: 3 days Added: head/sys/modules/cxgbe/if_cxgbe/ head/sys/modules/cxgbe/if_cxgbe/Makefile - copied, changed from r220221, head/sys/modules/cxgbe/Makefile Replaced: head/sys/modules/cxgbe/Makefile (contents, props changed) Added: head/sys/modules/cxgbe/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/cxgbe/Makefile Fri Apr 1 00:25:32 2011 (r220231) @@ -0,0 +1,7 @@ +# +# $FreeBSD$ +# + +SUBDIR = if_cxgbe + +.include Copied and modified: head/sys/modules/cxgbe/if_cxgbe/Makefile (from r220221, head/sys/modules/cxgbe/Makefile) ============================================================================== --- head/sys/modules/cxgbe/Makefile Thu Mar 31 18:35:44 2011 (r220221, copy source) +++ head/sys/modules/cxgbe/if_cxgbe/Makefile Fri Apr 1 00:25:32 2011 (r220231) @@ -2,7 +2,7 @@ # $FreeBSD$ # -CXGBE = ${.CURDIR}/../../dev/cxgbe +CXGBE = ${.CURDIR}/../../../dev/cxgbe .PATH: ${CXGBE} ${CXGBE}/common KMOD = if_cxgbe @@ -11,6 +11,6 @@ SRCS+= t4_hw.c SRCS+= device_if.h bus_if.h pci_if.h SRCS+= opt_inet.h -CFLAGS+= -g -I${CXGBE} +CFLAGS+= -I${CXGBE} .include From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 00:40:25 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 32759106564A; Fri, 1 Apr 2011 00:40:25 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 22D348FC0A; Fri, 1 Apr 2011 00:40:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p310ePb7027409; Fri, 1 Apr 2011 00:40:25 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p310ePWM027405; Fri, 1 Apr 2011 00:40:25 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201104010040.p310ePWM027405@svn.freebsd.org> From: Navdeep Parhar Date: Fri, 1 Apr 2011 00:40:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220232 - in head/sys/dev/cxgbe: . common X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 00:40:25 -0000 Author: np Date: Fri Apr 1 00:40:24 2011 New Revision: 220232 URL: http://svn.freebsd.org/changeset/base/220232 Log: Update header and related code for firmware 1.3.8 MFC after: 3 days Modified: head/sys/dev/cxgbe/common/common.h head/sys/dev/cxgbe/common/t4fw_interface.h head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/common/common.h ============================================================================== --- head/sys/dev/cxgbe/common/common.h Fri Apr 1 00:25:32 2011 (r220231) +++ head/sys/dev/cxgbe/common/common.h Fri Apr 1 00:40:24 2011 (r220232) @@ -54,7 +54,7 @@ enum { #define FW_VERSION_MAJOR 1 #define FW_VERSION_MINOR 3 -#define FW_VERSION_MICRO 0 +#define FW_VERSION_MICRO 8 struct port_stats { u64 tx_octets; /* total # of octets in good frames */ Modified: head/sys/dev/cxgbe/common/t4fw_interface.h ============================================================================== --- head/sys/dev/cxgbe/common/t4fw_interface.h Fri Apr 1 00:25:32 2011 (r220231) +++ head/sys/dev/cxgbe/common/t4fw_interface.h Fri Apr 1 00:40:24 2011 (r220232) @@ -47,7 +47,7 @@ enum fw_retval { FW_ENOSYS = 38, /* functionality not implemented */ FW_EPROTO = 71, /* protocol error */ FW_ETIMEDOUT = 110, /* timeout */ - FW_TIMEDOUT = 110, /* timeout */ + FW_EINPROGRESS = 115, /* fw internal */ FW_SCSI_ABORT_REQUESTED = 128, /* */ FW_SCSI_ABORT_TIMEDOUT = 129, /* */ FW_SCSI_ABORTED = 130, /* */ @@ -3934,13 +3934,11 @@ enum fw_port_cap { FW_PORT_CAP_FC_RX = 0x0040, FW_PORT_CAP_FC_TX = 0x0080, FW_PORT_CAP_ANEG = 0x0100, - FW_PORT_CAP_MDI_0 = 0x0200, - FW_PORT_CAP_MDI_1 = 0x0400, - FW_PORT_CAP_BEAN = 0x0800, - FW_PORT_CAP_PMA_LPBK = 0x1000, - FW_PORT_CAP_PCS_LPBK = 0x2000, - FW_PORT_CAP_PHYXS_LPBK = 0x4000, - FW_PORT_CAP_FAR_END_LPBK = 0x8000, + FW_PORT_CAP_MDIX = 0x0200, + FW_PORT_CAP_MDIAUTO = 0x0400, + FW_PORT_CAP_FEC = 0x0800, + FW_PORT_CAP_TECHKR = 0x1000, + FW_PORT_CAP_TECHKX4 = 0x2000, }; #define S_FW_PORT_CAP_SPEED 0 @@ -3955,6 +3953,12 @@ enum fw_port_cap { #define G_FW_PORT_CAP_FC(x) \ (((x) >> S_FW_PORT_CAP_FC) & M_FW_PORT_CAP_FC) +#define S_FW_PORT_CAP_ANEG 8 +#define M_FW_PORT_CAP_ANEG 0x1 +#define V_FW_PORT_CAP_ANEG(x) ((x) << S_FW_PORT_CAP_ANEG) +#define G_FW_PORT_CAP_ANEG(x) \ + (((x) >> S_FW_PORT_CAP_ANEG) & M_FW_PORT_CAP_ANEG) + enum fw_port_mdi { FW_PORT_CAP_MDI_UNCHANGED, FW_PORT_CAP_MDI_AUTO, @@ -4253,16 +4257,16 @@ enum fw_port_type { /* These are read from module's EEPROM and determined once the module is inserted. */ enum fw_port_module_type { - FW_PORT_MOD_TYPE_NA, - FW_PORT_MOD_TYPE_LR = 0x1, - FW_PORT_MOD_TYPE_SR = 0x2, - FW_PORT_MOD_TYPE_ER = 0x3, - FW_PORT_MOD_TYPE_TWINAX_PASSIVE = 0x4, - FW_PORT_MOD_TYPE_TWINAX_ACTIVE = 0x5, - - FW_PORT_MOD_TYPE_LRM = 0x6, - - FW_PORT_MOD_TYPE_NONE = M_FW_PORT_CMD_MODTYPE + FW_PORT_MOD_TYPE_NA = 0x0, + FW_PORT_MOD_TYPE_LR = 0x1, + FW_PORT_MOD_TYPE_SR = 0x2, + FW_PORT_MOD_TYPE_ER = 0x3, + FW_PORT_MOD_TYPE_TWINAX_PASSIVE = 0x4, + FW_PORT_MOD_TYPE_TWINAX_ACTIVE = 0x5, + FW_PORT_MOD_TYPE_LRM = 0x6, + FW_PORT_MOD_TYPE_UNKNOWN = M_FW_PORT_CMD_MODTYPE - 2, + FW_PORT_MOD_TYPE_NOTSUPPORTED = M_FW_PORT_CMD_MODTYPE - 1, + FW_PORT_MOD_TYPE_NONE = M_FW_PORT_CMD_MODTYPE }; /* used by FW and tools may use this to generate VPD */ Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Fri Apr 1 00:25:32 2011 (r220231) +++ head/sys/dev/cxgbe/t4_main.c Fri Apr 1 00:40:24 2011 (r220232) @@ -2748,11 +2748,15 @@ t4_os_portmod_changed(const struct adapt { struct port_info *pi = sc->port[idx]; static const char *mod_str[] = { - NULL, "LR", "SR", "ER", "TWINAX", "active TWINAX" + NULL, "LR", "SR", "ER", "TWINAX", "active TWINAX", "LRM" }; if (pi->mod_type == FW_PORT_MOD_TYPE_NONE) if_printf(pi->ifp, "transceiver unplugged.\n"); + else if (pi->mod_type == FW_PORT_MOD_TYPE_UNKNOWN) + if_printf(pi->ifp, "unknown transceiver inserted.\n"); + else if (pi->mod_type == FW_PORT_MOD_TYPE_NOTSUPPORTED) + if_printf(pi->ifp, "unsupported transceiver inserted.\n"); else if (pi->mod_type > 0 && pi->mod_type < ARRAY_SIZE(mod_str)) { if_printf(pi->ifp, "%s transceiver inserted.\n", mod_str[pi->mod_type]); From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 01:13:30 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9A80A106564A; Fri, 1 Apr 2011 01:13:30 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8C1FC8FC0C; Fri, 1 Apr 2011 01:13:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p311DULS028117; Fri, 1 Apr 2011 01:13:30 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p311DUBx028115; Fri, 1 Apr 2011 01:13:30 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201104010113.p311DUBx028115@svn.freebsd.org> From: Ed Maste Date: Fri, 1 Apr 2011 01:13:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220233 - head/share/examples X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 01:13:30 -0000 Author: emaste Date: Fri Apr 1 01:13:30 2011 New Revision: 220233 URL: http://svn.freebsd.org/changeset/base/220233 Log: Unbreak installworld after r220205. Noticed by: np Pointy hat to: emaste Modified: head/share/examples/Makefile Modified: head/share/examples/Makefile ============================================================================== --- head/share/examples/Makefile Fri Apr 1 00:40:24 2011 (r220232) +++ head/share/examples/Makefile Fri Apr 1 01:13:30 2011 (r220233) @@ -99,7 +99,7 @@ XFILES= BSD_daemon/FreeBSD.pfa \ kld/firmware/fwconsumer/Makefile \ kld/firmware/fwconsumer/fw_consumer.c \ kld/firmware/fwimage/Makefile \ - kld/firmware/fwimage/firmware.img \ + kld/firmware/fwimage/firmware.img.in \ kld/khelp/Makefile \ kld/khelp/README \ kld/khelp/h_example.c \ From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 01:30:21 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 86A1C106564A; Fri, 1 Apr 2011 01:30:21 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 78CB08FC0A; Fri, 1 Apr 2011 01:30:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p311UL3Z028468; Fri, 1 Apr 2011 01:30:21 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p311ULsE028466; Fri, 1 Apr 2011 01:30:21 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201104010130.p311ULsE028466@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 1 Apr 2011 01:30:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220234 - head/sys/dev/bxe X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 01:30:21 -0000 Author: yongari Date: Fri Apr 1 01:30:21 2011 New Revision: 220234 URL: http://svn.freebsd.org/changeset/base/220234 Log: Make bxe(4) build with BXE_DEBUG. Modified: head/sys/dev/bxe/if_bxe.c Modified: head/sys/dev/bxe/if_bxe.c ============================================================================== --- head/sys/dev/bxe/if_bxe.c Fri Apr 1 01:13:30 2011 (r220233) +++ head/sys/dev/bxe/if_bxe.c Fri Apr 1 01:30:21 2011 (r220234) @@ -15740,7 +15740,7 @@ bxe_add_sysctls(struct bxe_softc *sc) CTLFLAG_RD, &sc->mbuf_alloc_failed, 0, "mbuf cluster allocation failures"); - do() { + do { #define QUEUE_NAME_LEN 32 char namebuf[QUEUE_NAME_LEN]; struct sysctl_oid *queue_node; @@ -15770,7 +15770,7 @@ bxe_add_sysctls(struct bxe_softc *sc) "Mbuf defrag successes"); } - } + } while (0); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "driver_state", CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 03:27:55 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73CB91065673; Fri, 1 Apr 2011 03:27:55 +0000 (UTC) (envelope-from kevlo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6481E8FC08; Fri, 1 Apr 2011 03:27:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p313RtFE031140; Fri, 1 Apr 2011 03:27:55 GMT (envelope-from kevlo@svn.freebsd.org) Received: (from kevlo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p313Rtqg031138; Fri, 1 Apr 2011 03:27:55 GMT (envelope-from kevlo@svn.freebsd.org) Message-Id: <201104010327.p313Rtqg031138@svn.freebsd.org> From: Kevin Lo Date: Fri, 1 Apr 2011 03:27:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220235 - head/sys/dev/usb/wlan X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 03:27:55 -0000 Author: kevlo Date: Fri Apr 1 03:27:55 2011 New Revision: 220235 URL: http://svn.freebsd.org/changeset/base/220235 Log: - Minor style(9) cleanup - Make functions static Modified: head/sys/dev/usb/wlan/if_run.c Modified: head/sys/dev/usb/wlan/if_run.c ============================================================================== --- head/sys/dev/usb/wlan/if_run.c Fri Apr 1 01:30:21 2011 (r220234) +++ head/sys/dev/usb/wlan/if_run.c Fri Apr 1 03:27:55 2011 (r220235) @@ -71,8 +71,8 @@ __FBSDID("$FreeBSD$"); #define USB_DEBUG_VAR run_debug #include -#include "if_runreg.h" -#include "if_runvar.h" +#include +#include #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) @@ -523,7 +523,7 @@ static const struct usb_config run_confi } }; -int +static int run_match(device_t self) { struct usb_attach_arg *uaa = device_get_ivars(self); @@ -604,7 +604,7 @@ run_attach(device_t self) RUN_UNLOCK(sc); ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211); - if(ifp == NULL){ + if (ifp == NULL) { device_printf(sc->sc_dev, "can not if_alloc()\n"); goto detach; } @@ -958,7 +958,7 @@ run_unsetup_tx_list(struct run_softc *sc } } -int +static int run_load_microcode(struct run_softc *sc) { usb_device_request_t req; @@ -1018,7 +1018,8 @@ run_load_microcode(struct run_softc *sc) USETW(req.wValue, 8); USETW(req.wIndex, 0); USETW(req.wLength, 0); - if ((error = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL)) != 0) { + if ((error = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL)) + != 0) { device_printf(sc->sc_dev, "firmware reset failed\n"); goto fail; } From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 03:41:41 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E091D106568A; Fri, 1 Apr 2011 03:41:41 +0000 (UTC) (envelope-from kevlo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D0D358FC2F; Fri, 1 Apr 2011 03:41:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p313ff8w031490; Fri, 1 Apr 2011 03:41:41 GMT (envelope-from kevlo@svn.freebsd.org) Received: (from kevlo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p313ffVC031488; Fri, 1 Apr 2011 03:41:41 GMT (envelope-from kevlo@svn.freebsd.org) Message-Id: <201104010341.p313ffVC031488@svn.freebsd.org> From: Kevin Lo Date: Fri, 1 Apr 2011 03:41:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220236 - head/sys/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 03:41:42 -0000 Author: kevlo Date: Fri Apr 1 03:41:41 2011 New Revision: 220236 URL: http://svn.freebsd.org/changeset/base/220236 Log: Add 'mos' interface to NOTES Modified: head/sys/conf/NOTES Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Fri Apr 1 03:27:55 2011 (r220235) +++ head/sys/conf/NOTES Fri Apr 1 03:41:41 2011 (r220236) @@ -2711,6 +2711,9 @@ device rue # Davicom DM9601E USB to fast ethernet. Supports the Corega FEther USB-TXC. device udav # +# Moschip MCS7730/MCS7840 USB to fast ethernet. Supports the Sitecom LN030. +device mos +# # HSxPA devices from Option N.V device uhso From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 06:28:21 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9BC431065677; Fri, 1 Apr 2011 06:28:21 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 88D598FC1C; Fri, 1 Apr 2011 06:28:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p316SLfX034953; Fri, 1 Apr 2011 06:28:21 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p316SLEp034951; Fri, 1 Apr 2011 06:28:21 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201104010628.p316SLEp034951@svn.freebsd.org> From: Lawrence Stewart Date: Fri, 1 Apr 2011 06:28:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220237 - head/share/man/man4 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 06:28:21 -0000 Author: lstewart Date: Fri Apr 1 06:28:21 2011 New Revision: 220237 URL: http://svn.freebsd.org/changeset/base/220237 Log: Add a missing .El macro. Modified: head/share/man/man4/cc_chd.4 Modified: head/share/man/man4/cc_chd.4 ============================================================================== --- head/share/man/man4/cc_chd.4 Fri Apr 1 03:41:41 2011 (r220236) +++ head/share/man/man4/cc_chd.4 Fri Apr 1 06:28:21 2011 (r220237) @@ -58,6 +58,7 @@ do not cause cwnd to be reduced. .It CHD uses a shadow window to help regain lost transmission opportunities when competing with loss-based TCP flows. +.El .Sh MIB Variables The algorithm exposes the following tunable variables in the .Va net.inet.tcp.cc.chd From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 10:19:07 2011 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4EC41106566B; Fri, 1 Apr 2011 10:19:07 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 2E1288FC08; Fri, 1 Apr 2011 10:19:05 +0000 (UTC) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id NAA22892; Fri, 01 Apr 2011 13:19:04 +0300 (EEST) (envelope-from avg@FreeBSD.org) Message-ID: <4D95A697.3050009@FreeBSD.org> Date: Fri, 01 Apr 2011 13:19:03 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.15) Gecko/20110309 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: Subject: svn commit r220401- in head: lib/libc/gen sys/kern sys/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 10:19:07 -0000 Author: avg Date: Fri Apr 1 07:28:21 2011 New Revision: 220401 URL: http://svn.freebsd.org/changeset/base/220401 Log: errno: add a new error code EDAVE This error code should be used when a system, having a superior knowledge of its state and environment, has to deny a user action. Introduce the first usage of the new error code in vfs unmount to deny unmounting of root filesystem. Inspired by: 2001: The Space Odyssey Inspired by: GDB 7 Inspired by: EDOOFUS MFC after: Apr 1 2012 Modified: lib/libc/gen/errlst.c sys/kern/vfs_mount.c sys/sys/errno.h Modified: lib/libc/gen/errlst.c =================================================================== --- lib/libc/gen/errlst.c (revision 220181) +++ lib/libc/gen/errlst.c (working copy) @@ -152,5 +152,6 @@ const char *const sys_errlist[] = { "Protocol error", /* 92 - EPROTO */ "Capabilities insufficient", /* 93 - ENOTCAPABLE */ "Not permitted in capability mode", /* 94 - ECAPMODE */ + "I'm sorry Dave, I'm afraid I can't do that", /* 95 - EDAVE */ }; const int sys_nerr = sizeof(sys_errlist) / sizeof(sys_errlist[0]); Modified: sys/kern/vfs_mount.c =================================================================== --- sys/kern/vfs_mount.c (revision 220181) +++ sys/kern/vfs_mount.c (working copy) @@ -1206,7 +1206,7 @@ unmount(td, uap) */ if (mp->mnt_flag & MNT_ROOTFS) { mtx_unlock(&Giant); - return (EINVAL); + return (EDAVE); } error = dounmount(mp, uap->flags, td); mtx_unlock(&Giant); Modified: sys/sys/errno.h =================================================================== --- sys/sys/errno.h (revision 220181) +++ sys/sys/errno.h (working copy) @@ -175,13 +175,17 @@ __END_DECLS #ifndef _POSIX_SOURCE #define ENOTCAPABLE 93 /* Capabilities insufficient */ -#define ECAPMODE 94 /* Not permitted in capability mode */ +#define ECAPMODE 94 /* Not permitted in capability mode */ #endif /* _POSIX_SOURCE */ #ifndef _POSIX_SOURCE -#define ELAST 94 /* Must be equal largest errno */ +#define EDAVE 95 /* I'm sorry Dave, I'm afraid I can't do that. */ #endif /* _POSIX_SOURCE */ +#ifndef _POSIX_SOURCE +#define ELAST 95 /* Must be equal largest errno */ +#endif /* _POSIX_SOURCE */ + #ifdef _KERNEL /* pseudo-errors returned inside kernel to modify return to process */ #define ERESTART (-1) /* restart syscall */ From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 10:29:43 2011 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE9EB106566B; Fri, 1 Apr 2011 10:29:43 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 909968FC08; Fri, 1 Apr 2011 10:29:43 +0000 (UTC) Received: from 63.imp.bsdimp.com (63.imp.bsdimp.com [10.0.0.63]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id p31ARp4V027916 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Fri, 1 Apr 2011 04:27:51 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <4D95A697.3050009@FreeBSD.org> Date: Fri, 1 Apr 2011 04:27:50 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <789C49A1-A444-4594-9BD7-AC5E70752BB7@bsdimp.com> References: <4D95A697.3050009@FreeBSD.org> To: Andriy Gapon X-Mailer: Apple Mail (2.1082) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Fri, 01 Apr 2011 04:27:51 -0600 (MDT) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit r220401- in head: lib/libc/gen sys/kern sys/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 10:29:44 -0000 Great commit. Just one nit. See below... On Apr 1, 2011, at 4:19 AM, Andriy Gapon wrote: > --- sys/sys/errno.h (revision 220181) > +++ sys/sys/errno.h (working copy) > @@ -175,13 +175,17 @@ __END_DECLS >=20 > #ifndef _POSIX_SOURCE > #define ENOTCAPABLE 93 /* Capabilities = insufficient */ > -#define ECAPMODE 94 /* Not permitted = in capability mode */ > +#define ECAPMODE 94 /* Not permitted in = capability mode */ > #endif /* _POSIX_SOURCE */ You really shouldn't mix functional changes with white-space changes = like this. Warner From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 10:36:23 2011 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA4851065672; Fri, 1 Apr 2011 10:36:23 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id AC0498FC08; Fri, 1 Apr 2011 10:36:22 +0000 (UTC) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id NAA23187; Fri, 01 Apr 2011 13:36:16 +0300 (EEST) (envelope-from avg@FreeBSD.org) Message-ID: <4D95AAA0.6010904@FreeBSD.org> Date: Fri, 01 Apr 2011 13:36:16 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.15) Gecko/20110309 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: Warner Losh References: <4D95A697.3050009@FreeBSD.org> <789C49A1-A444-4594-9BD7-AC5E70752BB7@bsdimp.com> In-Reply-To: <789C49A1-A444-4594-9BD7-AC5E70752BB7@bsdimp.com> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit r220401- in head: lib/libc/gen sys/kern sys/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 10:36:23 -0000 on 01/04/2011 13:27 Warner Losh said the following: > Great commit. Just one nit. See below... > > > On Apr 1, 2011, at 4:19 AM, Andriy Gapon wrote: >> --- sys/sys/errno.h (revision 220181) >> +++ sys/sys/errno.h (working copy) >> @@ -175,13 +175,17 @@ __END_DECLS >> >> #ifndef _POSIX_SOURCE >> #define ENOTCAPABLE 93 /* Capabilities insufficient */ >> -#define ECAPMODE 94 /* Not permitted in capability mode */ >> +#define ECAPMODE 94 /* Not permitted in capability mode */ >> #endif /* _POSIX_SOURCE */ > > You really shouldn't mix functional changes with white-space changes like this. Oops, sorry, that was meant to be a separate commit. -- Andriy Gapon From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 11:16:31 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D5371065670; Fri, 1 Apr 2011 11:16:30 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1B9198FC08; Fri, 1 Apr 2011 11:16:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31BGUcp042331; Fri, 1 Apr 2011 11:16:30 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31BGTx4042314; Fri, 1 Apr 2011 11:16:29 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011116.p31BGTx4042314@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 11:16:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220238 - in head/sys: amd64/ia32 compat/freebsd32 compat/ia32 ia64/ia32 kern modules sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 11:16:31 -0000 Author: kib Date: Fri Apr 1 11:16:29 2011 New Revision: 220238 URL: http://svn.freebsd.org/changeset/base/220238 Log: Add support for executing the FreeBSD 1/i386 a.out binaries on amd64. In particular: - implement compat shims for old stat(2) variants and ogetdirentries(2); - implement delivery of signals with ancient stack frame layout and corresponding sigreturn(2); - implement old getpagesize(2); - provide a user-mode trampoline and LDT call gate for lcall $7,$0; - port a.out image activator and connect it to the build as a module on amd64. The changes are hidden under COMPAT_43. MFC after: 1 month Modified: head/sys/amd64/ia32/ia32_misc.c head/sys/amd64/ia32/ia32_signal.c head/sys/amd64/ia32/ia32_sigtramp.S head/sys/amd64/ia32/ia32_syscall.c head/sys/compat/freebsd32/freebsd32_misc.c head/sys/compat/freebsd32/syscalls.master head/sys/compat/ia32/ia32_genassym.c head/sys/compat/ia32/ia32_signal.h head/sys/compat/ia32/ia32_sysvec.c head/sys/compat/ia32/ia32_util.h head/sys/ia64/ia32/ia32_misc.c head/sys/ia64/ia32/ia32_signal.c head/sys/kern/imgact_aout.c head/sys/kern/vfs_syscalls.c head/sys/modules/Makefile head/sys/sys/syscallsubr.h Modified: head/sys/amd64/ia32/ia32_misc.c ============================================================================== --- head/sys/amd64/ia32/ia32_misc.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/amd64/ia32/ia32_misc.c Fri Apr 1 11:16:29 2011 (r220238) @@ -69,3 +69,14 @@ freebsd32_sysarch(struct thread *td, str return (sysarch(td, &uap1)); } } + +#ifdef COMPAT_43 +int +ofreebsd32_getpagesize(struct thread *td, + struct ofreebsd32_getpagesize_args *uap) +{ + + td->td_retval[0] = IA32_PAGE_SIZE; + return (0); +} +#endif Modified: head/sys/amd64/ia32/ia32_signal.c ============================================================================== --- head/sys/amd64/ia32/ia32_signal.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/amd64/ia32/ia32_signal.c Fri Apr 1 11:16:29 2011 (r220238) @@ -300,6 +300,109 @@ freebsd32_swapcontext(struct thread *td, * frame pointer, it returns to the user * specified pc, psl. */ + +#ifdef COMPAT_43 +static void +ia32_osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) +{ + struct ia32_sigframe3 sf, *fp; + struct proc *p; + struct thread *td; + struct sigacts *psp; + struct trapframe *regs; + int sig; + int oonstack; + + td = curthread; + p = td->td_proc; + PROC_LOCK_ASSERT(p, MA_OWNED); + sig = ksi->ksi_signo; + psp = p->p_sigacts; + mtx_assert(&psp->ps_mtx, MA_OWNED); + regs = td->td_frame; + oonstack = sigonstack(regs->tf_rsp); + + /* Allocate space for the signal handler context. */ + if ((td->td_pflags & TDP_ALTSTACK) && !oonstack && + SIGISMEMBER(psp->ps_sigonstack, sig)) { + fp = (struct ia32_sigframe3 *)(td->td_sigstk.ss_sp + + td->td_sigstk.ss_size - sizeof(sf)); + td->td_sigstk.ss_flags |= SS_ONSTACK; + } else + fp = (struct ia32_sigframe3 *)regs->tf_rsp - 1; + + /* Translate the signal if appropriate. */ + if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize) + sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; + + /* Build the argument list for the signal handler. */ + sf.sf_signum = sig; + sf.sf_scp = (register_t)&fp->sf_siginfo.si_sc; + if (SIGISMEMBER(psp->ps_siginfo, sig)) { + /* Signal handler installed with SA_SIGINFO. */ + sf.sf_arg2 = (register_t)&fp->sf_siginfo; + sf.sf_siginfo.si_signo = sig; + sf.sf_siginfo.si_code = ksi->ksi_code; + sf.sf_ah = (uintptr_t)catcher; + } else { + /* Old FreeBSD-style arguments. */ + sf.sf_arg2 = ksi->ksi_code; + sf.sf_addr = (register_t)ksi->ksi_addr; + sf.sf_ah = (uintptr_t)catcher; + } + mtx_unlock(&psp->ps_mtx); + PROC_UNLOCK(p); + + /* Save most if not all of trap frame. */ + sf.sf_siginfo.si_sc.sc_eax = regs->tf_rax; + sf.sf_siginfo.si_sc.sc_ebx = regs->tf_rbx; + sf.sf_siginfo.si_sc.sc_ecx = regs->tf_rcx; + sf.sf_siginfo.si_sc.sc_edx = regs->tf_rdx; + sf.sf_siginfo.si_sc.sc_esi = regs->tf_rsi; + sf.sf_siginfo.si_sc.sc_edi = regs->tf_rdi; + sf.sf_siginfo.si_sc.sc_cs = regs->tf_cs; + sf.sf_siginfo.si_sc.sc_ds = regs->tf_ds; + sf.sf_siginfo.si_sc.sc_ss = regs->tf_ss; + sf.sf_siginfo.si_sc.sc_es = regs->tf_es; + sf.sf_siginfo.si_sc.sc_fs = regs->tf_fs; + sf.sf_siginfo.si_sc.sc_gs = regs->tf_gs; + sf.sf_siginfo.si_sc.sc_isp = regs->tf_rsp; + + /* Build the signal context to be used by osigreturn(). */ + sf.sf_siginfo.si_sc.sc_onstack = (oonstack) ? 1 : 0; + SIG2OSIG(*mask, sf.sf_siginfo.si_sc.sc_mask); + sf.sf_siginfo.si_sc.sc_esp = regs->tf_rsp; + sf.sf_siginfo.si_sc.sc_ebp = regs->tf_rbp; + sf.sf_siginfo.si_sc.sc_eip = regs->tf_rip; + sf.sf_siginfo.si_sc.sc_eflags = regs->tf_rflags; + sf.sf_siginfo.si_sc.sc_trapno = regs->tf_trapno; + sf.sf_siginfo.si_sc.sc_err = regs->tf_err; + + /* + * Copy the sigframe out to the user's stack. + */ + if (copyout(&sf, fp, sizeof(*fp)) != 0) { +#ifdef DEBUG + printf("process %ld has trashed its stack\n", (long)p->p_pid); +#endif + PROC_LOCK(p); + sigexit(td, SIGILL); + } + + regs->tf_rsp = (uintptr_t)fp; + regs->tf_rip = p->p_sysent->sv_psstrings - sz_ia32_osigcode; + regs->tf_rflags &= ~(PSL_T | PSL_D); + regs->tf_cs = _ucode32sel; + regs->tf_ds = _udatasel; + regs->tf_es = _udatasel; + regs->tf_fs = _udatasel; + regs->tf_ss = _udatasel; + set_pcb_flags(td->td_pcb, PCB_FULL_IRET); + PROC_LOCK(p); + mtx_lock(&psp->ps_mtx); +} +#endif + #ifdef COMPAT_FREEBSD4 static void freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) @@ -441,6 +544,12 @@ ia32_sendsig(sig_t catcher, ksiginfo_t * return; } #endif +#ifdef COMPAT_43 + if (SIGISMEMBER(psp->ps_osigset, sig)) { + ia32_osendsig(catcher, ksi, mask); + return; + } +#endif mtx_assert(&psp->ps_mtx, MA_OWNED); regs = td->td_frame; oonstack = sigonstack(regs->tf_rsp); @@ -547,6 +656,64 @@ ia32_sendsig(sig_t catcher, ksiginfo_t * * make sure that the user has not modified the * state to gain improper privileges. */ + +#ifdef COMPAT_43 +int +ofreebsd32_sigreturn(struct thread *td, struct ofreebsd32_sigreturn_args *uap) +{ + struct ia32_sigcontext3 sc, *scp; + struct trapframe *regs; + int eflags, error; + ksiginfo_t ksi; + + regs = td->td_frame; + error = copyin(uap->sigcntxp, &sc, sizeof(sc)); + if (error != 0) + return (error); + scp = ≻ + eflags = scp->sc_eflags; + if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_rflags & ~PSL_RF)) { + return (EINVAL); + } + if (!CS_SECURE(scp->sc_cs)) { + ksiginfo_init_trap(&ksi); + ksi.ksi_signo = SIGBUS; + ksi.ksi_code = BUS_OBJERR; + ksi.ksi_trapno = T_PROTFLT; + ksi.ksi_addr = (void *)regs->tf_rip; + trapsignal(td, &ksi); + return (EINVAL); + } + regs->tf_ds = scp->sc_ds; + regs->tf_es = scp->sc_es; + regs->tf_fs = scp->sc_fs; + regs->tf_gs = scp->sc_gs; + + regs->tf_rax = scp->sc_eax; + regs->tf_rbx = scp->sc_ebx; + regs->tf_rcx = scp->sc_ecx; + regs->tf_rdx = scp->sc_edx; + regs->tf_rsi = scp->sc_esi; + regs->tf_rdi = scp->sc_edi; + regs->tf_cs = scp->sc_cs; + regs->tf_ss = scp->sc_ss; + regs->tf_rbp = scp->sc_ebp; + regs->tf_rsp = scp->sc_esp; + regs->tf_rip = scp->sc_eip; + regs->tf_rflags = eflags; + + if (scp->sc_onstack & 1) + td->td_sigstk.ss_flags |= SS_ONSTACK; + else + td->td_sigstk.ss_flags &= ~SS_ONSTACK; + + kern_sigprocmask(td, SIG_SETMASK, (sigset_t *)&scp->sc_mask, NULL, + SIGPROCMASK_OLD); + set_pcb_flags(td->td_pcb, PCB_FULL_IRET); + return (EJUSTRETURN); +} +#endif + #ifdef COMPAT_FREEBSD4 /* * MPSAFE @@ -734,6 +901,9 @@ ia32_setregs(struct thread *td, struct i user_ldt_free(td); else mtx_unlock(&dt_lock); +#ifdef COMPAT_43 + setup_lcall_gate(); +#endif pcb->pcb_fsbase = 0; pcb->pcb_gsbase = 0; Modified: head/sys/amd64/ia32/ia32_sigtramp.S ============================================================================== --- head/sys/amd64/ia32/ia32_sigtramp.S Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/amd64/ia32/ia32_sigtramp.S Fri Apr 1 11:16:29 2011 (r220238) @@ -66,6 +66,35 @@ freebsd4_ia32_sigcode: jmp 1b #endif +#ifdef COMPAT_43 + ALIGN_TEXT +ia32_osigcode: + calll *IA32_SIGF_HANDLER(%esp)/* call signal handler */ + leal IA32_SIGF_SC(%esp),%eax /* get sigcontext */ + pushl %eax + movl $103,%eax /* 3.x SYS_sigreturn */ + pushl %eax /* junk to fake return addr. */ + int $0x80 /* enter kernel with args */ +1: + jmp 1b + + + ALIGN_TEXT +lcall_tramp: + pushl %ebp + movl %esp,%ebp + pushl 0x24(%ebp) /* arg 6 */ + pushl 0x20(%ebp) + pushl 0x1c(%ebp) + pushl 0x18(%ebp) + pushl 0x14(%ebp) + pushl 0x10(%ebp) /* arg 1 */ + pushl 0xc(%ebp) /* gap */ + int $0x80 + leave + lretl +#endif + ALIGN_TEXT esigcode: @@ -78,3 +107,11 @@ sz_ia32_sigcode: sz_freebsd4_ia32_sigcode: .long esigcode-freebsd4_ia32_sigcode #endif +#ifdef COMPAT_43 + .globl sz_ia32_osigcode +sz_ia32_osigcode: + .long esigcode-ia32_osigcode + .globl sz_lcall_tramp +sz_lcall_tramp: + .long esigcode-lcall_tramp +#endif Modified: head/sys/amd64/ia32/ia32_syscall.c ============================================================================== --- head/sys/amd64/ia32/ia32_syscall.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/amd64/ia32/ia32_syscall.c Fri Apr 1 11:16:29 2011 (r220238) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); */ #include "opt_clock.h" +#include "opt_compat.h" #include "opt_cpu.h" #include "opt_isa.h" @@ -78,7 +79,17 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define IDTVEC(name) __CONCAT(X,name) @@ -198,3 +209,45 @@ ia32_syscall_disable(void *dummy) SYSINIT(ia32_syscall, SI_SUB_EXEC, SI_ORDER_ANY, ia32_syscall_enable, NULL); SYSUNINIT(ia32_syscall, SI_SUB_EXEC, SI_ORDER_ANY, ia32_syscall_disable, NULL); + +#ifdef COMPAT_43 +int +setup_lcall_gate(void) +{ + struct i386_ldt_args uap; + struct user_segment_descriptor descs[2]; + struct gate_descriptor *ssd; + uint32_t lcall_addr; + int error; + + bzero(&uap, sizeof(uap)); + uap.start = 0; + uap.num = 2; + + /* + * This is the easiest way to cut the space for system + * descriptor in ldt. Manually adjust the descriptor type to + * the call gate later. + */ + bzero(&descs[0], sizeof(descs)); + descs[0].sd_type = SDT_SYSNULL; + descs[1].sd_type = SDT_SYSNULL; + error = amd64_set_ldt(curthread, &uap, descs); + if (error != 0) + return (error); + + lcall_addr = curproc->p_sysent->sv_psstrings - sz_lcall_tramp; + mtx_lock(&dt_lock); + ssd = (struct gate_descriptor *)(curproc->p_md.md_ldt->ldt_base); + bzero(ssd, sizeof(*ssd)); + ssd->gd_looffset = lcall_addr; + ssd->gd_hioffset = lcall_addr >> 16; + ssd->gd_selector = _ucode32sel; + ssd->gd_type = SDT_SYSCGT; + ssd->gd_dpl = SEL_UPL; + ssd->gd_p = 1; + mtx_unlock(&dt_lock); + + return (0); +} +#endif Modified: head/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_misc.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/compat/freebsd32/freebsd32_misc.c Fri Apr 1 11:16:29 2011 (r220238) @@ -1454,6 +1454,29 @@ freebsd32_ftruncate(struct thread *td, s return (ftruncate(td, &ap)); } +#ifdef COMPAT_43 +int +ofreebsd32_getdirentries(struct thread *td, + struct ofreebsd32_getdirentries_args *uap) +{ + struct ogetdirentries_args ap; + int error; + long loff; + int32_t loff_cut; + + ap.fd = uap->fd; + ap.buf = uap->buf; + ap.count = uap->count; + ap.basep = NULL; + error = kern_ogetdirentries(td, &ap, &loff); + if (error == 0) { + loff_cut = loff; + error = copyout(&loff_cut, uap->basep, sizeof(int32_t)); + } + return (error); +} +#endif + int freebsd32_getdirentries(struct thread *td, struct freebsd32_getdirentries_args *uap) @@ -1638,6 +1661,29 @@ copy_stat(struct stat *in, struct stat32 TS_CP(*in, *out, st_birthtim); } +#ifdef COMPAT_43 +static void +copy_ostat(struct stat *in, struct ostat32 *out) +{ + + CP(*in, *out, st_dev); + CP(*in, *out, st_ino); + CP(*in, *out, st_mode); + CP(*in, *out, st_nlink); + CP(*in, *out, st_uid); + CP(*in, *out, st_gid); + CP(*in, *out, st_rdev); + CP(*in, *out, st_size); + TS_CP(*in, *out, st_atim); + TS_CP(*in, *out, st_mtim); + TS_CP(*in, *out, st_ctim); + CP(*in, *out, st_blksize); + CP(*in, *out, st_blocks); + CP(*in, *out, st_flags); + CP(*in, *out, st_gen); +} +#endif + int freebsd32_stat(struct thread *td, struct freebsd32_stat_args *uap) { @@ -1653,6 +1699,23 @@ freebsd32_stat(struct thread *td, struct return (error); } +#ifdef COMPAT_43 +int +ofreebsd32_stat(struct thread *td, struct ofreebsd32_stat_args *uap) +{ + struct stat sb; + struct ostat32 sb32; + int error; + + error = kern_stat(td, uap->path, UIO_USERSPACE, &sb); + if (error) + return (error); + copy_ostat(&sb, &sb32); + error = copyout(&sb32, uap->ub, sizeof (sb32)); + return (error); +} +#endif + int freebsd32_fstat(struct thread *td, struct freebsd32_fstat_args *uap) { @@ -1668,6 +1731,23 @@ freebsd32_fstat(struct thread *td, struc return (error); } +#ifdef COMPAT_43 +int +ofreebsd32_fstat(struct thread *td, struct ofreebsd32_fstat_args *uap) +{ + struct stat ub; + struct ostat32 ub32; + int error; + + error = kern_fstat(td, uap->fd, &ub); + if (error) + return (error); + copy_ostat(&ub, &ub32); + error = copyout(&ub32, uap->ub, sizeof(ub32)); + return (error); +} +#endif + int freebsd32_fstatat(struct thread *td, struct freebsd32_fstatat_args *uap) { @@ -1698,9 +1778,23 @@ freebsd32_lstat(struct thread *td, struc return (error); } -/* - * MPSAFE - */ +#ifdef COMPAT_43 +int +ofreebsd32_lstat(struct thread *td, struct ofreebsd32_lstat_args *uap) +{ + struct stat sb; + struct ostat32 sb32; + int error; + + error = kern_lstat(td, uap->path, UIO_USERSPACE, &sb); + if (error) + return (error); + copy_ostat(&sb, &sb32); + error = copyout(&sb32, uap->ub, sizeof (sb32)); + return (error); +} +#endif + int freebsd32_sysctl(struct thread *td, struct freebsd32_sysctl_args *uap) { Modified: head/sys/compat/freebsd32/syscalls.master ============================================================================== --- head/sys/compat/freebsd32/syscalls.master Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/compat/freebsd32/syscalls.master Fri Apr 1 11:16:29 2011 (r220238) @@ -117,9 +117,11 @@ 35 AUE_FCHFLAGS NOPROTO { int fchflags(int fd, int flags); } 36 AUE_SYNC NOPROTO { int sync(void); } 37 AUE_KILL NOPROTO { int kill(int pid, int signum); } -38 AUE_STAT UNIMPL ostat +38 AUE_STAT COMPAT { int freebsd32_stat(char *path, \ + struct ostat32 *ub); } 39 AUE_GETPPID NOPROTO { pid_t getppid(void); } -40 AUE_LSTAT UNIMPL olstat +40 AUE_LSTAT COMPAT { int freebsd32_lstat(char *path, \ + struct ostat *ub); } 41 AUE_DUP NOPROTO { int dup(u_int fd); } 42 AUE_PIPE NOPROTO { int pipe(void); } 43 AUE_GETEGID NOPROTO { gid_t getegid(void); } @@ -153,9 +155,11 @@ 60 AUE_UMASK NOPROTO { int umask(int newmask); } umask \ umask_args int 61 AUE_CHROOT NOPROTO { int chroot(char *path); } -62 AUE_FSTAT OBSOL ofstat +62 AUE_FSTAT COMPAT { int freebsd32_fstat(int fd, \ + struct ostat32 *ub); } 63 AUE_NULL OBSOL ogetkerninfo -64 AUE_NULL OBSOL ogetpagesize +64 AUE_NULL COMPAT { int freebsd32_getpagesize( \ + int32_t dummy); } 65 AUE_MSYNC NOPROTO { int msync(void *addr, size_t len, \ int flags); } 66 AUE_VFORK NOPROTO { int vfork(void); } @@ -210,7 +214,8 @@ 100 AUE_GETPRIORITY NOPROTO { int getpriority(int which, int who); } 101 AUE_NULL OBSOL osend 102 AUE_NULL OBSOL orecv -103 AUE_NULL OBSOL osigreturn +103 AUE_NULL COMPAT { int freebsd32_sigreturn( \ + struct ia32_sigcontext3 *sigcntxp); } 104 AUE_BIND NOPROTO { int bind(int s, caddr_t name, \ int namelen); } 105 AUE_SETSOCKOPT NOPROTO { int setsockopt(int s, int level, \ @@ -292,7 +297,8 @@ ; 155 is initialized by the NFS code, if present. ; XXX this is a problem!!! 155 AUE_NFS_SVC UNIMPL nfssvc -156 AUE_GETDIRENTRIES OBSOL ogetdirentries +156 AUE_GETDIRENTRIES COMPAT { int freebsd32_getdirentries(int fd, \ + char *buf, u_int count, uint32_t *basep); } 157 AUE_STATFS COMPAT4 { int freebsd32_statfs(char *path, \ struct statfs32 *buf); } 158 AUE_FSTATFS COMPAT4 { int freebsd32_fstatfs(int fd, \ Modified: head/sys/compat/ia32/ia32_genassym.c ============================================================================== --- head/sys/compat/ia32/ia32_genassym.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/compat/ia32/ia32_genassym.c Fri Apr 1 11:16:29 2011 (r220238) @@ -13,6 +13,9 @@ __FBSDID("$FreeBSD$"); ASSYM(IA32_SIGF_HANDLER, offsetof(struct ia32_sigframe, sf_ah)); ASSYM(IA32_SIGF_UC, offsetof(struct ia32_sigframe, sf_uc)); +#ifdef COMPAT_43 +ASSYM(IA32_SIGF_SC, offsetof(struct ia32_sigframe3, sf_siginfo.si_sc)); +#endif ASSYM(IA32_UC_GS, offsetof(struct ia32_ucontext, uc_mcontext.mc_gs)); ASSYM(IA32_UC_FS, offsetof(struct ia32_ucontext, uc_mcontext.mc_fs)); ASSYM(IA32_UC_ES, offsetof(struct ia32_ucontext, uc_mcontext.mc_es)); Modified: head/sys/compat/ia32/ia32_signal.h ============================================================================== --- head/sys/compat/ia32/ia32_signal.h Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/compat/ia32/ia32_signal.h Fri Apr 1 11:16:29 2011 (r220238) @@ -112,7 +112,7 @@ struct ia32_ucontext4 { }; #endif -#ifdef COMPAT_FREEBSD3 +#ifdef COMPAT_43 struct ia32_sigcontext3 { u_int32_t sc_onstack; u_int32_t sc_mask; @@ -165,7 +165,7 @@ struct ia32_sigframe { struct siginfo32 sf_si; /* = *sf_siginfo (SA_SIGINFO case) */ }; -#ifdef COMPAT_FREEBSD3 +#ifdef COMPAT_43 struct ia32_siginfo3 { struct ia32_sigcontext3 si_sc; int si_signo; @@ -186,10 +186,15 @@ struct ksiginfo; struct image_params; extern char ia32_sigcode[]; extern char freebsd4_ia32_sigcode[]; +extern char ia32_osigcode[]; +extern char lcall_tramp; extern int sz_ia32_sigcode; extern int sz_freebsd4_ia32_sigcode; -extern void ia32_sendsig(sig_t, struct ksiginfo *, sigset_t *); -extern void ia32_setregs(struct thread *td, struct image_params *imgp, +extern int sz_ia32_osigcode; +extern int sz_lcall_tramp; +void ia32_sendsig(sig_t, struct ksiginfo *, sigset_t *); +void ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack); +int setup_lcall_gate(void); #endif Modified: head/sys/compat/ia32/ia32_sysvec.c ============================================================================== --- head/sys/compat/ia32/ia32_sysvec.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/compat/ia32/ia32_sysvec.c Fri Apr 1 11:16:29 2011 (r220238) @@ -95,14 +95,12 @@ CTASSERT(sizeof(struct ia32_sigframe4) = extern const char *freebsd32_syscallnames[]; -static void ia32_fixlimit(struct rlimit *rl, int which); - SYSCTL_NODE(_compat, OID_AUTO, ia32, CTLFLAG_RW, 0, "ia32 mode"); static u_long ia32_maxdsiz = IA32_MAXDSIZ; SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxdsiz, CTLFLAG_RW, &ia32_maxdsiz, 0, ""); TUNABLE_ULONG("compat.ia32.maxdsiz", &ia32_maxdsiz); -static u_long ia32_maxssiz = IA32_MAXSSIZ; +u_long ia32_maxssiz = IA32_MAXSSIZ; SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxssiz, CTLFLAG_RW, &ia32_maxssiz, 0, ""); TUNABLE_ULONG("compat.ia32.maxssiz", &ia32_maxssiz); static u_long ia32_maxvmem = IA32_MAXVMEM; @@ -206,7 +204,7 @@ elf32_dump_thread(struct thread *td __un { } -static void +void ia32_fixlimit(struct rlimit *rl, int which) { Modified: head/sys/compat/ia32/ia32_util.h ============================================================================== --- head/sys/compat/ia32/ia32_util.h Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/compat/ia32/ia32_util.h Fri Apr 1 11:16:29 2011 (r220238) @@ -58,5 +58,6 @@ struct syscall_args; int ia32_fetch_syscall_args(struct thread *td, struct syscall_args *sa); void ia32_set_syscall_retval(struct thread *, int); +void ia32_fixlimit(struct rlimit *rl, int which); #endif Modified: head/sys/ia64/ia32/ia32_misc.c ============================================================================== --- head/sys/ia64/ia32/ia32_misc.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/ia64/ia32/ia32_misc.c Fri Apr 1 11:16:29 2011 (r220238) @@ -48,3 +48,14 @@ freebsd32_sysarch(struct thread *td, str return (EOPNOTSUPP); } + +#ifdef COMPAT_43 +int +ofreebsd32_getpagesize(struct thread *td, + struct ofreebsd32_getpagesize_args *uap) +{ + + td->td_retval[0] = IA32_PAGE_SIZE; + return (0); +} +#endif Modified: head/sys/ia64/ia32/ia32_signal.c ============================================================================== --- head/sys/ia64/ia32/ia32_signal.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/ia64/ia32/ia32_signal.c Fri Apr 1 11:16:29 2011 (r220238) @@ -92,6 +92,15 @@ x) */ }; int sz_ia32_sigcode = sizeof(ia32_sigcode); +#ifdef COMPAT_43 +int +ofreebsd32_sigreturn(struct thread *td, struct ofreebsd32_sigreturn_args *uap) +{ + + return (EOPNOTSUPP); +} +#endif + /* * Signal sending has not been implemented on ia64. This causes * the sigtramp code to not understand the arguments and the application Modified: head/sys/kern/imgact_aout.c ============================================================================== --- head/sys/kern/imgact_aout.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/kern/imgact_aout.c Fri Apr 1 11:16:29 2011 (r220238) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -52,9 +53,18 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef __amd64__ +#include +#include +#include +#include +#include +#endif + static int exec_aout_imgact(struct image_params *imgp); static int aout_fixup(register_t **stack_base, struct image_params *imgp); +#if defined(__i386__) struct sysentvec aout_sysvec = { .sv_size = SYS_MAXSYSCALL, .sv_table = sysent, @@ -83,31 +93,69 @@ struct sysentvec aout_sysvec = { .sv_setregs = exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, - .sv_flags = SV_ABI_FREEBSD | SV_AOUT | -#if defined(__i386__) - SV_IA32 | SV_ILP32 -#else -#error Choose SV_XXX flags for the platform -#endif - , + .sv_flags = SV_ABI_FREEBSD | SV_AOUT | SV_IA32 | SV_ILP32, .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, .sv_schedtail = NULL, }; +#elif defined(__amd64__) + +#define AOUT32_USRSTACK 0xbfc0000 +#define AOUT32_PS_STRINGS \ + (AOUT32_USRSTACK - sizeof(struct freebsd32_ps_strings)) + +extern const char *freebsd32_syscallnames[]; +extern u_long ia32_maxssiz; + +struct sysentvec aout_sysvec = { + .sv_size = FREEBSD32_SYS_MAXSYSCALL, + .sv_table = freebsd32_sysent, + .sv_mask = 0, + .sv_sigsize = 0, + .sv_sigtbl = NULL, + .sv_errsize = 0, + .sv_errtbl = NULL, + .sv_transtrap = NULL, + .sv_fixup = aout_fixup, + .sv_sendsig = ia32_sendsig, + .sv_sigcode = ia32_sigcode, + .sv_szsigcode = &sz_ia32_sigcode, + .sv_prepsyscall = NULL, + .sv_name = "FreeBSD a.out", + .sv_coredump = NULL, + .sv_imgact_try = NULL, + .sv_minsigstksz = MINSIGSTKSZ, + .sv_pagesize = IA32_PAGE_SIZE, + .sv_minuser = 0, + .sv_maxuser = AOUT32_USRSTACK, + .sv_usrstack = AOUT32_USRSTACK, + .sv_psstrings = AOUT32_PS_STRINGS, + .sv_stackprot = VM_PROT_ALL, + .sv_copyout_strings = freebsd32_copyout_strings, + .sv_setregs = ia32_setregs, + .sv_fixlimit = ia32_fixlimit, + .sv_maxssiz = &ia32_maxssiz, + .sv_flags = SV_ABI_FREEBSD | SV_AOUT | SV_IA32 | SV_ILP32, + .sv_set_syscall_retval = ia32_set_syscall_retval, + .sv_fetch_syscall_args = ia32_fetch_syscall_args, + .sv_syscallnames = freebsd32_syscallnames, +}; +#else +#error "Port me" +#endif + static int -aout_fixup(stack_base, imgp) - register_t **stack_base; - struct image_params *imgp; +aout_fixup(register_t **stack_base, struct image_params *imgp) { - return (suword(--(*stack_base), imgp->args->argc)); + *(char **)stack_base -= sizeof(uint32_t); + return (suword(*stack_base, imgp->args->argc)); } static int -exec_aout_imgact(imgp) - struct image_params *imgp; +exec_aout_imgact(struct image_params *imgp) { const struct exec *a_out = (const struct exec *) imgp->image_header; struct vmspace *vmspace; @@ -175,7 +223,14 @@ exec_aout_imgact(imgp) a_out->a_entry >= virtual_offset + a_out->a_text || /* text and data size must each be page rounded */ - a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK) + a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK + +#ifdef __amd64__ + || + /* overflows */ + virtual_offset + a_out->a_text + a_out->a_data + bss_size > UINT_MAX +#endif + ) return (-1); /* text + data can't exceed file size */ Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/kern/vfs_syscalls.c Fri Apr 1 11:16:29 2011 (r220238) @@ -3898,14 +3898,20 @@ struct ogetdirentries_args { }; #endif int -ogetdirentries(td, uap) - struct thread *td; - register struct ogetdirentries_args /* { - int fd; - char *buf; - u_int count; - long *basep; - } */ *uap; +ogetdirentries(struct thread *td, struct ogetdirentries_args *uap) +{ + long loff; + int error; + + error = kern_ogetdirentries(td, uap, &loff); + if (error == 0) + error = copyout(&loff, uap->basep, sizeof(long)); + return (error); +} + +int +kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap, + long *ploff) { struct vnode *vp; struct file *fp; @@ -4024,9 +4030,10 @@ unionread: } VOP_UNLOCK(vp, 0); VFS_UNLOCK_GIANT(vfslocked); - error = copyout(&loff, uap->basep, sizeof(long)); fdrop(fp, td); td->td_retval[0] = uap->count - auio.uio_resid; + if (error == 0) + *ploff = loff; return (error); } #endif /* COMPAT_43 */ Modified: head/sys/modules/Makefile ============================================================================== --- head/sys/modules/Makefile Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/modules/Makefile Fri Apr 1 11:16:29 2011 (r220238) @@ -518,6 +518,7 @@ _snc= snc .if ${MACHINE_CPUARCH} == "amd64" _aac= aac +_aout= aout _acpi= acpi .if ${MK_CRYPT} != "no" || defined(ALL_MODULES) _aesni= aesni Modified: head/sys/sys/syscallsubr.h ============================================================================== --- head/sys/sys/syscallsubr.h Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/sys/syscallsubr.h Fri Apr 1 11:16:29 2011 (r220238) @@ -52,6 +52,7 @@ struct kld_file_stat; struct ksiginfo; struct sendfile_args; struct thr_param; +struct ogetdirentries_args; int kern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg, u_int buflen); @@ -143,6 +144,8 @@ int kern_msgsnd(struct thread *, int, co int kern_msgrcv(struct thread *, int, void *, size_t, long, int, long *); int kern_nanosleep(struct thread *td, struct timespec *rqt, struct timespec *rmt); +int kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap, + long *ploff); int kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags, int mode); int kern_openat(struct thread *td, int fd, char *path, From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 11:16:53 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 638BE1065673; Fri, 1 Apr 2011 11:16:53 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 531868FC17; Fri, 1 Apr 2011 11:16:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31BGrJc042379; Fri, 1 Apr 2011 11:16:53 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31BGrCL042374; Fri, 1 Apr 2011 11:16:53 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011116.p31BGrCL042374@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 11:16:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220239 - head/sys/compat/freebsd32 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 11:16:53 -0000 Author: kib Date: Fri Apr 1 11:16:53 2011 New Revision: 220239 URL: http://svn.freebsd.org/changeset/base/220239 Log: Regen Modified: head/sys/compat/freebsd32/freebsd32_proto.h head/sys/compat/freebsd32/freebsd32_syscall.h head/sys/compat/freebsd32/freebsd32_syscalls.c head/sys/compat/freebsd32/freebsd32_sysent.c Modified: head/sys/compat/freebsd32/freebsd32_proto.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_proto.h Fri Apr 1 11:16:29 2011 (r220238) +++ head/sys/compat/freebsd32/freebsd32_proto.h Fri Apr 1 11:16:53 2011 (r220239) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220238 2011-04-01 11:16:29Z kib */ #ifndef _FREEBSD32_SYSPROTO_H_ @@ -682,6 +682,14 @@ int freebsd32_pselect(struct thread *, s #if !defined(PAD64_REQUIRED) && defined(__powerpc__) #define PAD64_REQUIRED #endif +struct ofreebsd32_stat_args { + char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; + char ub_l_[PADL_(struct ostat32 *)]; struct ostat32 * ub; char ub_r_[PADR_(struct ostat32 *)]; +}; +struct ofreebsd32_lstat_args { + char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; + char ub_l_[PADL_(struct ostat *)]; struct ostat * ub; char ub_r_[PADR_(struct ostat *)]; +}; struct ofreebsd32_sigaction_args { char signum_l_[PADL_(int)]; int signum; char signum_r_[PADR_(int)]; char nsa_l_[PADL_(struct osigaction32 *)]; struct osigaction32 * nsa; char nsa_r_[PADR_(struct osigaction32 *)]; @@ -691,6 +699,16 @@ struct ofreebsd32_sigprocmask_args { char how_l_[PADL_(int)]; int how; char how_r_[PADR_(int)]; char mask_l_[PADL_(osigset_t)]; osigset_t mask; char mask_r_[PADR_(osigset_t)]; }; +struct ofreebsd32_fstat_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char ub_l_[PADL_(struct ostat32 *)]; struct ostat32 * ub; char ub_r_[PADR_(struct ostat32 *)]; +}; +struct ofreebsd32_getpagesize_args { + char dummy_l_[PADL_(int32_t)]; int32_t dummy; char dummy_r_[PADR_(int32_t)]; +}; +struct ofreebsd32_sigreturn_args { + char sigcntxp_l_[PADL_(struct ia32_sigcontext3 *)]; struct ia32_sigcontext3 * sigcntxp; char sigcntxp_r_[PADR_(struct ia32_sigcontext3 *)]; +}; struct ofreebsd32_sigvec_args { char signum_l_[PADL_(int)]; int signum; char signum_r_[PADR_(int)]; char nsv_l_[PADL_(struct sigvec32 *)]; struct sigvec32 * nsv; char nsv_r_[PADR_(struct sigvec32 *)]; @@ -709,20 +727,32 @@ struct ofreebsd32_sigstack_args { char nss_l_[PADL_(struct sigstack32 *)]; struct sigstack32 * nss; char nss_r_[PADR_(struct sigstack32 *)]; char oss_l_[PADL_(struct sigstack32 *)]; struct sigstack32 * oss; char oss_r_[PADR_(struct sigstack32 *)]; }; +struct ofreebsd32_getdirentries_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)]; + char count_l_[PADL_(u_int)]; u_int count; char count_r_[PADR_(u_int)]; + char basep_l_[PADL_(uint32_t *)]; uint32_t * basep; char basep_r_[PADR_(uint32_t *)]; +}; #ifdef PAD64_REQUIRED #else #endif #ifdef PAD64_REQUIRED #else #endif +int ofreebsd32_stat(struct thread *, struct ofreebsd32_stat_args *); +int ofreebsd32_lstat(struct thread *, struct ofreebsd32_lstat_args *); int ofreebsd32_sigaction(struct thread *, struct ofreebsd32_sigaction_args *); int ofreebsd32_sigprocmask(struct thread *, struct ofreebsd32_sigprocmask_args *); int ofreebsd32_sigpending(struct thread *, struct ofreebsd32_sigpending_args *); +int ofreebsd32_fstat(struct thread *, struct ofreebsd32_fstat_args *); +int ofreebsd32_getpagesize(struct thread *, struct ofreebsd32_getpagesize_args *); +int ofreebsd32_sigreturn(struct thread *, struct ofreebsd32_sigreturn_args *); int ofreebsd32_sigvec(struct thread *, struct ofreebsd32_sigvec_args *); int ofreebsd32_sigblock(struct thread *, struct ofreebsd32_sigblock_args *); int ofreebsd32_sigsetmask(struct thread *, struct ofreebsd32_sigsetmask_args *); int ofreebsd32_sigsuspend(struct thread *, struct ofreebsd32_sigsuspend_args *); int ofreebsd32_sigstack(struct thread *, struct ofreebsd32_sigstack_args *); +int ofreebsd32_getdirentries(struct thread *, struct ofreebsd32_getdirentries_args *); #endif /* COMPAT_43 */ @@ -888,15 +918,20 @@ int freebsd7_freebsd32_shmctl(struct thr #define FREEBSD32_SYS_AUE_freebsd32_recvmsg AUE_RECVMSG #define FREEBSD32_SYS_AUE_freebsd32_sendmsg AUE_SENDMSG #define FREEBSD32_SYS_AUE_freebsd32_recvfrom AUE_RECVFROM +#define FREEBSD32_SYS_AUE_ofreebsd32_stat AUE_STAT +#define FREEBSD32_SYS_AUE_ofreebsd32_lstat AUE_LSTAT #define FREEBSD32_SYS_AUE_ofreebsd32_sigaction AUE_SIGACTION #define FREEBSD32_SYS_AUE_ofreebsd32_sigprocmask AUE_SIGPROCMASK #define FREEBSD32_SYS_AUE_ofreebsd32_sigpending AUE_SIGPENDING #define FREEBSD32_SYS_AUE_freebsd32_sigaltstack AUE_SIGALTSTACK #define FREEBSD32_SYS_AUE_freebsd32_ioctl AUE_NULL #define FREEBSD32_SYS_AUE_freebsd32_execve AUE_EXECVE +#define FREEBSD32_SYS_AUE_ofreebsd32_fstat AUE_FSTAT +#define FREEBSD32_SYS_AUE_ofreebsd32_getpagesize AUE_NULL #define FREEBSD32_SYS_AUE_freebsd32_setitimer AUE_SETITIMER #define FREEBSD32_SYS_AUE_freebsd32_getitimer AUE_GETITIMER #define FREEBSD32_SYS_AUE_freebsd32_select AUE_SELECT +#define FREEBSD32_SYS_AUE_ofreebsd32_sigreturn AUE_NULL #define FREEBSD32_SYS_AUE_ofreebsd32_sigvec AUE_O_SIGVEC #define FREEBSD32_SYS_AUE_ofreebsd32_sigblock AUE_O_SIGBLOCK #define FREEBSD32_SYS_AUE_ofreebsd32_sigsetmask AUE_O_SIGSETMASK @@ -909,6 +944,7 @@ int freebsd7_freebsd32_shmctl(struct thr #define FREEBSD32_SYS_AUE_freebsd32_settimeofday AUE_SETTIMEOFDAY #define FREEBSD32_SYS_AUE_freebsd32_utimes AUE_UTIMES #define FREEBSD32_SYS_AUE_freebsd32_adjtime AUE_ADJTIME +#define FREEBSD32_SYS_AUE_ofreebsd32_getdirentries AUE_GETDIRENTRIES #define FREEBSD32_SYS_AUE_freebsd4_freebsd32_statfs AUE_STATFS #define FREEBSD32_SYS_AUE_freebsd4_freebsd32_fstatfs AUE_FSTATFS #define FREEBSD32_SYS_AUE_freebsd32_sysarch AUE_SYSARCH Modified: head/sys/compat/freebsd32/freebsd32_syscall.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_syscall.h Fri Apr 1 11:16:29 2011 (r220238) +++ head/sys/compat/freebsd32/freebsd32_syscall.h Fri Apr 1 11:16:53 2011 (r220239) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220238 2011-04-01 11:16:29Z kib */ #define FREEBSD32_SYS_syscall 0 @@ -44,7 +44,9 @@ #define FREEBSD32_SYS_fchflags 35 #define FREEBSD32_SYS_sync 36 #define FREEBSD32_SYS_kill 37 + /* 38 is old freebsd32_stat */ #define FREEBSD32_SYS_getppid 39 + /* 40 is old freebsd32_lstat */ #define FREEBSD32_SYS_dup 41 #define FREEBSD32_SYS_pipe 42 #define FREEBSD32_SYS_getegid 43 @@ -66,9 +68,9 @@ #define FREEBSD32_SYS_freebsd32_execve 59 #define FREEBSD32_SYS_umask 60 #define FREEBSD32_SYS_chroot 61 - /* 62 is obsolete ofstat */ + /* 62 is old freebsd32_fstat */ /* 63 is obsolete ogetkerninfo */ - /* 64 is obsolete ogetpagesize */ + /* 64 is old freebsd32_getpagesize */ #define FREEBSD32_SYS_msync 65 #define FREEBSD32_SYS_vfork 66 /* 67 is obsolete vread */ @@ -105,7 +107,7 @@ #define FREEBSD32_SYS_getpriority 100 /* 101 is obsolete osend */ /* 102 is obsolete orecv */ - /* 103 is obsolete osigreturn */ + /* 103 is old freebsd32_sigreturn */ #define FREEBSD32_SYS_bind 104 #define FREEBSD32_SYS_setsockopt 105 #define FREEBSD32_SYS_listen 106 @@ -152,7 +154,7 @@ #define FREEBSD32_SYS_quotactl 148 /* 149 is obsolete oquota */ /* 150 is obsolete ogetsockname */ - /* 156 is obsolete ogetdirentries */ + /* 156 is old freebsd32_getdirentries */ #define FREEBSD32_SYS_freebsd4_freebsd32_statfs 157 #define FREEBSD32_SYS_freebsd4_freebsd32_fstatfs 158 #define FREEBSD32_SYS_getfh 161 Modified: head/sys/compat/freebsd32/freebsd32_syscalls.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_syscalls.c Fri Apr 1 11:16:29 2011 (r220238) +++ head/sys/compat/freebsd32/freebsd32_syscalls.c Fri Apr 1 11:16:53 2011 (r220239) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220238 2011-04-01 11:16:29Z kib */ const char *freebsd32_syscallnames[] = { @@ -48,9 +48,9 @@ const char *freebsd32_syscallnames[] = { "fchflags", /* 35 = fchflags */ "sync", /* 36 = sync */ "kill", /* 37 = kill */ - "#38", /* 38 = ostat */ + "compat.freebsd32_stat", /* 38 = old freebsd32_stat */ "getppid", /* 39 = getppid */ - "#40", /* 40 = olstat */ + "compat.freebsd32_lstat", /* 40 = old freebsd32_lstat */ "dup", /* 41 = dup */ "pipe", /* 42 = pipe */ "getegid", /* 43 = getegid */ @@ -72,9 +72,9 @@ const char *freebsd32_syscallnames[] = { "freebsd32_execve", /* 59 = freebsd32_execve */ "umask", /* 60 = umask */ "chroot", /* 61 = chroot */ - "obs_ofstat", /* 62 = obsolete ofstat */ + "compat.freebsd32_fstat", /* 62 = old freebsd32_fstat */ "obs_ogetkerninfo", /* 63 = obsolete ogetkerninfo */ - "obs_ogetpagesize", /* 64 = obsolete ogetpagesize */ + "compat.freebsd32_getpagesize", /* 64 = old freebsd32_getpagesize */ "msync", /* 65 = msync */ "vfork", /* 66 = vfork */ "obs_vread", /* 67 = obsolete vread */ @@ -113,7 +113,7 @@ const char *freebsd32_syscallnames[] = { "getpriority", /* 100 = getpriority */ "obs_osend", /* 101 = obsolete osend */ "obs_orecv", /* 102 = obsolete orecv */ - "obs_osigreturn", /* 103 = obsolete osigreturn */ + "compat.freebsd32_sigreturn", /* 103 = old freebsd32_sigreturn */ "bind", /* 104 = bind */ "setsockopt", /* 105 = setsockopt */ "listen", /* 106 = listen */ @@ -166,7 +166,7 @@ const char *freebsd32_syscallnames[] = { "#153", /* 153 = asyncdaemon */ "#154", /* 154 = nlm_syscall */ "#155", /* 155 = nfssvc */ - "obs_ogetdirentries", /* 156 = obsolete ogetdirentries */ + "compat.freebsd32_getdirentries", /* 156 = old freebsd32_getdirentries */ "compat4.freebsd32_statfs", /* 157 = freebsd4 freebsd32_statfs */ "compat4.freebsd32_fstatfs", /* 158 = freebsd4 freebsd32_fstatfs */ "#159", /* 159 = nosys */ Modified: head/sys/compat/freebsd32/freebsd32_sysent.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_sysent.c Fri Apr 1 11:16:29 2011 (r220238) +++ head/sys/compat/freebsd32/freebsd32_sysent.c Fri Apr 1 11:16:53 2011 (r220239) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220238 2011-04-01 11:16:29Z kib */ #include "opt_compat.h" @@ -85,9 +85,9 @@ struct sysent freebsd32_sysent[] = { { AS(fchflags_args), (sy_call_t *)fchflags, AUE_FCHFLAGS, NULL, 0, 0, 0, SY_THR_STATIC }, /* 35 = fchflags */ { 0, (sy_call_t *)sync, AUE_SYNC, NULL, 0, 0, 0, SY_THR_STATIC }, /* 36 = sync */ { AS(kill_args), (sy_call_t *)kill, AUE_KILL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 37 = kill */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 38 = ostat */ + { compat(AS(ofreebsd32_stat_args),freebsd32_stat), AUE_STAT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 38 = old freebsd32_stat */ { 0, (sy_call_t *)getppid, AUE_GETPPID, NULL, 0, 0, 0, SY_THR_STATIC }, /* 39 = getppid */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 40 = olstat */ + { compat(AS(ofreebsd32_lstat_args),freebsd32_lstat), AUE_LSTAT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 40 = old freebsd32_lstat */ { AS(dup_args), (sy_call_t *)dup, AUE_DUP, NULL, 0, 0, 0, SY_THR_STATIC }, /* 41 = dup */ { 0, (sy_call_t *)pipe, AUE_PIPE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 42 = pipe */ { 0, (sy_call_t *)getegid, AUE_GETEGID, NULL, 0, 0, 0, SY_THR_STATIC }, /* 43 = getegid */ @@ -109,9 +109,9 @@ struct sysent freebsd32_sysent[] = { { AS(freebsd32_execve_args), (sy_call_t *)freebsd32_execve, AUE_EXECVE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 59 = freebsd32_execve */ { AS(umask_args), (sy_call_t *)umask, AUE_UMASK, NULL, 0, 0, 0, SY_THR_STATIC }, /* 60 = umask */ { AS(chroot_args), (sy_call_t *)chroot, AUE_CHROOT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 61 = chroot */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 62 = obsolete ofstat */ + { compat(AS(ofreebsd32_fstat_args),freebsd32_fstat), AUE_FSTAT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 62 = old freebsd32_fstat */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 63 = obsolete ogetkerninfo */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 64 = obsolete ogetpagesize */ + { compat(AS(ofreebsd32_getpagesize_args),freebsd32_getpagesize), AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 64 = old freebsd32_getpagesize */ { AS(msync_args), (sy_call_t *)msync, AUE_MSYNC, NULL, 0, 0, 0, SY_THR_STATIC }, /* 65 = msync */ { 0, (sy_call_t *)vfork, AUE_VFORK, NULL, 0, 0, 0, SY_THR_STATIC }, /* 66 = vfork */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 67 = obsolete vread */ @@ -150,7 +150,7 @@ struct sysent freebsd32_sysent[] = { { AS(getpriority_args), (sy_call_t *)getpriority, AUE_GETPRIORITY, NULL, 0, 0, 0, SY_THR_STATIC }, /* 100 = getpriority */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 101 = obsolete osend */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 102 = obsolete orecv */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 103 = obsolete osigreturn */ + { compat(AS(ofreebsd32_sigreturn_args),freebsd32_sigreturn), AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 103 = old freebsd32_sigreturn */ { AS(bind_args), (sy_call_t *)bind, AUE_BIND, NULL, 0, 0, 0, SY_THR_STATIC }, /* 104 = bind */ { AS(setsockopt_args), (sy_call_t *)setsockopt, AUE_SETSOCKOPT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 105 = setsockopt */ { AS(listen_args), (sy_call_t *)listen, AUE_LISTEN, NULL, 0, 0, 0, SY_THR_STATIC }, /* 106 = listen */ @@ -203,7 +203,7 @@ struct sysent freebsd32_sysent[] = { { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 153 = asyncdaemon */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 154 = nlm_syscall */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 155 = nfssvc */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 156 = obsolete ogetdirentries */ + { compat(AS(ofreebsd32_getdirentries_args),freebsd32_getdirentries), AUE_GETDIRENTRIES, NULL, 0, 0, 0, SY_THR_STATIC }, /* 156 = old freebsd32_getdirentries */ { compat4(AS(freebsd4_freebsd32_statfs_args),freebsd32_statfs), AUE_STATFS, NULL, 0, 0, 0, SY_THR_STATIC }, /* 157 = freebsd4 freebsd32_statfs */ { compat4(AS(freebsd4_freebsd32_fstatfs_args),freebsd32_fstatfs), AUE_FSTATFS, NULL, 0, 0, 0, SY_THR_STATIC }, /* 158 = freebsd4 freebsd32_fstatfs */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 159 = nosys */ From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 11:39:14 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 02BE0106566C; Fri, 1 Apr 2011 11:39:14 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E759C8FC1E; Fri, 1 Apr 2011 11:39:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31BdDdu043094; Fri, 1 Apr 2011 11:39:13 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31BdDk0043092; Fri, 1 Apr 2011 11:39:13 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201104011139.p31BdDk0043092@svn.freebsd.org> From: Warner Losh Date: Fri, 1 Apr 2011 11:39:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220240 - head/share/man/man4/man4.i386 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 11:39:14 -0000 Author: imp Date: Fri Apr 1 11:39:13 2011 New Revision: 220240 URL: http://svn.freebsd.org/changeset/base/220240 Log: Minor tweaks to the man page: o Remove bogus ordering info o 3C1 actually works, so remove that o Add warning about making sure BIOS is configured properly for PnP configured 3c509 cards. Modified: head/share/man/man4/man4.i386/ep.4 Modified: head/share/man/man4/man4.i386/ep.4 ============================================================================== --- head/share/man/man4/man4.i386/ep.4 Fri Apr 1 11:16:53 2011 (r220239) +++ head/share/man/man4/man4.i386/ep.4 Fri Apr 1 11:39:13 2011 (r220240) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 1, 2008 +.Dd April 1, 2011 .Dt EP 4 i386 .Os .Sh NAME @@ -81,9 +81,6 @@ Use the BNC port. .It 10baseT/UTP Use the UTP port. .El -.Pp -If there are multiple cards in the computer, they are searched for -in the following order: bus, slot, then Ethernet address. .Sh HARDWARE The .Nm @@ -128,13 +125,14 @@ scan operation at IO address 0x110. Beware! Avoid placing other cards at that address! .Pp -Furthermore, -the 3c509 should only -be configured in EISA mode +Furthermore, the 3c509 should only be configured in EISA mode when installed in a computer that has actual EISA slots (and an EISA-aware BIOS). -The normal driver auto-detection support -is sufficient for non-EISA systems. +The normal driver auto-detection support is sufficient for non-EISA systems. +.Pp +Cards in PnP mode may conflict with other resources in the system. +Ensure your BIOS is configured correctly to exclude resources used by +the 3c509, especially IRQs, to avoid unpredictable behavior. .Pp Many different companies sold the 3Com PC Cards under their own private label. @@ -212,5 +210,3 @@ This should never happen. .Sh STANDARDS are great. There is so many to choose from. -.Sh BUGS -Support for the 3Com 3C1 CompactFlash is not working. From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 11:44:59 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1233) id E7A45106566C; Fri, 1 Apr 2011 11:44:59 +0000 (UTC) Date: Fri, 1 Apr 2011 11:44:59 +0000 From: Alexander Best To: Konstantin Belousov Message-ID: <20110401114459.GA13612@freebsd.org> References: <201104011116.p31BGTx4042314@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201104011116.p31BGTx4042314@svn.freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220238 - in head/sys: amd64/ia32 compat/freebsd32 compat/ia32 ia64/ia32 kern modules sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 11:45:00 -0000 On Fri Apr 1 11, Konstantin Belousov wrote: > Author: kib > Date: Fri Apr 1 11:16:29 2011 > New Revision: 220238 > URL: http://svn.freebsd.org/changeset/base/220238 > > Log: > Add support for executing the FreeBSD 1/i386 a.out binaries on amd64. > > In particular: > - implement compat shims for old stat(2) variants and ogetdirentries(2); > - implement delivery of signals with ancient stack frame layout and > corresponding sigreturn(2); > - implement old getpagesize(2); > - provide a user-mode trampoline and LDT call gate for lcall $7,$0; > - port a.out image activator and connect it to the build as a module > on amd64. > > The changes are hidden under COMPAT_43. hmm...for i386 there's # Enable i386 a.out binary support options COMPAT_AOUT why not make this feature dependant upon the same option and not COMPAT_43? ...also i noticed sys/amd/conf/NOTES says: # Enable 32-bit Linux ABI emulation (requires COMPAT_43 and COMPAT_FREEBSD32) options COMPAT_LINUX32 ...i don't think COMPAT_43 is actually necessary to use COMPAT_FREEBSD32, is it? cheers. alex > > MFC after: 1 month > > Modified: > head/sys/amd64/ia32/ia32_misc.c > head/sys/amd64/ia32/ia32_signal.c > head/sys/amd64/ia32/ia32_sigtramp.S > head/sys/amd64/ia32/ia32_syscall.c > head/sys/compat/freebsd32/freebsd32_misc.c > head/sys/compat/freebsd32/syscalls.master > head/sys/compat/ia32/ia32_genassym.c > head/sys/compat/ia32/ia32_signal.h > head/sys/compat/ia32/ia32_sysvec.c > head/sys/compat/ia32/ia32_util.h > head/sys/ia64/ia32/ia32_misc.c > head/sys/ia64/ia32/ia32_signal.c > head/sys/kern/imgact_aout.c > head/sys/kern/vfs_syscalls.c > head/sys/modules/Makefile > head/sys/sys/syscallsubr.h > > Modified: head/sys/amd64/ia32/ia32_misc.c > ============================================================================== > --- head/sys/amd64/ia32/ia32_misc.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/amd64/ia32/ia32_misc.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -69,3 +69,14 @@ freebsd32_sysarch(struct thread *td, str > return (sysarch(td, &uap1)); > } > } > + > +#ifdef COMPAT_43 > +int > +ofreebsd32_getpagesize(struct thread *td, > + struct ofreebsd32_getpagesize_args *uap) > +{ > + > + td->td_retval[0] = IA32_PAGE_SIZE; > + return (0); > +} > +#endif > > Modified: head/sys/amd64/ia32/ia32_signal.c > ============================================================================== > --- head/sys/amd64/ia32/ia32_signal.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/amd64/ia32/ia32_signal.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -300,6 +300,109 @@ freebsd32_swapcontext(struct thread *td, > * frame pointer, it returns to the user > * specified pc, psl. > */ > + > +#ifdef COMPAT_43 > +static void > +ia32_osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) > +{ > + struct ia32_sigframe3 sf, *fp; > + struct proc *p; > + struct thread *td; > + struct sigacts *psp; > + struct trapframe *regs; > + int sig; > + int oonstack; > + > + td = curthread; > + p = td->td_proc; > + PROC_LOCK_ASSERT(p, MA_OWNED); > + sig = ksi->ksi_signo; > + psp = p->p_sigacts; > + mtx_assert(&psp->ps_mtx, MA_OWNED); > + regs = td->td_frame; > + oonstack = sigonstack(regs->tf_rsp); > + > + /* Allocate space for the signal handler context. */ > + if ((td->td_pflags & TDP_ALTSTACK) && !oonstack && > + SIGISMEMBER(psp->ps_sigonstack, sig)) { > + fp = (struct ia32_sigframe3 *)(td->td_sigstk.ss_sp + > + td->td_sigstk.ss_size - sizeof(sf)); > + td->td_sigstk.ss_flags |= SS_ONSTACK; > + } else > + fp = (struct ia32_sigframe3 *)regs->tf_rsp - 1; > + > + /* Translate the signal if appropriate. */ > + if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize) > + sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; > + > + /* Build the argument list for the signal handler. */ > + sf.sf_signum = sig; > + sf.sf_scp = (register_t)&fp->sf_siginfo.si_sc; > + if (SIGISMEMBER(psp->ps_siginfo, sig)) { > + /* Signal handler installed with SA_SIGINFO. */ > + sf.sf_arg2 = (register_t)&fp->sf_siginfo; > + sf.sf_siginfo.si_signo = sig; > + sf.sf_siginfo.si_code = ksi->ksi_code; > + sf.sf_ah = (uintptr_t)catcher; > + } else { > + /* Old FreeBSD-style arguments. */ > + sf.sf_arg2 = ksi->ksi_code; > + sf.sf_addr = (register_t)ksi->ksi_addr; > + sf.sf_ah = (uintptr_t)catcher; > + } > + mtx_unlock(&psp->ps_mtx); > + PROC_UNLOCK(p); > + > + /* Save most if not all of trap frame. */ > + sf.sf_siginfo.si_sc.sc_eax = regs->tf_rax; > + sf.sf_siginfo.si_sc.sc_ebx = regs->tf_rbx; > + sf.sf_siginfo.si_sc.sc_ecx = regs->tf_rcx; > + sf.sf_siginfo.si_sc.sc_edx = regs->tf_rdx; > + sf.sf_siginfo.si_sc.sc_esi = regs->tf_rsi; > + sf.sf_siginfo.si_sc.sc_edi = regs->tf_rdi; > + sf.sf_siginfo.si_sc.sc_cs = regs->tf_cs; > + sf.sf_siginfo.si_sc.sc_ds = regs->tf_ds; > + sf.sf_siginfo.si_sc.sc_ss = regs->tf_ss; > + sf.sf_siginfo.si_sc.sc_es = regs->tf_es; > + sf.sf_siginfo.si_sc.sc_fs = regs->tf_fs; > + sf.sf_siginfo.si_sc.sc_gs = regs->tf_gs; > + sf.sf_siginfo.si_sc.sc_isp = regs->tf_rsp; > + > + /* Build the signal context to be used by osigreturn(). */ > + sf.sf_siginfo.si_sc.sc_onstack = (oonstack) ? 1 : 0; > + SIG2OSIG(*mask, sf.sf_siginfo.si_sc.sc_mask); > + sf.sf_siginfo.si_sc.sc_esp = regs->tf_rsp; > + sf.sf_siginfo.si_sc.sc_ebp = regs->tf_rbp; > + sf.sf_siginfo.si_sc.sc_eip = regs->tf_rip; > + sf.sf_siginfo.si_sc.sc_eflags = regs->tf_rflags; > + sf.sf_siginfo.si_sc.sc_trapno = regs->tf_trapno; > + sf.sf_siginfo.si_sc.sc_err = regs->tf_err; > + > + /* > + * Copy the sigframe out to the user's stack. > + */ > + if (copyout(&sf, fp, sizeof(*fp)) != 0) { > +#ifdef DEBUG > + printf("process %ld has trashed its stack\n", (long)p->p_pid); > +#endif > + PROC_LOCK(p); > + sigexit(td, SIGILL); > + } > + > + regs->tf_rsp = (uintptr_t)fp; > + regs->tf_rip = p->p_sysent->sv_psstrings - sz_ia32_osigcode; > + regs->tf_rflags &= ~(PSL_T | PSL_D); > + regs->tf_cs = _ucode32sel; > + regs->tf_ds = _udatasel; > + regs->tf_es = _udatasel; > + regs->tf_fs = _udatasel; > + regs->tf_ss = _udatasel; > + set_pcb_flags(td->td_pcb, PCB_FULL_IRET); > + PROC_LOCK(p); > + mtx_lock(&psp->ps_mtx); > +} > +#endif > + > #ifdef COMPAT_FREEBSD4 > static void > freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) > @@ -441,6 +544,12 @@ ia32_sendsig(sig_t catcher, ksiginfo_t * > return; > } > #endif > +#ifdef COMPAT_43 > + if (SIGISMEMBER(psp->ps_osigset, sig)) { > + ia32_osendsig(catcher, ksi, mask); > + return; > + } > +#endif > mtx_assert(&psp->ps_mtx, MA_OWNED); > regs = td->td_frame; > oonstack = sigonstack(regs->tf_rsp); > @@ -547,6 +656,64 @@ ia32_sendsig(sig_t catcher, ksiginfo_t * > * make sure that the user has not modified the > * state to gain improper privileges. > */ > + > +#ifdef COMPAT_43 > +int > +ofreebsd32_sigreturn(struct thread *td, struct ofreebsd32_sigreturn_args *uap) > +{ > + struct ia32_sigcontext3 sc, *scp; > + struct trapframe *regs; > + int eflags, error; > + ksiginfo_t ksi; > + > + regs = td->td_frame; > + error = copyin(uap->sigcntxp, &sc, sizeof(sc)); > + if (error != 0) > + return (error); > + scp = ≻ > + eflags = scp->sc_eflags; > + if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_rflags & ~PSL_RF)) { > + return (EINVAL); > + } > + if (!CS_SECURE(scp->sc_cs)) { > + ksiginfo_init_trap(&ksi); > + ksi.ksi_signo = SIGBUS; > + ksi.ksi_code = BUS_OBJERR; > + ksi.ksi_trapno = T_PROTFLT; > + ksi.ksi_addr = (void *)regs->tf_rip; > + trapsignal(td, &ksi); > + return (EINVAL); > + } > + regs->tf_ds = scp->sc_ds; > + regs->tf_es = scp->sc_es; > + regs->tf_fs = scp->sc_fs; > + regs->tf_gs = scp->sc_gs; > + > + regs->tf_rax = scp->sc_eax; > + regs->tf_rbx = scp->sc_ebx; > + regs->tf_rcx = scp->sc_ecx; > + regs->tf_rdx = scp->sc_edx; > + regs->tf_rsi = scp->sc_esi; > + regs->tf_rdi = scp->sc_edi; > + regs->tf_cs = scp->sc_cs; > + regs->tf_ss = scp->sc_ss; > + regs->tf_rbp = scp->sc_ebp; > + regs->tf_rsp = scp->sc_esp; > + regs->tf_rip = scp->sc_eip; > + regs->tf_rflags = eflags; > + > + if (scp->sc_onstack & 1) > + td->td_sigstk.ss_flags |= SS_ONSTACK; > + else > + td->td_sigstk.ss_flags &= ~SS_ONSTACK; > + > + kern_sigprocmask(td, SIG_SETMASK, (sigset_t *)&scp->sc_mask, NULL, > + SIGPROCMASK_OLD); > + set_pcb_flags(td->td_pcb, PCB_FULL_IRET); > + return (EJUSTRETURN); > +} > +#endif > + > #ifdef COMPAT_FREEBSD4 > /* > * MPSAFE > @@ -734,6 +901,9 @@ ia32_setregs(struct thread *td, struct i > user_ldt_free(td); > else > mtx_unlock(&dt_lock); > +#ifdef COMPAT_43 > + setup_lcall_gate(); > +#endif > > pcb->pcb_fsbase = 0; > pcb->pcb_gsbase = 0; > > Modified: head/sys/amd64/ia32/ia32_sigtramp.S > ============================================================================== > --- head/sys/amd64/ia32/ia32_sigtramp.S Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/amd64/ia32/ia32_sigtramp.S Fri Apr 1 11:16:29 2011 (r220238) > @@ -66,6 +66,35 @@ freebsd4_ia32_sigcode: > jmp 1b > #endif > > +#ifdef COMPAT_43 > + ALIGN_TEXT > +ia32_osigcode: > + calll *IA32_SIGF_HANDLER(%esp)/* call signal handler */ > + leal IA32_SIGF_SC(%esp),%eax /* get sigcontext */ > + pushl %eax > + movl $103,%eax /* 3.x SYS_sigreturn */ > + pushl %eax /* junk to fake return addr. */ > + int $0x80 /* enter kernel with args */ > +1: > + jmp 1b > + > + > + ALIGN_TEXT > +lcall_tramp: > + pushl %ebp > + movl %esp,%ebp > + pushl 0x24(%ebp) /* arg 6 */ > + pushl 0x20(%ebp) > + pushl 0x1c(%ebp) > + pushl 0x18(%ebp) > + pushl 0x14(%ebp) > + pushl 0x10(%ebp) /* arg 1 */ > + pushl 0xc(%ebp) /* gap */ > + int $0x80 > + leave > + lretl > +#endif > + > ALIGN_TEXT > esigcode: > > @@ -78,3 +107,11 @@ sz_ia32_sigcode: > sz_freebsd4_ia32_sigcode: > .long esigcode-freebsd4_ia32_sigcode > #endif > +#ifdef COMPAT_43 > + .globl sz_ia32_osigcode > +sz_ia32_osigcode: > + .long esigcode-ia32_osigcode > + .globl sz_lcall_tramp > +sz_lcall_tramp: > + .long esigcode-lcall_tramp > +#endif > > Modified: head/sys/amd64/ia32/ia32_syscall.c > ============================================================================== > --- head/sys/amd64/ia32/ia32_syscall.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/amd64/ia32/ia32_syscall.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); > */ > > #include "opt_clock.h" > +#include "opt_compat.h" > #include "opt_cpu.h" > #include "opt_isa.h" > > @@ -78,7 +79,17 @@ __FBSDID("$FreeBSD$"); > #include > #include > > +#include > #include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > > #define IDTVEC(name) __CONCAT(X,name) > > @@ -198,3 +209,45 @@ ia32_syscall_disable(void *dummy) > > SYSINIT(ia32_syscall, SI_SUB_EXEC, SI_ORDER_ANY, ia32_syscall_enable, NULL); > SYSUNINIT(ia32_syscall, SI_SUB_EXEC, SI_ORDER_ANY, ia32_syscall_disable, NULL); > + > +#ifdef COMPAT_43 > +int > +setup_lcall_gate(void) > +{ > + struct i386_ldt_args uap; > + struct user_segment_descriptor descs[2]; > + struct gate_descriptor *ssd; > + uint32_t lcall_addr; > + int error; > + > + bzero(&uap, sizeof(uap)); > + uap.start = 0; > + uap.num = 2; > + > + /* > + * This is the easiest way to cut the space for system > + * descriptor in ldt. Manually adjust the descriptor type to > + * the call gate later. > + */ > + bzero(&descs[0], sizeof(descs)); > + descs[0].sd_type = SDT_SYSNULL; > + descs[1].sd_type = SDT_SYSNULL; > + error = amd64_set_ldt(curthread, &uap, descs); > + if (error != 0) > + return (error); > + > + lcall_addr = curproc->p_sysent->sv_psstrings - sz_lcall_tramp; > + mtx_lock(&dt_lock); > + ssd = (struct gate_descriptor *)(curproc->p_md.md_ldt->ldt_base); > + bzero(ssd, sizeof(*ssd)); > + ssd->gd_looffset = lcall_addr; > + ssd->gd_hioffset = lcall_addr >> 16; > + ssd->gd_selector = _ucode32sel; > + ssd->gd_type = SDT_SYSCGT; > + ssd->gd_dpl = SEL_UPL; > + ssd->gd_p = 1; > + mtx_unlock(&dt_lock); > + > + return (0); > +} > +#endif > > Modified: head/sys/compat/freebsd32/freebsd32_misc.c > ============================================================================== > --- head/sys/compat/freebsd32/freebsd32_misc.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/compat/freebsd32/freebsd32_misc.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -1454,6 +1454,29 @@ freebsd32_ftruncate(struct thread *td, s > return (ftruncate(td, &ap)); > } > > +#ifdef COMPAT_43 > +int > +ofreebsd32_getdirentries(struct thread *td, > + struct ofreebsd32_getdirentries_args *uap) > +{ > + struct ogetdirentries_args ap; > + int error; > + long loff; > + int32_t loff_cut; > + > + ap.fd = uap->fd; > + ap.buf = uap->buf; > + ap.count = uap->count; > + ap.basep = NULL; > + error = kern_ogetdirentries(td, &ap, &loff); > + if (error == 0) { > + loff_cut = loff; > + error = copyout(&loff_cut, uap->basep, sizeof(int32_t)); > + } > + return (error); > +} > +#endif > + > int > freebsd32_getdirentries(struct thread *td, > struct freebsd32_getdirentries_args *uap) > @@ -1638,6 +1661,29 @@ copy_stat(struct stat *in, struct stat32 > TS_CP(*in, *out, st_birthtim); > } > > +#ifdef COMPAT_43 > +static void > +copy_ostat(struct stat *in, struct ostat32 *out) > +{ > + > + CP(*in, *out, st_dev); > + CP(*in, *out, st_ino); > + CP(*in, *out, st_mode); > + CP(*in, *out, st_nlink); > + CP(*in, *out, st_uid); > + CP(*in, *out, st_gid); > + CP(*in, *out, st_rdev); > + CP(*in, *out, st_size); > + TS_CP(*in, *out, st_atim); > + TS_CP(*in, *out, st_mtim); > + TS_CP(*in, *out, st_ctim); > + CP(*in, *out, st_blksize); > + CP(*in, *out, st_blocks); > + CP(*in, *out, st_flags); > + CP(*in, *out, st_gen); > +} > +#endif > + > int > freebsd32_stat(struct thread *td, struct freebsd32_stat_args *uap) > { > @@ -1653,6 +1699,23 @@ freebsd32_stat(struct thread *td, struct > return (error); > } > > +#ifdef COMPAT_43 > +int > +ofreebsd32_stat(struct thread *td, struct ofreebsd32_stat_args *uap) > +{ > + struct stat sb; > + struct ostat32 sb32; > + int error; > + > + error = kern_stat(td, uap->path, UIO_USERSPACE, &sb); > + if (error) > + return (error); > + copy_ostat(&sb, &sb32); > + error = copyout(&sb32, uap->ub, sizeof (sb32)); > + return (error); > +} > +#endif > + > int > freebsd32_fstat(struct thread *td, struct freebsd32_fstat_args *uap) > { > @@ -1668,6 +1731,23 @@ freebsd32_fstat(struct thread *td, struc > return (error); > } > > +#ifdef COMPAT_43 > +int > +ofreebsd32_fstat(struct thread *td, struct ofreebsd32_fstat_args *uap) > +{ > + struct stat ub; > + struct ostat32 ub32; > + int error; > + > + error = kern_fstat(td, uap->fd, &ub); > + if (error) > + return (error); > + copy_ostat(&ub, &ub32); > + error = copyout(&ub32, uap->ub, sizeof(ub32)); > + return (error); > +} > +#endif > + > int > freebsd32_fstatat(struct thread *td, struct freebsd32_fstatat_args *uap) > { > @@ -1698,9 +1778,23 @@ freebsd32_lstat(struct thread *td, struc > return (error); > } > > -/* > - * MPSAFE > - */ > +#ifdef COMPAT_43 > +int > +ofreebsd32_lstat(struct thread *td, struct ofreebsd32_lstat_args *uap) > +{ > + struct stat sb; > + struct ostat32 sb32; > + int error; > + > + error = kern_lstat(td, uap->path, UIO_USERSPACE, &sb); > + if (error) > + return (error); > + copy_ostat(&sb, &sb32); > + error = copyout(&sb32, uap->ub, sizeof (sb32)); > + return (error); > +} > +#endif > + > int > freebsd32_sysctl(struct thread *td, struct freebsd32_sysctl_args *uap) > { > > Modified: head/sys/compat/freebsd32/syscalls.master > ============================================================================== > --- head/sys/compat/freebsd32/syscalls.master Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/compat/freebsd32/syscalls.master Fri Apr 1 11:16:29 2011 (r220238) > @@ -117,9 +117,11 @@ > 35 AUE_FCHFLAGS NOPROTO { int fchflags(int fd, int flags); } > 36 AUE_SYNC NOPROTO { int sync(void); } > 37 AUE_KILL NOPROTO { int kill(int pid, int signum); } > -38 AUE_STAT UNIMPL ostat > +38 AUE_STAT COMPAT { int freebsd32_stat(char *path, \ > + struct ostat32 *ub); } > 39 AUE_GETPPID NOPROTO { pid_t getppid(void); } > -40 AUE_LSTAT UNIMPL olstat > +40 AUE_LSTAT COMPAT { int freebsd32_lstat(char *path, \ > + struct ostat *ub); } > 41 AUE_DUP NOPROTO { int dup(u_int fd); } > 42 AUE_PIPE NOPROTO { int pipe(void); } > 43 AUE_GETEGID NOPROTO { gid_t getegid(void); } > @@ -153,9 +155,11 @@ > 60 AUE_UMASK NOPROTO { int umask(int newmask); } umask \ > umask_args int > 61 AUE_CHROOT NOPROTO { int chroot(char *path); } > -62 AUE_FSTAT OBSOL ofstat > +62 AUE_FSTAT COMPAT { int freebsd32_fstat(int fd, \ > + struct ostat32 *ub); } > 63 AUE_NULL OBSOL ogetkerninfo > -64 AUE_NULL OBSOL ogetpagesize > +64 AUE_NULL COMPAT { int freebsd32_getpagesize( \ > + int32_t dummy); } > 65 AUE_MSYNC NOPROTO { int msync(void *addr, size_t len, \ > int flags); } > 66 AUE_VFORK NOPROTO { int vfork(void); } > @@ -210,7 +214,8 @@ > 100 AUE_GETPRIORITY NOPROTO { int getpriority(int which, int who); } > 101 AUE_NULL OBSOL osend > 102 AUE_NULL OBSOL orecv > -103 AUE_NULL OBSOL osigreturn > +103 AUE_NULL COMPAT { int freebsd32_sigreturn( \ > + struct ia32_sigcontext3 *sigcntxp); } > 104 AUE_BIND NOPROTO { int bind(int s, caddr_t name, \ > int namelen); } > 105 AUE_SETSOCKOPT NOPROTO { int setsockopt(int s, int level, \ > @@ -292,7 +297,8 @@ > ; 155 is initialized by the NFS code, if present. > ; XXX this is a problem!!! > 155 AUE_NFS_SVC UNIMPL nfssvc > -156 AUE_GETDIRENTRIES OBSOL ogetdirentries > +156 AUE_GETDIRENTRIES COMPAT { int freebsd32_getdirentries(int fd, \ > + char *buf, u_int count, uint32_t *basep); } > 157 AUE_STATFS COMPAT4 { int freebsd32_statfs(char *path, \ > struct statfs32 *buf); } > 158 AUE_FSTATFS COMPAT4 { int freebsd32_fstatfs(int fd, \ > > Modified: head/sys/compat/ia32/ia32_genassym.c > ============================================================================== > --- head/sys/compat/ia32/ia32_genassym.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/compat/ia32/ia32_genassym.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -13,6 +13,9 @@ __FBSDID("$FreeBSD$"); > > ASSYM(IA32_SIGF_HANDLER, offsetof(struct ia32_sigframe, sf_ah)); > ASSYM(IA32_SIGF_UC, offsetof(struct ia32_sigframe, sf_uc)); > +#ifdef COMPAT_43 > +ASSYM(IA32_SIGF_SC, offsetof(struct ia32_sigframe3, sf_siginfo.si_sc)); > +#endif > ASSYM(IA32_UC_GS, offsetof(struct ia32_ucontext, uc_mcontext.mc_gs)); > ASSYM(IA32_UC_FS, offsetof(struct ia32_ucontext, uc_mcontext.mc_fs)); > ASSYM(IA32_UC_ES, offsetof(struct ia32_ucontext, uc_mcontext.mc_es)); > > Modified: head/sys/compat/ia32/ia32_signal.h > ============================================================================== > --- head/sys/compat/ia32/ia32_signal.h Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/compat/ia32/ia32_signal.h Fri Apr 1 11:16:29 2011 (r220238) > @@ -112,7 +112,7 @@ struct ia32_ucontext4 { > }; > #endif > > -#ifdef COMPAT_FREEBSD3 > +#ifdef COMPAT_43 > struct ia32_sigcontext3 { > u_int32_t sc_onstack; > u_int32_t sc_mask; > @@ -165,7 +165,7 @@ struct ia32_sigframe { > struct siginfo32 sf_si; /* = *sf_siginfo (SA_SIGINFO case) */ > }; > > -#ifdef COMPAT_FREEBSD3 > +#ifdef COMPAT_43 > struct ia32_siginfo3 { > struct ia32_sigcontext3 si_sc; > int si_signo; > @@ -186,10 +186,15 @@ struct ksiginfo; > struct image_params; > extern char ia32_sigcode[]; > extern char freebsd4_ia32_sigcode[]; > +extern char ia32_osigcode[]; > +extern char lcall_tramp; > extern int sz_ia32_sigcode; > extern int sz_freebsd4_ia32_sigcode; > -extern void ia32_sendsig(sig_t, struct ksiginfo *, sigset_t *); > -extern void ia32_setregs(struct thread *td, struct image_params *imgp, > +extern int sz_ia32_osigcode; > +extern int sz_lcall_tramp; > +void ia32_sendsig(sig_t, struct ksiginfo *, sigset_t *); > +void ia32_setregs(struct thread *td, struct image_params *imgp, > u_long stack); > +int setup_lcall_gate(void); > > #endif > > Modified: head/sys/compat/ia32/ia32_sysvec.c > ============================================================================== > --- head/sys/compat/ia32/ia32_sysvec.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/compat/ia32/ia32_sysvec.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -95,14 +95,12 @@ CTASSERT(sizeof(struct ia32_sigframe4) = > > extern const char *freebsd32_syscallnames[]; > > -static void ia32_fixlimit(struct rlimit *rl, int which); > - > SYSCTL_NODE(_compat, OID_AUTO, ia32, CTLFLAG_RW, 0, "ia32 mode"); > > static u_long ia32_maxdsiz = IA32_MAXDSIZ; > SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxdsiz, CTLFLAG_RW, &ia32_maxdsiz, 0, ""); > TUNABLE_ULONG("compat.ia32.maxdsiz", &ia32_maxdsiz); > -static u_long ia32_maxssiz = IA32_MAXSSIZ; > +u_long ia32_maxssiz = IA32_MAXSSIZ; > SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxssiz, CTLFLAG_RW, &ia32_maxssiz, 0, ""); > TUNABLE_ULONG("compat.ia32.maxssiz", &ia32_maxssiz); > static u_long ia32_maxvmem = IA32_MAXVMEM; > @@ -206,7 +204,7 @@ elf32_dump_thread(struct thread *td __un > { > } > > -static void > +void > ia32_fixlimit(struct rlimit *rl, int which) > { > > > Modified: head/sys/compat/ia32/ia32_util.h > ============================================================================== > --- head/sys/compat/ia32/ia32_util.h Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/compat/ia32/ia32_util.h Fri Apr 1 11:16:29 2011 (r220238) > @@ -58,5 +58,6 @@ > struct syscall_args; > int ia32_fetch_syscall_args(struct thread *td, struct syscall_args *sa); > void ia32_set_syscall_retval(struct thread *, int); > +void ia32_fixlimit(struct rlimit *rl, int which); > > #endif > > Modified: head/sys/ia64/ia32/ia32_misc.c > ============================================================================== > --- head/sys/ia64/ia32/ia32_misc.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/ia64/ia32/ia32_misc.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -48,3 +48,14 @@ freebsd32_sysarch(struct thread *td, str > > return (EOPNOTSUPP); > } > + > +#ifdef COMPAT_43 > +int > +ofreebsd32_getpagesize(struct thread *td, > + struct ofreebsd32_getpagesize_args *uap) > +{ > + > + td->td_retval[0] = IA32_PAGE_SIZE; > + return (0); > +} > +#endif > > Modified: head/sys/ia64/ia32/ia32_signal.c > ============================================================================== > --- head/sys/ia64/ia32/ia32_signal.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/ia64/ia32/ia32_signal.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -92,6 +92,15 @@ x) */ > }; > int sz_ia32_sigcode = sizeof(ia32_sigcode); > > +#ifdef COMPAT_43 > +int > +ofreebsd32_sigreturn(struct thread *td, struct ofreebsd32_sigreturn_args *uap) > +{ > + > + return (EOPNOTSUPP); > +} > +#endif > + > /* > * Signal sending has not been implemented on ia64. This causes > * the sigtramp code to not understand the arguments and the application > > Modified: head/sys/kern/imgact_aout.c > ============================================================================== > --- head/sys/kern/imgact_aout.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/kern/imgact_aout.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #include > #include > #include > @@ -52,9 +53,18 @@ __FBSDID("$FreeBSD$"); > #include > #include > > +#ifdef __amd64__ > +#include > +#include > +#include > +#include > +#include > +#endif > + > static int exec_aout_imgact(struct image_params *imgp); > static int aout_fixup(register_t **stack_base, struct image_params *imgp); > > +#if defined(__i386__) > struct sysentvec aout_sysvec = { > .sv_size = SYS_MAXSYSCALL, > .sv_table = sysent, > @@ -83,31 +93,69 @@ struct sysentvec aout_sysvec = { > .sv_setregs = exec_setregs, > .sv_fixlimit = NULL, > .sv_maxssiz = NULL, > - .sv_flags = SV_ABI_FREEBSD | SV_AOUT | > -#if defined(__i386__) > - SV_IA32 | SV_ILP32 > -#else > -#error Choose SV_XXX flags for the platform > -#endif > - , > + .sv_flags = SV_ABI_FREEBSD | SV_AOUT | SV_IA32 | SV_ILP32, > .sv_set_syscall_retval = cpu_set_syscall_retval, > .sv_fetch_syscall_args = cpu_fetch_syscall_args, > .sv_syscallnames = syscallnames, > .sv_schedtail = NULL, > }; > > +#elif defined(__amd64__) > + > +#define AOUT32_USRSTACK 0xbfc0000 > +#define AOUT32_PS_STRINGS \ > + (AOUT32_USRSTACK - sizeof(struct freebsd32_ps_strings)) > + > +extern const char *freebsd32_syscallnames[]; > +extern u_long ia32_maxssiz; > + > +struct sysentvec aout_sysvec = { > + .sv_size = FREEBSD32_SYS_MAXSYSCALL, > + .sv_table = freebsd32_sysent, > + .sv_mask = 0, > + .sv_sigsize = 0, > + .sv_sigtbl = NULL, > + .sv_errsize = 0, > + .sv_errtbl = NULL, > + .sv_transtrap = NULL, > + .sv_fixup = aout_fixup, > + .sv_sendsig = ia32_sendsig, > + .sv_sigcode = ia32_sigcode, > + .sv_szsigcode = &sz_ia32_sigcode, > + .sv_prepsyscall = NULL, > + .sv_name = "FreeBSD a.out", > + .sv_coredump = NULL, > + .sv_imgact_try = NULL, > + .sv_minsigstksz = MINSIGSTKSZ, > + .sv_pagesize = IA32_PAGE_SIZE, > + .sv_minuser = 0, > + .sv_maxuser = AOUT32_USRSTACK, > + .sv_usrstack = AOUT32_USRSTACK, > + .sv_psstrings = AOUT32_PS_STRINGS, > + .sv_stackprot = VM_PROT_ALL, > + .sv_copyout_strings = freebsd32_copyout_strings, > + .sv_setregs = ia32_setregs, > + .sv_fixlimit = ia32_fixlimit, > + .sv_maxssiz = &ia32_maxssiz, > + .sv_flags = SV_ABI_FREEBSD | SV_AOUT | SV_IA32 | SV_ILP32, > + .sv_set_syscall_retval = ia32_set_syscall_retval, > + .sv_fetch_syscall_args = ia32_fetch_syscall_args, > + .sv_syscallnames = freebsd32_syscallnames, > +}; > +#else > +#error "Port me" > +#endif > + > static int > -aout_fixup(stack_base, imgp) > - register_t **stack_base; > - struct image_params *imgp; > +aout_fixup(register_t **stack_base, struct image_params *imgp) > { > > - return (suword(--(*stack_base), imgp->args->argc)); > + *(char **)stack_base -= sizeof(uint32_t); > + return (suword(*stack_base, imgp->args->argc)); > } > > static int > -exec_aout_imgact(imgp) > - struct image_params *imgp; > +exec_aout_imgact(struct image_params *imgp) > { > const struct exec *a_out = (const struct exec *) imgp->image_header; > struct vmspace *vmspace; > @@ -175,7 +223,14 @@ exec_aout_imgact(imgp) > a_out->a_entry >= virtual_offset + a_out->a_text || > > /* text and data size must each be page rounded */ > - a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK) > + a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK > + > +#ifdef __amd64__ > + || > + /* overflows */ > + virtual_offset + a_out->a_text + a_out->a_data + bss_size > UINT_MAX > +#endif > + ) > return (-1); > > /* text + data can't exceed file size */ > > Modified: head/sys/kern/vfs_syscalls.c > ============================================================================== > --- head/sys/kern/vfs_syscalls.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/kern/vfs_syscalls.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -3898,14 +3898,20 @@ struct ogetdirentries_args { > }; > #endif > int > -ogetdirentries(td, uap) > - struct thread *td; > - register struct ogetdirentries_args /* { > - int fd; > - char *buf; > - u_int count; > - long *basep; > - } */ *uap; > +ogetdirentries(struct thread *td, struct ogetdirentries_args *uap) > +{ > + long loff; > + int error; > + > + error = kern_ogetdirentries(td, uap, &loff); > + if (error == 0) > + error = copyout(&loff, uap->basep, sizeof(long)); > + return (error); > +} > + > +int > +kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap, > + long *ploff) > { > struct vnode *vp; > struct file *fp; > @@ -4024,9 +4030,10 @@ unionread: > } > VOP_UNLOCK(vp, 0); > VFS_UNLOCK_GIANT(vfslocked); > - error = copyout(&loff, uap->basep, sizeof(long)); > fdrop(fp, td); > td->td_retval[0] = uap->count - auio.uio_resid; > + if (error == 0) > + *ploff = loff; > return (error); > } > #endif /* COMPAT_43 */ > > Modified: head/sys/modules/Makefile > ============================================================================== > --- head/sys/modules/Makefile Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/modules/Makefile Fri Apr 1 11:16:29 2011 (r220238) > @@ -518,6 +518,7 @@ _snc= snc > > .if ${MACHINE_CPUARCH} == "amd64" > _aac= aac > +_aout= aout > _acpi= acpi > .if ${MK_CRYPT} != "no" || defined(ALL_MODULES) > _aesni= aesni > > Modified: head/sys/sys/syscallsubr.h > ============================================================================== > --- head/sys/sys/syscallsubr.h Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/sys/syscallsubr.h Fri Apr 1 11:16:29 2011 (r220238) > @@ -52,6 +52,7 @@ struct kld_file_stat; > struct ksiginfo; > struct sendfile_args; > struct thr_param; > +struct ogetdirentries_args; > > int kern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg, > u_int buflen); > @@ -143,6 +144,8 @@ int kern_msgsnd(struct thread *, int, co > int kern_msgrcv(struct thread *, int, void *, size_t, long, int, long *); > int kern_nanosleep(struct thread *td, struct timespec *rqt, > struct timespec *rmt); > +int kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap, > + long *ploff); > int kern_open(struct thread *td, char *path, enum uio_seg pathseg, > int flags, int mode); > int kern_openat(struct thread *td, int fd, char *path, -- a13x From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 12:50:30 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 434C51065670; Fri, 1 Apr 2011 12:50:30 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3265C8FC12; Fri, 1 Apr 2011 12:50:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31CoUkx045358; Fri, 1 Apr 2011 12:50:30 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31CoULd045353; Fri, 1 Apr 2011 12:50:30 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011250.p31CoULd045353@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 12:50:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220241 - in stable/8/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 12:50:30 -0000 Author: kib Date: Fri Apr 1 12:50:29 2011 New Revision: 220241 URL: http://svn.freebsd.org/changeset/base/220241 Log: MFC r219999: Add O_CLOEXEC flag to open(2) and fhopen(2). Modified: stable/8/sys/kern/kern_descrip.c stable/8/sys/kern/vfs_syscalls.c stable/8/sys/sys/fcntl.h stable/8/sys/sys/filedesc.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/kern_descrip.c ============================================================================== --- stable/8/sys/kern/kern_descrip.c Fri Apr 1 11:39:13 2011 (r220240) +++ stable/8/sys/kern/kern_descrip.c Fri Apr 1 12:50:29 2011 (r220241) @@ -1514,7 +1514,7 @@ fdavail(struct thread *td, int n) * release the FILEDESC lock. */ int -falloc(struct thread *td, struct file **resultfp, int *resultfd) +fallocf(struct thread *td, struct file **resultfp, int *resultfd, int flags) { struct proc *p = td->td_proc; struct file *fp; @@ -1557,6 +1557,8 @@ falloc(struct thread *td, struct file ** return (error); } p->p_fd->fd_ofiles[i] = fp; + if ((flags & O_CLOEXEC) != 0) + p->p_fd->fd_ofileflags[i] |= UF_EXCLOSE; FILEDESC_XUNLOCK(p->p_fd); if (resultfp) *resultfp = fp; @@ -1565,6 +1567,13 @@ falloc(struct thread *td, struct file ** return (0); } +int +falloc(struct thread *td, struct file **resultfp, int *resultfd) +{ + + return (fallocf(td, resultfp, resultfd, 0)); +} + /* * Build a new filedesc structure from another. * Copy the current, root, and jail root vnode references. Modified: stable/8/sys/kern/vfs_syscalls.c ============================================================================== --- stable/8/sys/kern/vfs_syscalls.c Fri Apr 1 11:39:13 2011 (r220240) +++ stable/8/sys/kern/vfs_syscalls.c Fri Apr 1 12:50:29 2011 (r220241) @@ -1069,7 +1069,7 @@ kern_openat(struct thread *td, int fd, c else flags = FFLAGS(flags); - error = falloc(td, &nfp, &indx); + error = fallocf(td, &nfp, &indx, flags); if (error) return (error); /* An extra reference on `nfp' has been held for us by falloc(). */ @@ -4478,7 +4478,7 @@ fhopen(td, uap) * end of vn_open code */ - if ((error = falloc(td, &nfp, &indx)) != 0) { + if ((error = fallocf(td, &nfp, &indx, fmode)) != 0) { if (fmode & FWRITE) vp->v_writecount--; goto bad; Modified: stable/8/sys/sys/fcntl.h ============================================================================== --- stable/8/sys/sys/fcntl.h Fri Apr 1 11:39:13 2011 (r220240) +++ stable/8/sys/sys/fcntl.h Fri Apr 1 12:50:29 2011 (r220241) @@ -123,9 +123,11 @@ typedef __pid_t pid_t; #define FEXEC O_EXEC #endif -/* Defined by POSIX 1003.1-2008; BSD default, but reserve for future use. */ #if __POSIX_VISIBLE >= 200809 +/* Defined by POSIX 1003.1-2008; BSD default, but reserve for future use. */ #define O_TTY_INIT 0x00080000 /* Restore default termios attributes */ + +#define O_CLOEXEC 0x00100000 #endif /* Modified: stable/8/sys/sys/filedesc.h ============================================================================== --- stable/8/sys/sys/filedesc.h Fri Apr 1 11:39:13 2011 (r220240) +++ stable/8/sys/sys/filedesc.h Fri Apr 1 12:50:29 2011 (r220241) @@ -112,6 +112,8 @@ int closef(struct file *fp, struct threa int dupfdopen(struct thread *td, struct filedesc *fdp, int indx, int dfd, int mode, int error); int falloc(struct thread *td, struct file **resultfp, int *resultfd); +int fallocf(struct thread *td, struct file **resultfp, int *resultfd, + int flags); int fdalloc(struct thread *td, int minfd, int *result); int fdavail(struct thread *td, int n); int fdcheckstd(struct thread *td); From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 12:52:55 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B18C3106566B; Fri, 1 Apr 2011 12:52:55 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A0EAE8FC0A; Fri, 1 Apr 2011 12:52:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31Cqte3045527; Fri, 1 Apr 2011 12:52:55 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31CqtoA045525; Fri, 1 Apr 2011 12:52:55 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011252.p31CqtoA045525@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 12:52:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220242 - stable/8/lib/libc/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 12:52:55 -0000 Author: kib Date: Fri Apr 1 12:52:55 2011 New Revision: 220242 URL: http://svn.freebsd.org/changeset/base/220242 Log: MFC r220000: Document O_CLOEXEC. Modified: stable/8/lib/libc/sys/open.2 Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) Modified: stable/8/lib/libc/sys/open.2 ============================================================================== --- stable/8/lib/libc/sys/open.2 Fri Apr 1 12:50:29 2011 (r220241) +++ stable/8/lib/libc/sys/open.2 Fri Apr 1 12:52:55 2011 (r220242) @@ -28,7 +28,7 @@ .\" @(#)open.2 8.2 (Berkeley) 11/16/93 .\" $FreeBSD$ .\" -.Dd February 28, 2009 +.Dd March 25, 2011 .Dt OPEN 2 .Os .Sh NAME @@ -117,6 +117,7 @@ O_SYNC synchronous writes O_NOFOLLOW do not follow symlinks O_NOCTTY don't assign controlling terminal O_TTY_INIT restore default terminal attributes +O_CLOEXEC set FD_CLOEXEC upon open .Ed .Pp Opening a file with @@ -222,6 +223,11 @@ The initial call to on a TTY will always restore default terminal attributes on .Fx . .Pp +.Dv O_CLOEXEC +may be used to set +.Dv FD_CLOEXEC +flag for the newly returned file descriptor. +.Pp If successful, .Fn open returns a non-negative integer, termed a file descriptor. @@ -232,12 +238,18 @@ file is set to the beginning of the file When a new file is created it is given the group of the directory which contains it. .Pp -The new descriptor is set to remain open across +Unless +.Dv +O_CLOEXEC +flag was specified, +the new descriptor is set to remain open across .Xr execve 2 system calls; see -.Xr close 2 +.Xr close 2 , +.Xr fcntl 2 and -.Xr fcntl 2 . +.Dv O_CLOEXEC +description. .Pp The system imposes a limit on the number of file descriptors open simultaneously by one process. From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 13:20:39 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 69E1C106564A; Fri, 1 Apr 2011 13:20:39 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 58E718FC17; Fri, 1 Apr 2011 13:20:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31DKda3046513; Fri, 1 Apr 2011 13:20:39 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31DKdEJ046511; Fri, 1 Apr 2011 13:20:39 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011320.p31DKdEJ046511@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 13:20:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220243 - stable/8/sys/compat/freebsd32 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 13:20:39 -0000 Author: kib Date: Fri Apr 1 13:20:39 2011 New Revision: 220243 URL: http://svn.freebsd.org/changeset/base/220243 Log: MFC r219988: Fully emulate MDIOCLIST for compat32. Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c ============================================================================== --- stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Fri Apr 1 12:52:55 2011 (r220242) +++ stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Fri Apr 1 13:20:39 2011 (r220243) @@ -64,7 +64,7 @@ freebsd32_ioctl_md(struct thread *td, st struct md_ioctl mdv; struct md_ioctl32 md32; u_long com = 0; - int error; + int i, error; if (uap->com & IOC_IN) { if ((error = copyin(uap->data, &md32, sizeof(md32)))) { @@ -116,6 +116,14 @@ freebsd32_ioctl_md(struct thread *td, st CP(mdv, md32, md_base); CP(mdv, md32, md_fwheads); CP(mdv, md32, md_fwsectors); + if (com == MDIOCLIST) { + /* + * Use MDNPAD, and not MDNPAD32. Padding is + * allocated and used by compat32 ABI. + */ + for (i = 0; i < MDNPAD; i++) + CP(mdv, md32, md_pad[i]); + } error = copyout(&md32, uap->data, sizeof(md32)); } return error; From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 13:23:54 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E1B2D106564A; Fri, 1 Apr 2011 13:23:53 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D062A8FC14; Fri, 1 Apr 2011 13:23:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31DNrUq046655; Fri, 1 Apr 2011 13:23:53 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31DNru3046652; Fri, 1 Apr 2011 13:23:53 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011323.p31DNru3046652@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 13:23:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220244 - stable/8/sys/compat/freebsd32 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 13:23:54 -0000 Author: kib Date: Fri Apr 1 13:23:53 2011 New Revision: 220244 URL: http://svn.freebsd.org/changeset/base/220244 Log: MFC r219989: Implement compat32 MEMRANGE_GET and MEMRANGE_SET. Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c stable/8/sys/compat/freebsd32/freebsd32_ioctl.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c ============================================================================== --- stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Fri Apr 1 13:20:39 2011 (r220243) +++ stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Fri Apr 1 13:23:53 2011 (r220244) @@ -38,7 +38,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include #include @@ -55,6 +57,7 @@ __FBSDID("$FreeBSD$"); CTASSERT((sizeof(struct md_ioctl32)+4) == 436); CTASSERT(sizeof(struct ioc_read_toc_entry32) == 8); CTASSERT(sizeof(struct ioc_toc_header32) == 4); +CTASSERT(sizeof(struct mem_range_op32) == 12); static int @@ -191,6 +194,49 @@ freebsd32_ioctl_fiodgname(struct thread return (error); } +static int +freebsd32_ioctl_memrange(struct thread *td, + struct freebsd32_ioctl_args *uap, struct file *fp) +{ + struct mem_range_op mro; + struct mem_range_op32 mro32; + int error; + u_long com; + + if ((error = copyin(uap->data, &mro32, sizeof(mro32))) != 0) + return (error); + + PTRIN_CP(mro32, mro, mo_desc); + CP(mro32, mro, mo_arg[0]); + CP(mro32, mro, mo_arg[1]); + + com = 0; + switch (uap->com) { + case MEMRANGE_GET32: + com = MEMRANGE_GET; + break; + + case MEMRANGE_SET32: + com = MEMRANGE_SET; + break; + + default: + panic("%s: unknown MEMRANGE %#x", __func__, uap->com); + } + + if ((error = fo_ioctl(fp, com, (caddr_t)&mro, td->td_ucred, td)) != 0) + return (error); + + if ( (com & IOC_OUT) ) { + CP(mro, mro32, mo_arg[0]); + CP(mro, mro32, mo_arg[1]); + + error = copyout(&mro32, uap->data, sizeof(mro32)); + } + + return (error); +} + int freebsd32_ioctl(struct thread *td, struct freebsd32_ioctl_args *uap) { @@ -229,6 +275,11 @@ freebsd32_ioctl(struct thread *td, struc error = freebsd32_ioctl_fiodgname(td, uap, fp); break; + case MEMRANGE_GET32: /* FALLTHROUGH */ + case MEMRANGE_SET32: + error = freebsd32_ioctl_memrange(td, uap, fp); + break; + default: fdrop(fp, td); ap.fd = uap->fd; Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.h ============================================================================== --- stable/8/sys/compat/freebsd32/freebsd32_ioctl.h Fri Apr 1 13:20:39 2011 (r220243) +++ stable/8/sys/compat/freebsd32/freebsd32_ioctl.h Fri Apr 1 13:23:53 2011 (r220244) @@ -67,6 +67,12 @@ struct fiodgname_arg32 { caddr_t32 buf; }; +struct mem_range_op32 +{ + caddr_t32 mo_desc; + int mo_arg[2]; +}; + #define CDIOREADTOCENTRYS_32 _IOWR('c', 5, struct ioc_read_toc_entry32) #define CDIOREADTOCHEADER_32 _IOR('c', 4, struct ioc_toc_header32) #define MDIOCATTACH_32 _IOC(IOC_INOUT, 'm', 0, sizeof(struct md_ioctl32) + 4) @@ -74,5 +80,7 @@ struct fiodgname_arg32 { #define MDIOCQUERY_32 _IOC(IOC_INOUT, 'm', 2, sizeof(struct md_ioctl32) + 4) #define MDIOCLIST_32 _IOC(IOC_INOUT, 'm', 3, sizeof(struct md_ioctl32) + 4) #define FIODGNAME_32 _IOW('f', 120, struct fiodgname_arg32) +#define MEMRANGE_GET32 _IOWR('m', 50, struct mem_range_op32) +#define MEMRANGE_SET32 _IOW('m', 51, struct mem_range_op32) #endif /* _COMPAT_FREEBSD32_IOCTL_H_ */ From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 13:28:35 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 66FC1106566B; Fri, 1 Apr 2011 13:28:35 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 556B08FC15; Fri, 1 Apr 2011 13:28:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31DSZ4P046808; Fri, 1 Apr 2011 13:28:35 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31DSZud046795; Fri, 1 Apr 2011 13:28:35 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011328.p31DSZud046795@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 13:28:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220245 - in head/sys: dev/streams kern opencrypto sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 13:28:35 -0000 Author: kib Date: Fri Apr 1 13:28:34 2011 New Revision: 220245 URL: http://svn.freebsd.org/changeset/base/220245 Log: After the r219999 is merged to stable/8, rename fallocf(9) to falloc(9) and remove the falloc() version that lacks flag argument. This is done to reduce the KPI bloat. Requested by: jhb X-MFC-note: do not Modified: head/sys/dev/streams/streams.c head/sys/kern/kern_descrip.c head/sys/kern/kern_event.c head/sys/kern/sys_pipe.c head/sys/kern/tty_pts.c head/sys/kern/uipc_mqueue.c head/sys/kern/uipc_sem.c head/sys/kern/uipc_shm.c head/sys/kern/uipc_syscalls.c head/sys/kern/vfs_syscalls.c head/sys/opencrypto/cryptodev.c head/sys/sys/filedesc.h Modified: head/sys/dev/streams/streams.c ============================================================================== --- head/sys/dev/streams/streams.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/dev/streams/streams.c Fri Apr 1 13:28:34 2011 (r220245) @@ -241,7 +241,7 @@ streamsopen(struct cdev *dev, int oflags } fdp = td->td_proc->p_fd; - if ((error = falloc(td, &fp, &fd)) != 0) + if ((error = falloc(td, &fp, &fd, 0)) != 0) return error; /* An extra reference on `fp' has been held for us by falloc(). */ Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/kern_descrip.c Fri Apr 1 13:28:34 2011 (r220245) @@ -1516,7 +1516,7 @@ fdavail(struct thread *td, int n) * release the FILEDESC lock. */ int -fallocf(struct thread *td, struct file **resultfp, int *resultfd, int flags) +falloc(struct thread *td, struct file **resultfp, int *resultfd, int flags) { struct proc *p = td->td_proc; struct file *fp; @@ -1569,13 +1569,6 @@ fallocf(struct thread *td, struct file * return (0); } -int -falloc(struct thread *td, struct file **resultfp, int *resultfd) -{ - - return (fallocf(td, resultfp, resultfd, 0)); -} - /* * Build a new filedesc structure from another. * Copy the current, root, and jail root vnode references. Modified: head/sys/kern/kern_event.c ============================================================================== --- head/sys/kern/kern_event.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/kern_event.c Fri Apr 1 13:28:34 2011 (r220245) @@ -684,7 +684,7 @@ kqueue(struct thread *td, struct kqueue_ int fd, error; fdp = td->td_proc->p_fd; - error = falloc(td, &fp, &fd); + error = falloc(td, &fp, &fd, 0); if (error) goto done2; Modified: head/sys/kern/sys_pipe.c ============================================================================== --- head/sys/kern/sys_pipe.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/sys_pipe.c Fri Apr 1 13:28:34 2011 (r220245) @@ -348,7 +348,7 @@ kern_pipe(struct thread *td, int fildes[ rpipe->pipe_state |= PIPE_DIRECTOK; wpipe->pipe_state |= PIPE_DIRECTOK; - error = falloc(td, &rf, &fd); + error = falloc(td, &rf, &fd, 0); if (error) { pipeclose(rpipe); pipeclose(wpipe); @@ -364,7 +364,7 @@ kern_pipe(struct thread *td, int fildes[ * side while we are blocked trying to allocate the write side. */ finit(rf, FREAD | FWRITE, DTYPE_PIPE, rpipe, &pipeops); - error = falloc(td, &wf, &fd); + error = falloc(td, &wf, &fd, 0); if (error) { fdclose(fdp, rf, fildes[0], td); fdrop(rf, td); Modified: head/sys/kern/tty_pts.c ============================================================================== --- head/sys/kern/tty_pts.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/tty_pts.c Fri Apr 1 13:28:34 2011 (r220245) @@ -805,7 +805,7 @@ posix_openpt(struct thread *td, struct p if (uap->flags & ~(O_RDWR|O_NOCTTY)) return (EINVAL); - error = falloc(td, &fp, &fd); + error = falloc(td, &fp, &fd, 0); if (error) return (error); Modified: head/sys/kern/uipc_mqueue.c ============================================================================== --- head/sys/kern/uipc_mqueue.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/uipc_mqueue.c Fri Apr 1 13:28:34 2011 (r220245) @@ -1974,7 +1974,7 @@ kern_kmq_open(struct thread *td, const c if (len < 2 || path[0] != '/' || index(path + 1, '/') != NULL) return (EINVAL); - error = falloc(td, &fp, &fd); + error = falloc(td, &fp, &fd, 0); if (error) return (error); Modified: head/sys/kern/uipc_sem.c ============================================================================== --- head/sys/kern/uipc_sem.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/uipc_sem.c Fri Apr 1 13:28:34 2011 (r220245) @@ -422,7 +422,7 @@ ksem_create(struct thread *td, const cha fdp = td->td_proc->p_fd; mode = (mode & ~fdp->fd_cmask) & ACCESSPERMS; - error = falloc(td, &fp, &fd); + error = falloc(td, &fp, &fd, 0); if (error) { if (name == NULL) error = ENOSPC; Modified: head/sys/kern/uipc_shm.c ============================================================================== --- head/sys/kern/uipc_shm.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/uipc_shm.c Fri Apr 1 13:28:34 2011 (r220245) @@ -496,7 +496,7 @@ shm_open(struct thread *td, struct shm_o fdp = td->td_proc->p_fd; cmode = (uap->mode & ~fdp->fd_cmask) & ACCESSPERMS; - error = falloc(td, &fp, &fd); + error = falloc(td, &fp, &fd, 0); if (error) return (error); Modified: head/sys/kern/uipc_syscalls.c ============================================================================== --- head/sys/kern/uipc_syscalls.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/uipc_syscalls.c Fri Apr 1 13:28:34 2011 (r220245) @@ -176,7 +176,7 @@ socket(td, uap) return (error); #endif fdp = td->td_proc->p_fd; - error = falloc(td, &fp, &fd); + error = falloc(td, &fp, &fd, 0); if (error) return (error); /* An extra reference on `fp' has been held for us by falloc(). */ @@ -358,7 +358,7 @@ kern_accept(struct thread *td, int s, st if (error != 0) goto done; #endif - error = falloc(td, &nfp, &fd); + error = falloc(td, &nfp, &fd, 0); if (error) goto done; ACCEPT_LOCK(); @@ -606,12 +606,12 @@ kern_socketpair(struct thread *td, int d if (error) goto free1; /* On success extra reference to `fp1' and 'fp2' is set by falloc. */ - error = falloc(td, &fp1, &fd); + error = falloc(td, &fp1, &fd, 0); if (error) goto free2; rsv[0] = fd; fp1->f_data = so1; /* so1 already has ref count */ - error = falloc(td, &fp2, &fd); + error = falloc(td, &fp2, &fd, 0); if (error) goto free3; fp2->f_data = so2; /* so2 already has ref count */ @@ -2299,7 +2299,7 @@ sctp_peeloff(td, uap) * but that is ok. */ - error = falloc(td, &nfp, &fd); + error = falloc(td, &nfp, &fd, 0); if (error) goto done; td->td_retval[0] = fd; Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/vfs_syscalls.c Fri Apr 1 13:28:34 2011 (r220245) @@ -1069,7 +1069,7 @@ kern_openat(struct thread *td, int fd, c else flags = FFLAGS(flags); - error = fallocf(td, &nfp, &indx, flags); + error = falloc(td, &nfp, &indx, flags); if (error) return (error); /* An extra reference on `nfp' has been held for us by falloc(). */ @@ -4495,7 +4495,7 @@ fhopen(td, uap) * end of vn_open code */ - if ((error = fallocf(td, &nfp, &indx, fmode)) != 0) { + if ((error = falloc(td, &nfp, &indx, fmode)) != 0) { if (fmode & FWRITE) vp->v_writecount--; goto bad; Modified: head/sys/opencrypto/cryptodev.c ============================================================================== --- head/sys/opencrypto/cryptodev.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/opencrypto/cryptodev.c Fri Apr 1 13:28:34 2011 (r220245) @@ -1109,7 +1109,7 @@ cryptoioctl(struct cdev *dev, u_long cmd TAILQ_INIT(&fcr->csessions); fcr->sesn = 0; - error = falloc(td, &f, &fd); + error = falloc(td, &f, &fd, 0); if (error) { free(fcr, M_XDATA); Modified: head/sys/sys/filedesc.h ============================================================================== --- head/sys/sys/filedesc.h Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/sys/filedesc.h Fri Apr 1 13:28:34 2011 (r220245) @@ -111,8 +111,7 @@ struct thread; int closef(struct file *fp, struct thread *td); int dupfdopen(struct thread *td, struct filedesc *fdp, int indx, int dfd, int mode, int error); -int falloc(struct thread *td, struct file **resultfp, int *resultfd); -int fallocf(struct thread *td, struct file **resultfp, int *resultfd, +int falloc(struct thread *td, struct file **resultfp, int *resultfd, int flags); int fdalloc(struct thread *td, int minfd, int *result); int fdavail(struct thread *td, int n); From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 14:04:36 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A65CB10656B3; Fri, 1 Apr 2011 14:04:36 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 954228FC24; Fri, 1 Apr 2011 14:04:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31E4aTE047754; Fri, 1 Apr 2011 14:04:36 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31E4a2w047752; Fri, 1 Apr 2011 14:04:36 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011404.p31E4a2w047752@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 14:04:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220246 - stable/8/sys/fs/msdosfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 14:04:36 -0000 Author: kib Date: Fri Apr 1 14:04:36 2011 New Revision: 220246 URL: http://svn.freebsd.org/changeset/base/220246 Log: MFC r220014: Report EBUSY instead of EROFS for attempt of deleting or renaming the root directory of msdosfs mount. Modified: stable/8/sys/fs/msdosfs/msdosfs_lookup.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/fs/msdosfs/msdosfs_lookup.c ============================================================================== --- stable/8/sys/fs/msdosfs/msdosfs_lookup.c Fri Apr 1 13:28:34 2011 (r220245) +++ stable/8/sys/fs/msdosfs/msdosfs_lookup.c Fri Apr 1 14:04:36 2011 (r220246) @@ -458,7 +458,7 @@ foundroot: * Don't allow deleting the root. */ if (blkoff == MSDOSFSROOT_OFS) - return EROFS; /* really? XXX */ + return (EBUSY); /* * Write access to directory required to delete files. @@ -491,7 +491,7 @@ foundroot: */ if (nameiop == RENAME && (flags & ISLASTCN)) { if (blkoff == MSDOSFSROOT_OFS) - return EROFS; /* really? XXX */ + return (EBUSY); error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, cnp->cn_thread); if (error) From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 14:13:50 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 54C841065672; Fri, 1 Apr 2011 14:13:50 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4446B8FC0C; Fri, 1 Apr 2011 14:13:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31EDogV048061; Fri, 1 Apr 2011 14:13:50 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31EDowO048059; Fri, 1 Apr 2011 14:13:50 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201104011413.p31EDowO048059@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Fri, 1 Apr 2011 14:13:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220247 - head/sys/netipsec X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 14:13:50 -0000 Author: bz Date: Fri Apr 1 14:13:49 2011 New Revision: 220247 URL: http://svn.freebsd.org/changeset/base/220247 Log: Do not allow recursive RFC3173 IPComp payload. Reviewed by: Tavis Ormandy (taviso cmpxchg8b.com) MFC after: 5 days Security: CVE-2011-1547 Modified: head/sys/netipsec/xform_ipcomp.c Modified: head/sys/netipsec/xform_ipcomp.c ============================================================================== --- head/sys/netipsec/xform_ipcomp.c Fri Apr 1 14:04:36 2011 (r220246) +++ head/sys/netipsec/xform_ipcomp.c Fri Apr 1 14:13:49 2011 (r220247) @@ -142,8 +142,29 @@ ipcomp_input(struct mbuf *m, struct seca struct tdb_crypto *tc; struct cryptodesc *crdc; struct cryptop *crp; + struct ipcomp *ipcomp; + caddr_t addr; int hlen = IPCOMP_HLENGTH; + /* + * Check that the next header of the IPComp is not IPComp again, before + * doing any real work. Given it is not possible to do double + * compression it means someone is playing tricks on us. + */ + if (m->m_len < skip + hlen && (m = m_pullup(m, skip + hlen)) == NULL) { + V_ipcompstat.ipcomps_hdrops++; /*XXX*/ + DPRINTF(("%s: m_pullup failed\n", __func__)); + return (ENOBUFS); + } + addr = (caddr_t) mtod(m, struct ip *) + skip; + ipcomp = (struct ipcomp *)addr; + if (ipcomp->comp_nxt == IPPROTO_IPCOMP) { + m_freem(m); + V_ipcompstat.ipcomps_pdrops++; /* XXX have our own stats? */ + DPRINTF(("%s: recursive compression detected\n", __func__)); + return (EINVAL); + } + /* Get crypto descriptors */ crp = crypto_getreq(1); if (crp == NULL) { From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 16:06:21 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 80E3C1065674; Fri, 1 Apr 2011 16:06:21 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 43DD88FC0A; Fri, 1 Apr 2011 16:06:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31G6KEl051276; Fri, 1 Apr 2011 16:06:20 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31G6KUJ051274; Fri, 1 Apr 2011 16:06:20 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201104011606.p31G6KUJ051274@svn.freebsd.org> From: Andriy Gapon Date: Fri, 1 Apr 2011 16:06:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-svnadmin@freebsd.org X-SVN-Group: svnadmin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220248 - svnadmin/conf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 16:06:21 -0000 Author: avg Date: Fri Apr 1 16:06:19 2011 New Revision: 220248 URL: http://svn.freebsd.org/changeset/base/220248 Log: Welcome Artem Belevich to src committers ranks Approved by: core Modified: svnadmin/conf/access Modified: svnadmin/conf/access ============================================================================== --- svnadmin/conf/access Fri Apr 1 14:13:49 2011 (r220247) +++ svnadmin/conf/access Fri Apr 1 16:06:19 2011 (r220248) @@ -30,6 +30,7 @@ andreast andrew antoine ariff +art attilio avatar avg From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 16:45:26 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 737C81065670; Fri, 1 Apr 2011 16:45:26 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 61CEE8FC16; Fri, 1 Apr 2011 16:45:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31GjQOi052325; Fri, 1 Apr 2011 16:45:26 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31GjQk5052323; Fri, 1 Apr 2011 16:45:26 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201104011645.p31GjQk5052323@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 1 Apr 2011 16:45:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220249 - head/sys/dev/age X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 16:45:26 -0000 Author: yongari Date: Fri Apr 1 16:45:26 2011 New Revision: 220249 URL: http://svn.freebsd.org/changeset/base/220249 Log: 64bit DMA caused data corruption. Unfortunately there is no known workaround to use 64bit DMA. Disable 64bit DMA on Attansic L1 controller. Tested by: Yamagi Burmeister (lists <> yamagi dot org) MFC after: 1 week Modified: head/sys/dev/age/if_age.c Modified: head/sys/dev/age/if_age.c ============================================================================== --- head/sys/dev/age/if_age.c Fri Apr 1 16:06:19 2011 (r220248) +++ head/sys/dev/age/if_age.c Fri Apr 1 16:45:26 2011 (r220249) @@ -1092,11 +1092,14 @@ again: * Create Tx/Rx buffer parent tag. * L1 supports full 64bit DMA addressing in Tx/Rx buffers * so it needs separate parent DMA tag. + * XXX + * It seems enabling 64bit DMA causes data corruption. Limit + * DMA address space to 32bit. */ error = bus_dma_tag_create( bus_get_dma_tag(sc->age_dev), /* parent */ 1, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ BUS_SPACE_MAXSIZE_32BIT, /* maxsize */ From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 18:23:44 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E91FB106564A; Fri, 1 Apr 2011 18:23:44 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D60E38FC08; Fri, 1 Apr 2011 18:23:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31INixW055198; Fri, 1 Apr 2011 18:23:44 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31INiHv055195; Fri, 1 Apr 2011 18:23:44 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201104011823.p31INiHv055195@svn.freebsd.org> From: Xin LI Date: Fri, 1 Apr 2011 18:23:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220250 - in stable/8: bin/test tools/regression/bin/test X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 18:23:45 -0000 Author: delphij Date: Fri Apr 1 18:23:44 2011 New Revision: 220250 URL: http://svn.freebsd.org/changeset/base/220250 Log: MFC r219084: Accept == as an alias of = which is a popular GNU extension. This is intentionally undocumented for now since it's not part of any standard. Modified: stable/8/bin/test/test.c stable/8/tools/regression/bin/test/regress.sh Directory Properties: stable/8/bin/test/ (props changed) stable/8/tools/regression/bin/test/ (props changed) Modified: stable/8/bin/test/test.c ============================================================================== --- stable/8/bin/test/test.c Fri Apr 1 16:45:26 2011 (r220249) +++ stable/8/bin/test/test.c Fri Apr 1 18:23:44 2011 (r220250) @@ -144,6 +144,7 @@ struct t_op { {"-L", FILSYM, UNOP}, {"-S", FILSOCK,UNOP}, {"=", STREQ, BINOP}, + {"==", STREQ, BINOP}, {"!=", STRNE, BINOP}, {"<", STRLT, BINOP}, {">", STRGT, BINOP}, Modified: stable/8/tools/regression/bin/test/regress.sh ============================================================================== --- stable/8/tools/regression/bin/test/regress.sh Fri Apr 1 16:45:26 2011 (r220249) +++ stable/8/tools/regression/bin/test/regress.sh Fri Apr 1 18:23:44 2011 (r220250) @@ -52,12 +52,15 @@ t () } count=0 -echo "1..94" +echo "1..97" t 0 'b = b' +t 0 'b == b' t 1 'b != b' t 0 '\( b = b \)' +t 0 '\( b == b \)' t 1 '! \( b = b \)' +t 1 '! \( b == b \)' t 1 '! -f /etc/passwd' t 0 '-h = -h' From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 18:48:31 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8A0EF1065670; Fri, 1 Apr 2011 18:48:31 +0000 (UTC) (envelope-from jfv@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 770278FC16; Fri, 1 Apr 2011 18:48:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31ImVPP055811; Fri, 1 Apr 2011 18:48:31 GMT (envelope-from jfv@svn.freebsd.org) Received: (from jfv@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31ImVLd055808; Fri, 1 Apr 2011 18:48:31 GMT (envelope-from jfv@svn.freebsd.org) Message-Id: <201104011848.p31ImVLd055808@svn.freebsd.org> From: Jack F Vogel Date: Fri, 1 Apr 2011 18:48:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220251 - head/sys/dev/e1000 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 18:48:31 -0000 Author: jfv Date: Fri Apr 1 18:48:31 2011 New Revision: 220251 URL: http://svn.freebsd.org/changeset/base/220251 Log: Change the refresh_mbuf logic slightly, add an inline to calculate the outstanding descriptors that need to be refreshed at any time, and use THAT in rxeof to determine if refreshing needs to be done. Also change the local_timer to simply fire off the appropriate interrupt rather than schedule a tasklet, its simpler. MFC in two weeks Modified: head/sys/dev/e1000/if_em.c head/sys/dev/e1000/if_em.h Modified: head/sys/dev/e1000/if_em.c ============================================================================== --- head/sys/dev/e1000/if_em.c Fri Apr 1 18:23:44 2011 (r220250) +++ head/sys/dev/e1000/if_em.c Fri Apr 1 18:48:31 2011 (r220251) @@ -1,6 +1,6 @@ /****************************************************************************** - Copyright (c) 2001-2010, Intel Corporation + Copyright (c) 2001-2011, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without @@ -93,7 +93,7 @@ int em_display_debug_stats = 0; /********************************************************************* * Driver version: *********************************************************************/ -char em_driver_version[] = "7.2.2"; +char em_driver_version[] = "7.2.3"; /********************************************************************* * PCI Device ID Table @@ -2182,6 +2182,7 @@ em_local_timer(void *arg) struct ifnet *ifp = adapter->ifp; struct tx_ring *txr = adapter->tx_rings; struct rx_ring *rxr = adapter->rx_rings; + u32 trigger; EM_CORE_LOCK_ASSERT(adapter); @@ -2193,12 +2194,11 @@ em_local_timer(void *arg) e1000_get_laa_state_82571(&adapter->hw)) e1000_rar_set(&adapter->hw, adapter->hw.mac.addr, 0); - /* trigger tq to refill rx ring queue if it is empty */ - for (int i = 0; i < adapter->num_queues; i++, rxr++) { - if (rxr->next_to_check == rxr->next_to_refresh) { - taskqueue_enqueue(rxr->tq, &rxr->rx_task); - } - } + /* Mask to use in the irq trigger */ + if (adapter->msix_mem) + trigger = rxr->ims; /* RX for 82574 */ + else + trigger = E1000_ICS_RXDMT0; /* ** Don't do TX watchdog check if we've been paused @@ -2217,6 +2217,10 @@ em_local_timer(void *arg) goto hung; out: callout_reset(&adapter->timer, hz, em_local_timer, adapter); +#ifndef DEVICE_POLLING + /* Trigger an RX interrupt to guarantee mbuf refresh */ + E1000_WRITE_REG(&adapter->hw, E1000_ICS, trigger); +#endif return; hung: /* Looks like we're hung */ @@ -4327,7 +4331,7 @@ next_desc: } /* Catch any remaining refresh work */ - if (processed != 0 || i == rxr->next_to_refresh) + if (e1000_rx_unrefreshed(rxr)) em_refresh_mbufs(rxr, i); rxr->next_to_check = i; Modified: head/sys/dev/e1000/if_em.h ============================================================================== --- head/sys/dev/e1000/if_em.h Fri Apr 1 18:23:44 2011 (r220250) +++ head/sys/dev/e1000/if_em.h Fri Apr 1 18:48:31 2011 (r220251) @@ -1,6 +1,6 @@ /****************************************************************************** - Copyright (c) 2001-2010, Intel Corporation + Copyright (c) 2001-2011, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without @@ -463,6 +463,22 @@ struct em_buffer { bus_dmamap_t map; /* bus_dma map for packet */ }; + +/* +** Find the number of unrefreshed RX descriptors +*/ +static inline u16 +e1000_rx_unrefreshed(struct rx_ring *rxr) +{ + struct adapter *adapter = rxr->adapter; + + if (rxr->next_to_check > rxr->next_to_refresh) + return (rxr->next_to_check - rxr->next_to_refresh - 1); + else + return ((adapter->num_rx_desc + rxr->next_to_check) - + rxr->next_to_refresh - 1); +} + #define EM_CORE_LOCK_INIT(_sc, _name) \ mtx_init(&(_sc)->core_mtx, _name, "EM Core Lock", MTX_DEF) #define EM_TX_LOCK_INIT(_sc, _name) \ From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 18:53:41 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C24CD106566C; Fri, 1 Apr 2011 18:53:41 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AEF9F8FC15; Fri, 1 Apr 2011 18:53:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31Irfr8055958; Fri, 1 Apr 2011 18:53:41 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31Irfx5055956; Fri, 1 Apr 2011 18:53:41 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201104011853.p31Irfx5055956@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 1 Apr 2011 18:53:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220252 - head/sys/dev/age X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 18:53:41 -0000 Author: yongari Date: Fri Apr 1 18:53:41 2011 New Revision: 220252 URL: http://svn.freebsd.org/changeset/base/220252 Log: Partially revert r184106. RX buffer ring also needs bus_dmamap_sync(). Tested by: Yamagi Burmeister (lists <> yamagi dot org) MFC after: 1 week Modified: head/sys/dev/age/if_age.c Modified: head/sys/dev/age/if_age.c ============================================================================== --- head/sys/dev/age/if_age.c Fri Apr 1 18:48:31 2011 (r220251) +++ head/sys/dev/age/if_age.c Fri Apr 1 18:53:41 2011 (r220252) @@ -2424,6 +2424,8 @@ age_rxintr(struct age_softc *sc, int rr_ bus_dmamap_sync(sc->age_cdata.age_rr_ring_tag, sc->age_cdata.age_rr_ring_map, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); + bus_dmamap_sync(sc->age_cdata.age_rx_ring_tag, + sc->age_cdata.age_rx_ring_map, BUS_DMASYNC_POSTWRITE); for (prog = 0; rr_cons != rr_prod; prog++) { if (count <= 0) @@ -2455,6 +2457,8 @@ age_rxintr(struct age_softc *sc, int rr_ /* Update the consumer index. */ sc->age_cdata.age_rr_cons = rr_cons; + bus_dmamap_sync(sc->age_cdata.age_rx_ring_tag, + sc->age_cdata.age_rx_ring_map, BUS_DMASYNC_PREWRITE); /* Sync descriptors. */ bus_dmamap_sync(sc->age_cdata.age_rr_ring_tag, sc->age_cdata.age_rr_ring_map, @@ -2981,8 +2985,7 @@ age_init_rx_ring(struct age_softc *sc) } bus_dmamap_sync(sc->age_cdata.age_rx_ring_tag, - sc->age_cdata.age_rx_ring_map, - BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + sc->age_cdata.age_rx_ring_map, BUS_DMASYNC_PREWRITE); return (0); } From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 19:57:27 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 95F26106564A; Fri, 1 Apr 2011 19:57:27 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 846228FC17; Fri, 1 Apr 2011 19:57:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31JvRxI057509; Fri, 1 Apr 2011 19:57:27 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31JvRcj057507; Fri, 1 Apr 2011 19:57:27 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011957.p31JvRcj057507@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 19:57:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220253 - head/lib/libc/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 19:57:27 -0000 Author: kib Date: Fri Apr 1 19:57:27 2011 New Revision: 220253 URL: http://svn.freebsd.org/changeset/base/220253 Log: Fix mdoc errors. Submitted by: ru MFC after: 3 days Modified: head/lib/libc/sys/open.2 Modified: head/lib/libc/sys/open.2 ============================================================================== --- head/lib/libc/sys/open.2 Fri Apr 1 18:53:41 2011 (r220252) +++ head/lib/libc/sys/open.2 Fri Apr 1 19:57:27 2011 (r220253) @@ -248,8 +248,7 @@ When a new file is created it is given t which contains it. .Pp Unless -.Dv -O_CLOEXEC +.Dv O_CLOEXEC flag was specified, the new descriptor is set to remain open across .Xr execve 2 @@ -416,7 +415,7 @@ of .Dv O_WRONLY , .Dv O_RDWR and -.Dv O_EXEC. +.Dv O_EXEC . .It Bq Eq EBADF The .Fa path From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 20:24:52 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 423181065670; Fri, 1 Apr 2011 20:24:52 +0000 (UTC) (envelope-from jfv@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1730E8FC12; Fri, 1 Apr 2011 20:24:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31KOpur058133; Fri, 1 Apr 2011 20:24:51 GMT (envelope-from jfv@svn.freebsd.org) Received: (from jfv@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31KOpvX058131; Fri, 1 Apr 2011 20:24:51 GMT (envelope-from jfv@svn.freebsd.org) Message-Id: <201104012024.p31KOpvX058131@svn.freebsd.org> From: Jack F Vogel Date: Fri, 1 Apr 2011 20:24:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220254 - head/sys/dev/e1000 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 20:24:52 -0000 Author: jfv Date: Fri Apr 1 20:24:51 2011 New Revision: 220254 URL: http://svn.freebsd.org/changeset/base/220254 Log: Fix to an error condition case, when an mbuf chain get's defragged due to a mapping failure the header pointers will be invalidated and can result in a TSO or other failure down the line. So, when the remapping occurs force a retry thru the offload calculation code. Thanks to Andrew Boyer for discovering this and cooking up the fix!! Modified: head/sys/dev/e1000/if_em.c Modified: head/sys/dev/e1000/if_em.c ============================================================================== --- head/sys/dev/e1000/if_em.c Fri Apr 1 19:57:27 2011 (r220253) +++ head/sys/dev/e1000/if_em.c Fri Apr 1 20:24:51 2011 (r220254) @@ -1761,8 +1761,9 @@ em_xmit(struct tx_ring *txr, struct mbuf u32 txd_upper, txd_lower, txd_used, txd_saved; int ip_off, poff; int nsegs, i, j, first, last = 0; - int error, do_tso, tso_desc = 0; + int error, do_tso, tso_desc = 0, remap = 1; +retry: m_head = *m_headp; txd_upper = txd_lower = txd_used = txd_saved = 0; do_tso = ((m_head->m_pkthdr.csum_flags & CSUM_TSO) != 0); @@ -1900,7 +1901,7 @@ em_xmit(struct tx_ring *txr, struct mbuf * All other errors, in particular EINVAL, are fatal and prevent the * mbuf chain from ever going through. Drop it and report error. */ - if (error == EFBIG) { + if (error == EFBIG && remap) { struct mbuf *m; m = m_defrag(*m_headp, M_DONTWAIT); @@ -1912,20 +1913,9 @@ em_xmit(struct tx_ring *txr, struct mbuf } *m_headp = m; - /* Try it again */ - error = bus_dmamap_load_mbuf_sg(txr->txtag, map, - *m_headp, segs, &nsegs, BUS_DMA_NOWAIT); - - if (error == ENOMEM) { - adapter->no_tx_dma_setup++; - return (error); - } else if (error != 0) { - adapter->no_tx_dma_setup++; - m_freem(*m_headp); - *m_headp = NULL; - return (error); - } - + /* Try it again, but only once */ + remap = 0; + goto retry; } else if (error == ENOMEM) { adapter->no_tx_dma_setup++; return (error); From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 20:59:24 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B55B1065677; Fri, 1 Apr 2011 20:59:24 +0000 (UTC) (envelope-from uqs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3BE088FC1A; Fri, 1 Apr 2011 20:59:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31KxO6c058933; Fri, 1 Apr 2011 20:59:24 GMT (envelope-from uqs@svn.freebsd.org) Received: (from uqs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31KxOA0058931; Fri, 1 Apr 2011 20:59:24 GMT (envelope-from uqs@svn.freebsd.org) Message-Id: <201104012059.p31KxOA0058931@svn.freebsd.org> From: Ulrich Spoerlein Date: Fri, 1 Apr 2011 20:59:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220255 - head X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 20:59:24 -0000 Author: uqs Date: Fri Apr 1 20:59:23 2011 New Revision: 220255 URL: http://svn.freebsd.org/changeset/base/220255 Log: Fix the delete-old/check-old targets to work with arbitrarily long OLD_FILES/OLD_DIRS/OLD_LIBS lists. If you specify enough WITHOUT_FOO flags, the argument list passed to the shell will be too long. Using .for/.endfor make(1) "loop" will make the parser of the Makefile explode. Hack around this with good old pipes. No objections: netchild Reported by: b.f. Modified: head/Makefile.inc1 Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Fri Apr 1 20:24:51 2011 (r220254) +++ head/Makefile.inc1 Fri Apr 1 20:59:23 2011 (r220255) @@ -1355,10 +1355,16 @@ delete-old-files: @echo ">>> Removing old files (only deletes safe to delete libs)" # Ask for every old file if the user really wants to remove it. # It's annoying, but better safe than sorry. - @for file in ${OLD_FILES} ${OLD_FILES:Musr/share/*.gz:R}; do \ +# NB: We cannot pass the list of OLD_FILES as a parameter because the +# argument list will get too long. Using .for/.endfor make "loops" will make +# the Makefile parser segfault. + @exec 3<&0; \ + ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \ + while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ - rm ${RM_I} "${DESTDIR}/$${file}"; \ + rm ${RM_I} "${DESTDIR}/$${file}" <&3; \ fi; \ done # Remove catpages without corresponding manpages. @@ -1368,14 +1374,16 @@ delete-old-files: while read catpage; do \ read manpage; \ if [ ! -e "$${manpage}" ]; then \ - rm ${RM_I} $${catpage} <&3 ; \ + rm ${RM_I} $${catpage} <&3; \ fi; \ done @echo ">>> Old files removed" check-old-files: @echo ">>> Checking for old files" - @for file in ${OLD_FILES} ${OLD_FILES:Musr/share/*.gz:R}; do \ + @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \ + while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ echo "${DESTDIR}/$${file}"; \ fi; \ @@ -1386,24 +1394,29 @@ check-old-files: while read catpage; do \ read manpage; \ if [ ! -e "$${manpage}" ]; then \ - echo $${catpage} ; \ + echo $${catpage}; \ fi; \ done delete-old-libs: @echo ">>> Removing old libraries" @echo "${OLD_LIBS_MESSAGE}" | fmt - @for file in ${OLD_LIBS}; do \ + @exec 3<&0; \ + ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_LIBS | xargs -n1 | \ + while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ - rm ${RM_I} "${DESTDIR}/$${file}"; \ + rm ${RM_I} "${DESTDIR}/$${file}" <&3; \ fi; \ done @echo ">>> Old libraries removed" check-old-libs: @echo ">>> Checking for old libraries" - @for file in ${OLD_LIBS}; do \ + @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_LIBS | xargs -n1 | \ + while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ echo "${DESTDIR}/$${file}"; \ fi; \ @@ -1411,7 +1424,9 @@ check-old-libs: delete-old-dirs: @echo ">>> Removing old directories" - @for dir in ${OLD_DIRS}; do \ + @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_DIRS | xargs -n1 | \ + while read dir; do \ if [ -d "${DESTDIR}/$${dir}" ]; then \ rmdir -v "${DESTDIR}/$${dir}" || true; \ elif [ -L "${DESTDIR}/$${dir}" ]; then \ @@ -1422,7 +1437,9 @@ delete-old-dirs: check-old-dirs: @echo ">>> Checking for old directories" - @for dir in ${OLD_DIRS}; do \ + @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_DIRS | xargs -n1 | \ + while read dir; do \ if [ -d "${DESTDIR}/$${dir}" ]; then \ echo "${DESTDIR}/$${dir}"; \ elif [ -L "${DESTDIR}/$${dir}" ]; then \ From owner-svn-src-all@FreeBSD.ORG Fri Apr 1 23:47:11 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0419E106566C; Fri, 1 Apr 2011 23:47:11 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CFC188FC18; Fri, 1 Apr 2011 23:47:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31NlAcl062587; Fri, 1 Apr 2011 23:47:10 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31NlADA062583; Fri, 1 Apr 2011 23:47:10 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201104012347.p31NlADA062583@svn.freebsd.org> From: Ed Maste Date: Fri, 1 Apr 2011 23:47:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220256 - in head/share/examples: . kld/firmware/fwimage X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 23:47:11 -0000 Author: emaste Date: Fri Apr 1 23:47:10 2011 New Revision: 220256 URL: http://svn.freebsd.org/changeset/base/220256 Log: Uuencode the sample "binary" firmware image file (instead of explicitly adding \0 bytes). This is a technique that would be used in an actual driver and is more suitable as an example. Reviewed by: mlaier Added: head/share/examples/kld/firmware/fwimage/firmware.img.uu (contents, props changed) Deleted: head/share/examples/kld/firmware/fwimage/firmware.img.in Modified: head/share/examples/Makefile head/share/examples/kld/firmware/fwimage/Makefile Modified: head/share/examples/Makefile ============================================================================== --- head/share/examples/Makefile Fri Apr 1 20:59:23 2011 (r220255) +++ head/share/examples/Makefile Fri Apr 1 23:47:10 2011 (r220256) @@ -99,7 +99,7 @@ XFILES= BSD_daemon/FreeBSD.pfa \ kld/firmware/fwconsumer/Makefile \ kld/firmware/fwconsumer/fw_consumer.c \ kld/firmware/fwimage/Makefile \ - kld/firmware/fwimage/firmware.img.in \ + kld/firmware/fwimage/firmware.img.uu \ kld/khelp/Makefile \ kld/khelp/README \ kld/khelp/h_example.c \ Modified: head/share/examples/kld/firmware/fwimage/Makefile ============================================================================== --- head/share/examples/kld/firmware/fwimage/Makefile Fri Apr 1 20:59:23 2011 (r220255) +++ head/share/examples/kld/firmware/fwimage/Makefile Fri Apr 1 23:47:10 2011 (r220256) @@ -3,8 +3,9 @@ KMOD= beastie FIRMWS= firmware.img:beastie -firmware.img: firmware.img.in - cp ${.ALLSRC} ${.TARGET} - printf '\0\0\0\0\0' >> ${.TARGET} +CLEANFILES= firmware.img + +firmware.img: firmware.img.uu + uudecode -p ${.ALLSRC} > ${.TARGET} .include Added: head/share/examples/kld/firmware/fwimage/firmware.img.uu ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/examples/kld/firmware/fwimage/firmware.img.uu Fri Apr 1 23:47:10 2011 (r220256) @@ -0,0 +1,16 @@ +$FreeBSD$ +begin 644 firmware.img +M("`@("`@("`@("`@("`L("`@("`@("`L"B`@("`@("`@("`@("`O*"`@("`@ +M("`@*0H@("`@("`@("`@("`@7"!<7U]?("`@+R!\"B`@("`@("`@("`@("`O +M+2!?("`M+R`@)PH@("`@("`@("`@("`H+UPO(%P@7"`@("]<"B`@("`@("`@ +M("`@("\@+R`@('P@("`@(%P*("`@("`@("`@("`@3R!/("`@*2`O("`@('P* +M("`@("`@("`@("`@+5XM+2<\("`@("`G"B`@("`@("`@("`@*%\N*2`@7R`@ +M*2`@("\*("`@("`@("`@("`@+E]?7R\@("`@+PH@("`@("`@("`@("`@("TM +M+2TM)R`O"B`\+2TM+2X@("`@(%]?("\@7U\@("!<"B`\+2TM+7P]/3T]3RDI +M*3T]*2!<*2`O/3T]/0H@/"TM+2TG("`@("TM)R`N7U\L)R!<"B`@("`@("`@ +M("`@("`@?"`@("`@("`@?`H@("`@("`@("`@("`@("!<("`@("`@("\@("`@ +M("`@+UP*("`@("`@("`@(%]?7U]?7R@@*%\@("\@7%]?7U]?7R\*("`@("`@ +M("`L)R`@+"TM+2TM)R`@('P*("`@("`@("`M+7M?7U]?7U]?7U]?*2`@0V]P +@>7)I9VAT("AC*2`R,#`S(%-C;W1T($QO;F<*```````` +` +end From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 00:08:32 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5F586106566B; Sat, 2 Apr 2011 00:08:32 +0000 (UTC) (envelope-from art@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 519988FC08; Sat, 2 Apr 2011 00:08:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3208W7s064410; Sat, 2 Apr 2011 00:08:32 GMT (envelope-from art@svn.freebsd.org) Received: (from art@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3208W6e064408; Sat, 2 Apr 2011 00:08:32 GMT (envelope-from art@svn.freebsd.org) Message-Id: <201104020008.p3208W6e064408@svn.freebsd.org> From: Artem Belevich Date: Sat, 2 Apr 2011 00:08:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220257 - head/share/misc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 00:08:32 -0000 Author: art Date: Sat Apr 2 00:08:32 2011 New Revision: 220257 URL: http://svn.freebsd.org/changeset/base/220257 Log: Added myself as src committer. Approved by: avg (mentor) Modified: head/share/misc/committers-src.dot Modified: head/share/misc/committers-src.dot ============================================================================== --- head/share/misc/committers-src.dot Fri Apr 1 23:47:10 2011 (r220256) +++ head/share/misc/committers-src.dot Sat Apr 2 00:08:32 2011 (r220257) @@ -98,6 +98,7 @@ andreast [label="Andreas Tobler\nandreas andrew [label="Andrew Turner\nandrew@FreeBSD.org\n2010/07/19"] antoine [label="Antoine Brodin\nantoine@FreeBSD.org\n2008/02/03"] ariff [label="Ariff Abdullah\nariff@FreeBSD.org\n2005/11/14"] +art [label="Artem Belevich\nart@FreeBSD.org\n2011/03/29"] avg [label="Andriy Gapon\navg@FreeBSD.org\n2009/02/18"] benno [label="Benno Rice\nbenno@FreeBSD.org\n2000/11/02"] bms [label="Bruce M Simpson\nbms@FreeBSD.org\n2003/08/06"] @@ -270,6 +271,7 @@ andre -> qingli anholt -> jkim +avg -> art avg -> pluknet benno -> grehan @@ -440,6 +442,7 @@ kib -> trociny kmacy -> lstewart +marcel -> art marcel -> arun marcel -> marius marcel -> nwhitehorn From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 00:24:14 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 542E21065670; Sat, 2 Apr 2011 00:24:14 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 45C978FC0C; Sat, 2 Apr 2011 00:24:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p320OElQ064957; Sat, 2 Apr 2011 00:24:14 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p320OEcX064955; Sat, 2 Apr 2011 00:24:14 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201104020024.p320OEcX064955@svn.freebsd.org> From: Adrian Chadd Date: Sat, 2 Apr 2011 00:24:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220258 - head/sys/dev/ath/ath_hal/ar5416 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 00:24:14 -0000 Author: adrian Date: Sat Apr 2 00:24:13 2011 New Revision: 220258 URL: http://svn.freebsd.org/changeset/base/220258 Log: Add some more debugging Modified: head/sys/dev/ath/ath_hal/ar5416/ar2133.c Modified: head/sys/dev/ath/ath_hal/ar5416/ar2133.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar2133.c Sat Apr 2 00:08:32 2011 (r220257) +++ head/sys/dev/ath/ath_hal/ar5416/ar2133.c Sat Apr 2 00:24:13 2011 (r220258) @@ -251,11 +251,19 @@ ar2133SetRfRegs(struct ath_hal *ah, cons /* Only the 5 or 2 GHz OB/DB need to be set for a mode */ if (IEEE80211_IS_CHAN_2GHZ(chan)) { + HALDEBUG(ah, HAL_DEBUG_EEPROM, "%s: 2ghz: OB_2:%d, DB_2:%d\n", + __func__, + ath_hal_eepromGet(ah, AR_EEP_OB_2, AH_NULL), + ath_hal_eepromGet(ah, AR_EEP_DB_2, AH_NULL)); ar5416ModifyRfBuffer(priv->Bank6Data, ath_hal_eepromGet(ah, AR_EEP_OB_2, AH_NULL), 3, 197, 0); ar5416ModifyRfBuffer(priv->Bank6Data, ath_hal_eepromGet(ah, AR_EEP_DB_2, AH_NULL), 3, 194, 0); } else { + HALDEBUG(ah, HAL_DEBUG_EEPROM, "%s: 5ghz: OB_5:%d, DB_5:%d\n", + __func__, + ath_hal_eepromGet(ah, AR_EEP_OB_5, AH_NULL), + ath_hal_eepromGet(ah, AR_EEP_DB_5, AH_NULL)); ar5416ModifyRfBuffer(priv->Bank6Data, ath_hal_eepromGet(ah, AR_EEP_OB_5, AH_NULL), 3, 203, 0); ar5416ModifyRfBuffer(priv->Bank6Data, From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 00:27:22 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 72A39106566C; Sat, 2 Apr 2011 00:27:22 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 642398FC1A; Sat, 2 Apr 2011 00:27:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p320RMXb065110; Sat, 2 Apr 2011 00:27:22 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p320RMa2065108; Sat, 2 Apr 2011 00:27:22 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201104020027.p320RMa2065108@svn.freebsd.org> From: Adrian Chadd Date: Sat, 2 Apr 2011 00:27:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220259 - head/sys/dev/ath/ath_hal/ar5416 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 00:27:22 -0000 Author: adrian Date: Sat Apr 2 00:27:22 2011 New Revision: 220259 URL: http://svn.freebsd.org/changeset/base/220259 Log: From ath9k - clear the RX descriptor status before recycling it. Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c Sat Apr 2 00:24:13 2011 (r220258) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c Sat Apr 2 00:27:22 2011 (r220259) @@ -67,6 +67,7 @@ ar5416SetupRxDesc(struct ath_hal *ah, st uint32_t size, u_int flags) { struct ar5416_desc *ads = AR5416DESC(ds); + HAL_CAPABILITIES *pCap = &AH_PRIVATE(ah)->ah_caps; HALASSERT((size &~ AR_BufLen) == 0); @@ -77,6 +78,10 @@ ar5416SetupRxDesc(struct ath_hal *ah, st /* this should be enough */ ads->ds_rxstatus8 &= ~AR_RxDone; + /* clear the rest of the status fields */ + if (! pCap->halAutoSleepSupport) + OS_MEMZERO(&(ads->u), sizeof(ads->u)); + return AH_TRUE; } From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 01:55:52 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1033) id B5FC91065674; Sat, 2 Apr 2011 01:55:52 +0000 (UTC) Date: Sat, 2 Apr 2011 01:55:52 +0000 From: Alexey Dokuchaev To: Xin LI Message-ID: <20110402015552.GA32901@FreeBSD.org> References: <201104011823.p31INiHv055195@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <201104011823.p31INiHv055195@svn.freebsd.org> User-Agent: Mutt/1.4.2.1i Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r220250 - in stable/8: bin/test tools/regression/bin/test X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 01:55:52 -0000 On Fri, Apr 01, 2011 at 06:23:44PM +0000, Xin LI wrote: > Accept == as an alias of = which is a popular GNU extension. > > This is intentionally undocumented for now since it's not part > of any standard. I thought general consensus that this change should never be part of FreeBSD, not just being undocumented (which, as we all know, is bad practice pe se). ./danfe From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 03:48:15 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C5A0106564A; Sat, 2 Apr 2011 03:48:15 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CBDA8FC12; Sat, 2 Apr 2011 03:48:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p323mFFB069367; Sat, 2 Apr 2011 03:48:15 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p323mFeb069365; Sat, 2 Apr 2011 03:48:15 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201104020348.p323mFeb069365@svn.freebsd.org> From: Adrian Chadd Date: Sat, 2 Apr 2011 03:48:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220260 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 03:48:15 -0000 Author: adrian Date: Sat Apr 2 03:48:15 2011 New Revision: 220260 URL: http://svn.freebsd.org/changeset/base/220260 Log: A handful of the openwrt devices use a MAC address that's at a hard-coded offset in the flash. Some devices (eg the TPLink WR-1043ND) don't have a flash environment partition which can be queried for the current board settings. This particular workaround allows for image creators to use a hint to set the base MAC address. For example: hint.arge.0.eeprommac=0x1f01fc00 Modified: head/sys/mips/atheros/if_arge.c Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Sat Apr 2 00:27:22 2011 (r220259) +++ head/sys/mips/atheros/if_arge.c Sat Apr 2 03:48:15 2011 (r220260) @@ -227,11 +227,32 @@ arge_attach(device_t dev) uint32_t reg, rnd; int is_base_mac_empty, i, phys_total; uint32_t hint; + long eeprom_mac_addr = 0; sc = device_get_softc(dev); sc->arge_dev = dev; sc->arge_mac_unit = device_get_unit(dev); + /* + * Some units (eg the TP-Link WR-1043ND) do not have a convenient + * EEPROM location to read the ethernet MAC address from. + * OpenWRT simply snaffles it from a fixed location. + * + * Since multiple units seem to use this feature, include + * a method of setting the MAC address based on an flash location + * in CPU address space. + */ + if (sc->arge_mac_unit == 0 && + resource_long_value(device_get_name(dev), device_get_unit(dev), + "eeprommac", &eeprom_mac_addr) == 0) { + int i; + const char *mac = (const char *) MIPS_PHYS_TO_KSEG1(eeprom_mac_addr); + device_printf(dev, "Overriding MAC from EEPROM\n"); + for (i = 0; i < 6; i++) { + ar711_base_mac[i] = mac[i]; + } + } + KASSERT(((sc->arge_mac_unit == 0) || (sc->arge_mac_unit == 1)), ("if_arge: Only MAC0 and MAC1 supported")); From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 04:05:32 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A67B1065673; Sat, 2 Apr 2011 04:05:32 +0000 (UTC) (envelope-from juli@clockworksquid.com) Received: from mail-gw0-f54.google.com (mail-gw0-f54.google.com [74.125.83.54]) by mx1.freebsd.org (Postfix) with ESMTP id 079FC8FC0C; Sat, 2 Apr 2011 04:05:31 +0000 (UTC) Received: by gwb15 with SMTP id 15so1933717gwb.13 for ; Fri, 01 Apr 2011 21:05:31 -0700 (PDT) Received: by 10.151.158.18 with SMTP id k18mr4692694ybo.299.1301717131106; Fri, 01 Apr 2011 21:05:31 -0700 (PDT) MIME-Version: 1.0 Sender: juli@clockworksquid.com Received: by 10.151.13.12 with HTTP; Fri, 1 Apr 2011 21:05:11 -0700 (PDT) In-Reply-To: <201104020348.p323mFeb069365@svn.freebsd.org> References: <201104020348.p323mFeb069365@svn.freebsd.org> From: Juli Mallett Date: Fri, 1 Apr 2011 21:05:11 -0700 X-Google-Sender-Auth: U9GqEbsG4SOf1sBRUnoHmdRrE9s Message-ID: To: Adrian Chadd Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220260 - head/sys/mips/atheros X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 04:05:32 -0000 On Fri, Apr 1, 2011 at 20:48, Adrian Chadd wrote: > Author: adrian > Date: Sat Apr =A02 03:48:15 2011 > New Revision: 220260 > URL: http://svn.freebsd.org/changeset/base/220260 > > Log: > =A0A handful of the openwrt devices use a MAC address that's at a hard-co= ded > =A0offset in the flash. > > =A0Some devices (eg the TPLink WR-1043ND) don't have a flash environment > =A0partition which can be queried for the current board settings. > > =A0This particular workaround allows for image creators to use a hint > =A0to set the base MAC address. For example: > > =A0hint.arge.0.eeprommac=3D0x1f01fc00 It isn't obvious from the wording here that it's the address of the MAC in flash, it sounds like it's the base MAC-address. Might be useful to add "phys" or "pa" or something to suggest that it's a physical address in RAM. From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 05:01:10 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C7DD1065672; Sat, 2 Apr 2011 05:01:10 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2D97F8FC08; Sat, 2 Apr 2011 05:01:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3251Aog070948; Sat, 2 Apr 2011 05:01:10 GMT (envelope-from gordon@svn.freebsd.org) Received: (from gordon@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3251AEL070946; Sat, 2 Apr 2011 05:01:10 GMT (envelope-from gordon@svn.freebsd.org) Message-Id: <201104020501.p3251AEL070946@svn.freebsd.org> From: Gordon Tetlow Date: Sat, 2 Apr 2011 05:01:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220261 - head/usr.bin/man X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 05:01:10 -0000 Author: gordon Date: Sat Apr 2 05:01:09 2011 New Revision: 220261 URL: http://svn.freebsd.org/changeset/base/220261 Log: Overhaul locale handling. Use locale(1) to determine the locale instead of trying to hand roll it. Correctly construct groff call based on charset and locale independently, not the mix between the two. Submitted by: uqs@ Modified: head/usr.bin/man/man.sh Modified: head/usr.bin/man/man.sh ============================================================================== --- head/usr.bin/man/man.sh Sat Apr 2 03:48:15 2011 (r220260) +++ head/usr.bin/man/man.sh Sat Apr 2 05:01:09 2011 (r220261) @@ -312,11 +312,10 @@ man_display_page() { # device flag (-T) we have to pass to eqn(1) and groff(1). Then, # setup the pipeline of commands based on the user's request. - # Apparently the locale flags are switched on where the manpage is - # found not just the locale env variables. - nroff_dev="ascii" - case "X${use_locale}X${manpage}" in - XyesX*/${man_lang}*${man_charset}/*) + # If the manpage is from a particular charset, we need to setup nroff + # to properly output for the correct device. + case "${manpage}" in + *.${man_charset}/*) # I don't pretend to know this; I'm just copying from the # previous version of man(1). case "$man_charset" in @@ -327,9 +326,20 @@ man_display_page() { *) nroff_dev="ascii" ;; esac - NROFF="$NROFF -T$nroff_dev -dlocale=$man_lang.$man_charset" + NROFF="$NROFF -T$nroff_dev" EQN="$EQN -T$nroff_dev" + # Iff the manpage is from the locale and not just the charset, + # then we need to define the locale string. + case "${manpage}" in + */${man_lang}_${man_country}.${man_charset}/*) + NROFF="$NROFF -dlocale=$man_lang.$man_charset" + ;; + */${man_lang}.${man_charset}/*) + NROFF="$NROFF -dlocale=$man_lang.$man_charset" + ;; + esac + # Allow language specific calls to override the default # set of utilities. l=$(echo $man_lang | tr [:lower:] [:upper:]) @@ -557,28 +567,38 @@ man_setup() { # Usage: man_setup_locale # Setup necessary locale variables. man_setup_locale() { + local lang_cc + + locpaths='.' + man_charset='US-ASCII' + # Setup locale information. if [ -n "$oflag" ]; then - decho "Using non-localized manpages" - unset use_locale - elif [ -n "$LC_ALL" ]; then - parse_locale "$LC_ALL" - elif [ -n "$LC_CTYPE" ]; then - parse_locale "$LC_CTYPE" - elif [ -n "$LANG" ]; then - parse_locale "$LANG" - fi - - if [ -n "$use_locale" ]; then - locpaths="${man_lang}_${man_country}.${man_charset}" - locpaths="$locpaths:$man_lang.$man_charset" - if [ "$man_lang" != "en" ]; then - locpaths="$locpaths:en.$man_charset" - fi - locpaths="$locpaths:." + decho 'Using non-localized manpages' else - locpaths="." + # Use the locale tool to give us the proper LC_CTYPE + eval $( $LOCALE ) + + case "$LC_CTYPE" in + C) ;; + POSIX) ;; + [a-z][a-z]_[A-Z][A-Z]\.*) + lang_cc="${LC_CTYPE%.*}" + man_lang="${LC_CTYPE%_*}" + man_country="${lang_cc#*_}" + man_charset="${LC_CTYPE#*.}" + locpaths="$LC_CTYPE" + locpaths="$locpaths:$man_lang.$man_charset" + if [ "$man_lang" != "en" ]; then + locpaths="$locpaths:en.$man_charset" + fi + locpaths="$locpaths:." + ;; + *) echo 'Unknown locale, assuming C' >&2 + ;; + esac fi + decho "Using locale paths: $locpaths" } @@ -660,28 +680,6 @@ parse_file() { done < "$file" } -# Usage: parse_locale localestring -# Setup locale variables for proper parsing. -parse_locale() { - local lang_cc - - case "$1" in - C) ;; - POSIX) ;; - [a-z][a-z]_[A-Z][A-Z]\.*) lang_cc="${1%.*}" - man_lang="${1%_*}" - man_country="${lang_cc#*_}" - man_charset="${1#*.}" - use_locale=yes - return 0 - ;; - *) echo 'Unknown locale, assuming C' >&2 - ;; - esac - - unset use_locale -} - # Usage: search_path # Traverse $PATH looking for manpaths. search_path() { @@ -893,6 +891,7 @@ do_whatis() { EQN=/usr/bin/eqn COL=/usr/bin/col +LOCALE=/usr/bin/locale NROFF='/usr/bin/groff -S -Wall -mtty-char -man' PIC=/usr/bin/pic SYSCTL=/sbin/sysctl From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 06:13:31 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B994B106564A; Sat, 2 Apr 2011 06:13:31 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A98A18FC08; Sat, 2 Apr 2011 06:13:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p326DVlP072504; Sat, 2 Apr 2011 06:13:31 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p326DVpE072499; Sat, 2 Apr 2011 06:13:31 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201104020613.p326DVpE072499@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 2 Apr 2011 06:13:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220262 - in stable/8/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 06:13:31 -0000 Author: dchagin Date: Sat Apr 2 06:13:31 2011 New Revision: 220262 URL: http://svn.freebsd.org/changeset/base/220262 Log: MFC r219041: ktrace_resize_pool() locking slightly reworked: 1) do not take a lock around the single atomic operation. 2) do not lose the invariant of lock by dropping/acquiring ktrace_mtx around free() or malloc(). MFC r219042: Introduce preliminary support of the show description of the ABI of traced process by adding two new events which records value of process sv_flags to the trace file at process creation/execing/exiting time. MFC r219311: Partially rework r219042. The reason for this is a bug at ktrops() where process dereferenced without having a lock. This might cause a panic if ktrace was runned with -p flag and the specified process exited between the dropping a lock and writing sv_flags. Since it is impossible to acquire sx lock while holding mtx switch to use asynchronous enqueuerequest() instead of writerequest(). Rename ktr_getrequest_ne() to more understandable name. MFC r219312: Fix indentation in comment, double ';' in variable declaration. Modified: stable/8/sys/kern/kern_exec.c stable/8/sys/kern/kern_fork.c stable/8/sys/kern/kern_ktrace.c stable/8/sys/sys/ktrace.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/kern_exec.c ============================================================================== --- stable/8/sys/kern/kern_exec.c Sat Apr 2 05:01:09 2011 (r220261) +++ stable/8/sys/kern/kern_exec.c Sat Apr 2 06:13:31 2011 (r220262) @@ -896,6 +896,12 @@ done2: exit1(td, W_EXITCODE(0, SIGABRT)); /* NOT REACHED */ } + +#ifdef KTRACE + if (error == 0) + ktrprocctor(p); +#endif + return (error); } Modified: stable/8/sys/kern/kern_fork.c ============================================================================== --- stable/8/sys/kern/kern_fork.c Sat Apr 2 05:01:09 2011 (r220261) +++ stable/8/sys/kern/kern_fork.c Sat Apr 2 06:13:31 2011 (r220262) @@ -649,10 +649,6 @@ again: callout_init(&p2->p_itcallout, CALLOUT_MPSAFE); -#ifdef KTRACE - ktrprocfork(p1, p2); -#endif - /* * If PF_FORK is set, the child process inherits the * procfs ioctl flags from its parent. @@ -688,6 +684,10 @@ again: p2->p_acflag = AFORK; PROC_UNLOCK(p2); +#ifdef KTRACE + ktrprocfork(p1, p2); +#endif + /* * Finish creating the child process. It will return via a different * execution path later. (ie: directly into user mode) Modified: stable/8/sys/kern/kern_ktrace.c ============================================================================== --- stable/8/sys/kern/kern_ktrace.c Sat Apr 2 05:01:09 2011 (r220261) +++ stable/8/sys/kern/kern_ktrace.c Sat Apr 2 06:13:31 2011 (r220262) @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -91,6 +92,7 @@ struct ktr_request { struct ktr_header ktr_header; void *ktr_buffer; union { + struct ktr_proc_ctor ktr_proc_ctor; struct ktr_syscall ktr_syscall; struct ktr_sysret ktr_sysret; struct ktr_genio ktr_genio; @@ -111,6 +113,8 @@ static int data_lengths[] = { 0, /* KTR_USER */ 0, /* KTR_STRUCT */ 0, /* KTR_SYSCTL */ + sizeof(struct ktr_proc_ctor), /* KTR_PROCCTOR */ + 0, /* KTR_PROCDTOR */ }; static STAILQ_HEAD(, ktr_request) ktr_free; @@ -131,7 +135,8 @@ static struct sx ktrace_sx; static void ktrace_init(void *dummy); static int sysctl_kern_ktrace_request_pool(SYSCTL_HANDLER_ARGS); -static u_int ktrace_resize_pool(u_int newsize); +static u_int ktrace_resize_pool(u_int oldsize, u_int newsize); +static struct ktr_request *ktr_getrequest_entered(struct thread *td, int type); static struct ktr_request *ktr_getrequest(int type); static void ktr_submitrequest(struct thread *td, struct ktr_request *req); static void ktr_freeproc(struct proc *p, struct ucred **uc, @@ -142,6 +147,7 @@ static void ktr_writerequest(struct thre static int ktrcanset(struct thread *,struct proc *); static int ktrsetchildren(struct thread *,struct proc *,int,int,struct vnode *); static int ktrops(struct thread *,struct proc *,int,int,struct vnode *); +static void ktrprocctor_entered(struct thread *, struct proc *); /* * ktrace itself generates events, such as context switches, which we do not @@ -197,9 +203,7 @@ sysctl_kern_ktrace_request_pool(SYSCTL_H /* Handle easy read-only case first to avoid warnings from GCC. */ if (!req->newptr) { - mtx_lock(&ktrace_mtx); oldsize = ktr_requestpool; - mtx_unlock(&ktrace_mtx); return (SYSCTL_OUT(req, &oldsize, sizeof(u_int))); } @@ -208,10 +212,8 @@ sysctl_kern_ktrace_request_pool(SYSCTL_H return (error); td = curthread; ktrace_enter(td); - mtx_lock(&ktrace_mtx); oldsize = ktr_requestpool; - newsize = ktrace_resize_pool(wantsize); - mtx_unlock(&ktrace_mtx); + newsize = ktrace_resize_pool(oldsize, wantsize); ktrace_exit(td); error = SYSCTL_OUT(req, &oldsize, sizeof(u_int)); if (error) @@ -224,38 +226,40 @@ SYSCTL_PROC(_kern_ktrace, OID_AUTO, requ &ktr_requestpool, 0, sysctl_kern_ktrace_request_pool, "IU", ""); static u_int -ktrace_resize_pool(u_int newsize) +ktrace_resize_pool(u_int oldsize, u_int newsize) { + STAILQ_HEAD(, ktr_request) ktr_new; struct ktr_request *req; int bound; - mtx_assert(&ktrace_mtx, MA_OWNED); print_message = 1; - bound = newsize - ktr_requestpool; + bound = newsize - oldsize; if (bound == 0) return (ktr_requestpool); - if (bound < 0) + if (bound < 0) { + mtx_lock(&ktrace_mtx); /* Shrink pool down to newsize if possible. */ while (bound++ < 0) { req = STAILQ_FIRST(&ktr_free); if (req == NULL) - return (ktr_requestpool); + break; STAILQ_REMOVE_HEAD(&ktr_free, ktr_list); ktr_requestpool--; - mtx_unlock(&ktrace_mtx); free(req, M_KTRACE); - mtx_lock(&ktrace_mtx); } - else + } else { /* Grow pool up to newsize. */ + STAILQ_INIT(&ktr_new); while (bound-- > 0) { - mtx_unlock(&ktrace_mtx); req = malloc(sizeof(struct ktr_request), M_KTRACE, M_WAITOK); - mtx_lock(&ktrace_mtx); - STAILQ_INSERT_HEAD(&ktr_free, req, ktr_list); - ktr_requestpool++; + STAILQ_INSERT_HEAD(&ktr_new, req, ktr_list); } + mtx_lock(&ktrace_mtx); + STAILQ_CONCAT(&ktr_free, &ktr_new); + ktr_requestpool += (newsize - oldsize); + } + mtx_unlock(&ktrace_mtx); return (ktr_requestpool); } @@ -264,18 +268,15 @@ CTASSERT(sizeof(((struct ktr_header *)NU (sizeof((struct thread *)NULL)->td_name)); static struct ktr_request * -ktr_getrequest(int type) +ktr_getrequest_entered(struct thread *td, int type) { struct ktr_request *req; - struct thread *td = curthread; struct proc *p = td->td_proc; int pm; - ktrace_enter(td); /* XXX: In caller instead? */ mtx_lock(&ktrace_mtx); if (!KTRCHECK(td, type)) { mtx_unlock(&ktrace_mtx); - ktrace_exit(td); return (NULL); } req = STAILQ_FIRST(&ktr_free); @@ -301,11 +302,24 @@ ktr_getrequest(int type) mtx_unlock(&ktrace_mtx); if (pm) printf("Out of ktrace request objects.\n"); - ktrace_exit(td); } return (req); } +static struct ktr_request * +ktr_getrequest(int type) +{ + struct thread *td = curthread; + struct ktr_request *req; + + ktrace_enter(td); + req = ktr_getrequest_entered(td, type); + if (req == NULL) + ktrace_exit(td); + + return (req); +} + /* * Some trace generation environments don't permit direct access to VFS, * such as during a context switch where sleeping is not allowed. Under these @@ -319,7 +333,6 @@ ktr_enqueuerequest(struct thread *td, st mtx_lock(&ktrace_mtx); STAILQ_INSERT_TAIL(&td->td_proc->p_ktr, req, ktr_list); mtx_unlock(&ktrace_mtx); - ktrace_exit(td); } /* @@ -369,7 +382,6 @@ ktr_submitrequest(struct thread *td, str ktr_writerequest(td, req); ktr_freerequest(req); sx_xunlock(&ktrace_sx); - ktrace_exit(td); } @@ -487,6 +499,7 @@ ktrprocexec(struct proc *p, struct ucred void ktrprocexit(struct thread *td) { + struct ktr_request *req; struct proc *p; struct ucred *cred; struct vnode *vp; @@ -497,6 +510,9 @@ ktrprocexit(struct thread *td) return; ktrace_enter(td); + req = ktr_getrequest_entered(td, KTR_PROCDTOR); + if (req != NULL) + ktr_enqueuerequest(td, req); sx_xlock(&ktrace_sx); ktr_drain(td); sx_xunlock(&ktrace_sx); @@ -515,6 +531,36 @@ ktrprocexit(struct thread *td) ktrace_exit(td); } +static void +ktrprocctor_entered(struct thread *td, struct proc *p) +{ + struct ktr_proc_ctor *ktp; + struct ktr_request *req; + struct thread *td2; + + ktrace_assert(td); + td2 = FIRST_THREAD_IN_PROC(p); + req = ktr_getrequest_entered(td2, KTR_PROCCTOR); + if (req == NULL) + return; + ktp = &req->ktr_data.ktr_proc_ctor; + ktp->sv_flags = p->p_sysent->sv_flags; + ktr_enqueuerequest(td2, req); +} + +void +ktrprocctor(struct proc *p) +{ + struct thread *td = curthread; + + if ((p->p_traceflag & KTRFAC_MASK) == 0) + return; + + ktrace_enter(td); + ktrprocctor_entered(td, p); + ktrace_exit(td); +} + /* * When a process forks, enable tracing in the new process if needed. */ @@ -522,8 +568,7 @@ void ktrprocfork(struct proc *p1, struct proc *p2) { - PROC_LOCK_ASSERT(p1, MA_OWNED); - PROC_LOCK_ASSERT(p2, MA_OWNED); + PROC_LOCK(p1); mtx_lock(&ktrace_mtx); KASSERT(p2->p_tracevp == NULL, ("new process has a ktrace vnode")); if (p1->p_traceflag & KTRFAC_INHERIT) { @@ -536,6 +581,9 @@ ktrprocfork(struct proc *p1, struct proc } } mtx_unlock(&ktrace_mtx); + PROC_UNLOCK(p1); + + ktrprocctor(p2); } /* @@ -659,6 +707,7 @@ ktrpsig(sig, action, mask, code) sigset_t *mask; int code; { + struct thread *td = curthread; struct ktr_request *req; struct ktr_psig *kp; @@ -670,13 +719,15 @@ ktrpsig(sig, action, mask, code) kp->action = action; kp->mask = *mask; kp->code = code; - ktr_enqueuerequest(curthread, req); + ktr_enqueuerequest(td, req); + ktrace_exit(td); } void ktrcsw(out, user) int out, user; { + struct thread *td = curthread; struct ktr_request *req; struct ktr_csw *kc; @@ -686,7 +737,8 @@ ktrcsw(out, user) kc = &req->ktr_data.ktr_csw; kc->out = out; kc->user = user; - ktr_enqueuerequest(curthread, req); + ktr_enqueuerequest(td, req); + ktrace_exit(td); } void @@ -962,6 +1014,8 @@ ktrops(td, p, ops, facs, vp) ktr_freeproc(p, &tracecred, &tracevp); } mtx_unlock(&ktrace_mtx); + if ((p->p_traceflag & KTRFAC_MASK) != 0) + ktrprocctor_entered(td, p); PROC_UNLOCK(p); if (tracevp != NULL) { int vfslocked; Modified: stable/8/sys/sys/ktrace.h ============================================================================== --- stable/8/sys/sys/ktrace.h Sat Apr 2 05:01:09 2011 (r220261) +++ stable/8/sys/sys/ktrace.h Sat Apr 2 06:13:31 2011 (r220262) @@ -156,6 +156,7 @@ struct ktr_csw { #define KTR_STRUCT 8 struct sockaddr; struct stat; +struct sysentvec; /* * KTR_SYSCTL - name of a sysctl MIB @@ -164,6 +165,19 @@ struct stat; /* record contains null-terminated MIB name */ /* + * KTR_PROCCTOR - trace process creation (multiple ABI support) + */ +#define KTR_PROCCTOR 10 +struct ktr_proc_ctor { + u_int sv_flags; /* struct sysentvec sv_flags copy */ +}; + +/* + * KTR_PROCDTOR - trace process destruction (multiple ABI support) + */ +#define KTR_PROCDTOR 11 + +/* * KTR_DROP - If this bit is set in ktr_type, then at least one event * between the previous record and this record was dropped. */ @@ -182,6 +196,8 @@ struct stat; #define KTRFAC_USER (1< Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7D4EF106564A; Sat, 2 Apr 2011 06:25:13 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6D6B48FC08; Sat, 2 Apr 2011 06:25:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p326PDIV072787; Sat, 2 Apr 2011 06:25:13 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p326PDlf072782; Sat, 2 Apr 2011 06:25:13 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201104020625.p326PDlf072782@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 2 Apr 2011 06:25:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220263 - in stable/7/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 06:25:13 -0000 Author: dchagin Date: Sat Apr 2 06:25:13 2011 New Revision: 220263 URL: http://svn.freebsd.org/changeset/base/220263 Log: MFC r219041: ktrace_resize_pool() locking slightly reworked: 1) do not take a lock around the single atomic operation. 2) do not lose the invariant of lock by dropping/acquiring ktrace_mtx around free() or malloc(). MFC r219042: Introduce preliminary support of the show description of the ABI of traced process by adding two new events which records value of process sv_flags to the trace file at process creation/execing/exiting time. MFC r219311: Partially rework r219042. The reason for this is a bug at ktrops() where process dereferenced without having a lock. This might cause a panic if ktrace was runned with -p flag and the specified process exited between the dropping a lock and writing sv_flags. Since it is impossible to acquire sx lock while holding mtx switch to use asynchronous enqueuerequest() instead of writerequest(). Rename ktr_getrequest_ne() to more understandable name. MFC r219312: Fix indentation in comment, double ';' in variable declaration. PR: ports/155083 Modified: stable/7/sys/kern/kern_exec.c stable/7/sys/kern/kern_fork.c stable/7/sys/kern/kern_ktrace.c stable/7/sys/sys/ktrace.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/kern_exec.c ============================================================================== --- stable/7/sys/kern/kern_exec.c Sat Apr 2 06:13:31 2011 (r220262) +++ stable/7/sys/kern/kern_exec.c Sat Apr 2 06:25:13 2011 (r220263) @@ -845,6 +845,12 @@ done2: exit1(td, W_EXITCODE(0, SIGABRT)); /* NOT REACHED */ } + +#ifdef KTRACE + if (error == 0) + ktrprocctor(p); +#endif + return (error); } Modified: stable/7/sys/kern/kern_fork.c ============================================================================== --- stable/7/sys/kern/kern_fork.c Sat Apr 2 06:13:31 2011 (r220262) +++ stable/7/sys/kern/kern_fork.c Sat Apr 2 06:25:13 2011 (r220263) @@ -613,10 +613,6 @@ again: callout_init(&p2->p_itcallout, CALLOUT_MPSAFE); -#ifdef KTRACE - ktrprocfork(p1, p2); -#endif - /* * If PF_FORK is set, the child process inherits the * procfs ioctl flags from its parent. @@ -661,6 +657,10 @@ again: p2->p_acflag = AFORK; PROC_UNLOCK(p2); +#ifdef KTRACE + ktrprocfork(p1, p2); +#endif + /* * Finish creating the child process. It will return via a different * execution path later. (ie: directly into user mode) Modified: stable/7/sys/kern/kern_ktrace.c ============================================================================== --- stable/7/sys/kern/kern_ktrace.c Sat Apr 2 06:13:31 2011 (r220262) +++ stable/7/sys/kern/kern_ktrace.c Sat Apr 2 06:25:13 2011 (r220263) @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -92,6 +93,7 @@ struct ktr_request { struct ktr_header ktr_header; void *ktr_buffer; union { + struct ktr_proc_ctor ktr_proc_ctor; struct ktr_syscall ktr_syscall; struct ktr_sysret ktr_sysret; struct ktr_genio ktr_genio; @@ -112,6 +114,8 @@ static int data_lengths[] = { 0, /* KTR_USER */ 0, /* KTR_STRUCT */ 0, /* KTR_SYSCTL */ + sizeof(struct ktr_proc_ctor), /* KTR_PROCCTOR */ + 0, /* KTR_PROCDTOR */ }; static STAILQ_HEAD(, ktr_request) ktr_free; @@ -132,7 +136,8 @@ static struct sx ktrace_sx; static void ktrace_init(void *dummy); static int sysctl_kern_ktrace_request_pool(SYSCTL_HANDLER_ARGS); -static u_int ktrace_resize_pool(u_int newsize); +static u_int ktrace_resize_pool(u_int oldsize, u_int newsize); +static struct ktr_request *ktr_getrequest_entered(struct thread *td, int type); static struct ktr_request *ktr_getrequest(int type); static void ktr_submitrequest(struct thread *td, struct ktr_request *req); static void ktr_freeproc(struct proc *p, struct ucred **uc, @@ -143,6 +148,7 @@ static void ktr_writerequest(struct thre static int ktrcanset(struct thread *,struct proc *); static int ktrsetchildren(struct thread *,struct proc *,int,int,struct vnode *); static int ktrops(struct thread *,struct proc *,int,int,struct vnode *); +static void ktrprocctor_entered(struct thread *, struct proc *); /* * ktrace itself generates events, such as context switches, which we do not @@ -198,9 +204,7 @@ sysctl_kern_ktrace_request_pool(SYSCTL_H /* Handle easy read-only case first to avoid warnings from GCC. */ if (!req->newptr) { - mtx_lock(&ktrace_mtx); oldsize = ktr_requestpool; - mtx_unlock(&ktrace_mtx); return (SYSCTL_OUT(req, &oldsize, sizeof(u_int))); } @@ -209,10 +213,8 @@ sysctl_kern_ktrace_request_pool(SYSCTL_H return (error); td = curthread; ktrace_enter(td); - mtx_lock(&ktrace_mtx); oldsize = ktr_requestpool; - newsize = ktrace_resize_pool(wantsize); - mtx_unlock(&ktrace_mtx); + newsize = ktrace_resize_pool(oldsize, wantsize); ktrace_exit(td); error = SYSCTL_OUT(req, &oldsize, sizeof(u_int)); if (error) @@ -225,38 +227,40 @@ SYSCTL_PROC(_kern_ktrace, OID_AUTO, requ &ktr_requestpool, 0, sysctl_kern_ktrace_request_pool, "IU", ""); static u_int -ktrace_resize_pool(u_int newsize) +ktrace_resize_pool(u_int oldsize, u_int newsize) { + STAILQ_HEAD(, ktr_request) ktr_new; struct ktr_request *req; int bound; - mtx_assert(&ktrace_mtx, MA_OWNED); print_message = 1; - bound = newsize - ktr_requestpool; + bound = newsize - oldsize; if (bound == 0) return (ktr_requestpool); - if (bound < 0) + if (bound < 0) { + mtx_lock(&ktrace_mtx); /* Shrink pool down to newsize if possible. */ while (bound++ < 0) { req = STAILQ_FIRST(&ktr_free); if (req == NULL) - return (ktr_requestpool); + break; STAILQ_REMOVE_HEAD(&ktr_free, ktr_list); ktr_requestpool--; - mtx_unlock(&ktrace_mtx); free(req, M_KTRACE); - mtx_lock(&ktrace_mtx); } - else + } else { /* Grow pool up to newsize. */ + STAILQ_INIT(&ktr_new); while (bound-- > 0) { - mtx_unlock(&ktrace_mtx); req = malloc(sizeof(struct ktr_request), M_KTRACE, M_WAITOK); - mtx_lock(&ktrace_mtx); - STAILQ_INSERT_HEAD(&ktr_free, req, ktr_list); - ktr_requestpool++; + STAILQ_INSERT_HEAD(&ktr_new, req, ktr_list); } + mtx_lock(&ktrace_mtx); + STAILQ_CONCAT(&ktr_free, &ktr_new); + ktr_requestpool += (newsize - oldsize); + } + mtx_unlock(&ktrace_mtx); return (ktr_requestpool); } @@ -265,18 +269,15 @@ CTASSERT(sizeof(((struct ktr_header *)NU (sizeof((struct proc *)NULL)->p_comm)); static struct ktr_request * -ktr_getrequest(int type) +ktr_getrequest_entered(struct thread *td, int type) { struct ktr_request *req; - struct thread *td = curthread; struct proc *p = td->td_proc; int pm; - ktrace_enter(td); /* XXX: In caller instead? */ mtx_lock(&ktrace_mtx); if (!KTRCHECK(td, type)) { mtx_unlock(&ktrace_mtx); - ktrace_exit(td); return (NULL); } req = STAILQ_FIRST(&ktr_free); @@ -302,11 +303,24 @@ ktr_getrequest(int type) mtx_unlock(&ktrace_mtx); if (pm) printf("Out of ktrace request objects.\n"); - ktrace_exit(td); } return (req); } +static struct ktr_request * +ktr_getrequest(int type) +{ + struct thread *td = curthread; + struct ktr_request *req; + + ktrace_enter(td); + req = ktr_getrequest_entered(td, type); + if (req == NULL) + ktrace_exit(td); + + return (req); +} + /* * Some trace generation environments don't permit direct access to VFS, * such as during a context switch where sleeping is not allowed. Under these @@ -320,7 +334,6 @@ ktr_enqueuerequest(struct thread *td, st mtx_lock(&ktrace_mtx); STAILQ_INSERT_TAIL(&td->td_proc->p_ktr, req, ktr_list); mtx_unlock(&ktrace_mtx); - ktrace_exit(td); } /* @@ -370,7 +383,6 @@ ktr_submitrequest(struct thread *td, str ktr_writerequest(td, req); ktr_freerequest(req); sx_xunlock(&ktrace_sx); - ktrace_exit(td); } @@ -488,6 +500,7 @@ ktrprocexec(struct proc *p, struct ucred void ktrprocexit(struct thread *td) { + struct ktr_request *req; struct proc *p; struct ucred *cred; struct vnode *vp; @@ -498,6 +511,9 @@ ktrprocexit(struct thread *td) return; ktrace_enter(td); + req = ktr_getrequest_entered(td, KTR_PROCDTOR); + if (req != NULL) + ktr_enqueuerequest(td, req); sx_xlock(&ktrace_sx); ktr_drain(td); sx_xunlock(&ktrace_sx); @@ -516,6 +532,36 @@ ktrprocexit(struct thread *td) ktrace_exit(td); } +static void +ktrprocctor_entered(struct thread *td, struct proc *p) +{ + struct ktr_proc_ctor *ktp; + struct ktr_request *req; + struct thread *td2; + + ktrace_assert(td); + td2 = FIRST_THREAD_IN_PROC(p); + req = ktr_getrequest_entered(td2, KTR_PROCCTOR); + if (req == NULL) + return; + ktp = &req->ktr_data.ktr_proc_ctor; + ktp->sv_flags = p->p_sysent->sv_flags; + ktr_enqueuerequest(td2, req); +} + +void +ktrprocctor(struct proc *p) +{ + struct thread *td = curthread; + + if ((p->p_traceflag & KTRFAC_MASK) == 0) + return; + + ktrace_enter(td); + ktrprocctor_entered(td, p); + ktrace_exit(td); +} + /* * When a process forks, enable tracing in the new process if needed. */ @@ -523,8 +569,7 @@ void ktrprocfork(struct proc *p1, struct proc *p2) { - PROC_LOCK_ASSERT(p1, MA_OWNED); - PROC_LOCK_ASSERT(p2, MA_OWNED); + PROC_LOCK(p1); mtx_lock(&ktrace_mtx); KASSERT(p2->p_tracevp == NULL, ("new process has a ktrace vnode")); if (p1->p_traceflag & KTRFAC_INHERIT) { @@ -537,6 +582,9 @@ ktrprocfork(struct proc *p1, struct proc } } mtx_unlock(&ktrace_mtx); + PROC_UNLOCK(p1); + + ktrprocctor(p2); } /* @@ -660,6 +708,7 @@ ktrpsig(sig, action, mask, code) sigset_t *mask; int code; { + struct thread *td = curthread; struct ktr_request *req; struct ktr_psig *kp; @@ -671,13 +720,15 @@ ktrpsig(sig, action, mask, code) kp->action = action; kp->mask = *mask; kp->code = code; - ktr_enqueuerequest(curthread, req); + ktr_enqueuerequest(td, req); + ktrace_exit(td); } void ktrcsw(out, user) int out, user; { + struct thread *td = curthread; struct ktr_request *req; struct ktr_csw *kc; @@ -687,7 +738,8 @@ ktrcsw(out, user) kc = &req->ktr_data.ktr_csw; kc->out = out; kc->user = user; - ktr_enqueuerequest(curthread, req); + ktr_enqueuerequest(td, req); + ktrace_exit(td); } void @@ -963,6 +1015,8 @@ ktrops(td, p, ops, facs, vp) ktr_freeproc(p, &tracecred, &tracevp); } mtx_unlock(&ktrace_mtx); + if ((p->p_traceflag & KTRFAC_MASK) != 0) + ktrprocctor_entered(td, p); PROC_UNLOCK(p); if (tracevp != NULL) { int vfslocked; Modified: stable/7/sys/sys/ktrace.h ============================================================================== --- stable/7/sys/sys/ktrace.h Sat Apr 2 06:13:31 2011 (r220262) +++ stable/7/sys/sys/ktrace.h Sat Apr 2 06:25:13 2011 (r220263) @@ -156,6 +156,7 @@ struct ktr_csw { #define KTR_STRUCT 8 struct sockaddr; struct stat; +struct sysentvec; /* * KTR_SYSCTL - name of a sysctl MIB @@ -164,6 +165,19 @@ struct stat; /* record contains null-terminated MIB name */ /* + * KTR_PROCCTOR - trace process creation (multiple ABI support) + */ +#define KTR_PROCCTOR 10 +struct ktr_proc_ctor { + u_int sv_flags; /* struct sysentvec sv_flags copy */ +}; + +/* + * KTR_PROCDTOR - trace process destruction (multiple ABI support) + */ +#define KTR_PROCDTOR 11 + +/* * KTR_DROP - If this bit is set in ktr_type, then at least one event * between the previous record and this record was dropped. */ @@ -182,6 +196,8 @@ struct stat; #define KTRFAC_USER (1< Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 85A6E106566C; Sat, 2 Apr 2011 06:56:07 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5D4128FC13; Sat, 2 Apr 2011 06:56:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p326u77e073509; Sat, 2 Apr 2011 06:56:07 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p326u7GW073507; Sat, 2 Apr 2011 06:56:07 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020656.p326u7GW073507@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 06:56:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220264 - head/sys/geom/gate X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 06:56:07 -0000 Author: pjd Date: Sat Apr 2 06:56:06 2011 New Revision: 220264 URL: http://svn.freebsd.org/changeset/base/220264 Log: GEOM has an internal mechanism to deal with ENOMEM errors returned via g_io_deliver(). In such case it increases 'pace' counter on each ENOMEM and reschedules the request. The 'pace' counter is decreased for each request going down, but until 'pace' is greater than zero, GEOM will handle at most 10 requests per second. For GEOM GATE users that are proxy to local GEOM providers (like ggatel(8) and HAST) we can end up with almost permanent slow down of GEOM down queue. This is because once we reach GEOM GATE queue limit, we return ENOMEM to the GEOM. This means that we have, eg. 1024 I/O requests in the GEOM GATE queue. To make room in the queue and stop returning ENOMEM we need to proceed the requests of course, but those requests are handled by userland daemons that handle them by reading/writing also from/to local GEOM providers. For example with HAST, a new requests comes to /dev/hast/data, which is GEOM GATE provider. GEOM GATE passes the request to hastd(8) and hastd(8) reads/writes from/to /dev/da0. Once we reach GEOM GATE queue limit, to free up a slot in GEOM GATE queue, hastd(8) has to read/write from/to /dev/da0, but this request will also be very slow, because GEOM now slows down all the requests. We end up with full queue that we can unload at the speed of 10 requests per second. This simply looks like a deadlock. Fix it by allowing userland daemons that work with both GEOM GATE and local GEOM providers to specify unlimited queue size, so GEOM GATE will never return ENOMEM to the GEOM. MFC after: 1 week Modified: head/sys/geom/gate/g_gate.c Modified: head/sys/geom/gate/g_gate.c ============================================================================== --- head/sys/geom/gate/g_gate.c Sat Apr 2 06:25:13 2011 (r220263) +++ head/sys/geom/gate/g_gate.c Sat Apr 2 06:56:06 2011 (r220264) @@ -194,7 +194,7 @@ g_gate_start(struct bio *bp) } mtx_lock(&sc->sc_queue_mtx); - if (sc->sc_queue_count > sc->sc_queue_size) { + if (sc->sc_queue_size > 0 && sc->sc_queue_count > sc->sc_queue_size) { mtx_unlock(&sc->sc_queue_mtx); G_GATE_LOGREQ(1, bp, "Queue full, request canceled."); g_io_deliver(bp, ENOMEM); From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 06:59:05 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B1A30106566C; Sat, 2 Apr 2011 06:59:05 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 893568FC12; Sat, 2 Apr 2011 06:59:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p326x5RS073608; Sat, 2 Apr 2011 06:59:05 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p326x5W4073605; Sat, 2 Apr 2011 06:59:05 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020659.p326x5W4073605@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 06:59:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220265 - head/sbin/ggate/ggatel X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 06:59:05 -0000 Author: pjd Date: Sat Apr 2 06:59:05 2011 New Revision: 220265 URL: http://svn.freebsd.org/changeset/base/220265 Log: Because ggatel(8) operates on local GEOM providers, use unlimited queue size in GEOM GATE to fix the issue described in r220264. This also means that we no longer need -q option, remove it. Don't bother to leaving it as a no-op, as ggatel(8) is just an example utility. Modified: head/sbin/ggate/ggatel/ggatel.8 head/sbin/ggate/ggatel/ggatel.c Modified: head/sbin/ggate/ggatel/ggatel.8 ============================================================================== --- head/sbin/ggate/ggatel/ggatel.8 Sat Apr 2 06:56:06 2011 (r220264) +++ head/sbin/ggate/ggatel/ggatel.8 Sat Apr 2 06:59:05 2011 (r220265) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 26, 2004 +.Dd April 2, 2011 .Dt GGATEL 8 .Os .Sh NAME @@ -35,7 +35,6 @@ .Cm create .Op Fl v .Op Fl o Cm ro | wo | rw -.Op Fl q Ar queue_size .Op Fl s Ar sectorsize .Op Fl t Ar timeout .Op Fl u Ar unit @@ -100,10 +99,6 @@ or read-write .Pq Cm rw . Default is .Cm rw . -.It Fl q Ar queue_size -Number of pending I/O requests that can be queued before they will -start to be canceled. -Default is 1024. .It Fl s Ar sectorsize Sector size for .Nm ggate Modified: head/sbin/ggate/ggatel/ggatel.c ============================================================================== --- head/sbin/ggate/ggatel/ggatel.c Sat Apr 2 06:56:06 2011 (r220264) +++ head/sbin/ggate/ggatel/ggatel.c Sat Apr 2 06:59:05 2011 (r220265) @@ -53,7 +53,6 @@ static const char *path = NULL; static int unit = G_GATE_UNIT_AUTO; static unsigned flags = 0; static int force = 0; -static unsigned queue_size = G_GATE_QUEUE_SIZE; static unsigned sectorsize = 0; static unsigned timeout = G_GATE_TIMEOUT; @@ -61,7 +60,7 @@ static void usage(void) { - fprintf(stderr, "usage: %s create [-v] [-o ] [-q queue_size] " + fprintf(stderr, "usage: %s create [-v] [-o ] " "[-s sectorsize] [-t timeout] [-u unit] \n", getprogname()); fprintf(stderr, " %s rescue [-v] [-o ] <-u unit> " "\n", getprogname()); @@ -182,7 +181,7 @@ g_gatel_create(void) ggioc.gctl_sectorsize = sectorsize; ggioc.gctl_timeout = timeout; ggioc.gctl_flags = flags; - ggioc.gctl_maxcount = queue_size; + ggioc.gctl_maxcount = 0; strlcpy(ggioc.gctl_info, path, sizeof(ggioc.gctl_info)); g_gate_ioctl(G_GATE_CMD_CREATE, &ggioc); if (unit == -1) @@ -230,7 +229,7 @@ main(int argc, char *argv[]) for (;;) { int ch; - ch = getopt(argc, argv, "fo:q:s:t:u:v"); + ch = getopt(argc, argv, "fo:s:t:u:v"); if (ch == -1) break; switch (ch) { @@ -253,14 +252,6 @@ main(int argc, char *argv[]) "Invalid argument for '-o' option."); } break; - case 'q': - if (action != CREATE) - usage(); - errno = 0; - queue_size = strtoul(optarg, NULL, 10); - if (queue_size == 0 && errno != 0) - errx(EXIT_FAILURE, "Invalid queue_size."); - break; case 's': if (action != CREATE) usage(); From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 07:01:10 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 54127106566B; Sat, 2 Apr 2011 07:01:10 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 469A38FC0C; Sat, 2 Apr 2011 07:01:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3271AsY073708; Sat, 2 Apr 2011 07:01:10 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3271AUt073706; Sat, 2 Apr 2011 07:01:10 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020701.p3271AUt073706@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 07:01:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220266 - head/sbin/hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 07:01:10 -0000 Author: pjd Date: Sat Apr 2 07:01:09 2011 New Revision: 220266 URL: http://svn.freebsd.org/changeset/base/220266 Log: Handle the problem described in r220264 by using GEOM GATE queue of unlimited length. This should fix deadlocks reported by HAST users. MFC after: 1 week Modified: head/sbin/hastd/primary.c Modified: head/sbin/hastd/primary.c ============================================================================== --- head/sbin/hastd/primary.c Sat Apr 2 06:59:05 2011 (r220265) +++ head/sbin/hastd/primary.c Sat Apr 2 07:01:09 2011 (r220266) @@ -761,7 +761,7 @@ init_ggate(struct hast_resource *res) ggiocreate.gctl_mediasize = res->hr_datasize; ggiocreate.gctl_sectorsize = res->hr_local_sectorsize; ggiocreate.gctl_flags = 0; - ggiocreate.gctl_maxcount = G_GATE_MAX_QUEUE_SIZE; + ggiocreate.gctl_maxcount = 0; ggiocreate.gctl_timeout = 0; ggiocreate.gctl_unit = G_GATE_NAME_GIVEN; snprintf(ggiocreate.gctl_name, sizeof(ggiocreate.gctl_name), "hast/%s", From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 07:56:15 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 844FF1065670; Sat, 2 Apr 2011 07:56:15 +0000 (UTC) (envelope-from delphij@gmail.com) Received: from mail-pw0-f54.google.com (mail-pw0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 3FED28FC19; Sat, 2 Apr 2011 07:56:15 +0000 (UTC) Received: by pwj8 with SMTP id 8so1079448pwj.13 for ; Sat, 02 Apr 2011 00:56:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=OU67HbBCOAGoIlSwKvNg+yG3Ktxw4HD/Teqb4FU+QkI=; b=n2F2cDXWsHI5t5Z3TuwqbXbqF+z9Av7k5GCy4aTgtBKcr94eIVqKaZQxcIUDOdriS8 ZcmICObnz9QpE8YZfytwcNx+GfqiG6VoAxKvJvLgWOx3rKjl6SWAldZ6u5IXNnxFo6za tVFzQfZym0sf8z2YY0/FNflaWsabYscyx5vis= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=RsBpw7otGYCHTVzvRbaX+1fCl9VfsnZXuRBmpYxV2rZJ4+cOqUs9964sbXXqMCRGTV NCAr4DURsWFeDCZmr6TFUd0M5Yunz3ZBDl4x5/aqRDdXq7ZzKy7xYCScjYHfLAPVIFds IBnWkxbSPZUEQUpxtsHMdNhakcxaYmN099w0Q= MIME-Version: 1.0 Received: by 10.143.27.39 with SMTP id e39mr3963246wfj.155.1301729624013; Sat, 02 Apr 2011 00:33:44 -0700 (PDT) Received: by 10.68.62.164 with HTTP; Sat, 2 Apr 2011 00:33:43 -0700 (PDT) In-Reply-To: <20110402015552.GA32901@FreeBSD.org> References: <201104011823.p31INiHv055195@svn.freebsd.org> <20110402015552.GA32901@FreeBSD.org> Date: Sat, 2 Apr 2011 00:33:43 -0700 Message-ID: From: Xin LI To: Alexey Dokuchaev Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Xin LI , svn-src-stable-8@freebsd.org Subject: Re: svn commit: r220250 - in stable/8: bin/test tools/regression/bin/test X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 07:56:15 -0000 2011/4/1 Alexey Dokuchaev : > On Fri, Apr 01, 2011 at 06:23:44PM +0000, Xin LI wrote: >> =C2=A0 Accept =3D=3D as an alias of =3D which is a popular GNU extension= . >> >> =C2=A0 This is intentionally undocumented for now since it's not part >> =C2=A0 of any standard. > > I thought general consensus that this change should never be part of > FreeBSD, not just being undocumented (which, as we all know, is bad > practice pe se). This have been discussed in -standards@ and have been settled for more than 1 month, there were two developers asked me after the commit but nobody asked for a revert (so far), so I don't think it's general consensus that this change should not be part of FreeBSD. Being undocumented means we do not encourage its use. I think there is good reason to add this extension for compatibility reasons, plus it does not break anything. So did I missed some discussion about why it's a bad move? Cheers, --=20 Xin LI http://www.delphij.net From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 08:29:02 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EAA461065674; Sat, 2 Apr 2011 08:29:02 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DD5388FC14; Sat, 2 Apr 2011 08:29:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p328T2cW075584; Sat, 2 Apr 2011 08:29:02 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p328T2aP075577; Sat, 2 Apr 2011 08:29:02 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201104020829.p328T2aP075577@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 2 Apr 2011 08:29:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220267 - in stable/8/usr.bin: kdump ktrace X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 08:29:03 -0000 Author: dchagin Date: Sat Apr 2 08:29:02 2011 New Revision: 220267 URL: http://svn.freebsd.org/changeset/base/220267 Log: MFC r219043: Teach kdump to understand sv_flags records in the trace files. MFC r219044: Update manual page to reflect latest changes of ABI description support. MFC r219138: Teach kdump to understand linux syscalls names too. Fix bug introduced in r219043: the kernel always dump native signal numbers, so no need to check the ABI in ktrpsig(). Added: stable/8/usr.bin/kdump/linux_syscalls.conf - copied unchanged from r219138, head/usr.bin/kdump/linux_syscalls.conf Modified: stable/8/usr.bin/kdump/Makefile stable/8/usr.bin/kdump/kdump.1 stable/8/usr.bin/kdump/kdump.c stable/8/usr.bin/ktrace/ktrace.c stable/8/usr.bin/ktrace/ktrace.h Directory Properties: stable/8/usr.bin/kdump/ (props changed) stable/8/usr.bin/ktrace/ (props changed) Modified: stable/8/usr.bin/kdump/Makefile ============================================================================== --- stable/8/usr.bin/kdump/Makefile Sat Apr 2 07:01:09 2011 (r220266) +++ stable/8/usr.bin/kdump/Makefile Sat Apr 2 08:29:02 2011 (r220267) @@ -1,13 +1,21 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ +.if (${MACHINE_ARCH} == "amd64") +SFX= 32 +.endif + .PATH: ${.CURDIR}/../ktrace PROG= kdump SRCS= kdump.c ioctl.c kdump_subr.c subr.c CFLAGS+= -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../.. -CLEANFILES= ioctl.c kdump_subr.c +.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" +SRCS+= linux_syscalls.c +.endif + +CLEANFILES= ioctl.c kdump_subr.c linux_syscalls.c ioctl.c: mkioctls sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include > ${.TARGET} @@ -15,4 +23,10 @@ ioctl.c: mkioctls kdump_subr.c: mksubr sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include > ${.TARGET} +linux_syscalls.c: + /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \ + ${.CURDIR}/../../sys/${MACHINE_ARCH}/linux${SFX}/syscalls.master ${.CURDIR}/linux_syscalls.conf + echo "int nlinux_syscalls = sizeof(linux_syscallnames) / sizeof(linux_syscallnames[0]);" \ + >> linux_syscalls.c + .include Modified: stable/8/usr.bin/kdump/kdump.1 ============================================================================== --- stable/8/usr.bin/kdump/kdump.1 Sat Apr 2 07:01:09 2011 (r220266) +++ stable/8/usr.bin/kdump/kdump.1 Sat Apr 2 08:29:02 2011 (r220267) @@ -40,7 +40,7 @@ .Nd display kernel trace data .Sh SYNOPSIS .Nm -.Op Fl dEnlHRsT +.Op Fl dEnlHRsTA .Op Fl f Ar trfile .Op Fl m Ar maxdata .Op Fl p Ar pid @@ -103,6 +103,8 @@ GIDs, dates etc. symbolically instead of Suppress display of I/O data. .It Fl T Display absolute timestamps for each entry (seconds since epoch). +.It Fl A +Display description of the ABI of traced process. .It Fl t Ar trstr See the .Fl t Modified: stable/8/usr.bin/kdump/kdump.c ============================================================================== --- stable/8/usr.bin/kdump/kdump.c Sat Apr 2 07:01:09 2011 (r220266) +++ stable/8/usr.bin/kdump/kdump.c Sat Apr 2 08:29:02 2011 (r220267) @@ -59,7 +59,9 @@ extern int errno; #include #include #include +#include #include +#include #ifdef IPX #include #include @@ -85,10 +87,12 @@ extern int errno; #include "ktrace.h" #include "kdump_subr.h" +u_int abidump(struct ktr_header *); +int fetchprocinfo(struct ktr_header *, u_int *); int fread_tail(void *, int, int); void dumpheader(struct ktr_header *); -void ktrsyscall(struct ktr_syscall *); -void ktrsysret(struct ktr_sysret *); +void ktrsyscall(struct ktr_syscall *, u_int); +void ktrsysret(struct ktr_sysret *, u_int); void ktrnamei(char *, int); void hexdump(char *, int, int); void visdump(char *, int, int); @@ -104,13 +108,57 @@ void sockfamilyname(int); const char *ioctlname(u_long); int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata, - resolv = 0; + resolv = 0, abiflag = 0; const char *tracefile = DEF_TRACEFILE; struct ktr_header ktr_header; #define TIME_FORMAT "%b %e %T %Y" #define eqs(s1, s2) (strcmp((s1), (s2)) == 0) +#define print_number(i,n,c) do { \ + if (decimal) \ + printf("%c%ld", c, (long)*i); \ + else \ + printf("%c%#lx", c, (long)*i); \ + i++; \ + n--; \ + c = ','; \ + } while (0); + +#if defined(__amd64__) || defined(__i386__) + +void linux_ktrsyscall(struct ktr_syscall *); +void linux_ktrsysret(struct ktr_sysret *); +extern char *linux_syscallnames[]; +extern int nlinux_syscalls; + +/* + * from linux.h + * Linux syscalls return negative errno's, we do positive and map them + */ +static int bsd_to_linux_errno[ELAST + 1] = { + -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, + -10, -35, -12, -13, -14, -15, -16, -17, -18, -19, + -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, + -30, -31, -32, -33, -34, -11,-115,-114, -88, -89, + -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, + -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, + -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, + -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, + -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, + -72, -67, -71 +}; +#endif + +struct proc_info +{ + TAILQ_ENTRY(proc_info) info; + u_int sv_flags; + pid_t pid; +}; + +TAILQ_HEAD(trace_procs, proc_info) trace_procs; + int main(int argc, char *argv[]) { @@ -119,11 +167,15 @@ main(int argc, char *argv[]) int trpoints = ALL_POINTS; int drop_logged; pid_t pid = 0; + u_int sv_flags; (void) setlocale(LC_CTYPE, ""); - while ((ch = getopt(argc,argv,"f:dElm:np:HRrsTt:")) != -1) + while ((ch = getopt(argc,argv,"f:dElm:np:AHRrsTt:")) != -1) switch((char)ch) { + case 'A': + abiflag = 1; + break; case 'f': tracefile = optarg; break; @@ -177,6 +229,7 @@ main(int argc, char *argv[]) errx(1, "%s", strerror(ENOMEM)); if (!freopen(tracefile, "r", stdin)) err(1, "%s", tracefile); + TAILQ_INIT(&trace_procs); drop_logged = 0; while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) { if (ktr_header.ktr_type & KTR_DROP) { @@ -209,6 +262,9 @@ main(int argc, char *argv[]) } if (ktrlen && fread_tail(m, ktrlen, 1) == 0) errx(1, "data too short"); + if (fetchprocinfo(&ktr_header, (u_int *)m) != 0) + continue; + sv_flags = abidump(&ktr_header); if (pid && ktr_header.ktr_pid != pid) continue; if ((trpoints & (1<ktr_type) { + case KTR_PROCCTOR: + TAILQ_FOREACH(pi, &trace_procs, info) { + if (pi->pid == kth->ktr_pid) { + TAILQ_REMOVE(&trace_procs, pi, info); + break; + } + } + pi = malloc(sizeof(struct proc_info)); + if (pi == NULL) + errx(1, "%s", strerror(ENOMEM)); + pi->sv_flags = *flags; + pi->pid = kth->ktr_pid; + TAILQ_INSERT_TAIL(&trace_procs, pi, info); + return (1); + + case KTR_PROCDTOR: + TAILQ_FOREACH(pi, &trace_procs, info) { + if (pi->pid == kth->ktr_pid) { + TAILQ_REMOVE(&trace_procs, pi, info); + free(pi); + break; + } + } + return (1); + } + + return (0); +} + +u_int +abidump(struct ktr_header *kth) +{ + struct proc_info *pi; + const char *abi; + const char *arch; + u_int flags = 0; + + TAILQ_FOREACH(pi, &trace_procs, info) { + if (pi->pid == kth->ktr_pid) { + flags = pi->sv_flags; + break; + } + } + + if (abiflag == 0) + return (flags); + + switch (flags & SV_ABI_MASK) { + case SV_ABI_LINUX: + abi = "L"; + break; + case SV_ABI_FREEBSD: + abi = "F"; + break; + default: + abi = "U"; + break; + } + + if (flags != 0) { + if (flags & SV_LP64) + arch = "64"; + else + arch = "32"; + } else + arch = "00"; + + printf("%s%s ", abi, arch); + + return (flags); +} + void dumpheader(struct ktr_header *kth) { @@ -297,6 +441,10 @@ dumpheader(struct ktr_header *kth) case KTR_SYSCTL: type = "SCTL"; break; + case KTR_PROCCTOR: + /* FALLTHROUGH */ + case KTR_PROCDTOR: + return; default: (void)sprintf(unknown, "UNKNOWN(%d)", kth->ktr_type); type = unknown; @@ -341,30 +489,21 @@ dumpheader(struct ktr_header *kth) int nsyscalls = sizeof (syscallnames) / sizeof (syscallnames[0]); void -ktrsyscall(struct ktr_syscall *ktr) +ktrsyscall(struct ktr_syscall *ktr, u_int flags) { int narg = ktr->ktr_narg; register_t *ip; - if (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0) + if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) || + (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0)) (void)printf("[%d]", ktr->ktr_code); else (void)printf("%s", syscallnames[ktr->ktr_code]); ip = &ktr->ktr_args[0]; if (narg) { char c = '('; - if (fancy) { - -#define print_number(i,n,c) do { \ - if (decimal) \ - (void)printf("%c%ld", c, (long)*i); \ - else \ - (void)printf("%c%#lx", c, (long)*i); \ - i++; \ - n--; \ - c = ','; \ - } while (0); - + if (fancy && + (flags == 0 || (flags & SV_ABI_MASK) == SV_ABI_FREEBSD)) { if (ktr->ktr_code == SYS_ioctl) { const char *cp; print_number(ip,narg,c); @@ -811,13 +950,14 @@ ktrsyscall(struct ktr_syscall *ktr) } void -ktrsysret(struct ktr_sysret *ktr) +ktrsysret(struct ktr_sysret *ktr, u_int flags) { register_t ret = ktr->ktr_retval; int error = ktr->ktr_error; int code = ktr->ktr_code; - if (code >= nsyscalls || code < 0) + if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) || + (code >= nsyscalls || code < 0)) (void)printf("[%d] ", code); else (void)printf("%s ", syscallnames[code]); @@ -1365,10 +1505,71 @@ invalid: printf("invalid record\n"); } +#if defined(__amd64__) || defined(__i386__) +void +linux_ktrsyscall(struct ktr_syscall *ktr) +{ + int narg = ktr->ktr_narg; + register_t *ip; + + if (ktr->ktr_code >= nlinux_syscalls || ktr->ktr_code < 0) + printf("[%d]", ktr->ktr_code); + else + printf("%s", linux_syscallnames[ktr->ktr_code]); + ip = &ktr->ktr_args[0]; + if (narg) { + char c = '('; + while (narg > 0) + print_number(ip, narg, c); + putchar(')'); + } + putchar('\n'); +} + +void +linux_ktrsysret(struct ktr_sysret *ktr) +{ + register_t ret = ktr->ktr_retval; + int error = ktr->ktr_error; + int code = ktr->ktr_code; + + if (code >= nlinux_syscalls || code < 0) + printf("[%d] ", code); + else + printf("%s ", linux_syscallnames[code]); + + if (error == 0) { + if (fancy) { + printf("%ld", (long)ret); + if (ret < 0 || ret > 9) + printf("/%#lx", (long)ret); + } else { + if (decimal) + printf("%ld", (long)ret); + else + printf("%#lx", (long)ret); + } + } else if (error == ERESTART) + printf("RESTART"); + else if (error == EJUSTRETURN) + printf("JUSTRETURN"); + else { + if (ktr->ktr_error <= ELAST + 1) + error = abs(bsd_to_linux_errno[ktr->ktr_error]); + else + error = 999; + printf("-1 errno %d", error); + if (fancy) + printf(" %s", strerror(ktr->ktr_error)); + } + putchar('\n'); +} +#endif + void usage(void) { - fprintf(stderr, "usage: kdump [-dEnlHRrsT] [-f trfile] " + fprintf(stderr, "usage: kdump [-dEnlHRrsTA] [-f trfile] " "[-m maxdata] [-p pid] [-t trstr]\n"); exit(1); } Copied: stable/8/usr.bin/kdump/linux_syscalls.conf (from r219138, head/usr.bin/kdump/linux_syscalls.conf) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/usr.bin/kdump/linux_syscalls.conf Sat Apr 2 08:29:02 2011 (r220267, copy of r219138, head/usr.bin/kdump/linux_syscalls.conf) @@ -0,0 +1,11 @@ +# $FreeBSD$ +sysnames="linux_syscalls.c" +sysproto="/dev/null" +sysproto_h=_LINUX_SYSPROTO_H_ +syshdr="/dev/null" +syssw="/dev/null" +sysmk="/dev/null" +syscallprefix="LINUX_SYS_" +switchname="/dev/null" +namesname="linux_syscallnames" +systrace="/dev/null" Modified: stable/8/usr.bin/ktrace/ktrace.c ============================================================================== --- stable/8/usr.bin/ktrace/ktrace.c Sat Apr 2 07:01:09 2011 (r220266) +++ stable/8/usr.bin/ktrace/ktrace.c Sat Apr 2 08:29:02 2011 (r220267) @@ -163,6 +163,8 @@ main(int argc, char *argv[]) (void)umask(omask); (void)close(fd); + trpoints |= PROC_ABI_POINTS; + if (*argv) { if (ktrace(tracefile, ops, trpoints, getpid()) < 0) err(1, "%s", tracefile); Modified: stable/8/usr.bin/ktrace/ktrace.h ============================================================================== --- stable/8/usr.bin/ktrace/ktrace.h Sat Apr 2 07:01:09 2011 (r220266) +++ stable/8/usr.bin/ktrace/ktrace.h Sat Apr 2 08:29:02 2011 (r220267) @@ -38,7 +38,9 @@ KTRFAC_GENIO | KTRFAC_PSIG | KTRFAC_USER | \ KTRFAC_STRUCT | KTRFAC_SYSCTL) -#define ALL_POINTS (DEF_POINTS | KTRFAC_CSW) +#define PROC_ABI_POINTS (KTRFAC_PROCCTOR | KTRFAC_PROCDTOR) + +#define ALL_POINTS (DEF_POINTS | KTRFAC_CSW | PROC_ABI_POINTS) #define DEF_TRACEFILE "ktrace.out" From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 08:34:24 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D8A42106564A; Sat, 2 Apr 2011 08:34:24 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CBBBE8FC15; Sat, 2 Apr 2011 08:34:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p328YOHj075768; Sat, 2 Apr 2011 08:34:24 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p328YOhG075761; Sat, 2 Apr 2011 08:34:24 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201104020834.p328YOhG075761@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 2 Apr 2011 08:34:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220268 - in stable/7/usr.bin: kdump ktrace X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 08:34:25 -0000 Author: dchagin Date: Sat Apr 2 08:34:24 2011 New Revision: 220268 URL: http://svn.freebsd.org/changeset/base/220268 Log: MFC r219043: Teach kdump to understand sv_flags records in the trace files. MFC r219044: Update manual page to reflect latest changes of ABI description support. MFC r219138: Teach kdump to understand linux syscalls names too. Fix bug introduced in r219043: the kernel always dump native signal numbers, so no need to check the ABI in ktrpsig(). Added: stable/7/usr.bin/kdump/linux_syscalls.conf - copied unchanged from r219138, head/usr.bin/kdump/linux_syscalls.conf Modified: stable/7/usr.bin/kdump/Makefile stable/7/usr.bin/kdump/kdump.1 stable/7/usr.bin/kdump/kdump.c stable/7/usr.bin/ktrace/ktrace.c stable/7/usr.bin/ktrace/ktrace.h Directory Properties: stable/7/usr.bin/kdump/ (props changed) stable/7/usr.bin/ktrace/ (props changed) Modified: stable/7/usr.bin/kdump/Makefile ============================================================================== --- stable/7/usr.bin/kdump/Makefile Sat Apr 2 08:29:02 2011 (r220267) +++ stable/7/usr.bin/kdump/Makefile Sat Apr 2 08:34:24 2011 (r220268) @@ -1,13 +1,21 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ +.if (${MACHINE_ARCH} == "amd64") +SFX= 32 +.endif + .PATH: ${.CURDIR}/../ktrace PROG= kdump SRCS= kdump.c ioctl.c kdump_subr.c subr.c CFLAGS+= -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../.. -CLEANFILES= ioctl.c kdump_subr.c +.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" +SRCS+= linux_syscalls.c +.endif + +CLEANFILES= ioctl.c kdump_subr.c linux_syscalls.c ioctl.c: mkioctls sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include > ${.TARGET} @@ -15,4 +23,10 @@ ioctl.c: mkioctls kdump_subr.c: mksubr sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include > ${.TARGET} +linux_syscalls.c: + /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \ + ${.CURDIR}/../../sys/${MACHINE_ARCH}/linux${SFX}/syscalls.master ${.CURDIR}/linux_syscalls.conf + echo "int nlinux_syscalls = sizeof(linux_syscallnames) / sizeof(linux_syscallnames[0]);" \ + >> linux_syscalls.c + .include Modified: stable/7/usr.bin/kdump/kdump.1 ============================================================================== --- stable/7/usr.bin/kdump/kdump.1 Sat Apr 2 08:29:02 2011 (r220267) +++ stable/7/usr.bin/kdump/kdump.1 Sat Apr 2 08:34:24 2011 (r220268) @@ -40,7 +40,7 @@ .Nd display kernel trace data .Sh SYNOPSIS .Nm -.Op Fl dEnlHRsT +.Op Fl dEnlHRsTA .Op Fl f Ar trfile .Op Fl m Ar maxdata .Op Fl p Ar pid @@ -103,6 +103,8 @@ GIDs, dates etc. symbolically instead of Suppress display of I/O data. .It Fl T Display absolute timestamps for each entry (seconds since epoch). +.It Fl A +Display description of the ABI of traced process. .It Fl t Ar trstr See the .Fl t Modified: stable/7/usr.bin/kdump/kdump.c ============================================================================== --- stable/7/usr.bin/kdump/kdump.c Sat Apr 2 08:29:02 2011 (r220267) +++ stable/7/usr.bin/kdump/kdump.c Sat Apr 2 08:34:24 2011 (r220268) @@ -59,7 +59,9 @@ extern int errno; #include #include #include +#include #include +#include #ifdef IPX #include #include @@ -83,10 +85,12 @@ extern int errno; #include "ktrace.h" #include "kdump_subr.h" +u_int abidump(struct ktr_header *); +int fetchprocinfo(struct ktr_header *, u_int *); int fread_tail(void *, int, int); void dumpheader(struct ktr_header *); -void ktrsyscall(struct ktr_syscall *); -void ktrsysret(struct ktr_sysret *); +void ktrsyscall(struct ktr_syscall *, u_int); +void ktrsysret(struct ktr_sysret *, u_int); void ktrnamei(char *, int); void hexdump(char *, int, int); void visdump(char *, int, int); @@ -101,13 +105,57 @@ void usage(void); const char *ioctlname(u_long); int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata, - resolv = 0; + resolv = 0, abiflag = 0; const char *tracefile = DEF_TRACEFILE; struct ktr_header ktr_header; #define TIME_FORMAT "%b %e %T %Y" #define eqs(s1, s2) (strcmp((s1), (s2)) == 0) +#define print_number(i,n,c) do { \ + if (decimal) \ + printf("%c%ld", c, (long)*i); \ + else \ + printf("%c%#lx", c, (long)*i); \ + i++; \ + n--; \ + c = ','; \ + } while (0); + +#if defined(__amd64__) || defined(__i386__) + +void linux_ktrsyscall(struct ktr_syscall *); +void linux_ktrsysret(struct ktr_sysret *); +extern char *linux_syscallnames[]; +extern int nlinux_syscalls; + +/* + * from linux.h + * Linux syscalls return negative errno's, we do positive and map them + */ +static int bsd_to_linux_errno[ELAST + 1] = { + -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, + -10, -35, -12, -13, -14, -15, -16, -17, -18, -19, + -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, + -30, -31, -32, -33, -34, -11,-115,-114, -88, -89, + -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, + -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, + -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, + -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, + -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, + -72, -67, -71 +}; +#endif + +struct proc_info +{ + TAILQ_ENTRY(proc_info) info; + u_int sv_flags; + pid_t pid; +}; + +TAILQ_HEAD(trace_procs, proc_info) trace_procs; + int main(int argc, char *argv[]) { @@ -116,11 +164,15 @@ main(int argc, char *argv[]) int trpoints = ALL_POINTS; int drop_logged; pid_t pid = 0; + u_int sv_flags; (void) setlocale(LC_CTYPE, ""); - while ((ch = getopt(argc,argv,"f:dElm:np:HRrsTt:")) != -1) + while ((ch = getopt(argc,argv,"f:dElm:np:AHRrsTt:")) != -1) switch((char)ch) { + case 'A': + abiflag = 1; + break; case 'f': tracefile = optarg; break; @@ -174,6 +226,7 @@ main(int argc, char *argv[]) errx(1, "%s", strerror(ENOMEM)); if (!freopen(tracefile, "r", stdin)) err(1, "%s", tracefile); + TAILQ_INIT(&trace_procs); drop_logged = 0; while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) { if (ktr_header.ktr_type & KTR_DROP) { @@ -206,6 +259,9 @@ main(int argc, char *argv[]) } if (ktrlen && fread_tail(m, ktrlen, 1) == 0) errx(1, "data too short"); + if (fetchprocinfo(&ktr_header, (u_int *)m) != 0) + continue; + sv_flags = abidump(&ktr_header); if (pid && ktr_header.ktr_pid != pid) continue; if ((trpoints & (1<ktr_type) { + case KTR_PROCCTOR: + TAILQ_FOREACH(pi, &trace_procs, info) { + if (pi->pid == kth->ktr_pid) { + TAILQ_REMOVE(&trace_procs, pi, info); + break; + } + } + pi = malloc(sizeof(struct proc_info)); + if (pi == NULL) + errx(1, "%s", strerror(ENOMEM)); + pi->sv_flags = *flags; + pi->pid = kth->ktr_pid; + TAILQ_INSERT_TAIL(&trace_procs, pi, info); + return (1); + + case KTR_PROCDTOR: + TAILQ_FOREACH(pi, &trace_procs, info) { + if (pi->pid == kth->ktr_pid) { + TAILQ_REMOVE(&trace_procs, pi, info); + free(pi); + break; + } + } + return (1); + } + + return (0); +} + +u_int +abidump(struct ktr_header *kth) +{ + struct proc_info *pi; + const char *abi; + const char *arch; + u_int flags = 0; + + TAILQ_FOREACH(pi, &trace_procs, info) { + if (pi->pid == kth->ktr_pid) { + flags = pi->sv_flags; + break; + } + } + + if (abiflag == 0) + return (flags); + + switch (flags & SV_ABI_MASK) { + case SV_ABI_LINUX: + abi = "L"; + break; + case SV_ABI_FREEBSD: + abi = "F"; + break; + default: + abi = "U"; + break; + } + + if (flags != 0) { + if (flags & SV_LP64) + arch = "64"; + else + arch = "32"; + } else + arch = "00"; + + printf("%s%s ", abi, arch); + + return (flags); +} + void dumpheader(struct ktr_header *kth) { @@ -294,6 +438,10 @@ dumpheader(struct ktr_header *kth) case KTR_SYSCTL: type = "SCTL"; break; + case KTR_PROCCTOR: + /* FALLTHROUGH */ + case KTR_PROCDTOR: + return; default: (void)sprintf(unknown, "UNKNOWN(%d)", kth->ktr_type); type = unknown; @@ -338,30 +486,21 @@ dumpheader(struct ktr_header *kth) int nsyscalls = sizeof (syscallnames) / sizeof (syscallnames[0]); void -ktrsyscall(struct ktr_syscall *ktr) +ktrsyscall(struct ktr_syscall *ktr, u_int flags) { int narg = ktr->ktr_narg; register_t *ip; - if (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0) + if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) || + (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0)) (void)printf("[%d]", ktr->ktr_code); else (void)printf("%s", syscallnames[ktr->ktr_code]); ip = &ktr->ktr_args[0]; if (narg) { char c = '('; - if (fancy) { - -#define print_number(i,n,c) do { \ - if (decimal) \ - (void)printf("%c%ld", c, (long)*i); \ - else \ - (void)printf("%c%#lx", c, (long)*i); \ - i++; \ - n--; \ - c = ','; \ - } while (0); - + if (fancy && + (flags == 0 || (flags & SV_ABI_MASK) == SV_ABI_FREEBSD)) { if (ktr->ktr_code == SYS_ioctl) { const char *cp; print_number(ip,narg,c); @@ -814,13 +953,14 @@ ktrsyscall(struct ktr_syscall *ktr) } void -ktrsysret(struct ktr_sysret *ktr) +ktrsysret(struct ktr_sysret *ktr, u_int flags) { register_t ret = ktr->ktr_retval; int error = ktr->ktr_error; int code = ktr->ktr_code; - if (code >= nsyscalls || code < 0) + if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) || + (code >= nsyscalls || code < 0)) (void)printf("[%d] ", code); else (void)printf("%s ", syscallnames[code]); @@ -1368,10 +1508,71 @@ invalid: printf("invalid record\n"); } +#if defined(__amd64__) || defined(__i386__) +void +linux_ktrsyscall(struct ktr_syscall *ktr) +{ + int narg = ktr->ktr_narg; + register_t *ip; + + if (ktr->ktr_code >= nlinux_syscalls || ktr->ktr_code < 0) + printf("[%d]", ktr->ktr_code); + else + printf("%s", linux_syscallnames[ktr->ktr_code]); + ip = &ktr->ktr_args[0]; + if (narg) { + char c = '('; + while (narg > 0) + print_number(ip, narg, c); + putchar(')'); + } + putchar('\n'); +} + +void +linux_ktrsysret(struct ktr_sysret *ktr) +{ + register_t ret = ktr->ktr_retval; + int error = ktr->ktr_error; + int code = ktr->ktr_code; + + if (code >= nlinux_syscalls || code < 0) + printf("[%d] ", code); + else + printf("%s ", linux_syscallnames[code]); + + if (error == 0) { + if (fancy) { + printf("%ld", (long)ret); + if (ret < 0 || ret > 9) + printf("/%#lx", (long)ret); + } else { + if (decimal) + printf("%ld", (long)ret); + else + printf("%#lx", (long)ret); + } + } else if (error == ERESTART) + printf("RESTART"); + else if (error == EJUSTRETURN) + printf("JUSTRETURN"); + else { + if (ktr->ktr_error <= ELAST + 1) + error = abs(bsd_to_linux_errno[ktr->ktr_error]); + else + error = 999; + printf("-1 errno %d", error); + if (fancy) + printf(" %s", strerror(ktr->ktr_error)); + } + putchar('\n'); +} +#endif + void usage(void) { - fprintf(stderr, "usage: kdump [-dEnlHRrsT] [-f trfile] " + fprintf(stderr, "usage: kdump [-dEnlHRrsTA] [-f trfile] " "[-m maxdata] [-p pid] [-t trstr]\n"); exit(1); } Copied: stable/7/usr.bin/kdump/linux_syscalls.conf (from r219138, head/usr.bin/kdump/linux_syscalls.conf) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/usr.bin/kdump/linux_syscalls.conf Sat Apr 2 08:34:24 2011 (r220268, copy of r219138, head/usr.bin/kdump/linux_syscalls.conf) @@ -0,0 +1,11 @@ +# $FreeBSD$ +sysnames="linux_syscalls.c" +sysproto="/dev/null" +sysproto_h=_LINUX_SYSPROTO_H_ +syshdr="/dev/null" +syssw="/dev/null" +sysmk="/dev/null" +syscallprefix="LINUX_SYS_" +switchname="/dev/null" +namesname="linux_syscallnames" +systrace="/dev/null" Modified: stable/7/usr.bin/ktrace/ktrace.c ============================================================================== --- stable/7/usr.bin/ktrace/ktrace.c Sat Apr 2 08:29:02 2011 (r220267) +++ stable/7/usr.bin/ktrace/ktrace.c Sat Apr 2 08:34:24 2011 (r220268) @@ -163,6 +163,8 @@ main(int argc, char *argv[]) (void)umask(omask); (void)close(fd); + trpoints |= PROC_ABI_POINTS; + if (*argv) { if (ktrace(tracefile, ops, trpoints, getpid()) < 0) err(1, "%s", tracefile); Modified: stable/7/usr.bin/ktrace/ktrace.h ============================================================================== --- stable/7/usr.bin/ktrace/ktrace.h Sat Apr 2 08:29:02 2011 (r220267) +++ stable/7/usr.bin/ktrace/ktrace.h Sat Apr 2 08:34:24 2011 (r220268) @@ -38,7 +38,9 @@ KTRFAC_GENIO | KTRFAC_PSIG | KTRFAC_USER | \ KTRFAC_STRUCT | KTRFAC_SYSCTL) -#define ALL_POINTS (DEF_POINTS | KTRFAC_CSW) +#define PROC_ABI_POINTS (KTRFAC_PROCCTOR | KTRFAC_PROCDTOR) + +#define ALL_POINTS (DEF_POINTS | KTRFAC_CSW | PROC_ABI_POINTS) #define DEF_TRACEFILE "ktrace.out" From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 08:45:13 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EF2EB1065673; Sat, 2 Apr 2011 08:45:13 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E3FBD8FC08; Sat, 2 Apr 2011 08:45:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p328jD9f076057; Sat, 2 Apr 2011 08:45:13 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p328jDxD076055; Sat, 2 Apr 2011 08:45:13 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201104020845.p328jDxD076055@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 2 Apr 2011 08:45:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220269 - stable/8/sys/amd64/linux32 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 08:45:14 -0000 Author: dchagin Date: Sat Apr 2 08:45:13 2011 New Revision: 220269 URL: http://svn.freebsd.org/changeset/base/220269 Log: MFC r219364: Remove dead (since r190620) code. Modified: stable/8/sys/amd64/linux32/linux32_genassym.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/amd64/linux32/linux32_genassym.c ============================================================================== --- stable/8/sys/amd64/linux32/linux32_genassym.c Sat Apr 2 08:34:24 2011 (r220268) +++ stable/8/sys/amd64/linux32/linux32_genassym.c Sat Apr 2 08:45:13 2011 (r220269) @@ -9,8 +9,6 @@ __FBSDID("$FreeBSD$"); ASSYM(LINUX_SIGF_HANDLER, offsetof(struct l_sigframe, sf_handler)); ASSYM(LINUX_SIGF_SC, offsetof(struct l_sigframe, sf_sc)); -ASSYM(LINUX_SC_ES, offsetof(struct l_sigcontext, sc_es)); -ASSYM(LINUX_SC_DS, offsetof(struct l_sigcontext, sc_ds)); ASSYM(LINUX_RT_SIGF_HANDLER, offsetof(struct l_rt_sigframe, sf_handler)); ASSYM(LINUX_RT_SIGF_UC, offsetof(struct l_rt_sigframe, sf_sc)); ASSYM(LINUX_RT_SIGF_SC, offsetof(struct l_ucontext, uc_mcontext)); From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 09:22:06 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E786B106564A; Sat, 2 Apr 2011 09:22:06 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DF6E88FC13; Sat, 2 Apr 2011 09:22:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p329M66t076874; Sat, 2 Apr 2011 09:22:06 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p329M6hF076872; Sat, 2 Apr 2011 09:22:06 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020922.p329M6hF076872@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 09:22:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220270 - head/sbin/hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 09:22:07 -0000 Author: pjd Date: Sat Apr 2 09:22:06 2011 New Revision: 220270 URL: http://svn.freebsd.org/changeset/base/220270 Log: Allow to disable sends or receives on a socket using shutdown(2) by interpreting NULL 'data' argument passed to proto_common_send() or proto_common_recv() as a will to do so. MFC after: 1 month Modified: head/sbin/hastd/proto_common.c Modified: head/sbin/hastd/proto_common.c ============================================================================== --- head/sbin/hastd/proto_common.c Sat Apr 2 08:45:13 2011 (r220269) +++ head/sbin/hastd/proto_common.c Sat Apr 2 09:22:06 2011 (r220270) @@ -82,6 +82,17 @@ proto_common_send(int sock, const unsign size_t sendsize; PJDLOG_ASSERT(sock >= 0); + + if (data == NULL) { + /* The caller is just trying to decide about direction. */ + + PJDLOG_ASSERT(size == 0); + + if (shutdown(sock, SHUT_RD) == -1) + return (errno); + return (0); + } + PJDLOG_ASSERT(data != NULL); PJDLOG_ASSERT(size > 0); @@ -141,6 +152,17 @@ proto_common_recv(int sock, unsigned cha ssize_t done; PJDLOG_ASSERT(sock >= 0); + + if (data == NULL) { + /* The caller is just trying to decide about direction. */ + + PJDLOG_ASSERT(size == 0); + + if (shutdown(sock, SHUT_WR) == -1) + return (errno); + return (0); + } + PJDLOG_ASSERT(data != NULL); PJDLOG_ASSERT(size > 0); From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 09:25:14 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 03CA91065689; Sat, 2 Apr 2011 09:25:14 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8EC938FC14; Sat, 2 Apr 2011 09:25:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p329PDWW076970; Sat, 2 Apr 2011 09:25:13 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p329PDX3076967; Sat, 2 Apr 2011 09:25:13 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020925.p329PDX3076967@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 09:25:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220271 - head/sbin/hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 09:25:14 -0000 Author: pjd Date: Sat Apr 2 09:25:13 2011 New Revision: 220271 URL: http://svn.freebsd.org/changeset/base/220271 Log: Declare directions for sockets between primary and secondary. In HAST we use two sockets - one for only sending the data and one for only receiving the data. MFC after: 1 month Modified: head/sbin/hastd/primary.c head/sbin/hastd/secondary.c Modified: head/sbin/hastd/primary.c ============================================================================== --- head/sbin/hastd/primary.c Sat Apr 2 09:22:06 2011 (r220270) +++ head/sbin/hastd/primary.c Sat Apr 2 09:25:13 2011 (r220271) @@ -701,6 +701,11 @@ init_remote(struct hast_resource *res, s (void)hast_activemap_flush(res); } nv_free(nvin); + /* Setup directions. */ + if (proto_send(out, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); + if (proto_recv(in, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); pjdlog_info("Connected to %s.", res->hr_remoteaddr); if (inp != NULL && outp != NULL) { *inp = in; Modified: head/sbin/hastd/secondary.c ============================================================================== --- head/sbin/hastd/secondary.c Sat Apr 2 09:22:06 2011 (r220270) +++ head/sbin/hastd/secondary.c Sat Apr 2 09:25:13 2011 (r220271) @@ -183,6 +183,10 @@ init_remote(struct hast_resource *res, s unsigned char *map; size_t mapsize; + /* Setup direction. */ + if (proto_send(res->hr_remoteout, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); + map = NULL; mapsize = 0; nvout = nv_alloc(); @@ -346,6 +350,9 @@ init_remote(struct hast_resource *res, s if (map != NULL) free(map); nv_free(nvout); + /* Setup direction. */ + if (proto_recv(res->hr_remotein, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); if (res->hr_secondary_localcnt > res->hr_primary_remotecnt && res->hr_primary_localcnt > res->hr_secondary_remotecnt) { /* Exit on split-brain. */ From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 09:29:53 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC386106564A; Sat, 2 Apr 2011 09:29:53 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B9E878FC0A; Sat, 2 Apr 2011 09:29:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p329Trc6077086; Sat, 2 Apr 2011 09:29:53 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p329TrRC077084; Sat, 2 Apr 2011 09:29:53 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020929.p329TrRC077084@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 09:29:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220272 - head/sbin/hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 09:29:54 -0000 Author: pjd Date: Sat Apr 2 09:29:53 2011 New Revision: 220272 URL: http://svn.freebsd.org/changeset/base/220272 Log: When we are operating on blocking socket and get EAGAIN on send(2) or recv(2) this means that request timed out. Translate the meaningless EAGAIN to ETIMEDOUT to give administrator a hint that he might need to increase timeout in configuration file. MFC after: 1 month Modified: head/sbin/hastd/proto_common.c Modified: head/sbin/hastd/proto_common.c ============================================================================== --- head/sbin/hastd/proto_common.c Sat Apr 2 09:25:13 2011 (r220271) +++ head/sbin/hastd/proto_common.c Sat Apr 2 09:29:53 2011 (r220272) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2009-2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -34,8 +35,11 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include #include +#include #include "pjdlog.h" #include "proto_impl.h" @@ -45,6 +49,16 @@ __FBSDID("$FreeBSD$"); #define MAX_SEND_SIZE 32768 #endif +static bool +blocking_socket(int sock) +{ + int flags; + + flags = fcntl(sock, F_GETFL); + PJDLOG_ASSERT(flags >= 0); + return ((flags & O_NONBLOCK) == 0); +} + static int proto_descriptor_send(int sock, int fd) { @@ -99,11 +113,19 @@ proto_common_send(int sock, const unsign do { sendsize = size < MAX_SEND_SIZE ? size : MAX_SEND_SIZE; done = send(sock, data, sendsize, MSG_NOSIGNAL); - if (done == 0) + if (done == 0) { return (ENOTCONN); - else if (done < 0) { + } else if (done < 0) { if (errno == EINTR) continue; + /* + * If this is blocking socket and we got EAGAIN, this + * means the request timed out. Translate errno to + * ETIMEDOUT, to give administrator a hint to + * eventually increase timeout. + */ + if (errno == EAGAIN && blocking_socket(sock)) + errno = ETIMEDOUT; return (errno); } data += done; @@ -169,10 +191,19 @@ proto_common_recv(int sock, unsigned cha do { done = recv(sock, data, size, MSG_WAITALL); } while (done == -1 && errno == EINTR); - if (done == 0) + if (done == 0) { return (ENOTCONN); - else if (done < 0) + } else if (done < 0) { + /* + * If this is blocking socket and we got EAGAIN, this + * means the request timed out. Translate errno to + * ETIMEDOUT, to give administrator a hint to + * eventually increase timeout. + */ + if (errno == EAGAIN && blocking_socket(sock)) + errno = ETIMEDOUT; return (errno); + } if (fdp == NULL) return (0); return (proto_descriptor_recv(sock, fdp)); From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 09:31:02 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A033C106566B; Sat, 2 Apr 2011 09:31:02 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 989418FC15; Sat, 2 Apr 2011 09:31:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p329V2Ve077156; Sat, 2 Apr 2011 09:31:02 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p329V2s8077154; Sat, 2 Apr 2011 09:31:02 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020931.p329V2s8077154@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 09:31:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220273 - head/sbin/hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 09:31:02 -0000 Author: pjd Date: Sat Apr 2 09:31:02 2011 New Revision: 220273 URL: http://svn.freebsd.org/changeset/base/220273 Log: Handle ENOBUFS on send(2) by retrying for a while and logging the problem. MFC after: 1 week Modified: head/sbin/hastd/proto_common.c Modified: head/sbin/hastd/proto_common.c ============================================================================== --- head/sbin/hastd/proto_common.c Sat Apr 2 09:29:53 2011 (r220272) +++ head/sbin/hastd/proto_common.c Sat Apr 2 09:31:02 2011 (r220273) @@ -94,6 +94,7 @@ proto_common_send(int sock, const unsign { ssize_t done; size_t sendsize; + int errcount = 0; PJDLOG_ASSERT(sock >= 0); @@ -118,6 +119,23 @@ proto_common_send(int sock, const unsign } else if (done < 0) { if (errno == EINTR) continue; + if (errno == ENOBUFS) { + /* + * If there are no buffers we retry. + * After each try we increase delay before the + * next one and we give up after fifteen times. + * This gives 11s of total wait time. + */ + if (errcount == 15) { + pjdlog_warning("Getting ENOBUFS errors for 11s on send(), giving up."); + } else { + if (errcount == 0) + pjdlog_warning("Got ENOBUFS error on send(), retrying for a bit."); + errcount++; + usleep(100000 * errcount); + continue; + } + } /* * If this is blocking socket and we got EAGAIN, this * means the request timed out. Translate errno to @@ -131,6 +149,10 @@ proto_common_send(int sock, const unsign data += done; size -= done; } while (size > 0); + if (errcount > 0) { + pjdlog_info("Data sent successfully after %d ENOBUFS error%s.", + errcount, errcount == 1 ? "" : "s"); + } if (fd == -1) return (0); From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 09:31:58 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2505B106566B; Sat, 2 Apr 2011 09:31:58 +0000 (UTC) (envelope-from pawel@dawidek.net) Received: from mail.garage.freebsd.pl (60.wheelsystems.com [83.12.187.60]) by mx1.freebsd.org (Postfix) with ESMTP id C8BEB8FC22; Sat, 2 Apr 2011 09:31:57 +0000 (UTC) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id 2C65645F60; Sat, 2 Apr 2011 11:31:56 +0200 (CEST) Received: from localhost (89-73-195-149.dynamic.chello.pl [89.73.195.149]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.garage.freebsd.pl (Postfix) with ESMTP id 5326B45C98; Sat, 2 Apr 2011 11:31:50 +0200 (CEST) Date: Sat, 2 Apr 2011 11:31:46 +0200 From: Pawel Jakub Dawidek To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-ID: <20110402093146.GC1849@garage.freebsd.pl> References: <201104020922.p329M6hF076872@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="kVXhAStRUZ/+rrGn" Content-Disposition: inline In-Reply-To: <201104020922.p329M6hF076872@svn.freebsd.org> X-OS: FreeBSD 9.0-CURRENT amd64 User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on mail.garage.freebsd.pl X-Spam-Level: X-Spam-Status: No, score=-0.6 required=4.5 tests=BAYES_00,RCVD_IN_SORBS_DUL autolearn=no version=3.0.4 Cc: Subject: Re: svn commit: r220270 - head/sbin/hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 09:31:58 -0000 --kVXhAStRUZ/+rrGn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Apr 02, 2011 at 09:22:06AM +0000, Pawel Jakub Dawidek wrote: > Author: pjd > Date: Sat Apr 2 09:22:06 2011 > New Revision: 220270 > URL: http://svn.freebsd.org/changeset/base/220270 >=20 > Log: > Allow to disable sends or receives on a socket using shutdown(2) by > interpreting NULL 'data' argument passed to proto_common_send() or > proto_common_recv() as a will to do so. > =20 > MFC after: 1 month This should've been 1 week here in the next two commits. --=20 Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com --kVXhAStRUZ/+rrGn Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk2W7QIACgkQForvXbEpPzRFRwCaA6JyroJPktKMsOVYsCaOfAEK dEMAnA1M64Kb9I5yAbc2PQBJmgfpeSYy =bMbT -----END PGP SIGNATURE----- --kVXhAStRUZ/+rrGn-- From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 09:34:33 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C617A106564A; Sat, 2 Apr 2011 09:34:33 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BE80D8FC1D; Sat, 2 Apr 2011 09:34:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p329YXHu077274; Sat, 2 Apr 2011 09:34:33 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p329YXcg077271; Sat, 2 Apr 2011 09:34:33 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020934.p329YXcg077271@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 09:34:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220274 - head/sbin/hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 09:34:33 -0000 Author: pjd Date: Sat Apr 2 09:34:33 2011 New Revision: 220274 URL: http://svn.freebsd.org/changeset/base/220274 Log: Increase default timeout from 5 seconds to 20 seconds. 5 seconds is definitely to short under heavy load and I was experiencing those timeouts in my recent tests. MFC after: 1 week Modified: head/sbin/hastd/hast.conf.5 head/sbin/hastd/hast.h Modified: head/sbin/hastd/hast.conf.5 ============================================================================== --- head/sbin/hastd/hast.conf.5 Sat Apr 2 09:31:02 2011 (r220273) +++ head/sbin/hastd/hast.conf.5 Sat Apr 2 09:34:33 2011 (r220274) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 20, 2011 +.Dd April 2, 2011 .Dt HAST.CONF 5 .Os .Sh NAME @@ -241,7 +241,7 @@ LZF is very fast, general purpose compre .Pp Connection timeout in seconds. The default value is -.Va 5 . +.Va 20 . .It Ic exec Aq path .Pp Execute the given program on various HAST events. Modified: head/sbin/hastd/hast.h ============================================================================== --- head/sbin/hastd/hast.h Sat Apr 2 09:31:02 2011 (r220273) +++ head/sbin/hastd/hast.h Sat Apr 2 09:34:33 2011 (r220274) @@ -83,7 +83,7 @@ #define HIO_KEEPALIVE 5 #define HAST_USER "hast" -#define HAST_TIMEOUT 5 +#define HAST_TIMEOUT 20 #define HAST_CONFIG "/etc/hast.conf" #define HAST_CONTROL "/var/run/hastctl" #define HASTD_LISTEN "tcp4://0.0.0.0:8457" From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 09:46:10 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3DFDF106566B; Sat, 2 Apr 2011 09:46:10 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 358CF8FC12; Sat, 2 Apr 2011 09:46:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p329kAnN077563; Sat, 2 Apr 2011 09:46:10 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p329kAlp077561; Sat, 2 Apr 2011 09:46:10 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201104020946.p329kAlp077561@svn.freebsd.org> From: Adrian Chadd Date: Sat, 2 Apr 2011 09:46:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220275 - head/sys/modules/ath_pci X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 09:46:10 -0000 Author: adrian Date: Sat Apr 2 09:46:09 2011 New Revision: 220275 URL: http://svn.freebsd.org/changeset/base/220275 Log: Add missing include. Reported by: Ulrich Sporlein Modified: head/sys/modules/ath_pci/Makefile Modified: head/sys/modules/ath_pci/Makefile ============================================================================== --- head/sys/modules/ath_pci/Makefile Sat Apr 2 09:34:33 2011 (r220274) +++ head/sys/modules/ath_pci/Makefile Sat Apr 2 09:46:09 2011 (r220275) @@ -34,7 +34,7 @@ KMOD= if_ath_pci SRCS= if_ath_pci.c -SRCS+= device_if.h bus_if.h pci_if.h +SRCS+= device_if.h bus_if.h pci_if.h opt_ah.h CFLAGS+= -I. -I${.CURDIR}/../../dev/ath -I${.CURDIR}/../../dev/ath/ath_hal From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 10:28:09 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 31CBF106566C; Sat, 2 Apr 2011 10:28:09 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 200E38FC13; Sat, 2 Apr 2011 10:28:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p32AS9Ae078629; Sat, 2 Apr 2011 10:28:09 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p32AS8c2078623; Sat, 2 Apr 2011 10:28:08 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201104021028.p32AS8c2078623@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 2 Apr 2011 10:28:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220276 - in stable/7/usr.bin: kdump ktrace X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 10:28:09 -0000 Author: dchagin Date: Sat Apr 2 10:28:08 2011 New Revision: 220276 URL: http://svn.freebsd.org/changeset/base/220276 Log: Revert r220268, SV_ABI patches was never merged to 7. Deleted: stable/7/usr.bin/kdump/linux_syscalls.conf Modified: stable/7/usr.bin/kdump/Makefile stable/7/usr.bin/kdump/kdump.1 stable/7/usr.bin/kdump/kdump.c stable/7/usr.bin/ktrace/ktrace.c stable/7/usr.bin/ktrace/ktrace.h Modified: stable/7/usr.bin/kdump/Makefile ============================================================================== --- stable/7/usr.bin/kdump/Makefile Sat Apr 2 09:46:09 2011 (r220275) +++ stable/7/usr.bin/kdump/Makefile Sat Apr 2 10:28:08 2011 (r220276) @@ -1,21 +1,13 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.if (${MACHINE_ARCH} == "amd64") -SFX= 32 -.endif - .PATH: ${.CURDIR}/../ktrace PROG= kdump SRCS= kdump.c ioctl.c kdump_subr.c subr.c CFLAGS+= -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../.. -.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" -SRCS+= linux_syscalls.c -.endif - -CLEANFILES= ioctl.c kdump_subr.c linux_syscalls.c +CLEANFILES= ioctl.c kdump_subr.c ioctl.c: mkioctls sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include > ${.TARGET} @@ -23,10 +15,4 @@ ioctl.c: mkioctls kdump_subr.c: mksubr sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include > ${.TARGET} -linux_syscalls.c: - /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \ - ${.CURDIR}/../../sys/${MACHINE_ARCH}/linux${SFX}/syscalls.master ${.CURDIR}/linux_syscalls.conf - echo "int nlinux_syscalls = sizeof(linux_syscallnames) / sizeof(linux_syscallnames[0]);" \ - >> linux_syscalls.c - .include Modified: stable/7/usr.bin/kdump/kdump.1 ============================================================================== --- stable/7/usr.bin/kdump/kdump.1 Sat Apr 2 09:46:09 2011 (r220275) +++ stable/7/usr.bin/kdump/kdump.1 Sat Apr 2 10:28:08 2011 (r220276) @@ -40,7 +40,7 @@ .Nd display kernel trace data .Sh SYNOPSIS .Nm -.Op Fl dEnlHRsTA +.Op Fl dEnlHRsT .Op Fl f Ar trfile .Op Fl m Ar maxdata .Op Fl p Ar pid @@ -103,8 +103,6 @@ GIDs, dates etc. symbolically instead of Suppress display of I/O data. .It Fl T Display absolute timestamps for each entry (seconds since epoch). -.It Fl A -Display description of the ABI of traced process. .It Fl t Ar trstr See the .Fl t Modified: stable/7/usr.bin/kdump/kdump.c ============================================================================== --- stable/7/usr.bin/kdump/kdump.c Sat Apr 2 09:46:09 2011 (r220275) +++ stable/7/usr.bin/kdump/kdump.c Sat Apr 2 10:28:08 2011 (r220276) @@ -59,9 +59,7 @@ extern int errno; #include #include #include -#include #include -#include #ifdef IPX #include #include @@ -85,12 +83,10 @@ extern int errno; #include "ktrace.h" #include "kdump_subr.h" -u_int abidump(struct ktr_header *); -int fetchprocinfo(struct ktr_header *, u_int *); int fread_tail(void *, int, int); void dumpheader(struct ktr_header *); -void ktrsyscall(struct ktr_syscall *, u_int); -void ktrsysret(struct ktr_sysret *, u_int); +void ktrsyscall(struct ktr_syscall *); +void ktrsysret(struct ktr_sysret *); void ktrnamei(char *, int); void hexdump(char *, int, int); void visdump(char *, int, int); @@ -105,57 +101,13 @@ void usage(void); const char *ioctlname(u_long); int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata, - resolv = 0, abiflag = 0; + resolv = 0; const char *tracefile = DEF_TRACEFILE; struct ktr_header ktr_header; #define TIME_FORMAT "%b %e %T %Y" #define eqs(s1, s2) (strcmp((s1), (s2)) == 0) -#define print_number(i,n,c) do { \ - if (decimal) \ - printf("%c%ld", c, (long)*i); \ - else \ - printf("%c%#lx", c, (long)*i); \ - i++; \ - n--; \ - c = ','; \ - } while (0); - -#if defined(__amd64__) || defined(__i386__) - -void linux_ktrsyscall(struct ktr_syscall *); -void linux_ktrsysret(struct ktr_sysret *); -extern char *linux_syscallnames[]; -extern int nlinux_syscalls; - -/* - * from linux.h - * Linux syscalls return negative errno's, we do positive and map them - */ -static int bsd_to_linux_errno[ELAST + 1] = { - -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, - -10, -35, -12, -13, -14, -15, -16, -17, -18, -19, - -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, - -30, -31, -32, -33, -34, -11,-115,-114, -88, -89, - -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, - -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, - -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, - -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, - -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, - -72, -67, -71 -}; -#endif - -struct proc_info -{ - TAILQ_ENTRY(proc_info) info; - u_int sv_flags; - pid_t pid; -}; - -TAILQ_HEAD(trace_procs, proc_info) trace_procs; - int main(int argc, char *argv[]) { @@ -164,15 +116,11 @@ main(int argc, char *argv[]) int trpoints = ALL_POINTS; int drop_logged; pid_t pid = 0; - u_int sv_flags; (void) setlocale(LC_CTYPE, ""); - while ((ch = getopt(argc,argv,"f:dElm:np:AHRrsTt:")) != -1) + while ((ch = getopt(argc,argv,"f:dElm:np:HRrsTt:")) != -1) switch((char)ch) { - case 'A': - abiflag = 1; - break; case 'f': tracefile = optarg; break; @@ -226,7 +174,6 @@ main(int argc, char *argv[]) errx(1, "%s", strerror(ENOMEM)); if (!freopen(tracefile, "r", stdin)) err(1, "%s", tracefile); - TAILQ_INIT(&trace_procs); drop_logged = 0; while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) { if (ktr_header.ktr_type & KTR_DROP) { @@ -259,9 +206,6 @@ main(int argc, char *argv[]) } if (ktrlen && fread_tail(m, ktrlen, 1) == 0) errx(1, "data too short"); - if (fetchprocinfo(&ktr_header, (u_int *)m) != 0) - continue; - sv_flags = abidump(&ktr_header); if (pid && ktr_header.ktr_pid != pid) continue; if ((trpoints & (1<ktr_type) { - case KTR_PROCCTOR: - TAILQ_FOREACH(pi, &trace_procs, info) { - if (pi->pid == kth->ktr_pid) { - TAILQ_REMOVE(&trace_procs, pi, info); - break; - } - } - pi = malloc(sizeof(struct proc_info)); - if (pi == NULL) - errx(1, "%s", strerror(ENOMEM)); - pi->sv_flags = *flags; - pi->pid = kth->ktr_pid; - TAILQ_INSERT_TAIL(&trace_procs, pi, info); - return (1); - - case KTR_PROCDTOR: - TAILQ_FOREACH(pi, &trace_procs, info) { - if (pi->pid == kth->ktr_pid) { - TAILQ_REMOVE(&trace_procs, pi, info); - free(pi); - break; - } - } - return (1); - } - - return (0); -} - -u_int -abidump(struct ktr_header *kth) -{ - struct proc_info *pi; - const char *abi; - const char *arch; - u_int flags = 0; - - TAILQ_FOREACH(pi, &trace_procs, info) { - if (pi->pid == kth->ktr_pid) { - flags = pi->sv_flags; - break; - } - } - - if (abiflag == 0) - return (flags); - - switch (flags & SV_ABI_MASK) { - case SV_ABI_LINUX: - abi = "L"; - break; - case SV_ABI_FREEBSD: - abi = "F"; - break; - default: - abi = "U"; - break; - } - - if (flags != 0) { - if (flags & SV_LP64) - arch = "64"; - else - arch = "32"; - } else - arch = "00"; - - printf("%s%s ", abi, arch); - - return (flags); -} - void dumpheader(struct ktr_header *kth) { @@ -438,10 +294,6 @@ dumpheader(struct ktr_header *kth) case KTR_SYSCTL: type = "SCTL"; break; - case KTR_PROCCTOR: - /* FALLTHROUGH */ - case KTR_PROCDTOR: - return; default: (void)sprintf(unknown, "UNKNOWN(%d)", kth->ktr_type); type = unknown; @@ -486,21 +338,30 @@ dumpheader(struct ktr_header *kth) int nsyscalls = sizeof (syscallnames) / sizeof (syscallnames[0]); void -ktrsyscall(struct ktr_syscall *ktr, u_int flags) +ktrsyscall(struct ktr_syscall *ktr) { int narg = ktr->ktr_narg; register_t *ip; - if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) || - (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0)) + if (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0) (void)printf("[%d]", ktr->ktr_code); else (void)printf("%s", syscallnames[ktr->ktr_code]); ip = &ktr->ktr_args[0]; if (narg) { char c = '('; - if (fancy && - (flags == 0 || (flags & SV_ABI_MASK) == SV_ABI_FREEBSD)) { + if (fancy) { + +#define print_number(i,n,c) do { \ + if (decimal) \ + (void)printf("%c%ld", c, (long)*i); \ + else \ + (void)printf("%c%#lx", c, (long)*i); \ + i++; \ + n--; \ + c = ','; \ + } while (0); + if (ktr->ktr_code == SYS_ioctl) { const char *cp; print_number(ip,narg,c); @@ -953,14 +814,13 @@ ktrsyscall(struct ktr_syscall *ktr, u_in } void -ktrsysret(struct ktr_sysret *ktr, u_int flags) +ktrsysret(struct ktr_sysret *ktr) { register_t ret = ktr->ktr_retval; int error = ktr->ktr_error; int code = ktr->ktr_code; - if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) || - (code >= nsyscalls || code < 0)) + if (code >= nsyscalls || code < 0) (void)printf("[%d] ", code); else (void)printf("%s ", syscallnames[code]); @@ -1508,71 +1368,10 @@ invalid: printf("invalid record\n"); } -#if defined(__amd64__) || defined(__i386__) -void -linux_ktrsyscall(struct ktr_syscall *ktr) -{ - int narg = ktr->ktr_narg; - register_t *ip; - - if (ktr->ktr_code >= nlinux_syscalls || ktr->ktr_code < 0) - printf("[%d]", ktr->ktr_code); - else - printf("%s", linux_syscallnames[ktr->ktr_code]); - ip = &ktr->ktr_args[0]; - if (narg) { - char c = '('; - while (narg > 0) - print_number(ip, narg, c); - putchar(')'); - } - putchar('\n'); -} - -void -linux_ktrsysret(struct ktr_sysret *ktr) -{ - register_t ret = ktr->ktr_retval; - int error = ktr->ktr_error; - int code = ktr->ktr_code; - - if (code >= nlinux_syscalls || code < 0) - printf("[%d] ", code); - else - printf("%s ", linux_syscallnames[code]); - - if (error == 0) { - if (fancy) { - printf("%ld", (long)ret); - if (ret < 0 || ret > 9) - printf("/%#lx", (long)ret); - } else { - if (decimal) - printf("%ld", (long)ret); - else - printf("%#lx", (long)ret); - } - } else if (error == ERESTART) - printf("RESTART"); - else if (error == EJUSTRETURN) - printf("JUSTRETURN"); - else { - if (ktr->ktr_error <= ELAST + 1) - error = abs(bsd_to_linux_errno[ktr->ktr_error]); - else - error = 999; - printf("-1 errno %d", error); - if (fancy) - printf(" %s", strerror(ktr->ktr_error)); - } - putchar('\n'); -} -#endif - void usage(void) { - fprintf(stderr, "usage: kdump [-dEnlHRrsTA] [-f trfile] " + fprintf(stderr, "usage: kdump [-dEnlHRrsT] [-f trfile] " "[-m maxdata] [-p pid] [-t trstr]\n"); exit(1); } Modified: stable/7/usr.bin/ktrace/ktrace.c ============================================================================== --- stable/7/usr.bin/ktrace/ktrace.c Sat Apr 2 09:46:09 2011 (r220275) +++ stable/7/usr.bin/ktrace/ktrace.c Sat Apr 2 10:28:08 2011 (r220276) @@ -163,8 +163,6 @@ main(int argc, char *argv[]) (void)umask(omask); (void)close(fd); - trpoints |= PROC_ABI_POINTS; - if (*argv) { if (ktrace(tracefile, ops, trpoints, getpid()) < 0) err(1, "%s", tracefile); Modified: stable/7/usr.bin/ktrace/ktrace.h ============================================================================== --- stable/7/usr.bin/ktrace/ktrace.h Sat Apr 2 09:46:09 2011 (r220275) +++ stable/7/usr.bin/ktrace/ktrace.h Sat Apr 2 10:28:08 2011 (r220276) @@ -38,9 +38,7 @@ KTRFAC_GENIO | KTRFAC_PSIG | KTRFAC_USER | \ KTRFAC_STRUCT | KTRFAC_SYSCTL) -#define PROC_ABI_POINTS (KTRFAC_PROCCTOR | KTRFAC_PROCDTOR) - -#define ALL_POINTS (DEF_POINTS | KTRFAC_CSW | PROC_ABI_POINTS) +#define ALL_POINTS (DEF_POINTS | KTRFAC_CSW) #define DEF_TRACEFILE "ktrace.out" From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 10:31:41 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8969D106566C; Sat, 2 Apr 2011 10:31:41 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7C07A8FC0A; Sat, 2 Apr 2011 10:31:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p32AVffM078777; Sat, 2 Apr 2011 10:31:41 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p32AVfbu078772; Sat, 2 Apr 2011 10:31:41 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201104021031.p32AVfbu078772@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 2 Apr 2011 10:31:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220277 - in stable/7/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 10:31:41 -0000 Author: dchagin Date: Sat Apr 2 10:31:41 2011 New Revision: 220277 URL: http://svn.freebsd.org/changeset/base/220277 Log: Revert r220263, SV_ABI patches was never merged to 7. Modified: stable/7/sys/kern/kern_exec.c stable/7/sys/kern/kern_fork.c stable/7/sys/kern/kern_ktrace.c stable/7/sys/sys/ktrace.h Modified: stable/7/sys/kern/kern_exec.c ============================================================================== --- stable/7/sys/kern/kern_exec.c Sat Apr 2 10:28:08 2011 (r220276) +++ stable/7/sys/kern/kern_exec.c Sat Apr 2 10:31:41 2011 (r220277) @@ -845,12 +845,6 @@ done2: exit1(td, W_EXITCODE(0, SIGABRT)); /* NOT REACHED */ } - -#ifdef KTRACE - if (error == 0) - ktrprocctor(p); -#endif - return (error); } Modified: stable/7/sys/kern/kern_fork.c ============================================================================== --- stable/7/sys/kern/kern_fork.c Sat Apr 2 10:28:08 2011 (r220276) +++ stable/7/sys/kern/kern_fork.c Sat Apr 2 10:31:41 2011 (r220277) @@ -613,6 +613,10 @@ again: callout_init(&p2->p_itcallout, CALLOUT_MPSAFE); +#ifdef KTRACE + ktrprocfork(p1, p2); +#endif + /* * If PF_FORK is set, the child process inherits the * procfs ioctl flags from its parent. @@ -657,10 +661,6 @@ again: p2->p_acflag = AFORK; PROC_UNLOCK(p2); -#ifdef KTRACE - ktrprocfork(p1, p2); -#endif - /* * Finish creating the child process. It will return via a different * execution path later. (ie: directly into user mode) Modified: stable/7/sys/kern/kern_ktrace.c ============================================================================== --- stable/7/sys/kern/kern_ktrace.c Sat Apr 2 10:28:08 2011 (r220276) +++ stable/7/sys/kern/kern_ktrace.c Sat Apr 2 10:31:41 2011 (r220277) @@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -93,7 +92,6 @@ struct ktr_request { struct ktr_header ktr_header; void *ktr_buffer; union { - struct ktr_proc_ctor ktr_proc_ctor; struct ktr_syscall ktr_syscall; struct ktr_sysret ktr_sysret; struct ktr_genio ktr_genio; @@ -114,8 +112,6 @@ static int data_lengths[] = { 0, /* KTR_USER */ 0, /* KTR_STRUCT */ 0, /* KTR_SYSCTL */ - sizeof(struct ktr_proc_ctor), /* KTR_PROCCTOR */ - 0, /* KTR_PROCDTOR */ }; static STAILQ_HEAD(, ktr_request) ktr_free; @@ -136,8 +132,7 @@ static struct sx ktrace_sx; static void ktrace_init(void *dummy); static int sysctl_kern_ktrace_request_pool(SYSCTL_HANDLER_ARGS); -static u_int ktrace_resize_pool(u_int oldsize, u_int newsize); -static struct ktr_request *ktr_getrequest_entered(struct thread *td, int type); +static u_int ktrace_resize_pool(u_int newsize); static struct ktr_request *ktr_getrequest(int type); static void ktr_submitrequest(struct thread *td, struct ktr_request *req); static void ktr_freeproc(struct proc *p, struct ucred **uc, @@ -148,7 +143,6 @@ static void ktr_writerequest(struct thre static int ktrcanset(struct thread *,struct proc *); static int ktrsetchildren(struct thread *,struct proc *,int,int,struct vnode *); static int ktrops(struct thread *,struct proc *,int,int,struct vnode *); -static void ktrprocctor_entered(struct thread *, struct proc *); /* * ktrace itself generates events, such as context switches, which we do not @@ -204,7 +198,9 @@ sysctl_kern_ktrace_request_pool(SYSCTL_H /* Handle easy read-only case first to avoid warnings from GCC. */ if (!req->newptr) { + mtx_lock(&ktrace_mtx); oldsize = ktr_requestpool; + mtx_unlock(&ktrace_mtx); return (SYSCTL_OUT(req, &oldsize, sizeof(u_int))); } @@ -213,8 +209,10 @@ sysctl_kern_ktrace_request_pool(SYSCTL_H return (error); td = curthread; ktrace_enter(td); + mtx_lock(&ktrace_mtx); oldsize = ktr_requestpool; - newsize = ktrace_resize_pool(oldsize, wantsize); + newsize = ktrace_resize_pool(wantsize); + mtx_unlock(&ktrace_mtx); ktrace_exit(td); error = SYSCTL_OUT(req, &oldsize, sizeof(u_int)); if (error) @@ -227,40 +225,38 @@ SYSCTL_PROC(_kern_ktrace, OID_AUTO, requ &ktr_requestpool, 0, sysctl_kern_ktrace_request_pool, "IU", ""); static u_int -ktrace_resize_pool(u_int oldsize, u_int newsize) +ktrace_resize_pool(u_int newsize) { - STAILQ_HEAD(, ktr_request) ktr_new; struct ktr_request *req; int bound; + mtx_assert(&ktrace_mtx, MA_OWNED); print_message = 1; - bound = newsize - oldsize; + bound = newsize - ktr_requestpool; if (bound == 0) return (ktr_requestpool); - if (bound < 0) { - mtx_lock(&ktrace_mtx); + if (bound < 0) /* Shrink pool down to newsize if possible. */ while (bound++ < 0) { req = STAILQ_FIRST(&ktr_free); if (req == NULL) - break; + return (ktr_requestpool); STAILQ_REMOVE_HEAD(&ktr_free, ktr_list); ktr_requestpool--; + mtx_unlock(&ktrace_mtx); free(req, M_KTRACE); + mtx_lock(&ktrace_mtx); } - } else { + else /* Grow pool up to newsize. */ - STAILQ_INIT(&ktr_new); while (bound-- > 0) { + mtx_unlock(&ktrace_mtx); req = malloc(sizeof(struct ktr_request), M_KTRACE, M_WAITOK); - STAILQ_INSERT_HEAD(&ktr_new, req, ktr_list); + mtx_lock(&ktrace_mtx); + STAILQ_INSERT_HEAD(&ktr_free, req, ktr_list); + ktr_requestpool++; } - mtx_lock(&ktrace_mtx); - STAILQ_CONCAT(&ktr_free, &ktr_new); - ktr_requestpool += (newsize - oldsize); - } - mtx_unlock(&ktrace_mtx); return (ktr_requestpool); } @@ -269,15 +265,18 @@ CTASSERT(sizeof(((struct ktr_header *)NU (sizeof((struct proc *)NULL)->p_comm)); static struct ktr_request * -ktr_getrequest_entered(struct thread *td, int type) +ktr_getrequest(int type) { struct ktr_request *req; + struct thread *td = curthread; struct proc *p = td->td_proc; int pm; + ktrace_enter(td); /* XXX: In caller instead? */ mtx_lock(&ktrace_mtx); if (!KTRCHECK(td, type)) { mtx_unlock(&ktrace_mtx); + ktrace_exit(td); return (NULL); } req = STAILQ_FIRST(&ktr_free); @@ -303,21 +302,8 @@ ktr_getrequest_entered(struct thread *td mtx_unlock(&ktrace_mtx); if (pm) printf("Out of ktrace request objects.\n"); - } - return (req); -} - -static struct ktr_request * -ktr_getrequest(int type) -{ - struct thread *td = curthread; - struct ktr_request *req; - - ktrace_enter(td); - req = ktr_getrequest_entered(td, type); - if (req == NULL) ktrace_exit(td); - + } return (req); } @@ -334,6 +320,7 @@ ktr_enqueuerequest(struct thread *td, st mtx_lock(&ktrace_mtx); STAILQ_INSERT_TAIL(&td->td_proc->p_ktr, req, ktr_list); mtx_unlock(&ktrace_mtx); + ktrace_exit(td); } /* @@ -383,6 +370,7 @@ ktr_submitrequest(struct thread *td, str ktr_writerequest(td, req); ktr_freerequest(req); sx_xunlock(&ktrace_sx); + ktrace_exit(td); } @@ -500,7 +488,6 @@ ktrprocexec(struct proc *p, struct ucred void ktrprocexit(struct thread *td) { - struct ktr_request *req; struct proc *p; struct ucred *cred; struct vnode *vp; @@ -511,9 +498,6 @@ ktrprocexit(struct thread *td) return; ktrace_enter(td); - req = ktr_getrequest_entered(td, KTR_PROCDTOR); - if (req != NULL) - ktr_enqueuerequest(td, req); sx_xlock(&ktrace_sx); ktr_drain(td); sx_xunlock(&ktrace_sx); @@ -532,36 +516,6 @@ ktrprocexit(struct thread *td) ktrace_exit(td); } -static void -ktrprocctor_entered(struct thread *td, struct proc *p) -{ - struct ktr_proc_ctor *ktp; - struct ktr_request *req; - struct thread *td2; - - ktrace_assert(td); - td2 = FIRST_THREAD_IN_PROC(p); - req = ktr_getrequest_entered(td2, KTR_PROCCTOR); - if (req == NULL) - return; - ktp = &req->ktr_data.ktr_proc_ctor; - ktp->sv_flags = p->p_sysent->sv_flags; - ktr_enqueuerequest(td2, req); -} - -void -ktrprocctor(struct proc *p) -{ - struct thread *td = curthread; - - if ((p->p_traceflag & KTRFAC_MASK) == 0) - return; - - ktrace_enter(td); - ktrprocctor_entered(td, p); - ktrace_exit(td); -} - /* * When a process forks, enable tracing in the new process if needed. */ @@ -569,7 +523,8 @@ void ktrprocfork(struct proc *p1, struct proc *p2) { - PROC_LOCK(p1); + PROC_LOCK_ASSERT(p1, MA_OWNED); + PROC_LOCK_ASSERT(p2, MA_OWNED); mtx_lock(&ktrace_mtx); KASSERT(p2->p_tracevp == NULL, ("new process has a ktrace vnode")); if (p1->p_traceflag & KTRFAC_INHERIT) { @@ -582,9 +537,6 @@ ktrprocfork(struct proc *p1, struct proc } } mtx_unlock(&ktrace_mtx); - PROC_UNLOCK(p1); - - ktrprocctor(p2); } /* @@ -708,7 +660,6 @@ ktrpsig(sig, action, mask, code) sigset_t *mask; int code; { - struct thread *td = curthread; struct ktr_request *req; struct ktr_psig *kp; @@ -720,15 +671,13 @@ ktrpsig(sig, action, mask, code) kp->action = action; kp->mask = *mask; kp->code = code; - ktr_enqueuerequest(td, req); - ktrace_exit(td); + ktr_enqueuerequest(curthread, req); } void ktrcsw(out, user) int out, user; { - struct thread *td = curthread; struct ktr_request *req; struct ktr_csw *kc; @@ -738,8 +687,7 @@ ktrcsw(out, user) kc = &req->ktr_data.ktr_csw; kc->out = out; kc->user = user; - ktr_enqueuerequest(td, req); - ktrace_exit(td); + ktr_enqueuerequest(curthread, req); } void @@ -1015,8 +963,6 @@ ktrops(td, p, ops, facs, vp) ktr_freeproc(p, &tracecred, &tracevp); } mtx_unlock(&ktrace_mtx); - if ((p->p_traceflag & KTRFAC_MASK) != 0) - ktrprocctor_entered(td, p); PROC_UNLOCK(p); if (tracevp != NULL) { int vfslocked; Modified: stable/7/sys/sys/ktrace.h ============================================================================== --- stable/7/sys/sys/ktrace.h Sat Apr 2 10:28:08 2011 (r220276) +++ stable/7/sys/sys/ktrace.h Sat Apr 2 10:31:41 2011 (r220277) @@ -156,7 +156,6 @@ struct ktr_csw { #define KTR_STRUCT 8 struct sockaddr; struct stat; -struct sysentvec; /* * KTR_SYSCTL - name of a sysctl MIB @@ -165,19 +164,6 @@ struct sysentvec; /* record contains null-terminated MIB name */ /* - * KTR_PROCCTOR - trace process creation (multiple ABI support) - */ -#define KTR_PROCCTOR 10 -struct ktr_proc_ctor { - u_int sv_flags; /* struct sysentvec sv_flags copy */ -}; - -/* - * KTR_PROCDTOR - trace process destruction (multiple ABI support) - */ -#define KTR_PROCDTOR 11 - -/* * KTR_DROP - If this bit is set in ktr_type, then at least one event * between the previous record and this record was dropped. */ @@ -196,8 +182,6 @@ struct ktr_proc_ctor { #define KTRFAC_USER (1< Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 493F9106564A; Sat, 2 Apr 2011 11:10:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3C2AB8FC08; Sat, 2 Apr 2011 11:10:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p32BAbrP080882; Sat, 2 Apr 2011 11:10:37 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p32BAbPn080880; Sat, 2 Apr 2011 11:10:37 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104021110.p32BAbPn080880@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 2 Apr 2011 11:10:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220278 - stable/8/gnu/usr.bin/gdb/libgdb X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 11:10:37 -0000 Author: kib Date: Sat Apr 2 11:10:36 2011 New Revision: 220278 URL: http://svn.freebsd.org/changeset/base/220278 Log: MFC r220043: Print the raw value of si_code, that is esp. useful for undecoded values. Sponsored by: The FreeBSD Foundation Modified: stable/8/gnu/usr.bin/gdb/libgdb/fbsd-threads.c Directory Properties: stable/8/gnu/usr.bin/gdb/ (props changed) stable/8/gnu/usr.bin/gdb/kgdb/ (props changed) Modified: stable/8/gnu/usr.bin/gdb/libgdb/fbsd-threads.c ============================================================================== --- stable/8/gnu/usr.bin/gdb/libgdb/fbsd-threads.c Sat Apr 2 10:31:41 2011 (r220277) +++ stable/8/gnu/usr.bin/gdb/libgdb/fbsd-threads.c Sat Apr 2 11:10:36 2011 (r220278) @@ -1389,9 +1389,10 @@ fbsd_thread_signal_cmd (char *exp, int f code = "UNKNOWN"; break; } - printf_filtered("si_code %s si_pid %d si_uid %d si_status %x si_addr %p\n", - code, ti.ti_siginfo.si_pid, ti.ti_siginfo.si_uid, ti.ti_siginfo.si_status, - ti.ti_siginfo.si_addr); + printf_filtered("si_code %s (%d) si_pid %d si_uid %d si_status %x " + "si_addr %p\n", + code, ti.ti_siginfo.si_code, ti.ti_siginfo.si_pid, ti.ti_siginfo.si_uid, + ti.ti_siginfo.si_status, ti.ti_siginfo.si_addr); } } From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 15:02:43 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5CAAE106566B; Sat, 2 Apr 2011 15:02:43 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 32F648FC18; Sat, 2 Apr 2011 15:02:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p32F2htK085659; Sat, 2 Apr 2011 15:02:43 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p32F2h3n085657; Sat, 2 Apr 2011 15:02:43 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201104021502.p32F2h3n085657@svn.freebsd.org> From: Edward Tomasz Napierala Date: Sat, 2 Apr 2011 15:02:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220279 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 15:02:43 -0000 Author: trasz Date: Sat Apr 2 15:02:42 2011 New Revision: 220279 URL: http://svn.freebsd.org/changeset/base/220279 Log: Add accounting for RACCT_NPTS. Modified: head/sys/kern/tty_pts.c Modified: head/sys/kern/tty_pts.c ============================================================================== --- head/sys/kern/tty_pts.c Sat Apr 2 11:10:36 2011 (r220278) +++ head/sys/kern/tty_pts.c Sat Apr 2 15:02:42 2011 (r220279) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -682,6 +683,7 @@ ptsdrv_free(void *softc) free_unr(pts_pool, psc->pts_unit); chgptscnt(psc->pts_cred->cr_ruidinfo, -1, 0); + racct_sub_cred(psc->pts_cred, RACCT_NPTS, 1); crfree(psc->pts_cred); knlist_destroy(&psc->pts_inpoll.si_note); @@ -712,7 +714,7 @@ static int pts_alloc(int fflags, struct thread *td, struct file *fp) { - int unit, ok; + int unit, ok, error; struct tty *tp; struct pts_softc *psc; struct proc *p = td->td_proc; @@ -720,14 +722,23 @@ pts_alloc(int fflags, struct thread *td, /* Resource limiting. */ PROC_LOCK(p); + error = racct_add(p, RACCT_NPTS, 1); + if (error != 0) { + PROC_UNLOCK(p); + return (EAGAIN); + } ok = chgptscnt(cred->cr_ruidinfo, 1, lim_cur(p, RLIMIT_NPTS)); - PROC_UNLOCK(p); - if (!ok) + if (!ok) { + racct_sub(p, RACCT_NPTS, 1); + PROC_UNLOCK(p); return (EAGAIN); + } + PROC_UNLOCK(p); /* Try to allocate a new pts unit number. */ unit = alloc_unr(pts_pool); if (unit < 0) { + racct_sub(p, RACCT_NPTS, 1); chgptscnt(cred->cr_ruidinfo, -1, 0); return (EAGAIN); } @@ -757,7 +768,7 @@ int pts_alloc_external(int fflags, struct thread *td, struct file *fp, struct cdev *dev, const char *name) { - int ok; + int ok, error; struct tty *tp; struct pts_softc *psc; struct proc *p = td->td_proc; @@ -765,10 +776,18 @@ pts_alloc_external(int fflags, struct th /* Resource limiting. */ PROC_LOCK(p); + error = racct_add(p, RACCT_NPTS, 1); + if (error != 0) { + PROC_UNLOCK(p); + return (EAGAIN); + } ok = chgptscnt(cred->cr_ruidinfo, 1, lim_cur(p, RLIMIT_NPTS)); - PROC_UNLOCK(p); - if (!ok) + if (!ok) { + racct_sub(p, RACCT_NPTS, 1); + PROC_UNLOCK(p); return (EAGAIN); + } + PROC_UNLOCK(p); /* Allocate TTY and softc. */ psc = malloc(sizeof(struct pts_softc), M_PTS, M_WAITOK|M_ZERO); From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 15:47:23 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B430D1065673; Sat, 2 Apr 2011 15:47:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A47AF8FC13; Sat, 2 Apr 2011 15:47:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p32FlNdk086598; Sat, 2 Apr 2011 15:47:23 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p32FlNG1086595; Sat, 2 Apr 2011 15:47:23 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104021547.p32FlNG1086595@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 2 Apr 2011 15:47:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220280 - head/sys/compat/freebsd32 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 15:47:23 -0000 Author: kib Date: Sat Apr 2 15:47:23 2011 New Revision: 220280 URL: http://svn.freebsd.org/changeset/base/220280 Log: Provide the structures and ioctl number definition for handling PCIOCGETCONF compat32. Submitted by: John Wehle MFC after: 2 weeks Modified: head/sys/compat/freebsd32/freebsd32_ioctl.c head/sys/compat/freebsd32/freebsd32_ioctl.h Modified: head/sys/compat/freebsd32/freebsd32_ioctl.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_ioctl.c Sat Apr 2 15:02:42 2011 (r220279) +++ head/sys/compat/freebsd32/freebsd32_ioctl.c Sat Apr 2 15:47:23 2011 (r220280) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -58,6 +59,9 @@ CTASSERT((sizeof(struct md_ioctl32)+4) = CTASSERT(sizeof(struct ioc_read_toc_entry32) == 8); CTASSERT(sizeof(struct ioc_toc_header32) == 4); CTASSERT(sizeof(struct mem_range_op32) == 12); +CTASSERT(sizeof(struct pci_conf_io32) == 36); +CTASSERT(sizeof(struct pci_match_conf32) == 44); +CTASSERT(sizeof(struct pci_conf32) == 44); static int Modified: head/sys/compat/freebsd32/freebsd32_ioctl.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_ioctl.h Sat Apr 2 15:02:42 2011 (r220279) +++ head/sys/compat/freebsd32/freebsd32_ioctl.h Sat Apr 2 15:47:23 2011 (r220280) @@ -73,6 +73,45 @@ struct mem_range_op32 int mo_arg[2]; }; +struct pci_conf32 { + struct pcisel pc_sel; /* domain+bus+slot+function */ + u_int8_t pc_hdr; /* PCI header type */ + u_int16_t pc_subvendor; /* card vendor ID */ + u_int16_t pc_subdevice; /* card device ID, assigned by + card vendor */ + u_int16_t pc_vendor; /* chip vendor ID */ + u_int16_t pc_device; /* chip device ID, assigned by + chip vendor */ + u_int8_t pc_class; /* chip PCI class */ + u_int8_t pc_subclass; /* chip PCI subclass */ + u_int8_t pc_progif; /* chip PCI programming interface */ + u_int8_t pc_revid; /* chip revision ID */ + char pd_name[PCI_MAXNAMELEN + 1]; /* device name */ + u_int32_t pd_unit; /* device unit number */ +}; + +struct pci_match_conf32 { + struct pcisel pc_sel; /* domain+bus+slot+function */ + char pd_name[PCI_MAXNAMELEN + 1]; /* device name */ + u_int32_t pd_unit; /* Unit number */ + u_int16_t pc_vendor; /* PCI Vendor ID */ + u_int16_t pc_device; /* PCI Device ID */ + u_int8_t pc_class; /* PCI class */ + u_int32_t flags; /* Matching expression */ +}; + +struct pci_conf_io32 { + u_int32_t pat_buf_len; /* pattern buffer length */ + u_int32_t num_patterns; /* number of patterns */ + caddr_t32 patterns; /* struct pci_match_conf ptr */ + u_int32_t match_buf_len; /* match buffer length */ + u_int32_t num_matches; /* number of matches returned */ + caddr_t32 matches; /* struct pci_conf ptr */ + u_int32_t offset; /* offset into device list */ + u_int32_t generation; /* device list generation */ + u_int32_t status; /* request status */ +}; + #define CDIOREADTOCENTRYS_32 _IOWR('c', 5, struct ioc_read_toc_entry32) #define CDIOREADTOCHEADER_32 _IOR('c', 4, struct ioc_toc_header32) #define MDIOCATTACH_32 _IOC(IOC_INOUT, 'm', 0, sizeof(struct md_ioctl32) + 4) @@ -82,5 +121,6 @@ struct mem_range_op32 #define FIODGNAME_32 _IOW('f', 120, struct fiodgname_arg32) #define MEMRANGE_GET32 _IOWR('m', 50, struct mem_range_op32) #define MEMRANGE_SET32 _IOW('m', 51, struct mem_range_op32) +#define PCIOCGETCONF_32 _IOWR('p', 5, struct pci_conf_io32) #endif /* _COMPAT_FREEBSD32_IOCTL_H_ */ From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 16:02:25 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 87BAE1065674; Sat, 2 Apr 2011 16:02:25 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 778258FC15; Sat, 2 Apr 2011 16:02:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p32G2P6Z086946; Sat, 2 Apr 2011 16:02:25 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p32G2Pqc086944; Sat, 2 Apr 2011 16:02:25 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104021602.p32G2Pqc086944@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 2 Apr 2011 16:02:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220281 - head/sys/compat/freebsd32 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 16:02:25 -0000 Author: kib Date: Sat Apr 2 16:02:25 2011 New Revision: 220281 URL: http://svn.freebsd.org/changeset/base/220281 Log: Implement compat32 shims for PCIOCGETCONF. There is a generic problem with the shims for ioctls that receive pointers to the usermode data areas in the data argument. We either have to modify the handler to accept UIO_USERSPACE/UIO_SYSSPACE indicator, or allocate and fill a usermode memory for data buffer in the host format. The change goes the second route, in particular because we do not need to modify the handler. Submitted by: John Wehle MFC after: 2 weeks Modified: head/sys/compat/freebsd32/freebsd32_ioctl.c Modified: head/sys/compat/freebsd32/freebsd32_ioctl.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_ioctl.c Sat Apr 2 15:47:23 2011 (r220280) +++ head/sys/compat/freebsd32/freebsd32_ioctl.c Sat Apr 2 16:02:25 2011 (r220281) @@ -241,6 +241,108 @@ freebsd32_ioctl_memrange(struct thread * return (error); } +static int +freebsd32_ioctl_pciocgetconf(struct thread *td, + struct freebsd32_ioctl_args *uap, struct file *fp) +{ + struct pci_conf_io pci; + struct pci_conf_io32 pci32; + struct pci_match_conf32 pmc32; + struct pci_match_conf32 *pmc32p; + struct pci_match_conf pmc; + struct pci_match_conf *pmcp; + struct pci_conf32 pc32; + struct pci_conf32 *pc32p; + struct pci_conf pc; + struct pci_conf *pcp; + u_int32_t i; + u_int32_t npat_to_convert; + u_int32_t nmatch_to_convert; + vm_offset_t addr; + int error; + + if ((error = copyin(uap->data, &pci32, sizeof(pci32))) != 0) + return (error); + + CP(pci32, pci, num_patterns); + CP(pci32, pci, offset); + CP(pci32, pci, generation); + + npat_to_convert = pci32.pat_buf_len / sizeof(struct pci_match_conf32); + pci.pat_buf_len = npat_to_convert * sizeof(struct pci_match_conf); + pci.patterns = NULL; + nmatch_to_convert = pci32.match_buf_len / sizeof(struct pci_conf32); + pci.match_buf_len = nmatch_to_convert * sizeof(struct pci_conf); + pci.matches = NULL; + + if ((error = copyout_map(td, &addr, pci.pat_buf_len)) != 0) + goto cleanup; + pci.patterns = (struct pci_match_conf *)addr; + if ((error = copyout_map(td, &addr, pci.match_buf_len)) != 0) + goto cleanup; + pci.matches = (struct pci_conf *)addr; + + npat_to_convert = min(npat_to_convert, pci.num_patterns); + + for (i = 0, pmc32p = (struct pci_match_conf32 *)PTRIN(pci32.patterns), + pmcp = pci.patterns; + i < npat_to_convert; i++, pmc32p++, pmcp++) { + if ((error = copyin(pmc32p, &pmc32, sizeof(pmc32))) != 0) + goto cleanup; + CP(pmc32,pmc,pc_sel); + strlcpy(pmc.pd_name, pmc32.pd_name, sizeof(pmc.pd_name)); + CP(pmc32,pmc,pd_unit); + CP(pmc32,pmc,pc_vendor); + CP(pmc32,pmc,pc_device); + CP(pmc32,pmc,pc_class); + CP(pmc32,pmc,flags); + if ((error = copyout(&pmc, pmcp, sizeof(pmc))) != 0) + goto cleanup; + } + + if ((error = fo_ioctl(fp, PCIOCGETCONF, (caddr_t)&pci, + td->td_ucred, td)) != 0) + goto cleanup; + + nmatch_to_convert = min(nmatch_to_convert, pci.num_matches); + + for (i = 0, pcp = pci.matches, + pc32p = (struct pci_conf32 *)PTRIN(pci32.matches); + i < nmatch_to_convert; i++, pcp++, pc32p++) { + if ((error = copyin(pcp, &pc, sizeof(pc))) != 0) + goto cleanup; + CP(pc,pc32,pc_sel); + CP(pc,pc32,pc_hdr); + CP(pc,pc32,pc_subvendor); + CP(pc,pc32,pc_subdevice); + CP(pc,pc32,pc_vendor); + CP(pc,pc32,pc_device); + CP(pc,pc32,pc_class); + CP(pc,pc32,pc_subclass); + CP(pc,pc32,pc_progif); + CP(pc,pc32,pc_revid); + strlcpy(pc32.pd_name, pc.pd_name, sizeof(pc32.pd_name)); + CP(pc,pc32,pd_unit); + if ((error = copyout(&pc32, pc32p, sizeof(pc32))) != 0) + goto cleanup; + } + + CP(pci, pci32, num_matches); + CP(pci, pci32, offset); + CP(pci, pci32, generation); + CP(pci, pci32, status); + + error = copyout(&pci32, uap->data, sizeof(pci32)); + +cleanup: + if (pci.patterns) + copyout_unmap(td, (vm_offset_t)pci.patterns, pci.pat_buf_len); + if (pci.matches) + copyout_unmap(td, (vm_offset_t)pci.matches, pci.match_buf_len); + + return (error); +} + int freebsd32_ioctl(struct thread *td, struct freebsd32_ioctl_args *uap) { @@ -284,6 +386,10 @@ freebsd32_ioctl(struct thread *td, struc error = freebsd32_ioctl_memrange(td, uap, fp); break; + case PCIOCGETCONF_32: + error = freebsd32_ioctl_pciocgetconf(td, uap, fp); + break; + default: fdrop(fp, td); ap.fd = uap->fd; From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 21:52:59 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 06700106564A; Sat, 2 Apr 2011 21:52:59 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E7A628FC0C; Sat, 2 Apr 2011 21:52:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p32Lqwn6094161; Sat, 2 Apr 2011 21:52:58 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p32Lqw9s094159; Sat, 2 Apr 2011 21:52:58 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201104022152.p32Lqw9s094159@svn.freebsd.org> From: Jeff Roberson Date: Sat, 2 Apr 2011 21:52:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220282 - head/sys/ufs/ffs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 21:52:59 -0000 Author: jeff Date: Sat Apr 2 21:52:58 2011 New Revision: 220282 URL: http://svn.freebsd.org/changeset/base/220282 Log: Fix problems that manifested from filesystem full conditions: - In softdep_revert_mkdir() find the dotaddref before we attempt to cancel the jaddref so we can make assumptions about where the dotaddref is on the list. cancel_jaddref() does not always remove items from the list anymore. - Always set GOINGAWAY on an inode in softdep_freefile() if DEPCOMPLETE was never set. This ensures that dependencies will continue to be processed on the inowait/bufwait list and is more an artifact of the structure of the code than a pure ordering problem. - Always set DEPCOMPLETE on canceled jaddrefs so that they can be freed appropriately. This normally occurs when the refs are added to the journal but if they are canceled before this point the state would never be set and the dependency could never be freed. Reported by: pho Tested by: pho Modified: head/sys/ufs/ffs/ffs_softdep.c Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Sat Apr 2 16:02:25 2011 (r220281) +++ head/sys/ufs/ffs/ffs_softdep.c Sat Apr 2 21:52:58 2011 (r220282) @@ -3501,10 +3501,14 @@ cancel_jaddref(jaddref, inodedep, wkhd) * us so that it is consistent with the in-memory reference. This * ensures that inode nlink rollbacks always have the correct link. */ - if (needsj == 0) + if (needsj == 0) { for (inoref = TAILQ_NEXT(&jaddref->ja_ref, if_deps); inoref; - inoref = TAILQ_NEXT(inoref, if_deps)) + inoref = TAILQ_NEXT(inoref, if_deps)) { + if (inoref->if_state & GOINGAWAY) + break; inoref->if_nlink--; + } + } jsegdep = inoref_jseg(&jaddref->ja_ref); if (jaddref->ja_state & NEWBLOCK) move_newblock_dep(jaddref, inodedep); @@ -3522,6 +3526,7 @@ cancel_jaddref(jaddref, inodedep, wkhd) if (jaddref->ja_state & DEPCOMPLETE) remove_from_journal(&jaddref->ja_list); } + jaddref->ja_state |= (GOINGAWAY | DEPCOMPLETE); /* * Leave NEWBLOCK jaddrefs on the inodedep so handle_workitem_remove * can arrange for them to be freed with the bitmap. Otherwise we @@ -3535,7 +3540,6 @@ cancel_jaddref(jaddref, inodedep, wkhd) free_jaddref(jaddref); return (needsj); } - jaddref->ja_state |= GOINGAWAY; /* * Leave the head of the list for jsegdeps for fast merging. */ @@ -4071,6 +4075,7 @@ softdep_revert_mkdir(dp, ip) { struct inodedep *inodedep; struct jaddref *jaddref; + struct jaddref *dotaddref; struct vnode *dvp; dvp = ITOV(dp); @@ -4090,12 +4095,12 @@ softdep_revert_mkdir(dp, ip) inoreflst); KASSERT(jaddref->ja_parent == dp->i_number, ("softdep_revert_mkdir: addref parent mismatch")); + dotaddref = (struct jaddref *)TAILQ_PREV(&jaddref->ja_ref, + inoreflst, if_deps); cancel_jaddref(jaddref, inodedep, &inodedep->id_inowait); - jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst, - inoreflst); - KASSERT(jaddref->ja_parent == ip->i_number, + KASSERT(dotaddref->ja_parent == ip->i_number, ("softdep_revert_mkdir: dot addref parent mismatch")); - cancel_jaddref(jaddref, inodedep, &inodedep->id_inowait); + cancel_jaddref(dotaddref, inodedep, &inodedep->id_inowait); } FREE_LOCK(&lk); } @@ -5734,14 +5739,14 @@ softdep_freefile(pvp, ino, mode) clear_unlinked_inodedep(inodedep); /* Re-acquire inodedep as we've dropped lk. */ inodedep_lookup(pvp->v_mount, ino, 0, &inodedep); - if (inodedep && (inodedep->id_state & DEPCOMPLETE) == 0) - inodedep->id_state |= GOINGAWAY; } if (inodedep == NULL || check_inode_unwritten(inodedep)) { FREE_LOCK(&lk); handle_workitem_freefile(freefile); return; } + if (inodedep && (inodedep->id_state & DEPCOMPLETE) == 0) + inodedep->id_state |= GOINGAWAY; WORKLIST_INSERT(&inodedep->id_inowait, &freefile->fx_list); FREE_LOCK(&lk); if (ip->i_number == ino)