From owner-svn-src-stable-9@FreeBSD.ORG Sun May 19 01:52:39 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id C212F9A0; Sun, 19 May 2013 01:52:39 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A3256E57; Sun, 19 May 2013 01:52:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4J1qd78031464; Sun, 19 May 2013 01:52:39 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4J1qdSX031463; Sun, 19 May 2013 01:52:39 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201305190152.r4J1qdSX031463@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 19 May 2013 01:52:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250798 - stable/9/sys/powerpc/powermac X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 May 2013 01:52:39 -0000 Author: nwhitehorn Date: Sun May 19 01:52:39 2013 New Revision: 250798 URL: http://svnweb.freebsd.org/changeset/base/250798 Log: MFC r250290: Only check fan type once. Not only is continuously rechecking pointless, a single random failure can reprogram what control mechanism we try to use. Modified: stable/9/sys/powerpc/powermac/smu.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/powerpc/powermac/smu.c ============================================================================== --- stable/9/sys/powerpc/powermac/smu.c Sun May 19 01:45:29 2013 (r250797) +++ stable/9/sys/powerpc/powermac/smu.c Sun May 19 01:52:39 2013 (r250798) @@ -78,8 +78,8 @@ struct smu_fan { SMU_FAN_RPM, SMU_FAN_PWM } type; - int old_style; int setpoint; + int old_style; int rpm; }; @@ -123,6 +123,7 @@ struct smu_softc { struct smu_fan *sc_fans; int sc_nfans; + int old_style_fans; struct smu_sensor *sc_sensors; int sc_nsensors; @@ -654,6 +655,37 @@ doorbell_attach(device_t dev) */ static int +smu_fan_check_old_style(struct smu_fan *fan) +{ + device_t smu = fan->dev; + struct smu_softc *sc = device_get_softc(smu); + struct smu_cmd cmd; + int error; + + if (sc->old_style_fans != -1) + return (sc->old_style_fans); + + /* + * Apple has two fan control mechanisms. We can't distinguish + * them except by seeing if the new one fails. If the new one + * fails, use the old one. + */ + + cmd.cmd = SMU_FAN; + cmd.len = 2; + cmd.data[0] = 0x31; + cmd.data[1] = fan->reg; + + do { + error = smu_run_cmd(smu, &cmd, 1); + } while (error == EWOULDBLOCK); + + sc->old_style_fans = (error != 0); + + return (sc->old_style_fans); +} + +static int smu_fan_set_rpm(struct smu_fan *fan, int rpm) { device_t smu = fan->dev; @@ -667,12 +699,8 @@ smu_fan_set_rpm(struct smu_fan *fan, int rpm = max(fan->fan.min_rpm, rpm); rpm = min(fan->fan.max_rpm, rpm); - /* - * Apple has two fan control mechanisms. We can't distinguish - * them except by seeing if the new one fails. If the new one - * fails, use the old one. - */ - + smu_fan_check_old_style(fan); + if (!fan->old_style) { cmd.len = 4; cmd.data[0] = 0x30; @@ -683,9 +711,7 @@ smu_fan_set_rpm(struct smu_fan *fan, int error = smu_run_cmd(smu, &cmd, 1); if (error && error != EWOULDBLOCK) fan->old_style = 1; - } - - if (fan->old_style) { + } else { cmd.len = 14; cmd.data[0] = 0x00; /* RPM fan. */ cmd.data[1] = 1 << fan->reg; @@ -707,6 +733,8 @@ smu_fan_read_rpm(struct smu_fan *fan) struct smu_cmd cmd; int rpm, error; + smu_fan_check_old_style(fan); + if (!fan->old_style) { cmd.cmd = SMU_FAN; cmd.len = 2; @@ -944,9 +972,10 @@ smu_count_fans(device_t dev) child = OF_peer(child)) { nfans++; /* When allocated, fill the fan properties. */ - if (sc->sc_fans != NULL) + if (sc->sc_fans != NULL) { smu_fill_fan_prop(dev, child, nfans - 1); + } } } if (nfans == 0) { From owner-svn-src-stable-9@FreeBSD.ORG Sun May 19 01:58:00 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id EA812D1E; Sun, 19 May 2013 01:58:00 +0000 (UTC) (envelope-from grog@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DAF02E8D; Sun, 19 May 2013 01:58:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4J1w0rb032658; Sun, 19 May 2013 01:58:00 GMT (envelope-from grog@svn.freebsd.org) Received: (from grog@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4J1w0b9032657; Sun, 19 May 2013 01:58:00 GMT (envelope-from grog@svn.freebsd.org) Message-Id: <201305190158.r4J1w0b9032657@svn.freebsd.org> From: Greg Lehey Date: Sun, 19 May 2013 01:58:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250799 - stable/9/lib/libc/stdio X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 May 2013 01:58:01 -0000 Author: grog Date: Sun May 19 01:58:00 2013 New Revision: 250799 URL: http://svnweb.freebsd.org/changeset/base/250799 Log: MFH r242738: Clarify that the ' flag is an apostrophe. Modified: stable/9/lib/libc/stdio/printf.3 Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/stdio/printf.3 ============================================================================== --- stable/9/lib/libc/stdio/printf.3 Sun May 19 01:52:39 2013 (r250798) +++ stable/9/lib/libc/stdio/printf.3 Sun May 19 01:58:00 2013 (r250799) @@ -277,7 +277,7 @@ number produced by a signed conversion. A .Cm + overrides a space if both are used. -.It Sq Cm ' +.It So "'" Sc (apostrophe) Decimal conversions .Cm ( d , u , or From owner-svn-src-stable-9@FreeBSD.ORG Mon May 20 02:34:46 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id A77734AF; Mon, 20 May 2013 02:34:46 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 99CAB38F; Mon, 20 May 2013 02:34:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4K2Ykk5059104; Mon, 20 May 2013 02:34:46 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4K2YkpD059098; Mon, 20 May 2013 02:34:46 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201305200234.r4K2YkpD059098@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Mon, 20 May 2013 02:34:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250821 - stable/9/gnu/usr.bin/grep X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 May 2013 02:34:46 -0000 Author: pfg Date: Mon May 20 02:34:45 2013 New Revision: 250821 URL: http://svnweb.freebsd.org/changeset/base/250821 Log: grep: change some int types. Change several int variables to size_t, ssize_t, or ptrdiff_t. This should fix the bug described in CVE-2012-5667 when an input line is so long that its length cannot be stored in an int variable. This is based on NetBSD's revision which says: This change to NetBSD's version of GNU grep 2.5.1 (licenced under GPLv2) was made without direct reference to any code licenced under GPLv3. Obtained from: NetBSD MFC after: 3 days Modified: stable/9/gnu/usr.bin/grep/dfa.c stable/9/gnu/usr.bin/grep/grep.c stable/9/gnu/usr.bin/grep/search.c Modified: stable/9/gnu/usr.bin/grep/dfa.c ============================================================================== --- stable/9/gnu/usr.bin/grep/dfa.c Mon May 20 02:10:18 2013 (r250820) +++ stable/9/gnu/usr.bin/grep/dfa.c Mon May 20 02:34:45 2013 (r250821) @@ -334,9 +334,10 @@ static int hard_LC_COLLATE; /* Nonzero i #ifdef MBS_SUPPORT /* These variables are used only if (MB_CUR_MAX > 1). */ static mbstate_t mbs; /* Mbstate for mbrlen(). */ -static int cur_mb_len; /* Byte length of the current scanning - multibyte character. */ -static int cur_mb_index; /* Byte index of the current scanning multibyte +static ssize_t cur_mb_len; /* Byte length of the current scanning + multibyte character. Must also handle + negative result from mbrlen(). */ +static ssize_t cur_mb_index; /* Byte index of the current scanning multibyte character. singlebyte character : cur_mb_index = 0 @@ -369,7 +370,7 @@ static unsigned char const *buf_end; /* /* This function update cur_mb_len, and cur_mb_index. p points current lexptr, len is the remaining buffer length. */ static void -update_mb_len_index (unsigned char const *p, int len) +update_mb_len_index (unsigned char const *p, size_t len) { /* If last character is a part of a multibyte character, we update cur_mb_index. */ @@ -2463,7 +2464,7 @@ match_mb_charset (struct dfa *d, int s, int match; /* Flag which represent that matching succeed. */ int match_len; /* Length of the character (or collating element) with which this operator match. */ - int op_len; /* Length of the operator. */ + size_t op_len; /* Length of the operator. */ char buffer[128]; wchar_t wcbuf[6]; Modified: stable/9/gnu/usr.bin/grep/grep.c ============================================================================== --- stable/9/gnu/usr.bin/grep/grep.c Mon May 20 02:10:18 2013 (r250820) +++ stable/9/gnu/usr.bin/grep/grep.c Mon May 20 02:34:45 2013 (r250821) @@ -1346,9 +1346,9 @@ int main (int argc, char **argv) { char *keys; - size_t keycc, oldcc, keyalloc; + size_t cc, keycc, oldcc, keyalloc; int with_filenames; - int opt, cc, status; + int opt, status; int default_context; FILE *fp; extern char *optarg; Modified: stable/9/gnu/usr.bin/grep/search.c ============================================================================== --- stable/9/gnu/usr.bin/grep/search.c Mon May 20 02:10:18 2013 (r250820) +++ stable/9/gnu/usr.bin/grep/search.c Mon May 20 02:34:45 2013 (r250821) @@ -112,7 +112,7 @@ static void kwsinit (void) { static char trans[NCHAR]; - int i; + size_t i; if (match_icase) for (i = 0; i < NCHAR; ++i) @@ -326,7 +326,8 @@ EGexecute (char const *buf, size_t size, { register char const *buflim, *beg, *end; char eol = eolbyte; - int backref, start, len; + int backref; + ptrdiff_t start, len; struct kwsmatch kwsm; size_t i, ret_val; static int use_dfa; From owner-svn-src-stable-9@FreeBSD.ORG Mon May 20 03:03:24 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id DAA68947; Mon, 20 May 2013 03:03:24 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id BD4DE7CD; Mon, 20 May 2013 03:03:24 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4K33On2070356; Mon, 20 May 2013 03:03:24 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4K33OJi070350; Mon, 20 May 2013 03:03:24 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201305200303.r4K33OJi070350@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Mon, 20 May 2013 03:03:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250822 - stable/9/gnu/usr.bin/grep X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 May 2013 03:03:24 -0000 Author: pfg Date: Mon May 20 03:03:23 2013 New Revision: 250822 URL: http://svnweb.freebsd.org/changeset/base/250822 Log: Revert r250821 - This was not meant to be a direct commit. (wrong tree) Pointy hat: me Modified: stable/9/gnu/usr.bin/grep/dfa.c stable/9/gnu/usr.bin/grep/grep.c stable/9/gnu/usr.bin/grep/search.c Modified: stable/9/gnu/usr.bin/grep/dfa.c ============================================================================== --- stable/9/gnu/usr.bin/grep/dfa.c Mon May 20 02:34:45 2013 (r250821) +++ stable/9/gnu/usr.bin/grep/dfa.c Mon May 20 03:03:23 2013 (r250822) @@ -334,10 +334,9 @@ static int hard_LC_COLLATE; /* Nonzero i #ifdef MBS_SUPPORT /* These variables are used only if (MB_CUR_MAX > 1). */ static mbstate_t mbs; /* Mbstate for mbrlen(). */ -static ssize_t cur_mb_len; /* Byte length of the current scanning - multibyte character. Must also handle - negative result from mbrlen(). */ -static ssize_t cur_mb_index; /* Byte index of the current scanning multibyte +static int cur_mb_len; /* Byte length of the current scanning + multibyte character. */ +static int cur_mb_index; /* Byte index of the current scanning multibyte character. singlebyte character : cur_mb_index = 0 @@ -370,7 +369,7 @@ static unsigned char const *buf_end; /* /* This function update cur_mb_len, and cur_mb_index. p points current lexptr, len is the remaining buffer length. */ static void -update_mb_len_index (unsigned char const *p, size_t len) +update_mb_len_index (unsigned char const *p, int len) { /* If last character is a part of a multibyte character, we update cur_mb_index. */ @@ -2464,7 +2463,7 @@ match_mb_charset (struct dfa *d, int s, int match; /* Flag which represent that matching succeed. */ int match_len; /* Length of the character (or collating element) with which this operator match. */ - size_t op_len; /* Length of the operator. */ + int op_len; /* Length of the operator. */ char buffer[128]; wchar_t wcbuf[6]; Modified: stable/9/gnu/usr.bin/grep/grep.c ============================================================================== --- stable/9/gnu/usr.bin/grep/grep.c Mon May 20 02:34:45 2013 (r250821) +++ stable/9/gnu/usr.bin/grep/grep.c Mon May 20 03:03:23 2013 (r250822) @@ -1346,9 +1346,9 @@ int main (int argc, char **argv) { char *keys; - size_t cc, keycc, oldcc, keyalloc; + size_t keycc, oldcc, keyalloc; int with_filenames; - int opt, status; + int opt, cc, status; int default_context; FILE *fp; extern char *optarg; Modified: stable/9/gnu/usr.bin/grep/search.c ============================================================================== --- stable/9/gnu/usr.bin/grep/search.c Mon May 20 02:34:45 2013 (r250821) +++ stable/9/gnu/usr.bin/grep/search.c Mon May 20 03:03:23 2013 (r250822) @@ -112,7 +112,7 @@ static void kwsinit (void) { static char trans[NCHAR]; - size_t i; + int i; if (match_icase) for (i = 0; i < NCHAR; ++i) @@ -326,8 +326,7 @@ EGexecute (char const *buf, size_t size, { register char const *buflim, *beg, *end; char eol = eolbyte; - int backref; - ptrdiff_t start, len; + int backref, start, len; struct kwsmatch kwsm; size_t i, ret_val; static int use_dfa; From owner-svn-src-stable-9@FreeBSD.ORG Tue May 21 06:01:41 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 9AEBAB55; Tue, 21 May 2013 06:01:41 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8CB451D2; Tue, 21 May 2013 06:01:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4L61fG1039492; Tue, 21 May 2013 06:01:41 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4L61fwg039491; Tue, 21 May 2013 06:01:41 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201305210601.r4L61fwg039491@svn.freebsd.org> From: Hans Petter Selasky Date: Tue, 21 May 2013 06:01:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250842 - stable/9/sys/dev/usb/wlan X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 May 2013 06:01:41 -0000 Author: hselasky Date: Tue May 21 06:01:41 2013 New Revision: 250842 URL: http://svnweb.freebsd.org/changeset/base/250842 Log: MFC r248566: Add new USB ID. PR: usb/177173 Modified: stable/9/sys/dev/usb/wlan/if_rum.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/wlan/if_rum.c ============================================================================== --- stable/9/sys/dev/usb/wlan/if_rum.c Tue May 21 05:51:49 2013 (r250841) +++ stable/9/sys/dev/usb/wlan/if_rum.c Tue May 21 06:01:41 2013 (r250842) @@ -120,6 +120,7 @@ static const STRUCT_USB_HOST_ID rum_devs RUM_DEV(HUAWEI3COM, WUB320G), RUM_DEV(MELCO, G54HP), RUM_DEV(MELCO, SG54HP), + RUM_DEV(MELCO, SG54HG), RUM_DEV(MELCO, WLIUCG), RUM_DEV(MELCO, WLRUCG), RUM_DEV(MELCO, WLRUCGAOSS), From owner-svn-src-stable-9@FreeBSD.ORG Tue May 21 06:06:53 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6674EDD; Tue, 21 May 2013 06:06:53 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5896C202; Tue, 21 May 2013 06:06:53 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4L66rs3040779; Tue, 21 May 2013 06:06:53 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4L66rrm040777; Tue, 21 May 2013 06:06:53 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201305210606.r4L66rrm040777@svn.freebsd.org> From: Hans Petter Selasky Date: Tue, 21 May 2013 06:06:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250845 - in stable/9/sys/dev/usb: . serial X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 May 2013 06:06:53 -0000 Author: hselasky Date: Tue May 21 06:06:52 2013 New Revision: 250845 URL: http://svnweb.freebsd.org/changeset/base/250845 Log: MFC r248499: Add new USB ID. PR: usb/177105 Modified: stable/9/sys/dev/usb/serial/u3g.c stable/9/sys/dev/usb/usbdevs Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/serial/u3g.c ============================================================================== --- stable/9/sys/dev/usb/serial/u3g.c Tue May 21 06:06:16 2013 (r250844) +++ stable/9/sys/dev/usb/serial/u3g.c Tue May 21 06:06:52 2013 (r250845) @@ -242,6 +242,8 @@ static const STRUCT_USB_HOST_ID u3g_devs U3G_DEV(DELL, U5730_2, 0), U3G_DEV(DELL, U5730_3, 0), U3G_DEV(DELL, U740, 0), + U3G_DEV(DLINK, DWR510_CD, U3GINIT_SCSIEJECT), + U3G_DEV(DLINK, DWR510, 0), U3G_DEV(DLINK3, DWM652, 0), U3G_DEV(HP, EV2200, 0), U3G_DEV(HP, HS2300, 0), Modified: stable/9/sys/dev/usb/usbdevs ============================================================================== --- stable/9/sys/dev/usb/usbdevs Tue May 21 06:06:16 2013 (r250844) +++ stable/9/sys/dev/usb/usbdevs Tue May 21 06:06:52 2013 (r250845) @@ -1509,6 +1509,8 @@ product DLINK DSB650TX3 0x400b 10/100 E product DLINK DSB650TX2 0x4102 10/100 Ethernet product DLINK DSB650 0xabc1 10/100 Ethernet product DLINK DUBH7 0xf103 DUB-H7 USB 2.0 7-Port Hub +product DLINK DWR510_CD 0xa805 DWR-510 CD-ROM Mode +product DLINK DWR510 0x7e12 DWR-510 product DLINK2 DWA120 0x3a0c DWA-120 product DLINK2 DWA120_NF 0x3a0d DWA-120 (no firmware) product DLINK2 DWLG122C1 0x3c03 DWL-G122 c1 From owner-svn-src-stable-9@FreeBSD.ORG Tue May 21 06:10:27 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 619A54C3; Tue, 21 May 2013 06:10:27 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 546AD22B; Tue, 21 May 2013 06:10:27 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4L6AR7J041906; Tue, 21 May 2013 06:10:27 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4L6AQGC041903; Tue, 21 May 2013 06:10:26 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201305210610.r4L6AQGC041903@svn.freebsd.org> From: Hans Petter Selasky Date: Tue, 21 May 2013 06:10:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250847 - in stable/9/sys/dev/usb: . wlan X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 May 2013 06:10:27 -0000 Author: hselasky Date: Tue May 21 06:10:26 2013 New Revision: 250847 URL: http://svnweb.freebsd.org/changeset/base/250847 Log: MFC r248458: Add new USB ID. PR: usb/177013 Modified: stable/9/sys/dev/usb/usbdevs stable/9/sys/dev/usb/wlan/if_run.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/usbdevs ============================================================================== --- stable/9/sys/dev/usb/usbdevs Tue May 21 06:09:19 2013 (r250846) +++ stable/9/sys/dev/usb/usbdevs Tue May 21 06:10:26 2013 (r250847) @@ -2491,6 +2491,7 @@ product LOGITEC RT2870_2 0x0163 RT2870 product LOGITEC RT2870_3 0x0164 RT2870 product LOGITEC LANW300NU2 0x0166 LAN-W300N/U2 product LOGITEC LANW150NU2 0x0168 LAN-W150N/U2 +product LOGITEC LANW300NU2S 0x0169 LAN-W300N/U2S /* Longcheer Holdings, Ltd. products */ product LONGCHEER WM66 0x6061 Longcheer WM66 HSDPA Modified: stable/9/sys/dev/usb/wlan/if_run.c ============================================================================== --- stable/9/sys/dev/usb/wlan/if_run.c Tue May 21 06:09:19 2013 (r250846) +++ stable/9/sys/dev/usb/wlan/if_run.c Tue May 21 06:10:26 2013 (r250847) @@ -211,6 +211,7 @@ static const STRUCT_USB_HOST_ID run_devs RUN_DEV(LOGITEC, RT2870_3), RUN_DEV(LOGITEC, LANW300NU2), RUN_DEV(LOGITEC, LANW150NU2), + RUN_DEV(LOGITEC, LANW300NU2S), RUN_DEV(MELCO, RT2870_1), RUN_DEV(MELCO, RT2870_2), RUN_DEV(MELCO, WLIUCAG300N), From owner-svn-src-stable-9@FreeBSD.ORG Tue May 21 19:04:18 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id A30AC5EA; Tue, 21 May 2013 19:04:18 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 9477275D; Tue, 21 May 2013 19:04:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4LJ4Ij4015813; Tue, 21 May 2013 19:04:18 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4LJ4HpW015804; Tue, 21 May 2013 19:04:17 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201305211904.r4LJ4HpW015804@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 21 May 2013 19:04:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250870 - in stable/9: . lib/libprocstat X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 May 2013 19:04:18 -0000 Author: trociny Date: Tue May 21 19:04:16 2013 New Revision: 250870 URL: http://svnweb.freebsd.org/changeset/base/250870 Log: MFC r249666, r249667, r249670, r249672, r249674, r249676, r249677, r249679, r249681, r249684, r249688, r249711, r249731, r250146 r249666, r249682: Make libprocstat(3) extract procstat notes from a process core file. PR: kern/173723 Suggested by: jhb Glanced by: kib r249667: Add procstat_getvmmap function to get VM layout of a process. r249670: Add procstat_getgroups function to retrieve process groups. r249672: Add procstat_getumask function to retrieve a process umask. r249674: Add procstat_getrlimit function to retrieve a process resource limits info. r249676: Add procstat_getpathname function to retrieve a process executable. r249677: Add procstat_getosrel function to retrieve a process osrel info. r249679: Extend libprocstat with functions to retrieve process command line arguments and environment variables. Suggested by: stas Reviewed by: jhb and stas (initial version) r249681: Add procstat_getauxv function to retrieve a process auxiliary vector. r249684: Add procstat_getkstack function to dump kernel stacks of a process. r249688: Bump date. r249711 (joel): mdoc: end function context properly. r249731: Embed revision id in the library. r250146: KVM method support for procstat_getgroups, procstat_getumask, procstat_getrlimit, and procstat_getosrel. Added: stable/9/lib/libprocstat/core.c - copied, changed from r249666, head/lib/libprocstat/core.c stable/9/lib/libprocstat/core.h - copied, changed from r249666, head/lib/libprocstat/core.h Modified: stable/9/Makefile.inc1 (contents, props changed) stable/9/lib/libprocstat/Makefile stable/9/lib/libprocstat/Symbol.map stable/9/lib/libprocstat/libprocstat.3 stable/9/lib/libprocstat/libprocstat.c stable/9/lib/libprocstat/libprocstat.h stable/9/lib/libprocstat/libprocstat_internal.h Directory Properties: stable/9/lib/libprocstat/ (props changed) Modified: stable/9/Makefile.inc1 ============================================================================== --- stable/9/Makefile.inc1 Tue May 21 18:52:37 2013 (r250869) +++ stable/9/Makefile.inc1 Tue May 21 19:04:16 2013 (r250870) @@ -1371,7 +1371,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \ ${_kerberos5_lib_libroken} \ lib/libbz2 lib/libcom_err lib/libcrypt \ - lib/libexpat \ + lib/libelf lib/libexpat \ ${_lib_libgssapi} ${_lib_libipx} \ lib/libkiconv lib/libkvm lib/liblzma lib/libmd \ lib/ncurses/ncurses lib/ncurses/ncursesw \ Modified: stable/9/lib/libprocstat/Makefile ============================================================================== --- stable/9/lib/libprocstat/Makefile Tue May 21 18:52:37 2013 (r250869) +++ stable/9/lib/libprocstat/Makefile Tue May 21 19:04:16 2013 (r250870) @@ -6,6 +6,7 @@ LIB= procstat SRCS= cd9660.c \ common_kvm.c \ + core.c \ libprocstat.c \ msdosfs.c \ ntfs.c \ @@ -19,8 +20,8 @@ INCS= libprocstat.h CFLAGS+= -I. -I${.CURDIR} -D_KVM_VNODE SHLIB_MAJOR= 1 -DPADD= ${LIBKVM} ${LIBUTIL} -LDADD= -lkvm -lutil +DPADD= ${LIBELF} ${LIBKVM} ${LIBUTIL} +LDADD= -lelf -lkvm -lutil MAN= libprocstat.3 Modified: stable/9/lib/libprocstat/Symbol.map ============================================================================== --- stable/9/lib/libprocstat/Symbol.map Tue May 21 18:52:37 2013 (r250869) +++ stable/9/lib/libprocstat/Symbol.map Tue May 21 19:04:16 2013 (r250870) @@ -16,5 +16,22 @@ FBSD_1.2 { }; FBSD_1.3 { + procstat_freeargv; + procstat_freeauxv; + procstat_freeenvv; + procstat_freegroups; + procstat_freekstack; + procstat_freevmmap; procstat_get_shm_info; + procstat_getargv; + procstat_getauxv; + procstat_getenvv; + procstat_getgroups; + procstat_getkstack; + procstat_getosrel; + procstat_getpathname; + procstat_getrlimit; + procstat_getumask; + procstat_getvmmap; + procstat_open_core; }; Copied and modified: stable/9/lib/libprocstat/core.c (from r249666, head/lib/libprocstat/core.c) ============================================================================== --- head/lib/libprocstat/core.c Sat Apr 20 07:47:26 2013 (r249666, copy source) +++ stable/9/lib/libprocstat/core.c Tue May 21 19:04:16 2013 (r250870) @@ -22,12 +22,14 @@ * 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 @@ -56,6 +58,10 @@ struct procstat_core static bool core_offset(struct procstat_core *core, off_t offset); static bool core_read(struct procstat_core *core, void *buf, size_t len); +static ssize_t core_read_mem(struct procstat_core *core, void *buf, + size_t len, vm_offset_t addr, bool readall); +static void *get_args(struct procstat_core *core, vm_offset_t psstrings, + enum psc_type type, void *buf, size_t *lenp); struct procstat_core * procstat_core_open(const char *filename) @@ -146,6 +152,7 @@ procstat_core_get(struct procstat_core * { Elf_Note nhdr; off_t offset, eoffset; + vm_offset_t psstrings; void *freebuf; size_t len; u_int32_t n_type; @@ -167,6 +174,32 @@ procstat_core_get(struct procstat_core * n_type = NT_PROCSTAT_VMMAP; structsize = sizeof(struct kinfo_vmentry); break; + case PSC_TYPE_GROUPS: + n_type = NT_PROCSTAT_GROUPS; + structsize = sizeof(gid_t); + break; + case PSC_TYPE_UMASK: + n_type = NT_PROCSTAT_UMASK; + structsize = sizeof(u_short); + break; + case PSC_TYPE_RLIMIT: + n_type = NT_PROCSTAT_RLIMIT; + structsize = sizeof(struct rlimit) * RLIM_NLIMITS; + break; + case PSC_TYPE_OSREL: + n_type = NT_PROCSTAT_OSREL; + structsize = sizeof(int); + break; + case PSC_TYPE_PSSTRINGS: + case PSC_TYPE_ARGV: + case PSC_TYPE_ENVV: + n_type = NT_PROCSTAT_PSSTRINGS; + structsize = sizeof(vm_offset_t); + break; + case PSC_TYPE_AUXV: + n_type = NT_PROCSTAT_AUXV; + structsize = sizeof(Elf_Auxinfo); + break; default: warnx("unknown core stat type: %d", type); return (NULL); @@ -222,6 +255,19 @@ procstat_core_get(struct procstat_core * free(freebuf); return (NULL); } + if (type == PSC_TYPE_ARGV || type == PSC_TYPE_ENVV) { + if (len < sizeof(psstrings)) { + free(freebuf); + return (NULL); + } + psstrings = *(vm_offset_t *)buf; + if (freebuf == NULL) + len = *lenp; + else + buf = NULL; + free(freebuf); + buf = get_args(core, psstrings, type, buf, &len); + } *lenp = len; return (buf); } @@ -260,3 +306,128 @@ core_read(struct procstat_core *core, vo } return (true); } + +static ssize_t +core_read_mem(struct procstat_core *core, void *buf, size_t len, + vm_offset_t addr, bool readall) +{ + GElf_Phdr phdr; + off_t offset; + int i; + + assert(core->pc_magic == PROCSTAT_CORE_MAGIC); + + for (i = 0; i < core->pc_ehdr.e_phnum; i++) { + if (gelf_getphdr(core->pc_elf, i, &phdr) != &phdr) { + warnx("gelf_getphdr: %s", elf_errmsg(-1)); + return (-1); + } + if (phdr.p_type != PT_LOAD) + continue; + if (addr < phdr.p_vaddr || addr > phdr.p_vaddr + phdr.p_memsz) + continue; + offset = phdr.p_offset + (addr - phdr.p_vaddr); + if ((phdr.p_vaddr + phdr.p_memsz) - addr < len) { + if (readall) { + warnx("format error: " + "attempt to read out of segment"); + return (-1); + } + len = (phdr.p_vaddr + phdr.p_memsz) - addr; + } + if (!core_offset(core, offset)) + return (-1); + if (!core_read(core, buf, len)) + return (-1); + return (len); + } + warnx("format error: address %ju not found", (uintmax_t)addr); + return (-1); +} + +#define ARGS_CHUNK_SZ 256 /* Chunk size (bytes) for get_args operations. */ + +static void * +get_args(struct procstat_core *core, vm_offset_t psstrings, enum psc_type type, + void *args, size_t *lenp) +{ + struct ps_strings pss; + void *freeargs; + vm_offset_t addr; + char **argv, *p; + size_t chunksz, done, len, nchr, size; + ssize_t n; + u_int i, nstr; + + assert(type == PSC_TYPE_ARGV || type == PSC_TYPE_ENVV); + + if (core_read_mem(core, &pss, sizeof(pss), psstrings, true) == -1) + return (NULL); + if (type == PSC_TYPE_ARGV) { + addr = (vm_offset_t)pss.ps_argvstr; + nstr = pss.ps_nargvstr; + } else /* type == PSC_TYPE_ENVV */ { + addr = (vm_offset_t)pss.ps_envstr; + nstr = pss.ps_nenvstr; + } + if (addr == 0 || nstr == 0) + return (NULL); + if (nstr > ARG_MAX) { + warnx("format error"); + return (NULL); + } + size = nstr * sizeof(char *); + argv = malloc(size); + if (argv == NULL) { + warn("malloc(%zu)", size); + return (NULL); + } + done = 0; + freeargs = NULL; + if (core_read_mem(core, argv, size, addr, true) == -1) + goto fail; + if (args != NULL) { + nchr = MIN(ARG_MAX, *lenp); + } else { + nchr = ARG_MAX; + freeargs = args = malloc(nchr); + if (args == NULL) { + warn("malloc(%zu)", nchr); + goto fail; + } + } + p = args; + for (i = 0; ; i++) { + if (i == nstr) + goto done; + /* + * The program may have scribbled into its argv array, e.g. to + * remove some arguments. If that has happened, break out + * before trying to read from NULL. + */ + if (argv[i] == NULL) + goto done; + for (addr = (vm_offset_t)argv[i]; ; addr += chunksz) { + chunksz = MIN(ARGS_CHUNK_SZ, nchr - 1 - done); + if (chunksz <= 0) + goto done; + n = core_read_mem(core, p, chunksz, addr, false); + if (n == -1) + goto fail; + len = strnlen(p, chunksz); + p += len; + done += len; + if (len != chunksz) + break; + } + *p++ = '\0'; + done++; + } +fail: + free(freeargs); + args = NULL; +done: + *lenp = done; + free(argv); + return (args); +} Copied and modified: stable/9/lib/libprocstat/core.h (from r249666, head/lib/libprocstat/core.h) ============================================================================== --- head/lib/libprocstat/core.h Sat Apr 20 07:47:26 2013 (r249666, copy source) +++ stable/9/lib/libprocstat/core.h Tue May 21 19:04:16 2013 (r250870) @@ -33,6 +33,14 @@ enum psc_type { PSC_TYPE_PROC, PSC_TYPE_FILES, PSC_TYPE_VMMAP, + PSC_TYPE_GROUPS, + PSC_TYPE_UMASK, + PSC_TYPE_RLIMIT, + PSC_TYPE_OSREL, + PSC_TYPE_PSSTRINGS, + PSC_TYPE_ARGV, + PSC_TYPE_ENVV, + PSC_TYPE_AUXV, }; struct procstat_core; Modified: stable/9/lib/libprocstat/libprocstat.3 ============================================================================== --- stable/9/lib/libprocstat/libprocstat.3 Tue May 21 18:52:37 2013 (r250869) +++ stable/9/lib/libprocstat/libprocstat.3 Tue May 21 19:04:16 2013 (r250870) @@ -24,17 +24,33 @@ .\" .\" $FreeBSD$ .\" -.Dd April 1, 2012 +.Dd April 20, 2013 .Dt LIBPROCSTAT 3 .Os .Sh NAME +.Nm procstat_open_core , .Nm procstat_open_kvm , .Nm procstat_open_sysctl , .Nm procstat_close , +.Nm procstat_getargv , +.Nm procstat_getauxv , +.Nm procstat_getenvv , .Nm procstat_getfiles , +.Nm procstat_getgroups , +.Nm procstat_getkstack , +.Nm procstat_getosrel , +.Nm procstat_getpathname , .Nm procstat_getprocs , +.Nm procstat_getumask , +.Nm procstat_getvmmap , +.Nm procstat_freeargv , +.Nm procstat_freeauxv , +.Nm procstat_freeenvv , .Nm procstat_freefiles , +.Nm procstat_freegroups , +.Nm procstat_freekstack , .Nm procstat_freeprocs , +.Nm procstat_freevmmap , .Nm procstat_get_pipe_info , .Nm procstat_get_pts_info , .Nm procstat_get_shm_info , @@ -50,12 +66,40 @@ .Ft void .Fn procstat_close "struct procstat *procstat" .Ft void +.Fo procstat_freeargv +.Fa "struct procstat *procstat" +.Fc +.Ft void +.Fo procstat_freeauxv +.Fa "struct procstat *procstat" +.Fa "Elf_Auxinfo *auxv" +.Fc +.Ft void +.Fo procstat_freeenvv +.Fa "struct procstat *procstat" +.Fc +.Ft void .Fo procstat_freefiles .Fa "struct procstat *procstat" .Fa "struct filestat_list *head" .Fc .Ft void +.Fo procstat_freegroups +.Fa "struct procstat *procstat" +.Fa "gid_t *groups" +.Fc +.Ft void +.Fo procstat_freekstack +.Fa "struct procstat *procstat" +.Fa "struct kinfo_kstack *kkstp" +.Fc +.Ft void .Fn procstat_freeprocs "struct procstat *procstat" "struct kinfo_proc *p" +.Ft void +.Fo procstat_freevmmap +.Fa "struct procstat *procstat" +.Fa "struct kinfo_vmentry *vmmap" +.Fc .Ft int .Fo procstat_get_pipe_info .Fa "struct procstat *procstat" @@ -91,12 +135,50 @@ .Fa "struct vnstat *vn" .Fa "char *errbuf" .Fc +.Ft "char **" +.Fo procstat_getargv +.Fa "struct procstat *procstat" +.Fa "const struct kinfo_proc *kp" +.Fa "size_t nchr" +.Fa "char *errbuf" +.Fc +.Ft "Elf_Auxinfo *" +.Fo procstat_getauxv +.Fa "struct procstat *procstat" +.Fa "struct kinfo_proc *kp" +.Fa "unsigned int *count" +.Fc +.Ft "char **" +.Fo procstat_getenvv +.Fa "struct procstat *procstat" +.Fa "const struct kinfo_proc *kp" +.Fa "size_t nchr" +.Fa "char *errbuf" +.Fc .Ft "struct filestat_list *" .Fo procstat_getfiles .Fa "struct procstat *procstat" .Fa "struct kinfo_proc *kp" .Fa "int mmapped" .Fc +.Ft "gid_t *" +.Fo procstat_getgroups +.Fa "struct procstat *procstat" +.Fa "struct kinfo_proc *kp" +.Fa "unsigned int *count" +.Fc +.Ft int +.Fo procstat_getosrel +.Fa "struct procstat *procstat" +.Fa "struct kinfo_proc *kp" +.Fa "int *osrelp" +.Fc +.Ft "struct kinfo_kstack *" +.Fo procstat_getkstack +.Fa "struct procstat *procstat" +.Fa "struct kinfo_proc *kp" +.Fa "unsigned int *count" +.Fc .Ft "struct kinfo_proc *" .Fo procstat_getprocs .Fa "struct procstat *procstat" @@ -104,6 +186,34 @@ .Fa "int arg" .Fa "unsigned int *count" .Fc +.Ft "int" +.Fo procstat_getpathname +.Fa "struct procstat *procstat" +.Fa "struct kinfo_proc *kp" +.Fa "char *pathname" +.Fa "size_t maxlen" +.Fc +.Ft "int" +.Fo procstat_getrlimit +.Fa "struct procstat *procstat" +.Fa "struct kinfo_proc *kp" +.Fa "int which" +.Fa "struct rlimit* rlimit" +.Fc +.Ft "int" +.Fo procstat_getumask +.Fa "struct procstat *procstat" +.Fa "struct kinfo_proc *kp" +.Fa "unsigned short *maskp" +.Fc +.Ft "struct kinfo_vmentry *" +.Fo procstat_getvmmap +.Fa "struct procstat *procstat" +.Fa "struct kinfo_proc *kp" +.Fa "unsigned int *count" +.Fc +.Ft "struct procstat *" +.Fn procstat_open_core "const char *filename" .Ft "struct procstat *" .Fn procstat_open_kvm "const char *nlistf" "const char *memf" .Ft "struct procstat *" @@ -116,7 +226,11 @@ retrieval from the running kernel via th .Xr sysctl 3 library backend, and for post-mortem analysis via the .Xr kvm 3 -library backend. +library backend, or from the process +.Xr core 5 +file, searching for statistics in special +.Xr elf 3 +note sections. .Pp The .Fn procstat_open_kvm @@ -129,6 +243,16 @@ or library routines, respectively, to access kernel state information used to retrieve processes and files states. The +.Fn procstat_open_core +uses +.Xr elf 3 +routines to access statistics stored as a set of notes in a process +.Xr core 5 +file, written by the kernel at the moment of the process abnormal termination. +The +.Fa filename +argument is the process core file name. +The .Fa nlistf argument is the executable image of the kernel being examined. If this argument is @@ -145,7 +269,7 @@ is assumed. See .Xr kvm_open 3 for more details. -Both functions dynamically allocate and return a +The functions dynamically allocate and return a .Vt procstat structure pointer used in the rest of the .Nm libprocstat @@ -179,6 +303,63 @@ The caller is responsible to free the al function call. .Pp The +.Fn procstat_getargv +function gets a pointer to the +.Vt procstat +structure from one of the +.Fn procstat_open_* +functions, a pointer to +.Vt kinfo_proc +structure from the array obtained from the +.Fn kvm_getprocs +function, and returns a null-terminated argument vector that corresponds to +the command line arguments passed to the process. +The +.Fa nchr +argument indicates the maximum number of characters, including null bytes, +to use in building the strings. +If this amount is exceeded, the string causing the overflow is truncated and +the partial result is returned. +This is handy for programs that print only a one line summary of a +command and should not copy out large amounts of text only to ignore it. +If +.Fa nchr +is zero, no limit is imposed and all argument strings are returned. +The values of the returned argument vector refer the strings stored +in the +.Vt procstat +internal buffer. +A subsequent call of the function with the same +.Vt procstat +argument will reuse the buffer. +To free the allocated memory +.Fn procstat_freeargv +function call can be used, or it will be released on +.Fn procstat_close . +.Pp +The +.Fn procstat_getenvv +function is similar to +.Fn procstat_getargv +but returns the vector of environment strings. +The caller may free the allocated memory with a subsequent +.Fn procstat_freeenv +function call. +.Pp +The +.Fn procstat_getauxv +function gets a pointer to the +.Vt procstat +structure, a pointer to +.Vt kinfo_proc +structure, and returns the auxiliary vector as a dynamically allocated array of +.Vt Elf_Auxinfo +elements. +The caller is responsible to free the allocated memory with a subsequent +.Fn procstat_freeauxv +function call. +.Pp +The .Fn procstat_getfiles function gets a pointer to the .Vt procstat @@ -197,6 +378,89 @@ The caller is responsible to free the al function call. .Pp The +.Fn procstat_getgroups +function gets a pointer to the +.Vt procstat +structure, a pointer to +.Vt kinfo_proc +structure, and returns the process groups as a dynamically allocated array of +.Vt gid_t +elements. +The caller is responsible to free the allocated memory with a subsequent +.Fn procstat_freegroups +function call. +.Pp +The +.Fn procstat_getkstack +function gets a pointer to the +.Vt procstat +structure initialized with one of the +.Fn procstat_open_* +functions, a pointer to +.Vt kinfo_proc +structure, and returns kernel stacks of the process as a dynamically allocated +array of +.Vt kinfo_kstack +structures. +The caller is responsible to free the allocated memory with a subsequent +.Fn procstat_freekstack +function call. +.Pp +The +.Fn procstat_getosrel +function gets a pointer to the +.Vt procstat +structure, a pointer to +.Vt kinfo_proc +structure, and returns osrel date in the 3rd reference parameter. +.Pp +The +.Fn procstat_getpathname +function gets a pointer to the +.Vt procstat +structure, a pointer to +.Vt kinfo_proc +structure, and copies the path of the process executable to +.Fa pathname +buffer, limiting to +.Fa maxlen +characters. +.Pp +The +.Fn procstat_getrlimit +function gets a pointer to the +.Vt procstat +structure, a pointer to +.Vt kinfo_proc +structure, resource index +.Fa which , +and returns the actual resource limit in the 4th reference parameter. +.Pp +The +.Fn procstat_getumask +function gets a pointer to the +.Vt procstat +structure, a pointer to +.Vt kinfo_proc +structure, and returns the process umask in the 3rd reference parameter. +.Pp +The +.Fn procstat_getvmmap +function gets a pointer to the +.Vt procstat +structure initialized with one of the +.Fn procstat_open_* +functions, a pointer to +.Vt kinfo_proc +structure, and returns VM layout of the process as a dynamically allocated +array of +.Vt kinfo_vmentry +structures. +The caller is responsible to free the allocated memory with a subsequent +.Fn procstat_freevmmap +function call. +.Pp +The .Fn procstat_get_pipe_info , .Fn procstat_get_pts_info , .Fn procstat_get_shm_info , @@ -250,10 +514,12 @@ argument indicates an actual error messa .Xr pipe 2 , .Xr shm_open 2 , .Xr socket 2 , +.Xr elf 3 , .Xr kvm 3 , .Xr queue 3 , .Xr sysctl 3 , .Xr pts 4 , +.Xr core 5 , .Xr vnode 9 .Sh HISTORY The Modified: stable/9/lib/libprocstat/libprocstat.c ============================================================================== --- stable/9/lib/libprocstat/libprocstat.c Tue May 21 18:52:37 2013 (r250869) +++ stable/9/lib/libprocstat/libprocstat.c Tue May 21 19:04:16 2013 (r250870) @@ -36,7 +36,12 @@ __FBSDID("$FreeBSD$"); #include +#include #include +#include +#define _WANT_UCRED +#include +#undef _WANT_UCRED #include #include #include @@ -96,13 +101,22 @@ __FBSDID("$FreeBSD$"); #include #include "libprocstat_internal.h" #include "common_kvm.h" +#include "core.h" int statfs(const char *, struct statfs *); /* XXX */ #define PROCSTAT_KVM 1 #define PROCSTAT_SYSCTL 2 +#define PROCSTAT_CORE 3 +static char **getargv(struct procstat *procstat, struct kinfo_proc *kp, + size_t nchr, int env); static char *getmnton(kvm_t *kd, struct mount *m); +static struct kinfo_vmentry * kinfo_getvmmap_core(struct procstat_core *core, + int *cntp); +static Elf_Auxinfo *procstat_getauxv_core(struct procstat_core *core, + unsigned int *cntp); +static Elf_Auxinfo *procstat_getauxv_sysctl(pid_t pid, unsigned int *cntp); static struct filestat_list *procstat_getfiles_kvm( struct procstat *procstat, struct kinfo_proc *kp, int mmapped); static struct filestat_list *procstat_getfiles_sysctl( @@ -128,6 +142,33 @@ static int procstat_get_vnode_info_kvm(k struct vnstat *vn, char *errbuf); static int procstat_get_vnode_info_sysctl(struct filestat *fst, struct vnstat *vn, char *errbuf); +static gid_t *procstat_getgroups_core(struct procstat_core *core, + unsigned int *count); +static gid_t * procstat_getgroups_kvm(kvm_t *kd, struct kinfo_proc *kp, + unsigned int *count); +static gid_t *procstat_getgroups_sysctl(pid_t pid, unsigned int *count); +static struct kinfo_kstack *procstat_getkstack_sysctl(pid_t pid, + int *cntp); +static int procstat_getosrel_core(struct procstat_core *core, + int *osrelp); +static int procstat_getosrel_kvm(kvm_t *kd, struct kinfo_proc *kp, + int *osrelp); +static int procstat_getosrel_sysctl(pid_t pid, int *osrelp); +static int procstat_getpathname_core(struct procstat_core *core, + char *pathname, size_t maxlen); +static int procstat_getpathname_sysctl(pid_t pid, char *pathname, + size_t maxlen); +static int procstat_getrlimit_core(struct procstat_core *core, int which, + struct rlimit* rlimit); +static int procstat_getrlimit_kvm(kvm_t *kd, struct kinfo_proc *kp, + int which, struct rlimit* rlimit); +static int procstat_getrlimit_sysctl(pid_t pid, int which, + struct rlimit* rlimit); +static int procstat_getumask_core(struct procstat_core *core, + unsigned short *maskp); +static int procstat_getumask_kvm(kvm_t *kd, struct kinfo_proc *kp, + unsigned short *maskp); +static int procstat_getumask_sysctl(pid_t pid, unsigned short *maskp); static int vntype2psfsttype(int type); void @@ -137,6 +178,10 @@ procstat_close(struct procstat *procstat assert(procstat); if (procstat->type == PROCSTAT_KVM) kvm_close(procstat->kd); + else if (procstat->type == PROCSTAT_CORE) + procstat_core_close(procstat->core); + procstat_freeargv(procstat); + procstat_freeenvv(procstat); free(procstat); } @@ -177,6 +222,27 @@ procstat_open_kvm(const char *nlistf, co return (procstat); } +struct procstat * +procstat_open_core(const char *filename) +{ + struct procstat *procstat; + struct procstat_core *core; + + procstat = calloc(1, sizeof(*procstat)); + if (procstat == NULL) { + warn("malloc()"); + return (NULL); + } + core = procstat_core_open(filename); + if (core == NULL) { + free(procstat); + return (NULL); + } + procstat->type = PROCSTAT_CORE; + procstat->core = core; + return (procstat); +} + struct kinfo_proc * procstat_getprocs(struct procstat *procstat, int what, int arg, unsigned int *count) @@ -231,6 +297,15 @@ procstat_getprocs(struct procstat *procs } /* Perform simple consistency checks. */ if ((len % sizeof(*p)) != 0 || p->ki_structsize != sizeof(*p)) { + warnx("kinfo_proc structure size mismatch (len = %zu)", len); + goto fail; + } + *count = len / sizeof(*p); + return (p); + } else if (procstat->type == PROCSTAT_CORE) { + p = procstat_core_get(procstat->core, PSC_TYPE_PROC, NULL, + &len); + if ((len % sizeof(*p)) != 0 || p->ki_structsize != sizeof(*p)) { warnx("kinfo_proc structure size mismatch"); goto fail; } @@ -258,13 +333,17 @@ procstat_freeprocs(struct procstat *proc struct filestat_list * procstat_getfiles(struct procstat *procstat, struct kinfo_proc *kp, int mmapped) { - - if (procstat->type == PROCSTAT_SYSCTL) - return (procstat_getfiles_sysctl(procstat, kp, mmapped)); - else if (procstat->type == PROCSTAT_KVM) + + switch(procstat->type) { + case PROCSTAT_KVM: return (procstat_getfiles_kvm(procstat, kp, mmapped)); - else + case PROCSTAT_SYSCTL: + case PROCSTAT_CORE: + return (procstat_getfiles_sysctl(procstat, kp, mmapped)); + default: + warnx("unknown access method: %d", procstat->type); return (NULL); + } } void @@ -647,8 +726,62 @@ kinfo_uflags2fst(int fd) return (0); } +static struct kinfo_file * +kinfo_getfile_core(struct procstat_core *core, int *cntp) +{ + int cnt; + size_t len; + char *buf, *bp, *eb; + struct kinfo_file *kif, *kp, *kf; + + buf = procstat_core_get(core, PSC_TYPE_FILES, NULL, &len); + if (buf == NULL) + return (NULL); + /* + * XXXMG: The code below is just copy&past from libutil. + * The code duplication can be avoided if libutil + * is extended to provide something like: + * struct kinfo_file *kinfo_getfile_from_buf(const char *buf, + * size_t len, int *cntp); + */ + + /* Pass 1: count items */ + cnt = 0; + bp = buf; + eb = buf + len; + while (bp < eb) { + kf = (struct kinfo_file *)(uintptr_t)bp; + bp += kf->kf_structsize; + cnt++; + } + + kif = calloc(cnt, sizeof(*kif)); + if (kif == NULL) { + free(buf); + return (NULL); + } + bp = buf; + eb = buf + len; + kp = kif; + /* Pass 2: unpack */ + while (bp < eb) { + kf = (struct kinfo_file *)(uintptr_t)bp; + /* Copy/expand into pre-zeroed buffer */ + memcpy(kp, kf, kf->kf_structsize); + /* Advance to next packed record */ + bp += kf->kf_structsize; + /* Set field size to fixed length, advance */ + kp->kf_structsize = sizeof(*kp); + kp++; + } + free(buf); + *cntp = cnt; + return (kif); /* Caller must free() return value */ +} + static struct filestat_list * -procstat_getfiles_sysctl(struct procstat *procstat, struct kinfo_proc *kp, int mmapped) +procstat_getfiles_sysctl(struct procstat *procstat, struct kinfo_proc *kp, + int mmapped) { struct kinfo_file *kif, *files; struct kinfo_vmentry *kve, *vmentries; @@ -664,8 +797,16 @@ procstat_getfiles_sysctl(struct procstat assert(kp); if (kp->ki_fd == NULL) return (NULL); - - files = kinfo_getfile(kp->ki_pid, &cnt); + switch(procstat->type) { + case PROCSTAT_SYSCTL: + files = kinfo_getfile(kp->ki_pid, &cnt); + break; + case PROCSTAT_CORE: + files = kinfo_getfile_core(procstat->core, &cnt); + break; + default: + assert(!"invalid type"); + } if (files == NULL && errno != EPERM) { warn("kinfo_getfile()"); return (NULL); @@ -703,7 +844,7 @@ procstat_getfiles_sysctl(struct procstat STAILQ_INSERT_TAIL(head, entry, next); } if (mmapped != 0) { - vmentries = kinfo_getvmmap(kp->ki_pid, &cnt); + vmentries = procstat_getvmmap(procstat, kp, &cnt); procstat->vmentries = vmentries; if (vmentries == NULL || cnt == 0) goto fail; @@ -743,7 +884,8 @@ procstat_get_pipe_info(struct procstat * if (procstat->type == PROCSTAT_KVM) { return (procstat_get_pipe_info_kvm(procstat->kd, fst, ps, errbuf)); - } else if (procstat->type == PROCSTAT_SYSCTL) { + } else if (procstat->type == PROCSTAT_SYSCTL || + procstat->type == PROCSTAT_CORE) { return (procstat_get_pipe_info_sysctl(fst, ps, errbuf)); } else { warnx("unknown access method: %d", procstat->type); @@ -807,7 +949,8 @@ procstat_get_pts_info(struct procstat *p if (procstat->type == PROCSTAT_KVM) { return (procstat_get_pts_info_kvm(procstat->kd, fst, pts, errbuf)); - } else if (procstat->type == PROCSTAT_SYSCTL) { + } else if (procstat->type == PROCSTAT_SYSCTL || + procstat->type == PROCSTAT_CORE) { return (procstat_get_pts_info_sysctl(fst, pts, errbuf)); } else { warnx("unknown access method: %d", procstat->type); @@ -869,7 +1012,8 @@ procstat_get_shm_info(struct procstat *p if (procstat->type == PROCSTAT_KVM) { return (procstat_get_shm_info_kvm(procstat->kd, fst, shm, errbuf)); - } else if (procstat->type == PROCSTAT_SYSCTL) { + } else if (procstat->type == PROCSTAT_SYSCTL || + procstat->type == PROCSTAT_CORE) { return (procstat_get_shm_info_sysctl(fst, shm, errbuf)); } else { warnx("unknown access method: %d", procstat->type); @@ -949,7 +1093,8 @@ procstat_get_vnode_info(struct procstat if (procstat->type == PROCSTAT_KVM) { return (procstat_get_vnode_info_kvm(procstat->kd, fst, vn, errbuf)); - } else if (procstat->type == PROCSTAT_SYSCTL) { + } else if (procstat->type == PROCSTAT_SYSCTL || + procstat->type == PROCSTAT_CORE) { return (procstat_get_vnode_info_sysctl(fst, vn, errbuf)); } else { warnx("unknown access method: %d", procstat->type); @@ -1156,7 +1301,8 @@ procstat_get_socket_info(struct procstat if (procstat->type == PROCSTAT_KVM) { return (procstat_get_socket_info_kvm(procstat->kd, fst, sock, errbuf)); - } else if (procstat->type == PROCSTAT_SYSCTL) { + } else if (procstat->type == PROCSTAT_SYSCTL || + procstat->type == PROCSTAT_CORE) { return (procstat_get_socket_info_sysctl(fst, sock, errbuf)); } else { warnx("unknown access method: %d", procstat->type); @@ -1407,3 +1553,866 @@ getmnton(kvm_t *kd, struct mount *m) mhead = mt; return (mt->mntonname); } + +/* + * Auxiliary structures and functions to get process environment or + * command line arguments. + */ +struct argvec { + char *buf; + size_t bufsize; + char **argv; + size_t argc; +}; + +static struct argvec * +argvec_alloc(size_t bufsize) +{ + struct argvec *av; + + av = malloc(sizeof(*av)); + if (av == NULL) + return (NULL); + av->bufsize = bufsize; + av->buf = malloc(av->bufsize); + if (av->buf == NULL) { + free(av); + return (NULL); + } + av->argc = 32; + av->argv = malloc(sizeof(char *) * av->argc); + if (av->argv == NULL) { + free(av->buf); + free(av); + return (NULL); + } + return av; +} + +static void +argvec_free(struct argvec * av) +{ + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Tue May 21 19:05:30 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9089C769; Tue, 21 May 2013 19:05:30 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 824CB76A; Tue, 21 May 2013 19:05:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4LJ5U6h016174; Tue, 21 May 2013 19:05:30 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4LJ5SU6016158; Tue, 21 May 2013 19:05:28 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201305211905.r4LJ5SU6016158@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 21 May 2013 19:05:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250871 - stable/9/usr.bin/procstat X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 May 2013 19:05:30 -0000 Author: trociny Date: Tue May 21 19:05:27 2013 New Revision: 250871 URL: http://svnweb.freebsd.org/changeset/base/250871 Log: MFC r249668, r249669, r249671, r249673, r249675, r249678, r249680, r249683, r249685, r249686: r249668: Use procstat_getprocs(3) for retrieving thread information instead of direct sysctl calls. r249669: Use more generic procstat_getvmmap(3) for retrieving VM layout of a process. r249671: Use procstat_getgroups(3) for retrieving groups information instead of direct sysctl. r249673: Use procstat_getumask(3) for retrieving umaks information instead of direct sysctl. r249675: Use procstat_getrlimit(3) for retrieving rlimit information instead of direct sysctl calls. r249678: Use libprocstat(3) when retrieving binary information for a process. r249680: Use libprocstat(3) to retrieve process command line arguments and environment variables. r249683: Use libprocstat(3) to retrieve ELF auxiliary vector. r249685: Use procstat_getkstack(3) for retrieving process kernel stacks instead of direct sysctl calls. r249686: Make use of newly added libprocstat(3) ability to extract procstat info from a process core file. So now one can run procstat(1) on a process core e.g. to get a list of files opened by a process when it crashed: root@lisa:/ # procstat -f /root/vi.core PID COMM FD T V FLAGS REF OFFSET PRO NAME 658 vi text v r r-------- - - - /usr/bin/vi 658 vi ctty v c rw------- - - - /dev/pts/0 658 vi cwd v d r-------- - - - /root 658 vi root v d r-------- - - - / 658 vi 0 v c rw------- 11 3208 - /dev/pts/0 658 vi 1 v c rw------- 11 3208 - /dev/pts/0 658 vi 2 v c rw------- 11 3208 - /dev/pts/0 658 vi 3 v r r----n-l- 1 0 - /tmp/vi.0AYKz3Lps7 658 vi 4 v r rw------- 1 0 - /var/tmp/vi.recover/vi.GaGYsz 658 vi 5 v r rw------- 1 0 - - PR: kern/173723 Suggested by: jhb Modified: stable/9/usr.bin/procstat/procstat.1 stable/9/usr.bin/procstat/procstat.c stable/9/usr.bin/procstat/procstat.h stable/9/usr.bin/procstat/procstat_args.c stable/9/usr.bin/procstat/procstat_auxv.c stable/9/usr.bin/procstat/procstat_bin.c stable/9/usr.bin/procstat/procstat_cred.c stable/9/usr.bin/procstat/procstat_kstack.c stable/9/usr.bin/procstat/procstat_rlimit.c stable/9/usr.bin/procstat/procstat_sigs.c stable/9/usr.bin/procstat/procstat_threads.c stable/9/usr.bin/procstat/procstat_vm.c Directory Properties: stable/9/usr.bin/procstat/ (props changed) Modified: stable/9/usr.bin/procstat/procstat.1 ============================================================================== --- stable/9/usr.bin/procstat/procstat.1 Tue May 21 19:04:16 2013 (r250870) +++ stable/9/usr.bin/procstat/procstat.1 Tue May 21 19:05:27 2013 (r250871) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 11, 2012 +.Dd April 20, 2013 .Dt PROCSTAT 1 .Os .Sh NAME @@ -38,7 +38,7 @@ .Op Fl C .Op Fl w Ar interval .Op Fl b | c | e | f | i | j | k | l | s | t | v | x -.Op Fl a | Ar pid ... +.Op Fl a | Ar pid | Ar core ... .Sh DESCRIPTION The .Nm @@ -47,6 +47,8 @@ utility displays detailed information ab arguments, or if the .Fl a flag is used, all processes. +It can also display information extracted from a process core file, if +the core file is specified as the argument. .Pp By default, basic process statistics are printed; one of the following options may be specified in order to select more detailed process information Modified: stable/9/usr.bin/procstat/procstat.c ============================================================================== --- stable/9/usr.bin/procstat/procstat.c Tue May 21 19:04:16 2013 (r250870) +++ stable/9/usr.bin/procstat/procstat.c Tue May 21 19:05:27 2013 (r250871) @@ -50,7 +50,7 @@ usage(void) fprintf(stderr, "usage: procstat [-h] [-C] [-M core] [-N system] " "[-w interval] \n"); fprintf(stderr, " [-b | -c | -e | -f | -i | -j | -k | " - "-l | -s | -t | -v | -x] [-a | pid ...]\n"); + "-l | -s | -t | -v | -x] [-a | pid | core ...]\n"); exit(EX_USAGE); } @@ -59,11 +59,11 @@ procstat(struct procstat *prstat, struct { if (bflag) - procstat_bin(kipp); + procstat_bin(prstat, kipp); else if (cflag) - procstat_args(kipp); + procstat_args(prstat, kipp); else if (eflag) - procstat_env(kipp); + procstat_env(prstat, kipp); else if (fflag) procstat_files(prstat, kipp); else if (iflag) @@ -71,17 +71,17 @@ procstat(struct procstat *prstat, struct else if (jflag) procstat_threads_sigs(prstat, kipp); else if (kflag) - procstat_kstack(kipp, kflag); + procstat_kstack(prstat, kipp, kflag); else if (lflag) - procstat_rlimit(kipp); + procstat_rlimit(prstat, kipp); else if (sflag) - procstat_cred(kipp); + procstat_cred(prstat, kipp); else if (tflag) - procstat_threads(kipp); + procstat_threads(prstat, kipp); else if (vflag) - procstat_vm(kipp); + procstat_vm(prstat, kipp); else if (xflag) - procstat_auxv(kipp); + procstat_auxv(prstat, kipp); else procstat_basic(kipp); } @@ -116,7 +116,7 @@ main(int argc, char *argv[]) int ch, interval, tmp; int i; struct kinfo_proc *p; - struct procstat *prstat; + struct procstat *prstat, *cprstat; long l; pid_t pid; char *dummy; @@ -255,19 +255,32 @@ main(int argc, char *argv[]) } for (i = 0; i < argc; i++) { l = strtol(argv[i], &dummy, 10); - if (*dummy != '\0') - usage(); - if (l < 0) - usage(); - pid = l; - - p = procstat_getprocs(prstat, KERN_PROC_PID, pid, &cnt); - if (p == NULL) - errx(1, "procstat_getprocs()"); - if (cnt != 0) - procstat(prstat, p); - procstat_freeprocs(prstat, p); - + if (*dummy == '\0') { + if (l < 0) + usage(); + pid = l; + + p = procstat_getprocs(prstat, KERN_PROC_PID, pid, &cnt); + if (p == NULL) + errx(1, "procstat_getprocs()"); + if (cnt != 0) + procstat(prstat, p); + procstat_freeprocs(prstat, p); + } else { + cprstat = procstat_open_core(argv[i]); + if (cprstat == NULL) { + warnx("procstat_open()"); + continue; + } + p = procstat_getprocs(cprstat, KERN_PROC_PID, + -1, &cnt); + if (p == NULL) + errx(1, "procstat_getprocs()"); + if (cnt != 0) + procstat(cprstat, p); + procstat_freeprocs(cprstat, p); + procstat_close(cprstat); + } /* Suppress header after first process. */ hflag = 1; } Modified: stable/9/usr.bin/procstat/procstat.h ============================================================================== --- stable/9/usr.bin/procstat/procstat.h Tue May 21 19:04:16 2013 (r250870) +++ stable/9/usr.bin/procstat/procstat.h Tue May 21 19:05:27 2013 (r250871) @@ -34,18 +34,19 @@ extern int hflag, nflag, Cflag; struct kinfo_proc; void kinfo_proc_sort(struct kinfo_proc *kipp, int count); -void procstat_args(struct kinfo_proc *kipp); -void procstat_auxv(struct kinfo_proc *kipp); +void procstat_args(struct procstat *prstat, struct kinfo_proc *kipp); +void procstat_auxv(struct procstat *prstat, struct kinfo_proc *kipp); void procstat_basic(struct kinfo_proc *kipp); -void procstat_bin(struct kinfo_proc *kipp); -void procstat_cred(struct kinfo_proc *kipp); -void procstat_env(struct kinfo_proc *kipp); +void procstat_bin(struct procstat *prstat, struct kinfo_proc *kipp); +void procstat_cred(struct procstat *prstat, struct kinfo_proc *kipp); +void procstat_env(struct procstat *prstat, struct kinfo_proc *kipp); void procstat_files(struct procstat *prstat, struct kinfo_proc *kipp); -void procstat_kstack(struct kinfo_proc *kipp, int kflag); -void procstat_rlimit(struct kinfo_proc *kipp); +void procstat_kstack(struct procstat *prstat, struct kinfo_proc *kipp, + int kflag); +void procstat_rlimit(struct procstat *prstat, struct kinfo_proc *kipp); void procstat_sigs(struct procstat *prstat, struct kinfo_proc *kipp); -void procstat_threads(struct kinfo_proc *kipp); +void procstat_threads(struct procstat *prstat, struct kinfo_proc *kipp); void procstat_threads_sigs(struct procstat *prstat, struct kinfo_proc *kipp); -void procstat_vm(struct kinfo_proc *kipp); +void procstat_vm(struct procstat *prstat, struct kinfo_proc *kipp); #endif /* !PROCSTAT_H */ Modified: stable/9/usr.bin/procstat/procstat_args.c ============================================================================== --- stable/9/usr.bin/procstat/procstat_args.c Tue May 21 19:04:16 2013 (r250870) +++ stable/9/usr.bin/procstat/procstat_args.c Tue May 21 19:05:27 2013 (r250871) @@ -40,52 +40,40 @@ #include "procstat.h" -static char args[ARG_MAX]; - static void -do_args(struct kinfo_proc *kipp, int env) +do_args(struct procstat *procstat, struct kinfo_proc *kipp, int env) { - int error, name[4]; - size_t len; - char *cp; + int i; + char **args; - if (!hflag) + if (!hflag) { printf("%5s %-16s %-53s\n", "PID", "COMM", env ? "ENVIRONMENT" : "ARGS"); - - name[0] = CTL_KERN; - name[1] = KERN_PROC; - name[2] = env ? KERN_PROC_ENV : KERN_PROC_ARGS; - name[3] = kipp->ki_pid; - len = sizeof(args); - error = sysctl(name, 4, args, &len, NULL, 0); - if (error < 0 && errno != ESRCH && errno != EPERM) { - warn("sysctl: kern.proc.%s: %d: %d", env ? "env" : "args", - kipp->ki_pid, errno); - return; } - if (error < 0) + + args = env ? procstat_getenvv(procstat, kipp, 0) : + procstat_getargv(procstat, kipp, 0); + + printf("%5d %-16s", kipp->ki_pid, kipp->ki_comm); + + if (args == NULL) { + printf(" -\n"); return; - if (len == 0 || strlen(args) == 0) { - strcpy(args, "-"); - len = strlen(args) + 1; } - printf("%5d ", kipp->ki_pid); - printf("%-16s ", kipp->ki_comm); - for (cp = args; cp < args + len; cp += strlen(cp) + 1) - printf("%s%s", cp != args ? " " : "", cp); + for (i = 0; args[i] != NULL; i++) + printf(" %s", args[i]); printf("\n"); } void -procstat_args(struct kinfo_proc *kipp) +procstat_args(struct procstat *procstat, struct kinfo_proc *kipp) { - do_args(kipp, 0); + do_args(procstat, kipp, 0); } void -procstat_env(struct kinfo_proc *kipp) +procstat_env(struct procstat *procstat, struct kinfo_proc *kipp) { - do_args(kipp, 1); + do_args(procstat, kipp, 1); } Modified: stable/9/usr.bin/procstat/procstat_auxv.c ============================================================================== --- stable/9/usr.bin/procstat/procstat_auxv.c Tue May 21 19:04:16 2013 (r250870) +++ stable/9/usr.bin/procstat/procstat_auxv.c Tue May 21 19:05:27 2013 (r250871) @@ -43,113 +43,26 @@ #include "procstat.h" -#define PROC_AUXV_MAX 256 - -static Elf_Auxinfo auxv[PROC_AUXV_MAX]; -static char prefix[256]; - -#if __ELF_WORD_SIZE == 64 -static Elf32_Auxinfo auxv32[PROC_AUXV_MAX]; - -static const char *elf32_sv_names[] = { - "Linux ELF32", - "FreeBSD ELF32", -}; - -static int -is_elf32(pid_t pid) -{ - int error, name[4]; - size_t len, i; - static char sv_name[256]; - - name[0] = CTL_KERN; - name[1] = KERN_PROC; - name[2] = KERN_PROC_SV_NAME; - name[3] = pid; - len = sizeof(sv_name); - error = sysctl(name, 4, sv_name, &len, NULL, 0); - if (error != 0 || len == 0) - return (0); - for (i = 0; i < sizeof(elf32_sv_names) / sizeof(*elf32_sv_names); i++) { - if (strncmp(sv_name, elf32_sv_names[i], sizeof(sv_name)) == 0) - return (1); - } - return (0); -} - -static size_t -retrieve_auxv32(pid_t pid) -{ - int name[4]; - size_t len, i; - void *ptr; - - name[0] = CTL_KERN; - name[1] = KERN_PROC; - name[2] = KERN_PROC_AUXV; - name[3] = pid; - len = sizeof(auxv32); - if (sysctl(name, 4, auxv32, &len, NULL, 0) == -1) { - if (errno != ESRCH && errno != EPERM) - warn("sysctl: kern.proc.auxv: %d: %d", pid, errno); - return (0); - } - for (i = 0; i < len; i++) { - /* - * XXX: We expect that values for a_type on a 32-bit platform - * are directly mapped to those on 64-bit one, which is not - * necessarily true. - */ - auxv[i].a_type = auxv32[i].a_type; - ptr = &auxv32[i].a_un; - auxv[i].a_un.a_val = *((uint32_t *)ptr); - } - return (len); -} -#endif /* __ELF_WORD_SIZE == 64 */ - #define PRINT(name, spec, val) \ printf("%s %-16s " #spec "\n", prefix, #name, (val)) #define PRINT_UNKNOWN(type, val) \ printf("%s %16ld %#lx\n", prefix, (long)type, (u_long)(val)) -static size_t -retrieve_auxv(pid_t pid) -{ - int name[4]; - size_t len; - -#if __ELF_WORD_SIZE == 64 - if (is_elf32(pid)) - return (retrieve_auxv32(pid)); -#endif - name[0] = CTL_KERN; - name[1] = KERN_PROC; - name[2] = KERN_PROC_AUXV; - name[3] = pid; - len = sizeof(auxv); - if (sysctl(name, 4, auxv, &len, NULL, 0) == -1) { - if (errno != ESRCH && errno != EPERM) - warn("sysctl: kern.proc.auxv: %d: %d", pid, errno); - return (0); - } - return (len); -} - void -procstat_auxv(struct kinfo_proc *kipp) +procstat_auxv(struct procstat *procstat, struct kinfo_proc *kipp) { - size_t len, i; + Elf_Auxinfo *auxv; + u_int count, i; + static char prefix[256]; if (!hflag) printf("%5s %-16s %-16s %-16s\n", "PID", "COMM", "AUXV", "VALUE"); - len = retrieve_auxv(kipp->ki_pid); - if (len == 0) + auxv = procstat_getauxv(procstat, kipp, &count); + if (auxv == NULL) return; snprintf(prefix, sizeof(prefix), "%5d %-16s", kipp->ki_pid, kipp->ki_comm); - for (i = 0; i < len; i++) { + for (i = 0; i < count; i++) { switch(auxv[i].a_type) { case AT_NULL: return; @@ -242,5 +155,6 @@ procstat_auxv(struct kinfo_proc *kipp) } } printf("\n"); + procstat_freeauxv(procstat, auxv); } Modified: stable/9/usr.bin/procstat/procstat_bin.c ============================================================================== --- stable/9/usr.bin/procstat/procstat_bin.c Tue May 21 19:04:16 2013 (r250870) +++ stable/9/usr.bin/procstat/procstat_bin.c Tue May 21 19:05:27 2013 (r250871) @@ -40,40 +40,19 @@ #include "procstat.h" void -procstat_bin(struct kinfo_proc *kipp) +procstat_bin(struct procstat *prstat, struct kinfo_proc *kipp) { - char pathname[PATH_MAX]; - int error, osrel, name[4]; - size_t len; + int osrel; + static char pathname[PATH_MAX]; if (!hflag) printf("%5s %-16s %8s %s\n", "PID", "COMM", "OSREL", "PATH"); - name[0] = CTL_KERN; - name[1] = KERN_PROC; - name[2] = KERN_PROC_PATHNAME; - name[3] = kipp->ki_pid; - - len = sizeof(pathname); - error = sysctl(name, 4, pathname, &len, NULL, 0); - if (error < 0 && errno != ESRCH) { - warn("sysctl: kern.proc.pathname: %d", kipp->ki_pid); - return; - } - if (error < 0) + if (procstat_getpathname(prstat, kipp, pathname, sizeof(pathname)) != 0) return; - if (len == 0 || strlen(pathname) == 0) + if (strlen(pathname) == 0) strcpy(pathname, "-"); - - name[2] = KERN_PROC_OSREL; - - len = sizeof(osrel); - error = sysctl(name, 4, &osrel, &len, NULL, 0); - if (error < 0 && errno != ESRCH) { - warn("sysctl: kern.proc.osrel: %d", kipp->ki_pid); - return; - } - if (error < 0) + if (procstat_getosrel(prstat, kipp, &osrel) != 0) return; printf("%5d ", kipp->ki_pid); Modified: stable/9/usr.bin/procstat/procstat_cred.c ============================================================================== --- stable/9/usr.bin/procstat/procstat_cred.c Tue May 21 19:04:16 2013 (r250870) +++ stable/9/usr.bin/procstat/procstat_cred.c Tue May 21 19:05:27 2013 (r250871) @@ -38,16 +38,14 @@ #include "procstat.h" -static const char *get_umask(struct kinfo_proc *kipp); +static const char *get_umask(struct procstat *procstat, + struct kinfo_proc *kipp); void -procstat_cred(struct kinfo_proc *kipp) +procstat_cred(struct procstat *procstat, struct kinfo_proc *kipp) { - int i; - int mib[4]; - int ngroups; - size_t len; - gid_t *groups = NULL; + unsigned int i, ngroups; + gid_t *groups; if (!hflag) printf("%5s %-16s %5s %5s %5s %5s %5s %5s %5s %5s %-15s\n", @@ -62,34 +60,18 @@ procstat_cred(struct kinfo_proc *kipp) printf("%5d ", kipp->ki_groups[0]); printf("%5d ", kipp->ki_rgid); printf("%5d ", kipp->ki_svgid); - printf("%5s ", get_umask(kipp)); + printf("%5s ", get_umask(procstat, kipp)); printf("%s", kipp->ki_cr_flags & CRED_FLAG_CAPMODE ? "C" : "-"); printf(" "); + groups = NULL; /* * We may have too many groups to fit in kinfo_proc's statically - * sized storage. If that occurs, attempt to retrieve them via - * sysctl. + * sized storage. If that occurs, attempt to retrieve them using + * libprocstat. */ - if (kipp->ki_cr_flags & KI_CRF_GRP_OVERFLOW) { - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_GROUPS; - mib[3] = kipp->ki_pid; - - ngroups = sysconf(_SC_NGROUPS_MAX) + 1; - len = ngroups * sizeof(gid_t); - if((groups = malloc(len)) == NULL) - err(-1, "malloc"); - - if (sysctl(mib, 4, groups, &len, NULL, 0) == -1) { - warn("sysctl: kern.proc.groups: %d " - "group list truncated", kipp->ki_pid); - free(groups); - groups = NULL; - } - ngroups = len / sizeof(gid_t); - } + if (kipp->ki_cr_flags & KI_CRF_GRP_OVERFLOW) + groups = procstat_getgroups(procstat, kipp, &ngroups); if (groups == NULL) { ngroups = kipp->ki_ngroups; groups = kipp->ki_groups; @@ -97,27 +79,18 @@ procstat_cred(struct kinfo_proc *kipp) for (i = 0; i < ngroups; i++) printf("%s%d", (i > 0) ? "," : "", groups[i]); if (groups != kipp->ki_groups) - free(groups); + procstat_freegroups(procstat, groups); printf("\n"); } static const char * -get_umask(struct kinfo_proc *kipp) +get_umask(struct procstat *procstat, struct kinfo_proc *kipp) { - int error; - int mib[4]; - size_t len; u_short fd_cmask; static char umask[4]; - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_UMASK; - mib[3] = kipp->ki_pid; - len = sizeof(fd_cmask); - error = sysctl(mib, 4, &fd_cmask, &len, NULL, 0); - if (error == 0) { + if (procstat_getumask(procstat, kipp, &fd_cmask) == 0) { snprintf(umask, 4, "%03o", fd_cmask); return (umask); } else { Modified: stable/9/usr.bin/procstat/procstat_kstack.c ============================================================================== --- stable/9/usr.bin/procstat/procstat_kstack.c Tue May 21 19:04:16 2013 (r250870) +++ stable/9/usr.bin/procstat/procstat_kstack.c Tue May 21 19:05:27 2013 (r250871) @@ -125,76 +125,35 @@ kinfo_kstack_sort(struct kinfo_kstack *k void -procstat_kstack(struct kinfo_proc *kipp, int kflag) +procstat_kstack(struct procstat *procstat, struct kinfo_proc *kipp, int kflag) { struct kinfo_kstack *kkstp, *kkstp_free; struct kinfo_proc *kip, *kip_free; char trace[KKST_MAXLEN]; - int error, name[4]; unsigned int i, j; - size_t kip_len, kstk_len; + unsigned int kip_count, kstk_count; if (!hflag) printf("%5s %6s %-16s %-16s %-29s\n", "PID", "TID", "COMM", "TDNAME", "KSTACK"); - name[0] = CTL_KERN; - name[1] = KERN_PROC; - name[2] = KERN_PROC_KSTACK; - name[3] = kipp->ki_pid; - - kstk_len = 0; - error = sysctl(name, 4, NULL, &kstk_len, NULL, 0); - if (error < 0 && errno != ESRCH && errno != EPERM && errno != ENOENT) { - warn("sysctl: kern.proc.kstack: %d", kipp->ki_pid); - return; - } - if (error < 0 && errno == ENOENT) { - warnx("sysctl: kern.proc.kstack unavailable"); - errx(-1, "options DDB or options STACK required in kernel"); - } - if (error < 0) - return; - - kkstp = kkstp_free = malloc(kstk_len); + kkstp = kkstp_free = procstat_getkstack(procstat, kipp, &kstk_count); if (kkstp == NULL) - err(-1, "malloc"); - - if (sysctl(name, 4, kkstp, &kstk_len, NULL, 0) < 0) { - warn("sysctl: kern.proc.pid: %d", kipp->ki_pid); - free(kkstp); return; - } /* * We need to re-query for thread information, so don't use *kipp. */ - name[0] = CTL_KERN; - name[1] = KERN_PROC; - name[2] = KERN_PROC_PID | KERN_PROC_INC_THREAD; - name[3] = kipp->ki_pid; - - kip_len = 0; - error = sysctl(name, 4, NULL, &kip_len, NULL, 0); - if (error < 0 && errno != ESRCH) { - warn("sysctl: kern.proc.pid: %d", kipp->ki_pid); - return; - } - if (error < 0) - return; + kip = kip_free = procstat_getprocs(procstat, + KERN_PROC_PID | KERN_PROC_INC_THREAD, kipp->ki_pid, &kip_count); - kip = kip_free = malloc(kip_len); - if (kip == NULL) - err(-1, "malloc"); - - if (sysctl(name, 4, kip, &kip_len, NULL, 0) < 0) { - warn("sysctl: kern.proc.pid: %d", kipp->ki_pid); - free(kip); + if (kip == NULL) { + procstat_freekstack(procstat, kkstp_free); return; } - kinfo_kstack_sort(kkstp, kstk_len / sizeof(*kkstp)); - for (i = 0; i < kstk_len / sizeof(*kkstp); i++) { + kinfo_kstack_sort(kkstp, kstk_count); + for (i = 0; i < kstk_count; i++) { kkstp = &kkstp_free[i]; /* @@ -202,7 +161,7 @@ procstat_kstack(struct kinfo_proc *kipp, * display the per-thread command line. */ kipp = NULL; - for (j = 0; j < kip_len / sizeof(*kipp); j++) { + for (j = 0; j < kip_count; j++) { kipp = &kip_free[j]; if (kkstp->kkst_tid == kipp->ki_tid) break; @@ -242,6 +201,6 @@ procstat_kstack(struct kinfo_proc *kipp, kstack_cleanup(kkstp->kkst_trace, trace, kflag); printf("%-29s\n", trace); } - free(kip_free); - free(kkstp_free); + procstat_freekstack(procstat, kkstp_free); + procstat_freeprocs(procstat, kip_free); } Modified: stable/9/usr.bin/procstat/procstat_rlimit.c ============================================================================== --- stable/9/usr.bin/procstat/procstat_rlimit.c Tue May 21 19:04:16 2013 (r250870) +++ stable/9/usr.bin/procstat/procstat_rlimit.c Tue May 21 19:05:27 2013 (r250871) @@ -86,31 +86,18 @@ humanize_rlimit(int indx, rlim_t limit) } void -procstat_rlimit(struct kinfo_proc *kipp) +procstat_rlimit(struct procstat *prstat, struct kinfo_proc *kipp) { struct rlimit rlimit; - int error, i, name[5]; - size_t len; + int i; if (!hflag) { printf("%5s %-16s %-16s %16s %16s\n", "PID", "COMM", "RLIMIT", "SOFT ", "HARD "); } - len = sizeof(struct rlimit); - name[0] = CTL_KERN; - name[1] = KERN_PROC; - name[2] = KERN_PROC_RLIMIT; - name[3] = kipp->ki_pid; for (i = 0; i < RLIM_NLIMITS; i++) { - name[4] = i; - error = sysctl(name, 5, &rlimit, &len, NULL, 0); - if (error < 0 && errno != ESRCH) { - warn("sysctl: kern.proc.rlimit: %d", kipp->ki_pid); + if (procstat_getrlimit(prstat, kipp, i, &rlimit) == -1) return; - } - if (error < 0 || len != sizeof(struct rlimit)) - return; - printf("%5d %-16s %-16s ", kipp->ki_pid, kipp->ki_comm, rlimit_param[i].name); printf("%16s ", humanize_rlimit(i, rlimit.rlim_cur)); Modified: stable/9/usr.bin/procstat/procstat_sigs.c ============================================================================== --- stable/9/usr.bin/procstat/procstat_sigs.c Tue May 21 19:04:16 2013 (r250870) +++ stable/9/usr.bin/procstat/procstat_sigs.c Tue May 21 19:05:27 2013 (r250871) @@ -86,48 +86,24 @@ procstat_sigs(struct procstat *prstat __ } void -procstat_threads_sigs(struct procstat *prstat __unused, struct kinfo_proc *kipp) +procstat_threads_sigs(struct procstat *procstat, struct kinfo_proc *kipp) { struct kinfo_proc *kip; pid_t pid; - int error, name[4], j; - unsigned int i; - size_t len; + int j; + unsigned int count, i; pid = kipp->ki_pid; if (!hflag) printf("%5s %6s %-16s %-7s %4s\n", "PID", "TID", "COMM", "SIG", "FLAGS"); - /* - * We need to re-query for thread information, so don't use *kipp. - */ - name[0] = CTL_KERN; - name[1] = KERN_PROC; - name[2] = KERN_PROC_PID | KERN_PROC_INC_THREAD; - name[3] = pid; - - len = 0; - error = sysctl(name, 4, NULL, &len, NULL, 0); - if (error < 0 && errno != ESRCH) { - warn("sysctl: kern.proc.pid: %d", pid); - return; - } - if (error < 0) - return; - - kip = malloc(len); + kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD, + pid, &count); if (kip == NULL) - err(-1, "malloc"); - - if (sysctl(name, 4, kip, &len, NULL, 0) < 0) { - warn("sysctl: kern.proc.pid: %d", pid); - free(kip); return; - } - - kinfo_proc_sort(kip, len / sizeof(*kipp)); - for (i = 0; i < len / sizeof(*kipp); i++) { + kinfo_proc_sort(kip, count); + for (i = 0; i < count; i++) { kipp = &kip[i]; for (j = 1; j <= _SIG_MAXSIG; j++) { printf("%5d ", pid); @@ -140,5 +116,5 @@ procstat_threads_sigs(struct procstat *p printf("\n"); } } - free(kip); + procstat_freeprocs(procstat, kip); } Modified: stable/9/usr.bin/procstat/procstat_threads.c ============================================================================== --- stable/9/usr.bin/procstat/procstat_threads.c Tue May 21 19:04:16 2013 (r250870) +++ stable/9/usr.bin/procstat/procstat_threads.c Tue May 21 19:05:27 2013 (r250871) @@ -40,47 +40,22 @@ #include "procstat.h" void -procstat_threads(struct kinfo_proc *kipp) +procstat_threads(struct procstat *procstat, struct kinfo_proc *kipp) { struct kinfo_proc *kip; - int error, name[4]; - unsigned int i; + unsigned int count, i; const char *str; - size_t len; if (!hflag) printf("%5s %6s %-16s %-16s %2s %4s %-7s %-9s\n", "PID", "TID", "COMM", "TDNAME", "CPU", "PRI", "STATE", "WCHAN"); - /* - * We need to re-query for thread information, so don't use *kipp. - */ - name[0] = CTL_KERN; - name[1] = KERN_PROC; - name[2] = KERN_PROC_PID | KERN_PROC_INC_THREAD; - name[3] = kipp->ki_pid; - - len = 0; - error = sysctl(name, 4, NULL, &len, NULL, 0); - if (error < 0 && errno != ESRCH) { - warn("sysctl: kern.proc.pid: %d", kipp->ki_pid); - return; - } - if (error < 0) - return; - - kip = malloc(len); + kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD, + kipp->ki_pid, &count); if (kip == NULL) - err(-1, "malloc"); - - if (sysctl(name, 4, kip, &len, NULL, 0) < 0) { - warn("sysctl: kern.proc.pid: %d", kipp->ki_pid); - free(kip); return; - } - - kinfo_proc_sort(kip, len / sizeof(*kipp)); - for (i = 0; i < len / sizeof(*kipp); i++) { + kinfo_proc_sort(kip, count); + for (i = 0; i < count; i++) { kipp = &kip[i]; printf("%5d ", kipp->ki_pid); printf("%6d ", kipp->ki_tid); @@ -139,5 +114,5 @@ procstat_threads(struct kinfo_proc *kipp } printf("\n"); } - free(kip); + procstat_freeprocs(procstat, kip); } Modified: stable/9/usr.bin/procstat/procstat_vm.c ============================================================================== --- stable/9/usr.bin/procstat/procstat_vm.c Tue May 21 19:04:16 2013 (r250870) +++ stable/9/usr.bin/procstat/procstat_vm.c Tue May 21 19:05:27 2013 (r250871) @@ -41,7 +41,7 @@ #include "procstat.h" void -procstat_vm(struct kinfo_proc *kipp) +procstat_vm(struct procstat *procstat, struct kinfo_proc *kipp) { struct kinfo_vmentry *freep, *kve; int ptrwidth; @@ -54,7 +54,7 @@ procstat_vm(struct kinfo_proc *kipp) "PID", ptrwidth, "START", ptrwidth, "END", "PRT", "RES", "PRES", "REF", "SHD", "FL", "TP", "PATH"); - freep = kinfo_getvmmap(kipp->ki_pid, &cnt); + freep = procstat_getvmmap(procstat, kipp, &cnt); if (freep == NULL) return; for (i = 0; i < cnt; i++) { From owner-svn-src-stable-9@FreeBSD.ORG Tue May 21 19:06:18 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 15BB6906; Tue, 21 May 2013 19:06:18 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 07A16782; Tue, 21 May 2013 19:06:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4LJ6IXC016384; Tue, 21 May 2013 19:06:18 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4LJ6Hng016382; Tue, 21 May 2013 19:06:17 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201305211906.r4LJ6Hng016382@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 21 May 2013 19:06:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250872 - stable/9/usr.bin/gcore X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 May 2013 19:06:18 -0000 Author: trociny Date: Tue May 21 19:06:17 2013 New Revision: 250872 URL: http://svnweb.freebsd.org/changeset/base/250872 Log: MFC r249687, r249704, r250511: r249687, r249704: Sync gcore(1) with the recent changes in kernel code aimed at adding procstat notes to a process core file. Suggested by: jhb r250511 (antoine): Add some missing DPADD. Modified: stable/9/usr.bin/gcore/Makefile stable/9/usr.bin/gcore/elfcore.c Directory Properties: stable/9/usr.bin/gcore/ (props changed) Modified: stable/9/usr.bin/gcore/Makefile ============================================================================== --- stable/9/usr.bin/gcore/Makefile Tue May 21 19:05:27 2013 (r250871) +++ stable/9/usr.bin/gcore/Makefile Tue May 21 19:06:17 2013 (r250872) @@ -3,8 +3,8 @@ PROG= gcore SRCS= elfcore.c gcore.c -DPADD= ${LIBUTIL} -LDADD= -lutil +DPADD= ${LIBSBUF} ${LIBUTIL} +LDADD= -lsbuf -lutil WARNS?= 1 Modified: stable/9/usr.bin/gcore/elfcore.c ============================================================================== --- stable/9/usr.bin/gcore/elfcore.c Tue May 21 19:05:27 2013 (r250871) +++ stable/9/usr.bin/gcore/elfcore.c Tue May 21 19:06:17 2013 (r250872) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -41,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -71,16 +73,33 @@ struct sseg_closure { size_t size; /* Total size of all writable segments. */ }; +typedef void* (*notefunc_t)(void *, size_t *); + static void cb_put_phdr(vm_map_entry_t, void *); static void cb_size_segment(vm_map_entry_t, void *); static void each_writable_segment(vm_map_entry_t, segment_callback, void *closure); static void elf_detach(void); /* atexit() handler. */ -static void elf_puthdr(pid_t, vm_map_entry_t, void *, size_t *, int numsegs); -static void elf_putnote(void *dst, size_t *off, const char *name, int type, - const void *desc, size_t descsz); +static void *elf_note_fpregset(void *, size_t *); +static void *elf_note_prpsinfo(void *, size_t *); +static void *elf_note_prstatus(void *, size_t *); +static void *elf_note_thrmisc(void *, size_t *); +static void *elf_note_procstat_auxv(void *, size_t *); +static void *elf_note_procstat_files(void *, size_t *); +static void *elf_note_procstat_groups(void *, size_t *); +static void *elf_note_procstat_osrel(void *, size_t *); +static void *elf_note_procstat_proc(void *, size_t *); +static void *elf_note_procstat_psstrings(void *, size_t *); +static void *elf_note_procstat_rlimit(void *, size_t *); +static void *elf_note_procstat_umask(void *, size_t *); +static void *elf_note_procstat_vmmap(void *, size_t *); +static void elf_puthdr(pid_t, vm_map_entry_t, void *, size_t, size_t, size_t, + int); +static void elf_putnote(int, notefunc_t, void *, struct sbuf *); +static void elf_putnotes(pid_t, struct sbuf *, size_t *); static void freemap(vm_map_entry_t); static vm_map_entry_t readmap(pid_t); +static void *procstat_sysctl(void *, int, size_t, size_t *sizep); static pid_t g_pid; /* Pid being dumped, global for elf_detach */ @@ -114,8 +133,10 @@ elf_coredump(int efd __unused, int fd, p { vm_map_entry_t map; struct sseg_closure seginfo; + struct sbuf *sb; void *hdr; - size_t hdrsize; + size_t hdrsize, notesz, segoff; + ssize_t n, old_len; Elf_Phdr *php; int i; @@ -139,27 +160,32 @@ elf_coredump(int efd __unused, int fd, p each_writable_segment(map, cb_size_segment, &seginfo); /* - * Calculate the size of the core file header area by making - * a dry run of generating it. Nothing is written, but the - * size is calculated. + * Build the header and the notes using sbuf and write to the file. */ - hdrsize = 0; - elf_puthdr(pid, map, NULL, &hdrsize, seginfo.count); - - /* - * Allocate memory for building the header, fill it up, - * and write it out. - */ - if ((hdr = calloc(1, hdrsize)) == NULL) - errx(1, "out of memory"); - + sb = sbuf_new_auto(); + hdrsize = sizeof(Elf_Ehdr) + sizeof(Elf_Phdr) * (1 + seginfo.count); + /* Start header + notes section. */ + sbuf_start_section(sb, NULL); + /* Make empty header subsection. */ + sbuf_start_section(sb, &old_len); + sbuf_putc(sb, 0); + sbuf_end_section(sb, old_len, hdrsize, 0); + /* Put notes. */ + elf_putnotes(pid, sb, ¬esz); + /* Align up to a page boundary for the program segments. */ + sbuf_end_section(sb, -1, PAGE_SIZE, 0); + if (sbuf_finish(sb) != 0) + err(1, "sbuf_finish"); + hdr = sbuf_data(sb); + segoff = sbuf_len(sb); /* Fill in the header. */ - hdrsize = 0; - elf_puthdr(pid, map, hdr, &hdrsize, seginfo.count); + elf_puthdr(pid, map, hdr, hdrsize, notesz, segoff, seginfo.count); - /* Write it to the core file. */ - if (write(fd, hdr, hdrsize) == -1) + n = write(fd, hdr, segoff); + if (n == -1) err(1, "write"); + if (n < segoff) + errx(1, "short write"); /* Write the contents of all of the writable segments. */ php = (Elf_Phdr *)((char *)hdr + sizeof(Elf_Ehdr)) + 1; @@ -195,7 +221,7 @@ elf_coredump(int efd __unused, int fd, p } php++; } - free(hdr); + sbuf_delete(sb); freemap(map); } @@ -257,209 +283,136 @@ each_writable_segment(vm_map_entry_t map } static void -elf_getstatus(pid_t pid, prpsinfo_t *psinfo) -{ - struct kinfo_proc kobj; - int name[4]; - size_t len; - - name[0] = CTL_KERN; - name[1] = KERN_PROC; - name[2] = KERN_PROC_PID; - name[3] = pid; - - len = sizeof(kobj); - if (sysctl(name, 4, &kobj, &len, NULL, 0) == -1) - err(1, "error accessing kern.proc.pid.%u sysctl", pid); - if (kobj.ki_pid != pid) - err(1, "error accessing kern.proc.pid.%u sysctl datas", pid); - strncpy(psinfo->pr_fname, kobj.ki_comm, MAXCOMLEN); - strncpy(psinfo->pr_psargs, psinfo->pr_fname, PRARGSZ); -} - -/* - * Generate the ELF coredump header into the buffer at "dst". "dst" may - * be NULL, in which case the header is sized but not actually generated. - */ -static void -elf_puthdr(pid_t pid, vm_map_entry_t map, void *dst, size_t *off, int numsegs) +elf_putnotes(pid_t pid, struct sbuf *sb, size_t *sizep) { - struct ptrace_lwpinfo lwpinfo; - struct { - prstatus_t status; - prfpregset_t fpregset; - prpsinfo_t psinfo; - thrmisc_t thrmisc; - } *tempdata; - size_t ehoff; - size_t phoff; - size_t noteoff; - size_t notesz; - size_t threads; lwpid_t *tids; + size_t threads, old_len; + ssize_t size; int i; - prstatus_t *status; - prfpregset_t *fpregset; - prpsinfo_t *psinfo; - thrmisc_t *thrmisc; - - ehoff = *off; - *off += sizeof(Elf_Ehdr); - - phoff = *off; - *off += (numsegs + 1) * sizeof(Elf_Phdr); - - noteoff = *off; - - if (dst != NULL) { - if ((tempdata = calloc(1, sizeof(*tempdata))) == NULL) - errx(1, "out of memory"); - status = &tempdata->status; - fpregset = &tempdata->fpregset; - psinfo = &tempdata->psinfo; - thrmisc = &tempdata->thrmisc; - } else { - tempdata = NULL; - status = NULL; - fpregset = NULL; - psinfo = NULL; - thrmisc = NULL; - } - errno = 0; threads = ptrace(PT_GETNUMLWPS, pid, NULL, 0); if (errno) err(1, "PT_GETNUMLWPS"); + tids = malloc(threads * sizeof(*tids)); + if (tids == NULL) + errx(1, "out of memory"); + errno = 0; + ptrace(PT_GETLWPLIST, pid, (void *)tids, threads); + if (errno) + err(1, "PT_GETLWPLIST"); - if (dst != NULL) { - psinfo->pr_version = PRPSINFO_VERSION; - psinfo->pr_psinfosz = sizeof(prpsinfo_t); - elf_getstatus(pid, psinfo); - - } - elf_putnote(dst, off, "FreeBSD", NT_PRPSINFO, psinfo, - sizeof *psinfo); + sbuf_start_section(sb, &old_len); + elf_putnote(NT_PRPSINFO, elf_note_prpsinfo, &pid, sb); - if (dst != NULL) { - tids = malloc(threads * sizeof(*tids)); - if (tids == NULL) - errx(1, "out of memory"); - errno = 0; - ptrace(PT_GETLWPLIST, pid, (void *)tids, threads); - if (errno) - err(1, "PT_GETLWPLIST"); - } for (i = 0; i < threads; ++i) { - if (dst != NULL) { - status->pr_version = PRSTATUS_VERSION; - status->pr_statussz = sizeof(prstatus_t); - status->pr_gregsetsz = sizeof(gregset_t); - status->pr_fpregsetsz = sizeof(fpregset_t); - status->pr_osreldate = __FreeBSD_version; - status->pr_pid = tids[i]; - - ptrace(PT_GETREGS, tids[i], (void *)&status->pr_reg, 0); - ptrace(PT_GETFPREGS, tids[i], (void *)fpregset, 0); - ptrace(PT_LWPINFO, tids[i], (void *)&lwpinfo, - sizeof(lwpinfo)); - memset(&thrmisc->_pad, 0, sizeof(thrmisc->_pad)); - strcpy(thrmisc->pr_tname, lwpinfo.pl_tdname); - } - elf_putnote(dst, off, "FreeBSD", NT_PRSTATUS, status, - sizeof *status); - elf_putnote(dst, off, "FreeBSD", NT_FPREGSET, fpregset, - sizeof *fpregset); - elf_putnote(dst, off, "FreeBSD", NT_THRMISC, thrmisc, - sizeof *thrmisc); - } - - notesz = *off - noteoff; - - if (dst != NULL) { - free(tids); - free(tempdata); + elf_putnote(NT_PRSTATUS, elf_note_prstatus, tids + i, sb); + elf_putnote(NT_FPREGSET, elf_note_fpregset, tids + i, sb); + elf_putnote(NT_THRMISC, elf_note_thrmisc, tids + i, sb); } - /* Align up to a page boundary for the program segments. */ - *off = round_page(*off); - - if (dst != NULL) { - Elf_Ehdr *ehdr; - Elf_Phdr *phdr; - struct phdr_closure phc; - - /* - * Fill in the ELF header. - */ - ehdr = (Elf_Ehdr *)((char *)dst + ehoff); - ehdr->e_ident[EI_MAG0] = ELFMAG0; - ehdr->e_ident[EI_MAG1] = ELFMAG1; - ehdr->e_ident[EI_MAG2] = ELFMAG2; - ehdr->e_ident[EI_MAG3] = ELFMAG3; - ehdr->e_ident[EI_CLASS] = ELF_CLASS; - ehdr->e_ident[EI_DATA] = ELF_DATA; - ehdr->e_ident[EI_VERSION] = EV_CURRENT; - ehdr->e_ident[EI_OSABI] = ELFOSABI_FREEBSD; - ehdr->e_ident[EI_ABIVERSION] = 0; - ehdr->e_ident[EI_PAD] = 0; - ehdr->e_type = ET_CORE; - ehdr->e_machine = ELF_ARCH; - ehdr->e_version = EV_CURRENT; - ehdr->e_entry = 0; - ehdr->e_phoff = phoff; - ehdr->e_flags = 0; - ehdr->e_ehsize = sizeof(Elf_Ehdr); - ehdr->e_phentsize = sizeof(Elf_Phdr); - ehdr->e_phnum = numsegs + 1; - ehdr->e_shentsize = sizeof(Elf_Shdr); - ehdr->e_shnum = 0; - ehdr->e_shstrndx = SHN_UNDEF; - - /* - * Fill in the program header entries. - */ - phdr = (Elf_Phdr *)((char *)dst + phoff); - - /* The note segment. */ - phdr->p_type = PT_NOTE; - phdr->p_offset = noteoff; - phdr->p_vaddr = 0; - phdr->p_paddr = 0; - phdr->p_filesz = notesz; - phdr->p_memsz = 0; - phdr->p_flags = 0; - phdr->p_align = 0; - phdr++; - - /* All the writable segments from the program. */ - phc.phdr = phdr; - phc.offset = *off; - each_writable_segment(map, cb_put_phdr, &phc); - } + elf_putnote(NT_PROCSTAT_PROC, elf_note_procstat_proc, &pid, sb); + elf_putnote(NT_PROCSTAT_FILES, elf_note_procstat_files, &pid, sb); + elf_putnote(NT_PROCSTAT_VMMAP, elf_note_procstat_vmmap, &pid, sb); + elf_putnote(NT_PROCSTAT_GROUPS, elf_note_procstat_groups, &pid, sb); + elf_putnote(NT_PROCSTAT_UMASK, elf_note_procstat_umask, &pid, sb); + elf_putnote(NT_PROCSTAT_RLIMIT, elf_note_procstat_rlimit, &pid, sb); + elf_putnote(NT_PROCSTAT_OSREL, elf_note_procstat_osrel, &pid, sb); + elf_putnote(NT_PROCSTAT_PSSTRINGS, elf_note_procstat_psstrings, &pid, + sb); + elf_putnote(NT_PROCSTAT_AUXV, elf_note_procstat_auxv, &pid, sb); + + size = sbuf_end_section(sb, old_len, 1, 0); + if (size == -1) + err(1, "sbuf_end_section"); + free(tids); + *sizep = size; } /* - * Emit one note section to "dst", or just size it if "dst" is NULL. + * Emit one note section to sbuf. */ static void -elf_putnote(void *dst, size_t *off, const char *name, int type, - const void *desc, size_t descsz) +elf_putnote(int type, notefunc_t notefunc, void *arg, struct sbuf *sb) { Elf_Note note; + size_t descsz; + ssize_t old_len; + void *desc; - note.n_namesz = strlen(name) + 1; + desc = notefunc(arg, &descsz); + note.n_namesz = 8; /* strlen("FreeBSD") + 1 */ note.n_descsz = descsz; note.n_type = type; - if (dst != NULL) - bcopy(¬e, (char *)dst + *off, sizeof note); - *off += sizeof note; - if (dst != NULL) - bcopy(name, (char *)dst + *off, note.n_namesz); - *off += roundup2(note.n_namesz, sizeof(Elf_Size)); - if (dst != NULL) - bcopy(desc, (char *)dst + *off, note.n_descsz); - *off += roundup2(note.n_descsz, sizeof(Elf_Size)); + + sbuf_bcat(sb, ¬e, sizeof(note)); + sbuf_start_section(sb, &old_len); + sbuf_bcat(sb, "FreeBSD", note.n_namesz); + sbuf_end_section(sb, old_len, sizeof(Elf32_Size), 0); + if (descsz == 0) + return; + sbuf_start_section(sb, &old_len); + sbuf_bcat(sb, desc, descsz); + sbuf_end_section(sb, old_len, sizeof(Elf32_Size), 0); + free(desc); +} + +/* + * Generate the ELF coredump header. + */ +static void +elf_puthdr(pid_t pid, vm_map_entry_t map, void *hdr, size_t hdrsize, + size_t notesz, size_t segoff, int numsegs) +{ + Elf_Ehdr *ehdr; + Elf_Phdr *phdr; + struct phdr_closure phc; + + ehdr = (Elf_Ehdr *)hdr; + phdr = (Elf_Phdr *)((char *)hdr + sizeof(Elf_Ehdr)); + + ehdr->e_ident[EI_MAG0] = ELFMAG0; + ehdr->e_ident[EI_MAG1] = ELFMAG1; + ehdr->e_ident[EI_MAG2] = ELFMAG2; + ehdr->e_ident[EI_MAG3] = ELFMAG3; + ehdr->e_ident[EI_CLASS] = ELF_CLASS; + ehdr->e_ident[EI_DATA] = ELF_DATA; + ehdr->e_ident[EI_VERSION] = EV_CURRENT; + ehdr->e_ident[EI_OSABI] = ELFOSABI_FREEBSD; + ehdr->e_ident[EI_ABIVERSION] = 0; + ehdr->e_ident[EI_PAD] = 0; + ehdr->e_type = ET_CORE; + ehdr->e_machine = ELF_ARCH; + ehdr->e_version = EV_CURRENT; + ehdr->e_entry = 0; + ehdr->e_phoff = sizeof(Elf_Ehdr); + ehdr->e_flags = 0; + ehdr->e_ehsize = sizeof(Elf_Ehdr); + ehdr->e_phentsize = sizeof(Elf_Phdr); + ehdr->e_phnum = numsegs + 1; + ehdr->e_shentsize = sizeof(Elf_Shdr); + ehdr->e_shnum = 0; + ehdr->e_shstrndx = SHN_UNDEF; + + /* + * Fill in the program header entries. + */ + + /* The note segement. */ + phdr->p_type = PT_NOTE; + phdr->p_offset = hdrsize; + phdr->p_vaddr = 0; + phdr->p_paddr = 0; + phdr->p_filesz = notesz; + phdr->p_memsz = 0; + phdr->p_flags = PF_R; + phdr->p_align = sizeof(Elf32_Size); + phdr++; + + /* All the writable segments from the program. */ + phc.phdr = phdr; + phc.offset = segoff; + each_writable_segment(map, cb_put_phdr, &phc); } /* @@ -530,5 +483,222 @@ readmap(pid_t pid) return (map); } +/* + * Miscellaneous note out functions. + */ + +static void * +elf_note_prpsinfo(void *arg, size_t *sizep) +{ + pid_t pid; + prpsinfo_t *psinfo; + struct kinfo_proc kip; + size_t len; + int name[4]; + + pid = *(pid_t *)arg; + psinfo = calloc(1, sizeof(*psinfo)); + if (psinfo == NULL) + errx(1, "out of memory"); + psinfo->pr_version = PRPSINFO_VERSION; + psinfo->pr_psinfosz = sizeof(prpsinfo_t); + + name[0] = CTL_KERN; + name[1] = KERN_PROC; + name[2] = KERN_PROC_PID; + name[3] = pid; + len = sizeof(kip); + if (sysctl(name, 4, &kip, &len, NULL, 0) == -1) + err(1, "kern.proc.pid.%u", pid); + if (kip.ki_pid != pid) + err(1, "kern.proc.pid.%u", pid); + strncpy(psinfo->pr_fname, kip.ki_comm, MAXCOMLEN); + strncpy(psinfo->pr_psargs, psinfo->pr_fname, PRARGSZ); + + *sizep = sizeof(*psinfo); + return (psinfo); +} + +static void * +elf_note_prstatus(void *arg, size_t *sizep) +{ + lwpid_t tid; + prstatus_t *status; + + tid = *(lwpid_t *)arg; + status = calloc(1, sizeof(*status)); + if (status == NULL) + errx(1, "out of memory"); + status->pr_version = PRSTATUS_VERSION; + status->pr_statussz = sizeof(prstatus_t); + status->pr_gregsetsz = sizeof(gregset_t); + status->pr_fpregsetsz = sizeof(fpregset_t); + status->pr_osreldate = __FreeBSD_version; + status->pr_pid = tid; + ptrace(PT_GETREGS, tid, (void *)&status->pr_reg, 0); + + *sizep = sizeof(*status); + return (status); +} + +static void * +elf_note_fpregset(void *arg, size_t *sizep) +{ + lwpid_t tid; + prfpregset_t *fpregset; + + tid = *(lwpid_t *)arg; + fpregset = calloc(1, sizeof(*fpregset)); + if (fpregset == NULL) + errx(1, "out of memory"); + ptrace(PT_GETFPREGS, tid, (void *)fpregset, 0); + + *sizep = sizeof(*fpregset); + return (fpregset); +} + +static void * +elf_note_thrmisc(void *arg, size_t *sizep) +{ + lwpid_t tid; + struct ptrace_lwpinfo lwpinfo; + thrmisc_t *thrmisc; + + tid = *(lwpid_t *)arg; + thrmisc = calloc(1, sizeof(*thrmisc)); + if (thrmisc == NULL) + errx(1, "out of memory"); + ptrace(PT_LWPINFO, tid, (void *)&lwpinfo, + sizeof(lwpinfo)); + memset(&thrmisc->_pad, 0, sizeof(thrmisc->_pad)); + strcpy(thrmisc->pr_tname, lwpinfo.pl_tdname); + + *sizep = sizeof(*thrmisc); + return (thrmisc); +} + +static void * +procstat_sysctl(void *arg, int what, size_t structsz, size_t *sizep) +{ + size_t len, oldlen; + pid_t pid; + int name[4], structsize; + void *buf, *p; + + pid = *(pid_t *)arg; + structsize = structsz; + name[0] = CTL_KERN; + name[1] = KERN_PROC; + name[2] = what; + name[3] = pid; + len = 0; + if (sysctl(name, 4, NULL, &len, NULL, 0) == -1) + err(1, "kern.proc.%d.%u", what, pid); + buf = calloc(1, sizeof(structsize) + len * 4 / 3); + if (buf == NULL) + errx(1, "out of memory"); + bcopy(&structsize, buf, sizeof(structsize)); + p = (char *)buf + sizeof(structsize); + if (sysctl(name, 4, p, &len, NULL, 0) == -1) + err(1, "kern.proc.%d.%u", what, pid); + + *sizep = sizeof(structsize) + len; + return (buf); +} + +static void * +elf_note_procstat_proc(void *arg, size_t *sizep) +{ + + return (procstat_sysctl(arg, KERN_PROC_PID | KERN_PROC_INC_THREAD, + sizeof(struct kinfo_proc), sizep)); +} + +static void * +elf_note_procstat_files(void *arg, size_t *sizep) +{ + + return (procstat_sysctl(arg, KERN_PROC_FILEDESC, + sizeof(struct kinfo_file), sizep)); +} + +static void * +elf_note_procstat_vmmap(void *arg, size_t *sizep) +{ + + return (procstat_sysctl(arg, KERN_PROC_VMMAP, + sizeof(struct kinfo_vmentry), sizep)); +} + +static void * +elf_note_procstat_groups(void *arg, size_t *sizep) +{ + + return (procstat_sysctl(arg, KERN_PROC_GROUPS, sizeof(gid_t), sizep)); +} + +static void * +elf_note_procstat_umask(void *arg, size_t *sizep) +{ + + return (procstat_sysctl(arg, KERN_PROC_UMASK, sizeof(u_short), sizep)); +} + +static void * +elf_note_procstat_osrel(void *arg, size_t *sizep) +{ + + return (procstat_sysctl(arg, KERN_PROC_OSREL, sizeof(int), sizep)); +} + +static void * +elf_note_procstat_psstrings(void *arg, size_t *sizep) +{ + + return (procstat_sysctl(arg, KERN_PROC_PS_STRINGS, + sizeof(vm_offset_t), sizep)); +} + +static void * +elf_note_procstat_auxv(void *arg, size_t *sizep) +{ + + return (procstat_sysctl(arg, KERN_PROC_AUXV, + sizeof(Elf_Auxinfo), sizep)); +} + +static void * +elf_note_procstat_rlimit(void *arg, size_t *sizep) +{ + pid_t pid; + size_t len; + int i, name[5], structsize; + void *buf, *p; + + pid = *(pid_t *)arg; + structsize = sizeof(struct rlimit) * RLIM_NLIMITS; + buf = calloc(1, sizeof(structsize) + structsize); + if (buf == NULL) + errx(1, "out of memory"); + bcopy(&structsize, buf, sizeof(structsize)); + p = (char *)buf + sizeof(structsize); + name[0] = CTL_KERN; + name[1] = KERN_PROC; + name[2] = KERN_PROC_RLIMIT; + name[3] = pid; + len = sizeof(struct rlimit); + for (i = 0; i < RLIM_NLIMITS; i++) { + name[4] = i; + if (sysctl(name, 5, p, &len, NULL, 0) == -1) + err(1, "kern.proc.rlimit.%u", pid); + if (len != sizeof(struct rlimit)) + errx(1, "kern.proc.rlimit.%u: short read", pid); + p += len; + } + + *sizep = sizeof(structsize) + structsize; + return (buf); +} + struct dumpers elfdump = { elf_ident, elf_coredump }; TEXT_SET(dumpset, elfdump); From owner-svn-src-stable-9@FreeBSD.ORG Wed May 22 00:31:34 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 245CBF9F; Wed, 22 May 2013 00:31:34 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id EFEE7AB4; Wed, 22 May 2013 00:31:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4M0VXcp032880; Wed, 22 May 2013 00:31:33 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4M0VXlR032879; Wed, 22 May 2013 00:31:33 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201305220031.r4M0VXlR032879@svn.freebsd.org> From: Xin LI Date: Wed, 22 May 2013 00:31:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250893 - stable/9/sys/ofed/include/linux X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 May 2013 00:31:34 -0000 Author: delphij Date: Wed May 22 00:31:33 2013 New Revision: 250893 URL: http://svnweb.freebsd.org/changeset/base/250893 Log: MFC r250374: According to the documentation, on Linux, cancel_delayed_work() does not do drain (flush_workqueue() in Linux terms) but instead returns true if the work was removed before it is run, or false otherwise. Simulate this by removing the taskqueue_drain() and return the value derived from taskqueue_cancel()'s return value. This would solve a witness warning caused by calling taskqueue_drain() with a non-sleepable lock held, like: taskqueue_drain with the following non-sleepable locks held: exclusive rw lle (lle) r = 0 (0xfffffe001450b410) locked @ /usr/src/sys/netinet/in.c:1484 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xffffff848d4f7690 kdb_backtrace() at kdb_backtrace+0x39/frame 0xffffff848d4f7740 witness_warn() at witness_warn+0x4a8/frame 0xffffff848d4f7800 taskqueue_drain() at taskqueue_drain+0x3a/frame 0xffffff848d4f7840 set_timeout() at set_timeout+0x4a/frame 0xffffff848d4f7860 netevent_callback() at netevent_callback+0x16/frame 0xffffff848d4f7870 arpintr() at arpintr+0x9b5/frame 0xffffff848d4f7930 This do not affect kernel without OFED compiled in. Reported by: Garrett Cooper Modified: stable/9/sys/ofed/include/linux/workqueue.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/ofed/include/linux/workqueue.h ============================================================================== --- stable/9/sys/ofed/include/linux/workqueue.h Wed May 22 00:30:34 2013 (r250892) +++ stable/9/sys/ofed/include/linux/workqueue.h Wed May 22 00:31:33 2013 (r250893) @@ -184,9 +184,9 @@ cancel_delayed_work(struct delayed_work { callout_stop(&work->timer); - if (work->work.taskqueue && - taskqueue_cancel(work->work.taskqueue, &work->work.work_task, NULL)) - taskqueue_drain(work->work.taskqueue, &work->work.work_task); + if (work->work.taskqueue) + return (taskqueue_cancel(work->work.taskqueue, + &work->work.work_task, NULL) == 0); return 0; } From owner-svn-src-stable-9@FreeBSD.ORG Wed May 22 07:52:42 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8CE47B1A; Wed, 22 May 2013 07:52:42 +0000 (UTC) (envelope-from grog@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7BD57FC5; Wed, 22 May 2013 07:52:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4M7qgNZ086789; Wed, 22 May 2013 07:52:42 GMT (envelope-from grog@svn.freebsd.org) Received: (from grog@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4M7qgsj086786; Wed, 22 May 2013 07:52:42 GMT (envelope-from grog@svn.freebsd.org) Message-Id: <201305220752.r4M7qgsj086786@svn.freebsd.org> From: Greg Lehey Date: Wed, 22 May 2013 07:52:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250905 - stable/9/usr.bin/locale X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 May 2013 07:52:42 -0000 Author: grog Date: Wed May 22 07:52:41 2013 New Revision: 250905 URL: http://svnweb.freebsd.org/changeset/base/250905 Log: MFH revisions 242743 to 243202: Make parameters to -c and -k options optional. If no parameters are supplied, print information for all keywords. Improve output of -c option, in particular in conjunction with -k option. Complete man page. Add comment on standards conformity. Modified: stable/9/usr.bin/locale/locale.1 stable/9/usr.bin/locale/locale.c Directory Properties: stable/9/usr.bin/locale/ (props changed) Modified: stable/9/usr.bin/locale/locale.1 ============================================================================== --- stable/9/usr.bin/locale/locale.1 Wed May 22 05:43:14 2013 (r250904) +++ stable/9/usr.bin/locale/locale.1 Wed May 22 07:52:41 2013 (r250905) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 1, 2005 +.Dd November 18, 2012 .Dt LOCALE 1 .Os .Sh NAME @@ -40,7 +40,7 @@ .Op Ar prefix .Nm .Op Fl ck -.Ar keyword ... +.Op Ar keyword ... .Sh DESCRIPTION The .Nm @@ -70,12 +70,16 @@ will respect the .Ev PATH_LOCALE environment variable, and use it instead of the system's default locale directory. -.It Fl m -Print names of all available charmaps. -.It Fl k -Print the names and values of all selected keywords. .It Fl c Print the category name for all selected keywords. +If no keywords are selected, print the category name for all defined +keywords. +.It Fl k +Print the names and values of all selected keywords. +If no keywords are selected, print the names and values of all defined +keywords. +.It Fl m +Print names of all available charmaps. .El .Sh IMPLEMENTATION NOTES The special @@ -89,6 +93,17 @@ a prefix string can be defined to limit .Ex -std .Sh SEE ALSO .Xr setlocale 3 +.Sh STANDARDS +The +.Nm +utility conforms to +.St -p1003.1-2004 . +The +.Ev LC_CTYPE , +.Ev LC_MESSAGES +and +.Ev NLSPATH +environment variables are not interpreted. .Sh BUGS Since .Fx Modified: stable/9/usr.bin/locale/locale.c ============================================================================== --- stable/9/usr.bin/locale/locale.c Wed May 22 05:43:14 2013 (r250904) +++ stable/9/usr.bin/locale/locale.c Wed May 22 07:52:41 2013 (r250905) @@ -31,7 +31,7 @@ * nl_langinfo(3) extensions) * * XXX: correctly handle reserved 'charmap' keyword and '-m' option (require - * localedef(1) implementation). Currently it's handled via + * localedef(1) implementation). Currently it's handled via * nl_langinfo(CODESET). */ @@ -79,32 +79,32 @@ struct _lcinfo { { "LC_MONETARY", LC_MONETARY }, { "LC_MESSAGES", LC_MESSAGES } }; -#define NLCINFO (sizeof(lcinfo)/sizeof(lcinfo[0])) +#define NLCINFO (sizeof(lcinfo)/sizeof(lcinfo[0])) /* ids for values not referenced by nl_langinfo() */ #define KW_ZERO 10000 #define KW_GROUPING (KW_ZERO+1) -#define KW_INT_CURR_SYMBOL (KW_ZERO+2) -#define KW_CURRENCY_SYMBOL (KW_ZERO+3) -#define KW_MON_DECIMAL_POINT (KW_ZERO+4) -#define KW_MON_THOUSANDS_SEP (KW_ZERO+5) -#define KW_MON_GROUPING (KW_ZERO+6) -#define KW_POSITIVE_SIGN (KW_ZERO+7) -#define KW_NEGATIVE_SIGN (KW_ZERO+8) -#define KW_INT_FRAC_DIGITS (KW_ZERO+9) -#define KW_FRAC_DIGITS (KW_ZERO+10) -#define KW_P_CS_PRECEDES (KW_ZERO+11) -#define KW_P_SEP_BY_SPACE (KW_ZERO+12) -#define KW_N_CS_PRECEDES (KW_ZERO+13) -#define KW_N_SEP_BY_SPACE (KW_ZERO+14) -#define KW_P_SIGN_POSN (KW_ZERO+15) -#define KW_N_SIGN_POSN (KW_ZERO+16) -#define KW_INT_P_CS_PRECEDES (KW_ZERO+17) -#define KW_INT_P_SEP_BY_SPACE (KW_ZERO+18) -#define KW_INT_N_CS_PRECEDES (KW_ZERO+19) -#define KW_INT_N_SEP_BY_SPACE (KW_ZERO+20) -#define KW_INT_P_SIGN_POSN (KW_ZERO+21) -#define KW_INT_N_SIGN_POSN (KW_ZERO+22) +#define KW_INT_CURR_SYMBOL (KW_ZERO+2) +#define KW_CURRENCY_SYMBOL (KW_ZERO+3) +#define KW_MON_DECIMAL_POINT (KW_ZERO+4) +#define KW_MON_THOUSANDS_SEP (KW_ZERO+5) +#define KW_MON_GROUPING (KW_ZERO+6) +#define KW_POSITIVE_SIGN (KW_ZERO+7) +#define KW_NEGATIVE_SIGN (KW_ZERO+8) +#define KW_INT_FRAC_DIGITS (KW_ZERO+9) +#define KW_FRAC_DIGITS (KW_ZERO+10) +#define KW_P_CS_PRECEDES (KW_ZERO+11) +#define KW_P_SEP_BY_SPACE (KW_ZERO+12) +#define KW_N_CS_PRECEDES (KW_ZERO+13) +#define KW_N_SEP_BY_SPACE (KW_ZERO+14) +#define KW_P_SIGN_POSN (KW_ZERO+15) +#define KW_N_SIGN_POSN (KW_ZERO+16) +#define KW_INT_P_CS_PRECEDES (KW_ZERO+17) +#define KW_INT_P_SEP_BY_SPACE (KW_ZERO+18) +#define KW_INT_N_CS_PRECEDES (KW_ZERO+19) +#define KW_INT_N_SEP_BY_SPACE (KW_ZERO+20) +#define KW_INT_P_SIGN_POSN (KW_ZERO+21) +#define KW_INT_N_SIGN_POSN (KW_ZERO+22) struct _kwinfo { const char *name; @@ -218,7 +218,7 @@ struct _kwinfo { "(POSIX legacy)" } /* compat */ }; -#define NKWINFO (sizeof(kwinfo)/sizeof(kwinfo[0])) +#define NKWINFO (sizeof(kwinfo)/sizeof(kwinfo[0])) const char *boguslocales[] = { "UTF-8" }; #define NBOGUS (sizeof(boguslocales)/sizeof(boguslocales[0])) @@ -253,12 +253,10 @@ main(int argc, char *argv[]) /* validate arguments */ if (all_locales && all_charmaps) usage(); - if ((all_locales || all_charmaps) && argc > 0) + if ((all_locales || all_charmaps) && argc > 0) usage(); if ((all_locales || all_charmaps) && (prt_categories || prt_keywords)) usage(); - if ((prt_categories || prt_keywords) && argc <= 0) - usage(); /* process '-a' */ if (all_locales) { @@ -281,13 +279,19 @@ main(int argc, char *argv[]) exit(0); } - /* process '-c' and/or '-k' */ + /* process '-c', '-k', or command line arguments. */ if (prt_categories || prt_keywords || argc > 0) { - setlocale(LC_ALL, ""); - while (argc > 0) { - showdetails(*argv); - argv++; - argc--; + if (argc > 0) { + setlocale(LC_ALL, ""); + while (argc > 0) { + showdetails(*argv); + argv++; + argc--; + } + } else { + uint i; + for (i = 0; i < sizeof (kwinfo) / sizeof (struct _kwinfo); i++) + showdetails ((char *)kwinfo [i].name); } exit(0); } @@ -302,8 +306,8 @@ void usage(void) { printf("Usage: locale [ -a | -m ]\n" - " locale -k list [prefix]\n" - " locale [ -ck ] keyword ...\n"); + " locale -k list [prefix]\n" + " locale [ -ck ] [keyword ...]\n"); exit(1); } @@ -423,10 +427,10 @@ init_locales_list(void) } closedir(dirp); - /* make sure that 'POSIX' and 'C' locales are present in the list. + /* make sure that 'POSIX' and 'C' locales are present in the list. * POSIX 1003.1-2001 requires presence of 'POSIX' name only here, but - * we also list 'C' for constistency - */ + * we also list 'C' for constistency + */ if (sl_find(locales, "POSIX") == NULL) sl_add(locales, "POSIX"); @@ -612,7 +616,10 @@ showdetails(char *kw) } if (prt_categories) { - printf("%s\n", lookup_localecat(cat)); + if (prt_keywords) + printf("%-20s ", lookup_localecat(cat)); + else + printf("%-20s\t%s\n", kw, lookup_localecat(cat)); } if (prt_keywords) { @@ -657,7 +664,7 @@ showkeywordslist(char *substring) { size_t i; -#define FMT "%-20s %-12s %-7s %-20s\n" +#define FMT "%-20s %-12s %-7s %-20s\n" if (substring == NULL) printf("List of available keywords\n\n"); From owner-svn-src-stable-9@FreeBSD.ORG Wed May 22 08:44:22 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0D7D4AEE; Wed, 22 May 2013 08:44:22 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D6E6D2F1; Wed, 22 May 2013 08:44:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4M8iL0h005149; Wed, 22 May 2013 08:44:21 GMT (envelope-from scottl@svn.freebsd.org) Received: (from scottl@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4M8iLWJ005148; Wed, 22 May 2013 08:44:21 GMT (envelope-from scottl@svn.freebsd.org) Message-Id: <201305220844.r4M8iLWJ005148@svn.freebsd.org> From: Scott Long Date: Wed, 22 May 2013 08:44:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250906 - stable/9/sys/kern X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 May 2013 08:44:22 -0000 Author: scottl Date: Wed May 22 08:44:21 2013 New Revision: 250906 URL: http://svnweb.freebsd.org/changeset/base/250906 Log: MFC r250327 Add a sysctl vfs.read_min to complement the exiting vfs.read_max. It defaults to 1, meaning that it's off. When read-ahead is enabled on a file, the vfs cluster code deliberately breaks a read into 2 I/O transactions; one to satisfy the actual read, and one to perform read-ahead. This makes sense in low-latency circumstances, but often produces unbalanced i/o transactions that penalize disks. By setting vfs.read_min, we can tell the algorithm to fetch a larger transaction that what we asked for, achieving the same effect as the read-ahead but without the doubled, unbalanced transaction and the slightly lower latency. This significantly helps our workloads with video streaming. Submitted by: emax Reviewed by: kib Obtained from: Netflix Modified: stable/9/sys/kern/vfs_cluster.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/kern/vfs_cluster.c ============================================================================== --- stable/9/sys/kern/vfs_cluster.c Wed May 22 07:52:41 2013 (r250905) +++ stable/9/sys/kern/vfs_cluster.c Wed May 22 08:44:21 2013 (r250906) @@ -75,6 +75,10 @@ static int read_max = 64; SYSCTL_INT(_vfs, OID_AUTO, read_max, CTLFLAG_RW, &read_max, 0, "Cluster read-ahead max block count"); +static int read_min = 1; +SYSCTL_INT(_vfs, OID_AUTO, read_min, CTLFLAG_RW, &read_min, 0, + "Cluster read min block count"); + /* Page expended to mark partially backed buffers */ extern vm_page_t bogus_page; @@ -169,6 +173,7 @@ cluster_read(vp, filesize, lblkno, size, } else { off_t firstread = bp->b_offset; int nblks; + long minread; KASSERT(bp->b_offset != NOOFFSET, ("cluster_read: no buffer offset")); @@ -176,6 +181,13 @@ cluster_read(vp, filesize, lblkno, size, ncontig = 0; /* + * Adjust totread if needed + */ + minread = read_min * size; + if (minread > totread) + totread = minread; + + /* * Compute the total number of blocks that we should read * synchronously. */ From owner-svn-src-stable-9@FreeBSD.ORG Wed May 22 10:37:29 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 34FA9948; Wed, 22 May 2013 10:37:29 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 1675AAEC; Wed, 22 May 2013 10:37:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4MAbSKs044945; Wed, 22 May 2013 10:37:28 GMT (envelope-from scottl@svn.freebsd.org) Received: (from scottl@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4MAbSIq044944; Wed, 22 May 2013 10:37:28 GMT (envelope-from scottl@svn.freebsd.org) Message-Id: <201305221037.r4MAbSIq044944@svn.freebsd.org> From: Scott Long Date: Wed, 22 May 2013 10:37:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250907 - stable/9/sys/kern X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 May 2013 10:37:29 -0000 Author: scottl Date: Wed May 22 10:37:28 2013 New Revision: 250907 URL: http://svnweb.freebsd.org/changeset/base/250907 Log: MFC r248830, r250027, r250409 Submitted by: gibbs, andre, kib Obtained from: Netflix Modified: stable/9/sys/kern/uipc_syscalls.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/kern/uipc_syscalls.c ============================================================================== --- stable/9/sys/kern/uipc_syscalls.c Wed May 22 08:44:21 2013 (r250906) +++ stable/9/sys/kern/uipc_syscalls.c Wed May 22 10:37:28 2013 (r250907) @@ -1835,9 +1835,11 @@ kern_sendfile(struct thread *td, struct struct mbuf *m = NULL; struct sf_buf *sf; struct vm_page *pg; + struct vattr va; off_t off, xfsize, fsbytes = 0, sbytes = 0, rem = 0; int error, hdrlen = 0, mnw = 0; int vfslocked; + int bsize; struct sendfile_sync *sfs = NULL; /* @@ -1852,6 +1854,18 @@ kern_sendfile(struct thread *td, struct vfslocked = VFS_LOCK_GIANT(vp->v_mount); vn_lock(vp, LK_SHARED | LK_RETRY); if (vp->v_type == VREG) { + bsize = vp->v_mount->mnt_stat.f_iosize; + if (uap->nbytes == 0) { + error = VOP_GETATTR(vp, &va, td->td_ucred); + if (error != 0) { + VOP_UNLOCK(vp, 0); + VFS_UNLOCK_GIANT(vfslocked); + obj = NULL; + goto out; + } + rem = va.va_size; + } else + rem = uap->nbytes; obj = vp->v_object; if (obj != NULL) { /* @@ -1869,7 +1883,8 @@ kern_sendfile(struct thread *td, struct obj = NULL; } } - } + } else + bsize = 0; /* silence gcc */ VOP_UNLOCK(vp, 0); VFS_UNLOCK_GIANT(vfslocked); if (obj == NULL) { @@ -1962,11 +1977,20 @@ kern_sendfile(struct thread *td, struct * The outer loop checks the state and available space of the socket * and takes care of the overall progress. */ - for (off = uap->offset, rem = uap->nbytes; ; ) { - struct mbuf *mtail = NULL; - int loopbytes = 0; - int space = 0; - int done = 0; + for (off = uap->offset; ; ) { + struct mbuf *mtail; + int loopbytes; + int space; + int done; + + if ((uap->nbytes != 0 && uap->nbytes == fsbytes) || + (uap->nbytes == 0 && va.va_size == fsbytes)) + break; + + mtail = NULL; + loopbytes = 0; + space = 0; + done = 0; /* * Check the socket state for ongoing connection, @@ -2034,6 +2058,20 @@ retry_space: */ space -= hdrlen; + vfslocked = VFS_LOCK_GIANT(vp->v_mount); + error = vn_lock(vp, LK_SHARED); + if (error != 0) { + VFS_UNLOCK_GIANT(vfslocked); + goto done; + } + error = VOP_GETATTR(vp, &va, td->td_ucred); + if (error != 0 || off >= va.va_size) { + VOP_UNLOCK(vp, 0); + VFS_UNLOCK_GIANT(vfslocked); + goto done; + } + VFS_UNLOCK_GIANT(vfslocked); + /* * Loop and construct maximum sized mbuf chain to be bulk * dumped into socket buffer. @@ -2043,25 +2081,20 @@ retry_space: vm_offset_t pgoff; struct mbuf *m0; - VM_OBJECT_LOCK(obj); /* * Calculate the amount to transfer. * Not to exceed a page, the EOF, * or the passed in nbytes. */ pgoff = (vm_offset_t)(off & PAGE_MASK); - xfsize = omin(PAGE_SIZE - pgoff, - obj->un_pager.vnp.vnp_size - uap->offset - - fsbytes - loopbytes); if (uap->nbytes) rem = (uap->nbytes - fsbytes - loopbytes); else - rem = obj->un_pager.vnp.vnp_size - + rem = va.va_size - uap->offset - fsbytes - loopbytes; - xfsize = omin(rem, xfsize); + xfsize = omin(PAGE_SIZE - pgoff, rem); xfsize = omin(space - loopbytes, xfsize); if (xfsize <= 0) { - VM_OBJECT_UNLOCK(obj); done = 1; /* all data sent */ break; } @@ -2071,6 +2104,7 @@ retry_space: * if not found or wait and loop if busy. */ pindex = OFF_TO_IDX(off); + VM_OBJECT_LOCK(obj); pg = vm_page_grab(obj, pindex, VM_ALLOC_NOBUSY | VM_ALLOC_NORMAL | VM_ALLOC_WIRED | VM_ALLOC_RETRY); @@ -2088,7 +2122,6 @@ retry_space: else if (uap->flags & SF_NODISKIO) error = EBUSY; else { - int bsize; ssize_t resid; /* @@ -2100,25 +2133,16 @@ retry_space: /* * Get the page from backing store. - */ - vfslocked = VFS_LOCK_GIANT(vp->v_mount); - error = vn_lock(vp, LK_SHARED); - if (error != 0) - goto after_read; - bsize = vp->v_mount->mnt_stat.f_iosize; - - /* * XXXMAC: Because we don't have fp->f_cred * here, we pass in NOCRED. This is probably * wrong, but is consistent with our original * implementation. */ + vfslocked = VFS_LOCK_GIANT(vp->v_mount); error = vn_rdwr(UIO_READ, vp, NULL, MAXBSIZE, trunc_page(off), UIO_NOCOPY, IO_NODELOCKED | IO_VMIO | ((MAXBSIZE / bsize) << IO_SEQSHIFT), td->td_ucred, NOCRED, &resid, td); - VOP_UNLOCK(vp, 0); - after_read: VFS_UNLOCK_GIANT(vfslocked); VM_OBJECT_LOCK(obj); vm_page_io_finish(pg); @@ -2174,7 +2198,7 @@ retry_space: m0 = m_get((mnw ? M_NOWAIT : M_WAITOK), MT_DATA); if (m0 == NULL) { error = (mnw ? EAGAIN : ENOBUFS); - sf_buf_mext((void *)sf_buf_kva(sf), sf); + sf_buf_mext(NULL, sf); break; } MEXTADD(m0, sf_buf_kva(sf), PAGE_SIZE, sf_buf_mext, @@ -2202,6 +2226,8 @@ retry_space: } } + VOP_UNLOCK(vp, 0); + /* Add the buffer chain to the socket buffer. */ if (m != NULL) { int mlen, err; From owner-svn-src-stable-9@FreeBSD.ORG Wed May 22 15:17:16 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B9688897; Wed, 22 May 2013 15:17:16 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) by mx1.freebsd.org (Postfix) with ESMTP id 8C898CDF; Wed, 22 May 2013 15:17:16 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 3303BB97D; Wed, 22 May 2013 11:17:15 -0400 (EDT) From: John Baldwin To: Scott Long Subject: Re: svn commit: r250907 - stable/9/sys/kern Date: Wed, 22 May 2013 11:07:36 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p25; KDE/4.5.5; amd64; ; ) References: <201305221037.r4MAbSIq044944@svn.freebsd.org> In-Reply-To: <201305221037.r4MAbSIq044944@svn.freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201305221107.36948.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 22 May 2013 11:17:15 -0400 (EDT) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 May 2013 15:17:16 -0000 On Wednesday, May 22, 2013 6:37:28 am Scott Long wrote: > Author: scottl > Date: Wed May 22 10:37:28 2013 > New Revision: 250907 > URL: http://svnweb.freebsd.org/changeset/base/250907 > > Log: > MFC r248830, r250027, r250409 > > Submitted by: gibbs, andre, kib > Obtained from: Netflix What does it do? (Perhaps a forced commit to include the missing bits of the commit message?) -- John Baldwin From owner-svn-src-stable-9@FreeBSD.ORG Wed May 22 18:26:13 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id DB093227; Wed, 22 May 2013 18:26:13 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CBCCBCD5; Wed, 22 May 2013 18:26:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4MIQDka008756; Wed, 22 May 2013 18:26:13 GMT (envelope-from jamie@svn.freebsd.org) Received: (from jamie@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4MIQCTM008747; Wed, 22 May 2013 18:26:12 GMT (envelope-from jamie@svn.freebsd.org) Message-Id: <201305221826.r4MIQCTM008747@svn.freebsd.org> From: Jamie Gritton Date: Wed, 22 May 2013 18:26:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250915 - in stable/9: etc etc/rc.d sys/kern X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 May 2013 18:26:13 -0000 Author: jamie Date: Wed May 22 18:26:12 2013 New Revision: 250915 URL: http://svnweb.freebsd.org/changeset/base/250915 Log: MFC r250804: Refine the "nojail" rc keyword, adding "nojailvnet" for files that don't apply to most jails but do apply to vnet jails. This includes adding a new sysctl "security.jail.vnet" to identify vnet jails. PR: conf/149050 Submitted by: mdodd Modified: stable/9/etc/rc stable/9/etc/rc.d/ipfw stable/9/etc/rc.d/netif stable/9/etc/rc.d/routing stable/9/etc/rc.shutdown stable/9/sys/kern/kern_jail.c Directory Properties: stable/9/etc/ (props changed) stable/9/etc/rc.d/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/etc/rc ============================================================================== --- stable/9/etc/rc Wed May 22 17:47:45 2013 (r250914) +++ stable/9/etc/rc Wed May 22 18:26:12 2013 (r250915) @@ -77,6 +77,9 @@ if [ `/sbin/sysctl -n security.jail.jail if [ "$early_late_divider" = "FILESYSTEMS" ]; then early_late_divider=NETWORKING fi + if [ `/sbin/sysctl -n security.jail.vnet` -ne 1 ]; then + skip="$skip -s nojailvnet" + fi fi # Do a first pass to get everything up to $early_late_divider so that Modified: stable/9/etc/rc.d/ipfw ============================================================================== --- stable/9/etc/rc.d/ipfw Wed May 22 17:47:45 2013 (r250914) +++ stable/9/etc/rc.d/ipfw Wed May 22 18:26:12 2013 (r250915) @@ -5,7 +5,7 @@ # PROVIDE: ipfw # REQUIRE: ppp -# KEYWORD: nojail +# KEYWORD: nojailvnet . /etc/rc.subr . /etc/network.subr Modified: stable/9/etc/rc.d/netif ============================================================================== --- stable/9/etc/rc.d/netif Wed May 22 17:47:45 2013 (r250914) +++ stable/9/etc/rc.d/netif Wed May 22 18:26:12 2013 (r250915) @@ -28,7 +28,7 @@ # PROVIDE: netif # REQUIRE: atm1 FILESYSTEMS serial sppp sysctl # REQUIRE: ipfilter ipfs -# KEYWORD: nojail +# KEYWORD: nojailvnet . /etc/rc.subr . /etc/network.subr Modified: stable/9/etc/rc.d/routing ============================================================================== --- stable/9/etc/rc.d/routing Wed May 22 17:47:45 2013 (r250914) +++ stable/9/etc/rc.d/routing Wed May 22 18:26:12 2013 (r250915) @@ -7,7 +7,7 @@ # PROVIDE: routing # REQUIRE: faith netif ppp stf -# KEYWORD: nojail +# KEYWORD: nojailvnet . /etc/rc.subr . /etc/network.subr Modified: stable/9/etc/rc.shutdown ============================================================================== --- stable/9/etc/rc.shutdown Wed May 22 17:47:45 2013 (r250914) +++ stable/9/etc/rc.shutdown Wed May 22 18:26:12 2013 (r250915) @@ -81,7 +81,12 @@ fi # and perform the operation # rcorder_opts="-k shutdown" -[ `/sbin/sysctl -n security.jail.jailed` -eq 1 ] && rcorder_opts="$rcorder_opts -s nojail" +if [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ]; then + rcorder_opts="$rcorder_opts -s nojail" + if [ `/sbin/sysctl -n security.jail.vnet` -ne 1 ]; then + rcorder_opts="$rcorder_opts -s nojailvnet" + fi +fi case ${local_startup} in [Nn][Oo] | '') ;; Modified: stable/9/sys/kern/kern_jail.c ============================================================================== --- stable/9/sys/kern/kern_jail.c Wed May 22 17:47:45 2013 (r250914) +++ stable/9/sys/kern/kern_jail.c Wed May 22 18:26:12 2013 (r250915) @@ -4147,6 +4147,26 @@ SYSCTL_PROC(_security_jail, OID_AUTO, ja CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, sysctl_jail_jailed, "I", "Process in jail?"); +static int +sysctl_jail_vnet(SYSCTL_HANDLER_ARGS) +{ + int error, havevnet; +#ifdef VIMAGE + struct ucred *cred = req->td->td_ucred; + + havevnet = jailed(cred) && prison_owns_vnet(cred); +#else + havevnet = 0; +#endif + error = SYSCTL_OUT(req, &havevnet, sizeof(havevnet)); + + return (error); +} + +SYSCTL_PROC(_security_jail, OID_AUTO, vnet, + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + sysctl_jail_vnet, "I", "Jail owns VNET?"); + #if defined(INET) || defined(INET6) SYSCTL_UINT(_security_jail, OID_AUTO, jail_max_af_ips, CTLFLAG_RW, &jail_max_af_ips, 0, From owner-svn-src-stable-9@FreeBSD.ORG Thu May 23 11:29:29 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 65B2C4DE; Thu, 23 May 2013 11:29:29 +0000 (UTC) (envelope-from oleg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 57891885; Thu, 23 May 2013 11:29:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4NBTT8b072514; Thu, 23 May 2013 11:29:29 GMT (envelope-from oleg@svn.freebsd.org) Received: (from oleg@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4NBTSg8072511; Thu, 23 May 2013 11:29:28 GMT (envelope-from oleg@svn.freebsd.org) Message-Id: <201305231129.r4NBTSg8072511@svn.freebsd.org> From: Oleg Bulyzhin Date: Thu, 23 May 2013 11:29:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250927 - in stable/9/sys: net netinet netinet6 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 May 2013 11:29:29 -0000 Author: oleg Date: Thu May 23 11:29:28 2013 New Revision: 250927 URL: http://svnweb.freebsd.org/changeset/base/250927 Log: MFC: r249628, r249742 - recover missing arp_ifinit() call. - plug static llentry leak (ipv4 & ipv6 were affected). PR: kern/172985 Modified: stable/9/sys/net/if_vlan.c stable/9/sys/netinet/in.c stable/9/sys/netinet6/in6.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/net/if_vlan.c ============================================================================== --- stable/9/sys/net/if_vlan.c Thu May 23 05:42:35 2013 (r250926) +++ stable/9/sys/net/if_vlan.c Thu May 23 11:29:28 2013 (r250927) @@ -41,6 +41,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_inet.h" #include "opt_vlan.h" #include @@ -66,6 +67,11 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef INET +#include +#include +#endif + #define VLANNAME "vlan" #define VLAN_DEF_HWIDTH 4 #define VLAN_IFFLAGS (IFF_BROADCAST | IFF_MULTICAST) Modified: stable/9/sys/netinet/in.c ============================================================================== --- stable/9/sys/netinet/in.c Thu May 23 05:42:35 2013 (r250926) +++ stable/9/sys/netinet/in.c Thu May 23 11:29:28 2013 (r250927) @@ -1528,10 +1528,14 @@ in_lltable_lookup(struct lltable *llt, u LLE_WLOCK(lle); lle->la_flags |= LLE_DELETED; EVENTHANDLER_INVOKE(arp_update_event, lle); - LLE_WUNLOCK(lle); #ifdef DIAGNOSTIC - log(LOG_INFO, "ifaddr cache = %p is deleted\n", lle); + log(LOG_INFO, "ifaddr cache = %p is deleted\n", lle); #endif + if ((lle->la_flags & + (LLE_STATIC | LLE_IFADDR)) == LLE_STATIC) + llentry_free(lle); + else + LLE_WUNLOCK(lle); } lle = (void *)-1; Modified: stable/9/sys/netinet6/in6.c ============================================================================== --- stable/9/sys/netinet6/in6.c Thu May 23 05:42:35 2013 (r250926) +++ stable/9/sys/netinet6/in6.c Thu May 23 11:29:28 2013 (r250927) @@ -194,10 +194,10 @@ in6_ifremloop(struct ifaddr *ifa) ia = ifa2ia6(ifa); ifp = ifa->ifa_ifp; - IF_AFDATA_LOCK(ifp); - lla_lookup(LLTABLE6(ifp), (LLE_DELETE | LLE_IFADDR), - (struct sockaddr *)&ia->ia_addr); - IF_AFDATA_UNLOCK(ifp); + memcpy(&addr, &ia->ia_addr, sizeof(ia->ia_addr)); + memcpy(&mask, &ia->ia_prefixmask, sizeof(ia->ia_prefixmask)); + lltable_prefix_free(AF_INET6, (struct sockaddr *)&addr, + (struct sockaddr *)&mask, LLE_STATIC); /* * initialize for rtmsg generation @@ -209,8 +209,6 @@ in6_ifremloop(struct ifaddr *ifa) gateway.sdl_alen = ifp->if_addrlen; bzero(&rt0, sizeof(rt0)); rt0.rt_gateway = (struct sockaddr *)&gateway; - memcpy(&mask, &ia->ia_prefixmask, sizeof(ia->ia_prefixmask)); - memcpy(&addr, &ia->ia_addr, sizeof(ia->ia_addr)); rt_mask(&rt0) = (struct sockaddr *)&mask; rt_key(&rt0) = (struct sockaddr *)&addr; rt0.rt_flags = RTF_HOST | RTF_STATIC; @@ -2581,10 +2579,14 @@ in6_lltable_lookup(struct lltable *llt, if (!(lle->la_flags & LLE_IFADDR) || (flags & LLE_IFADDR)) { LLE_WLOCK(lle); lle->la_flags |= LLE_DELETED; - LLE_WUNLOCK(lle); #ifdef DIAGNOSTIC - log(LOG_INFO, "ifaddr cache = %p is deleted\n", lle); + log(LOG_INFO, "ifaddr cache = %p is deleted\n", lle); #endif + if ((lle->la_flags & + (LLE_STATIC | LLE_IFADDR)) == LLE_STATIC) + llentry_free(lle); + else + LLE_WUNLOCK(lle); } lle = (void *)-1; } From owner-svn-src-stable-9@FreeBSD.ORG Thu May 23 15:41:09 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id DC903240; Thu, 23 May 2013 15:41:09 +0000 (UTC) (envelope-from schweikh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CEC45C2F; Thu, 23 May 2013 15:41:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4NFf9YN062578; Thu, 23 May 2013 15:41:09 GMT (envelope-from schweikh@svn.freebsd.org) Received: (from schweikh@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4NFf9x1062577; Thu, 23 May 2013 15:41:09 GMT (envelope-from schweikh@svn.freebsd.org) Message-Id: <201305231541.r4NFf9x1062577@svn.freebsd.org> From: Jens Schweikhardt Date: Thu, 23 May 2013 15:41:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250935 - stable/9 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 May 2013 15:41:09 -0000 Author: schweikh Date: Thu May 23 15:41:09 2013 New Revision: 250935 URL: http://svnweb.freebsd.org/changeset/base/250935 Log: Correct typo s/with/wish. Spaces to tabs at SOL while I'm here. Modified: stable/9/UPDATING Modified: stable/9/UPDATING ============================================================================== --- stable/9/UPDATING Thu May 23 14:37:08 2013 (r250934) +++ stable/9/UPDATING Thu May 23 15:41:09 2013 (r250935) @@ -24,7 +24,7 @@ Items affecting the ports and packages s Due to the use of the new -l option to install(1) during build and install, you must take care not to directly set the INSTALL make variable in your /etc/make.conf, /etc/src.conf, or on the - command line. If you with to use the -C flag for all installs + command line. If you wish to use the -C flag for all installs you may be able to add INSTALL+=-C to /etc/make.conf or /etc/src.conf. @@ -68,8 +68,8 @@ Items affecting the ports and packages s pools. The first two read-only compatible "feature flags" for ZFS pools are "com.delphix:async_destroy" and "com.delphix:empty_bpobj". For more information read the new zpool-features(7) manual page. - Please refer to the "ZFS notes" section of this file for information - on upgrading boot ZFS pools. + Please refer to the "ZFS notes" section of this file for information + on upgrading boot ZFS pools. 20121114: The commit introducing bsd.compiler.mk breaks the traditional From owner-svn-src-stable-9@FreeBSD.ORG Thu May 23 16:39:43 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id BF8B455A; Thu, 23 May 2013 16:39:43 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id B15CFF87; Thu, 23 May 2013 16:39:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4NGdhTQ083167; Thu, 23 May 2013 16:39:43 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4NGdhDB083160; Thu, 23 May 2013 16:39:43 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201305231639.r4NGdhDB083160@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Thu, 23 May 2013 16:39:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250937 - stable/9/gnu/usr.bin/grep X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 May 2013 16:39:43 -0000 Author: pfg Date: Thu May 23 16:39:42 2013 New Revision: 250937 URL: http://svnweb.freebsd.org/changeset/base/250937 Log: MFC r250823: grep: change some int types. Change several int variables to size_t, ssize_t, or ptrdiff_t. This should fix the bug described in CVE-2012-5667 when an input line is so long that its length cannot be stored in an int variable. Obtained from: NetBSD Modified: stable/9/gnu/usr.bin/grep/dfa.c stable/9/gnu/usr.bin/grep/grep.c stable/9/gnu/usr.bin/grep/search.c Directory Properties: stable/9/ (props changed) Modified: stable/9/gnu/usr.bin/grep/dfa.c ============================================================================== --- stable/9/gnu/usr.bin/grep/dfa.c Thu May 23 16:37:43 2013 (r250936) +++ stable/9/gnu/usr.bin/grep/dfa.c Thu May 23 16:39:42 2013 (r250937) @@ -334,9 +334,10 @@ static int hard_LC_COLLATE; /* Nonzero i #ifdef MBS_SUPPORT /* These variables are used only if (MB_CUR_MAX > 1). */ static mbstate_t mbs; /* Mbstate for mbrlen(). */ -static int cur_mb_len; /* Byte length of the current scanning - multibyte character. */ -static int cur_mb_index; /* Byte index of the current scanning multibyte +static ssize_t cur_mb_len; /* Byte length of the current scanning + multibyte character. Must also handle + negative result from mbrlen(). */ +static ssize_t cur_mb_index; /* Byte index of the current scanning multibyte character. singlebyte character : cur_mb_index = 0 @@ -369,7 +370,7 @@ static unsigned char const *buf_end; /* /* This function update cur_mb_len, and cur_mb_index. p points current lexptr, len is the remaining buffer length. */ static void -update_mb_len_index (unsigned char const *p, int len) +update_mb_len_index (unsigned char const *p, size_t len) { /* If last character is a part of a multibyte character, we update cur_mb_index. */ @@ -2463,7 +2464,7 @@ match_mb_charset (struct dfa *d, int s, int match; /* Flag which represent that matching succeed. */ int match_len; /* Length of the character (or collating element) with which this operator match. */ - int op_len; /* Length of the operator. */ + size_t op_len; /* Length of the operator. */ char buffer[128]; wchar_t wcbuf[6]; Modified: stable/9/gnu/usr.bin/grep/grep.c ============================================================================== --- stable/9/gnu/usr.bin/grep/grep.c Thu May 23 16:37:43 2013 (r250936) +++ stable/9/gnu/usr.bin/grep/grep.c Thu May 23 16:39:42 2013 (r250937) @@ -1346,9 +1346,9 @@ int main (int argc, char **argv) { char *keys; - size_t keycc, oldcc, keyalloc; + size_t cc, keycc, oldcc, keyalloc; int with_filenames; - int opt, cc, status; + int opt, status; int default_context; FILE *fp; extern char *optarg; Modified: stable/9/gnu/usr.bin/grep/search.c ============================================================================== --- stable/9/gnu/usr.bin/grep/search.c Thu May 23 16:37:43 2013 (r250936) +++ stable/9/gnu/usr.bin/grep/search.c Thu May 23 16:39:42 2013 (r250937) @@ -112,7 +112,7 @@ static void kwsinit (void) { static char trans[NCHAR]; - int i; + size_t i; if (match_icase) for (i = 0; i < NCHAR; ++i) @@ -326,7 +326,8 @@ EGexecute (char const *buf, size_t size, { register char const *buflim, *beg, *end; char eol = eolbyte; - int backref, start, len; + int backref; + ptrdiff_t start, len; struct kwsmatch kwsm; size_t i, ret_val; static int use_dfa; From owner-svn-src-stable-9@FreeBSD.ORG Thu May 23 22:45:59 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B7C0D2CF; Thu, 23 May 2013 22:45:59 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 9874B6D0; Thu, 23 May 2013 22:45:59 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4NMjxPP016597; Thu, 23 May 2013 22:45:59 GMT (envelope-from scottl@svn.freebsd.org) Received: (from scottl@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4NMjwtf016592; Thu, 23 May 2013 22:45:58 GMT (envelope-from scottl@svn.freebsd.org) Message-Id: <201305232245.r4NMjwtf016592@svn.freebsd.org> From: Scott Long Date: Thu, 23 May 2013 22:45:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250947 - in stable/9/sys: kern ufs/ffs vm X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 May 2013 22:45:59 -0000 Author: scottl Date: Thu May 23 22:45:58 2013 New Revision: 250947 URL: http://svnweb.freebsd.org/changeset/base/250947 Log: MFC r248283: Some style fixes Submitted by: kib Obtained from: Netflix Modified: stable/9/sys/kern/vfs_bio.c stable/9/sys/kern/vfs_cluster.c stable/9/sys/ufs/ffs/ffs_balloc.c stable/9/sys/vm/vnode_pager.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/kern/vfs_bio.c ============================================================================== --- stable/9/sys/kern/vfs_bio.c Thu May 23 22:11:57 2013 (r250946) +++ stable/9/sys/kern/vfs_bio.c Thu May 23 22:45:58 2013 (r250947) @@ -855,9 +855,8 @@ breadn(struct vnode * vp, daddr_t blkno, * getblk(). Also starts asynchronous I/O on read-ahead blocks. */ int -breadn_flags(struct vnode * vp, daddr_t blkno, int size, - daddr_t * rablkno, int *rabsize, int cnt, - struct ucred * cred, int flags, struct buf **bpp) +breadn_flags(struct vnode *vp, daddr_t blkno, int size, daddr_t *rablkno, + int *rabsize, int cnt, struct ucred *cred, int flags, struct buf **bpp) { struct buf *bp; int rv = 0, readwait = 0; @@ -1844,7 +1843,7 @@ vfs_bio_awrite(struct buf *bp) nwritten = bp->b_bufsize; (void) bwrite(bp); - return nwritten; + return (nwritten); } /* @@ -2678,7 +2677,7 @@ vfs_setdirty_locked_object(struct buf *b * prior to issuing the READ. biodone() will *not* clear B_INVAL. */ struct buf * -getblk(struct vnode * vp, daddr_t blkno, int size, int slpflag, int slptimeo, +getblk(struct vnode *vp, daddr_t blkno, int size, int slpflag, int slptimeo, int flags) { struct buf *bp; @@ -2752,9 +2751,8 @@ loop: BO_UNLOCK(bo); /* - * check for size inconsistancies for non-VMIO case. + * check for size inconsistencies for non-VMIO case. */ - if (bp->b_bcount != size) { if ((bp->b_flags & B_VMIO) == 0 || (size > bp->b_kvasize)) { Modified: stable/9/sys/kern/vfs_cluster.c ============================================================================== --- stable/9/sys/kern/vfs_cluster.c Thu May 23 22:11:57 2013 (r250946) +++ stable/9/sys/kern/vfs_cluster.c Thu May 23 22:45:58 2013 (r250947) @@ -581,7 +581,7 @@ cluster_wbuild_wb(struct vnode *vp, long { int r = 0; - switch(write_behind) { + switch (write_behind) { case 2: if (start_lbn < len) break; Modified: stable/9/sys/ufs/ffs/ffs_balloc.c ============================================================================== --- stable/9/sys/ufs/ffs/ffs_balloc.c Thu May 23 22:11:57 2013 (r250946) +++ stable/9/sys/ufs/ffs/ffs_balloc.c Thu May 23 22:45:58 2013 (r250947) @@ -681,9 +681,9 @@ ffs_balloc_ufs2(struct vnode *vp, off_t if (osize < fs->fs_bsize && osize > 0) { UFS_LOCK(ump); error = ffs_realloccg(ip, nb, dp->di_db[nb], - ffs_blkpref_ufs2(ip, lastlbn, (int)nb, - &dp->di_db[0]), osize, (int)fs->fs_bsize, - flags, cred, &bp); + ffs_blkpref_ufs2(ip, lastlbn, (int)nb, + &dp->di_db[0]), osize, (int)fs->fs_bsize, + flags, cred, &bp); if (error) return (error); if (DOINGSOFTDEP(vp)) @@ -735,7 +735,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t UFS_LOCK(ump); error = ffs_realloccg(ip, lbn, dp->di_db[lbn], ffs_blkpref_ufs2(ip, lbn, (int)lbn, - &dp->di_db[0]), osize, nsize, flags, + &dp->di_db[0]), osize, nsize, flags, cred, &bp); if (error) return (error); Modified: stable/9/sys/vm/vnode_pager.c ============================================================================== --- stable/9/sys/vm/vnode_pager.c Thu May 23 22:11:57 2013 (r250946) +++ stable/9/sys/vm/vnode_pager.c Thu May 23 22:45:58 2013 (r250947) @@ -908,7 +908,7 @@ vnode_pager_generic_getpages(vp, m, byte } bp = getpbuf(&vnode_pbuf_freecnt); - kva = (vm_offset_t) bp->b_data; + kva = (vm_offset_t)bp->b_data; /* * and map the pages to be read into the kva From owner-svn-src-stable-9@FreeBSD.ORG Thu May 23 22:48:41 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 24E54464; Thu, 23 May 2013 22:48:41 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 15EAF6ED; Thu, 23 May 2013 22:48:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4NMmeW0017124; Thu, 23 May 2013 22:48:40 GMT (envelope-from scottl@svn.freebsd.org) Received: (from scottl@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4NMmeUc017123; Thu, 23 May 2013 22:48:40 GMT (envelope-from scottl@svn.freebsd.org) Message-Id: <201305232248.r4NMmeUc017123@svn.freebsd.org> From: Scott Long Date: Thu, 23 May 2013 22:48:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250948 - stable/9/sys/cam X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 May 2013 22:48:41 -0000 Author: scottl Date: Thu May 23 22:48:40 2013 New Revision: 250948 URL: http://svnweb.freebsd.org/changeset/base/250948 Log: MFC 248501: Assert that a ccb passed to cam_periph_mapmem() for XPT_SCSI_IO and XPT_ATA_IO holds virtual buffer address. Submitted by: kib Obtained from: Netflix Modified: stable/9/sys/cam/cam_periph.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/cam_periph.c ============================================================================== --- stable/9/sys/cam/cam_periph.c Thu May 23 22:45:58 2013 (r250947) +++ stable/9/sys/cam/cam_periph.c Thu May 23 22:48:40 2013 (r250948) @@ -733,6 +733,8 @@ cam_periph_mapmem(union ccb *ccb, struct case XPT_CONT_TARGET_IO: if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE) return(0); + KASSERT((ccb->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_VADDR, + ("not VADDR for SCSI_IO %p %x\n", ccb, ccb->ccb_h.flags)); data_ptrs[0] = &ccb->csio.data_ptr; lengths[0] = ccb->csio.dxfer_len; @@ -742,6 +744,8 @@ cam_periph_mapmem(union ccb *ccb, struct case XPT_ATA_IO: if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE) return(0); + KASSERT((ccb->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_VADDR, + ("not VADDR for ATA_IO %p %x\n", ccb, ccb->ccb_h.flags)); data_ptrs[0] = &ccb->ataio.data_ptr; lengths[0] = ccb->ataio.dxfer_len; From owner-svn-src-stable-9@FreeBSD.ORG Fri May 24 05:26:42 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 49FEBEC9; Fri, 24 May 2013 05:26:42 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from onyx.glenbarber.us (onyx.glenbarber.us [199.48.134.227]) by mx1.freebsd.org (Postfix) with ESMTP id 29CB5AF2; Fri, 24 May 2013 05:26:41 +0000 (UTC) Received: from glenbarber.us (kaos.glenbarber.us [71.224.221.174]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: gjb) by onyx.glenbarber.us (Postfix) with ESMTPSA id 0EBA523F804; Fri, 24 May 2013 01:26:41 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.8.3 onyx.glenbarber.us 0EBA523F804 Authentication-Results: onyx.glenbarber.us; dkim=none reason="no signature"; dkim-adsp=none Date: Fri, 24 May 2013 01:26:39 -0400 From: Glen Barber To: Scott Long Subject: Re: svn commit: r250948 - stable/9/sys/cam Message-ID: <20130524052639.GG28865@glenbarber.us> References: <201305232248.r4NMmeUc017123@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="7lMq7vMTJT4tNk0a" Content-Disposition: inline In-Reply-To: <201305232248.r4NMmeUc017123@svn.freebsd.org> X-Operating-System: FreeBSD 10.0-CURRENT amd64 User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 May 2013 05:26:42 -0000 --7lMq7vMTJT4tNk0a Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 23, 2013 at 10:48:40PM +0000, Scott Long wrote: > Author: scottl > Date: Thu May 23 22:48:40 2013 > New Revision: 250948 > URL: http://svnweb.freebsd.org/changeset/base/250948 >=20 > Log: > MFC 248501: > =20 > Assert that a ccb passed to cam_periph_mapmem() for XPT_SCSI_IO and > XPT_ATA_IO holds virtual buffer address. > =20 > Submitted by: kib > Obtained from: Netflix >=20 > Modified: > stable/9/sys/cam/cam_periph.c > Directory Properties: > stable/9/sys/ (props changed) >=20 I think this breaks stable/9 build... http://tinderbox.freebsd.org/tinderbox-freebsd9-build-RELENG_9-arm-arm.full Glen --7lMq7vMTJT4tNk0a Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (FreeBSD) iQEcBAEBCAAGBQJRnvoPAAoJEFJPDDeguUajp90IAJ585xUcLibTNNQugIxiyVGc 3IAi5IbB2wU2g9ykvjMbHdwg3t43Nj1PEb5J0VvQBpBBcUXZhRbt4PguNp3ErOmD X0Zhn8UupfCh4+KjLqBCUA1zPHWjhgKhe7MUlH9EG/eQhTUwANolmB+kPUFjNwG+ RXj475Sp1jME61tiRobSppbq33aw2WB3++TqLoMBXr+RiOSiY/qKRmP5WOEN43YK w0XMJEM0nO2+LTVNWp8kBkG9oSLL8DlEI3bqh61V+XYQ4W0rb72744tzL1FUzrN8 FRsy+7FWWIcpqylz4WTFYcsrr8AZLFyCIgAIvJ6S6K/uTucfYqiQ8Wjxnt+fmus= =E32B -----END PGP SIGNATURE----- --7lMq7vMTJT4tNk0a-- From owner-svn-src-stable-9@FreeBSD.ORG Fri May 24 06:13:36 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B1E18513; Fri, 24 May 2013 06:13:36 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A2561EAF; Fri, 24 May 2013 06:13:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4O6DaYZ074088; Fri, 24 May 2013 06:13:36 GMT (envelope-from scottl@svn.freebsd.org) Received: (from scottl@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4O6Dade074087; Fri, 24 May 2013 06:13:36 GMT (envelope-from scottl@svn.freebsd.org) Message-Id: <201305240613.r4O6Dade074087@svn.freebsd.org> From: Scott Long Date: Fri, 24 May 2013 06:13:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250961 - stable/9/sys/cam X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 May 2013 06:13:36 -0000 Author: scottl Date: Fri May 24 06:13:36 2013 New Revision: 250961 URL: http://svnweb.freebsd.org/changeset/base/250961 Log: Revert r250948, it was merged too soon. Modified: stable/9/sys/cam/cam_periph.c Modified: stable/9/sys/cam/cam_periph.c ============================================================================== --- stable/9/sys/cam/cam_periph.c Fri May 24 04:03:04 2013 (r250960) +++ stable/9/sys/cam/cam_periph.c Fri May 24 06:13:36 2013 (r250961) @@ -733,8 +733,6 @@ cam_periph_mapmem(union ccb *ccb, struct case XPT_CONT_TARGET_IO: if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE) return(0); - KASSERT((ccb->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_VADDR, - ("not VADDR for SCSI_IO %p %x\n", ccb, ccb->ccb_h.flags)); data_ptrs[0] = &ccb->csio.data_ptr; lengths[0] = ccb->csio.dxfer_len; @@ -744,8 +742,6 @@ cam_periph_mapmem(union ccb *ccb, struct case XPT_ATA_IO: if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE) return(0); - KASSERT((ccb->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_VADDR, - ("not VADDR for ATA_IO %p %x\n", ccb, ccb->ccb_h.flags)); data_ptrs[0] = &ccb->ataio.data_ptr; lengths[0] = ccb->ataio.dxfer_len; From owner-svn-src-stable-9@FreeBSD.ORG Fri May 24 09:30:11 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0F25A66D; Fri, 24 May 2013 09:30:11 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id F40DADE7; Fri, 24 May 2013 09:30:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4O9UAkW042696; Fri, 24 May 2013 09:30:10 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4O9UAgb042695; Fri, 24 May 2013 09:30:10 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201305240930.r4O9UAgb042695@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 24 May 2013 09:30:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250964 - stable/9/sys/dev/pci X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 May 2013 09:30:11 -0000 Author: kib Date: Fri May 24 09:30:10 2013 New Revision: 250964 URL: http://svnweb.freebsd.org/changeset/base/250964 Log: MFC r250740: Add new capability types encodings from HyperTransport I/O Link Specification revisions 3.00 and 3.10. Modified: stable/9/sys/dev/pci/pcireg.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/pci/pcireg.h ============================================================================== --- stable/9/sys/dev/pci/pcireg.h Fri May 24 09:22:43 2013 (r250963) +++ stable/9/sys/dev/pci/pcireg.h Fri May 24 09:30:10 2013 (r250964) @@ -612,6 +612,10 @@ #define PCIM_HTCAP_VCSET 0xb800 /* 10111 */ #define PCIM_HTCAP_RETRY_MODE 0xc000 /* 11000 */ #define PCIM_HTCAP_X86_ENCODING 0xc800 /* 11001 */ +#define PCIM_HTCAP_GEN3 0xd000 /* 11010 */ +#define PCIM_HTCAP_FLE 0xd800 /* 11011 */ +#define PCIM_HTCAP_PM 0xe000 /* 11100 */ +#define PCIM_HTCAP_HIGH_NODE_COUNT 0xe800 /* 11101 */ /* HT MSI Mapping Capability definitions. */ #define PCIM_HTCMD_MSI_ENABLE 0x0001 From owner-svn-src-stable-9@FreeBSD.ORG Fri May 24 09:33:56 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C09CF9C5; Fri, 24 May 2013 09:33:56 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id B22F4E20; Fri, 24 May 2013 09:33:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4O9Xu1i044848; Fri, 24 May 2013 09:33:56 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4O9XuA6044847; Fri, 24 May 2013 09:33:56 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201305240933.r4O9XuA6044847@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 24 May 2013 09:33:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250965 - stable/9/usr.sbin/pciconf X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 May 2013 09:33:56 -0000 Author: kib Date: Fri May 24 09:33:55 2013 New Revision: 250965 URL: http://svnweb.freebsd.org/changeset/base/250965 Log: MFC r250741: Decode new HT 3.00 and 3.10 capabilities. Modified: stable/9/usr.sbin/pciconf/cap.c Directory Properties: stable/9/usr.sbin/pciconf/ (props changed) Modified: stable/9/usr.sbin/pciconf/cap.c ============================================================================== --- stable/9/usr.sbin/pciconf/cap.c Fri May 24 09:30:10 2013 (r250964) +++ stable/9/usr.sbin/pciconf/cap.c Fri May 24 09:33:55 2013 (r250965) @@ -276,6 +276,18 @@ cap_ht(int fd, struct pci_conf *p, uint8 case PCIM_HTCAP_X86_ENCODING: printf("X86 encoding"); break; + case PCIM_HTCAP_GEN3: + printf("Gen3"); + break; + case PCIM_HTCAP_FLE: + printf("function-level extension"); + break; + case PCIM_HTCAP_PM: + printf("power management"); + break; + case PCIM_HTCAP_HIGH_NODE_COUNT: + printf("high node count"); + break; default: printf("unknown %02x", command); break; From owner-svn-src-stable-9@FreeBSD.ORG Fri May 24 18:59:45 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id BEDB9D81; Fri, 24 May 2013 18:59:45 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 947269DF; Fri, 24 May 2013 18:59:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4OIxjJu044602; Fri, 24 May 2013 18:59:45 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4OIxjT7044598; Fri, 24 May 2013 18:59:45 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201305241859.r4OIxjT7044598@svn.freebsd.org> From: Jilles Tjoelker Date: Fri, 24 May 2013 18:59:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250973 - in stable/9: lib/libc/sys sys/kern X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 May 2013 18:59:45 -0000 Author: jilles Date: Fri May 24 18:59:44 2013 New Revision: 250973 URL: http://svnweb.freebsd.org/changeset/base/250973 Log: MFC r248593: Allow O_CLOEXEC in posix_openpt() flags. PR: kern/162374 Modified: stable/9/lib/libc/sys/posix_openpt.2 stable/9/sys/kern/tty_pts.c Directory Properties: stable/9/lib/libc/ (props changed) stable/9/lib/libc/sys/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/lib/libc/sys/posix_openpt.2 ============================================================================== --- stable/9/lib/libc/sys/posix_openpt.2 Fri May 24 18:54:52 2013 (r250972) +++ stable/9/lib/libc/sys/posix_openpt.2 Fri May 24 18:59:44 2013 (r250973) @@ -37,7 +37,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 20, 2008 +.Dd March 21, 2013 .Dt POSIX_OPENPT 2 .Os .Sh NAME @@ -71,7 +71,7 @@ Values for are constructed by a bitwise-inclusive OR of flags from the following list, defined in .In fcntl.h : -.Bl -tag -width ".Dv O_NOCTTY" +.Bl -tag -width ".Dv O_CLOEXEC" .It Dv O_RDWR Open for reading and writing. .It Dv O_NOCTTY @@ -79,6 +79,8 @@ If set .Fn posix_openpt shall not cause the terminal device to become the controlling terminal for the process. +.It Dv O_CLOEXEC +Set the close-on-exec flag for the new file descriptor. .El .Pp The @@ -116,6 +118,9 @@ The .Fn posix_openpt function conforms to .St -p1003.1-2001 . +The ability to use +.Dv O_CLOEXEC +is an extension to the standard. .Sh HISTORY The .Fn posix_openpt Modified: stable/9/sys/kern/tty_pts.c ============================================================================== --- stable/9/sys/kern/tty_pts.c Fri May 24 18:54:52 2013 (r250972) +++ stable/9/sys/kern/tty_pts.c Fri May 24 18:59:44 2013 (r250973) @@ -825,10 +825,10 @@ sys_posix_openpt(struct thread *td, stru * POSIX states it's unspecified when other flags are passed. We * don't allow this. */ - if (uap->flags & ~(O_RDWR|O_NOCTTY)) + if (uap->flags & ~(O_RDWR|O_NOCTTY|O_CLOEXEC)) return (EINVAL); - error = falloc(td, &fp, &fd, 0); + error = falloc(td, &fp, &fd, uap->flags); if (error) return (error); From owner-svn-src-stable-9@FreeBSD.ORG Sat May 25 09:47:33 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CC67C151; Sat, 25 May 2013 09:47:33 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id BD576919; Sat, 25 May 2013 09:47:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4P9lXwJ054882; Sat, 25 May 2013 09:47:33 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4P9lX4m054881; Sat, 25 May 2013 09:47:33 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201305250947.r4P9lX4m054881@svn.freebsd.org> From: Jaakko Heinonen Date: Sat, 25 May 2013 09:47:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250976 - stable/9/usr.sbin/ctladm X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 May 2013 09:47:33 -0000 Author: jh Date: Sat May 25 09:47:33 2013 New Revision: 250976 URL: http://svnweb.freebsd.org/changeset/base/250976 Log: MFC r250443: Check the return value of sbuf_finish(). Modified: stable/9/usr.sbin/ctladm/ctladm.c Directory Properties: stable/9/usr.sbin/ctladm/ (props changed) Modified: stable/9/usr.sbin/ctladm/ctladm.c ============================================================================== --- stable/9/usr.sbin/ctladm/ctladm.c Sat May 25 07:17:16 2013 (r250975) +++ stable/9/usr.sbin/ctladm/ctladm.c Sat May 25 09:47:33 2013 (r250976) @@ -545,7 +545,8 @@ retry: } if (xml != 0) { sbuf_printf(sb, "\n"); - sbuf_finish(sb); + if (sbuf_finish(sb) != 0) + err(1, "%s: sbuf_finish", __func__); printf("%s", sbuf_data(sb)); sbuf_delete(sb); } @@ -3492,7 +3493,8 @@ cctl_end_element(void *user_data, const errx(1, "%s: no valid sbuf at level %d (name %s)", __func__, devlist->level, name); - sbuf_finish(devlist->cur_sb[devlist->level]); + if (sbuf_finish(devlist->cur_sb[devlist->level]) != 0) + err(1, "%s: sbuf_finish", __func__); str = strdup(sbuf_data(devlist->cur_sb[devlist->level])); if (str == NULL) err(1, "%s can't allocate %zd bytes for string", __func__, From owner-svn-src-stable-9@FreeBSD.ORG Sat May 25 11:05:01 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id EB1C8FA7; Sat, 25 May 2013 11:05:01 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CB63DB5C; Sat, 25 May 2013 11:05:01 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4PB51n2082281; Sat, 25 May 2013 11:05:01 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4PB50hs082255; Sat, 25 May 2013 11:05:00 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201305251105.r4PB50hs082255@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 25 May 2013 11:05:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250978 - in stable/9/sys: fs/nullfs kern sys X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 May 2013 11:05:02 -0000 Author: kib Date: Sat May 25 11:05:00 2013 New Revision: 250978 URL: http://svnweb.freebsd.org/changeset/base/250978 Log: MFC r250505: - Fix nullfs vnode reference leak in nullfs_reclaim_lowervp(). The null_hashget() obtains the reference on the nullfs vnode, which must be dropped. - Fix a wart which existed from the introduction of the nullfs caching, do not unlock lower vnode in the nullfs_reclaim_lowervp(). It should be innocent, but now it is also formally safe. Inform the nullfs_reclaim() about this using the NULLV_NOUNLOCK flag set on nullfs inode. - Add a callback to the upper filesystems for the lower vnode unlinking. When inactivating a nullfs vnode, check if the lower vnode was unlinked, indicated by nullfs flag NULLV_DROP or VV_NOSYNC on the lower vnode, and reclaim upper vnode if so. This allows nullfs to purge cached vnodes for the unlinked lower vnode, avoiding excessive caching. MFC r250852: Do not leak the NULLV_NOUNLOCK flag from the nullfs_unlink_lowervp(), for the case when the nullfs vnode is not reclaimed. Otherwise, later reclamation would not unlock the lower vnode. Modified: stable/9/sys/fs/nullfs/null.h stable/9/sys/fs/nullfs/null_subr.c stable/9/sys/fs/nullfs/null_vfsops.c stable/9/sys/fs/nullfs/null_vnops.c stable/9/sys/kern/vfs_subr.c stable/9/sys/kern/vfs_syscalls.c stable/9/sys/sys/mount.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/sys/ (props changed) Modified: stable/9/sys/fs/nullfs/null.h ============================================================================== --- stable/9/sys/fs/nullfs/null.h Sat May 25 10:35:05 2013 (r250977) +++ stable/9/sys/fs/nullfs/null.h Sat May 25 11:05:00 2013 (r250978) @@ -53,8 +53,12 @@ struct null_node { LIST_ENTRY(null_node) null_hash; /* Hash list */ struct vnode *null_lowervp; /* VREFed once */ struct vnode *null_vnode; /* Back pointer */ + u_int null_flags; }; +#define NULLV_NOUNLOCK 0x0001 +#define NULLV_DROP 0x0002 + #define MOUNTTONULLMOUNT(mp) ((struct null_mount *)((mp)->mnt_data)) #define VTONULL(vp) ((struct null_node *)(vp)->v_data) #define NULLTOV(xp) ((xp)->null_vnode) Modified: stable/9/sys/fs/nullfs/null_subr.c ============================================================================== --- stable/9/sys/fs/nullfs/null_subr.c Sat May 25 10:35:05 2013 (r250977) +++ stable/9/sys/fs/nullfs/null_subr.c Sat May 25 11:05:00 2013 (r250978) @@ -251,6 +251,7 @@ null_nodeget(mp, lowervp, vpp) xp->null_vnode = vp; xp->null_lowervp = lowervp; + xp->null_flags = 0; vp->v_type = lowervp->v_type; vp->v_data = xp; vp->v_vnlock = lowervp->v_vnlock; Modified: stable/9/sys/fs/nullfs/null_vfsops.c ============================================================================== --- stable/9/sys/fs/nullfs/null_vfsops.c Sat May 25 10:35:05 2013 (r250977) +++ stable/9/sys/fs/nullfs/null_vfsops.c Sat May 25 11:05:00 2013 (r250978) @@ -65,7 +65,6 @@ static vfs_statfs_t nullfs_statfs; static vfs_unmount_t nullfs_unmount; static vfs_vget_t nullfs_vget; static vfs_extattrctl_t nullfs_extattrctl; -static vfs_reclaim_lowervp_t nullfs_reclaim_lowervp; /* * Mount null layer @@ -390,8 +389,49 @@ nullfs_reclaim_lowervp(struct mount *mp, vp = null_hashget(mp, lowervp); if (vp == NULL) return; + VTONULL(vp)->null_flags |= NULLV_NOUNLOCK; vgone(vp); - vn_lock(lowervp, LK_EXCLUSIVE | LK_RETRY); + vput(vp); +} + +static void +nullfs_unlink_lowervp(struct mount *mp, struct vnode *lowervp) +{ + struct vnode *vp; + struct null_node *xp; + + vp = null_hashget(mp, lowervp); + if (vp == NULL) + return; + xp = VTONULL(vp); + xp->null_flags |= NULLV_DROP | NULLV_NOUNLOCK; + vhold(vp); + vunref(vp); + + if (vp->v_usecount == 0) { + /* + * If vunref() dropped the last use reference on the + * nullfs vnode, it must be reclaimed, and its lock + * was split from the lower vnode lock. Need to do + * extra unlock before allowing the final vdrop() to + * free the vnode. + */ + KASSERT((vp->v_iflag & VI_DOOMED) != 0, + ("not reclaimed nullfs vnode %p", vp)); + VOP_UNLOCK(vp, 0); + } else { + /* + * Otherwise, the nullfs vnode still shares the lock + * with the lower vnode, and must not be unlocked. + * Also clear the NULLV_NOUNLOCK, the flag is not + * relevant for future reclamations. + */ + ASSERT_VOP_ELOCKED(vp, "unlink_lowervp"); + KASSERT((vp->v_iflag & VI_DOOMED) == 0, + ("reclaimed nullfs vnode %p", vp)); + xp->null_flags &= ~NULLV_NOUNLOCK; + } + vdrop(vp); } static struct vfsops null_vfsops = { @@ -407,6 +447,7 @@ static struct vfsops null_vfsops = { .vfs_unmount = nullfs_unmount, .vfs_vget = nullfs_vget, .vfs_reclaim_lowervp = nullfs_reclaim_lowervp, + .vfs_unlink_lowervp = nullfs_unlink_lowervp, }; VFS_SET(null_vfsops, nullfs, VFCF_LOOPBACK | VFCF_JAIL); Modified: stable/9/sys/fs/nullfs/null_vnops.c ============================================================================== --- stable/9/sys/fs/nullfs/null_vnops.c Sat May 25 10:35:05 2013 (r250977) +++ stable/9/sys/fs/nullfs/null_vnops.c Sat May 25 11:05:00 2013 (r250978) @@ -692,18 +692,24 @@ null_unlock(struct vop_unlock_args *ap) static int null_inactive(struct vop_inactive_args *ap __unused) { - struct vnode *vp; + struct vnode *vp, *lvp; + struct null_node *xp; struct mount *mp; struct null_mount *xmp; vp = ap->a_vp; + xp = VTONULL(vp); + lvp = NULLVPTOLOWERVP(vp); mp = vp->v_mount; xmp = MOUNTTONULLMOUNT(mp); - if ((xmp->nullm_flags & NULLM_CACHE) == 0) { + if ((xmp->nullm_flags & NULLM_CACHE) == 0 || + (xp->null_flags & NULLV_DROP) != 0 || + (lvp->v_vflag & VV_NOSYNC) != 0) { /* * If this is the last reference and caching of the - * nullfs vnodes is not enabled, then free up the - * vnode so as not to tie up the lower vnodes. + * nullfs vnodes is not enabled, or the lower vnode is + * deleted, then free up the vnode so as not to tie up + * the lower vnodes. */ vp->v_object = NULL; vrecycle(vp, curthread); @@ -748,7 +754,10 @@ null_reclaim(struct vop_reclaim_args *ap */ if (vp->v_writecount > 0) VOP_ADD_WRITECOUNT(lowervp, -1); - vput(lowervp); + if ((xp->null_flags & NULLV_NOUNLOCK) != 0) + vunref(lowervp); + else + vput(lowervp); free(xp, M_NULLFSNODE); return (0); Modified: stable/9/sys/kern/vfs_subr.c ============================================================================== --- stable/9/sys/kern/vfs_subr.c Sat May 25 10:35:05 2013 (r250977) +++ stable/9/sys/kern/vfs_subr.c Sat May 25 11:05:00 2013 (r250978) @@ -2756,19 +2756,20 @@ vgone(struct vnode *vp) } static void -vgonel_reclaim_lowervp_vfs(struct mount *mp __unused, +notify_lowervp_vfs_dummy(struct mount *mp __unused, struct vnode *lowervp __unused) { } /* - * Notify upper mounts about reclaimed vnode. + * Notify upper mounts about reclaimed or unlinked vnode. */ -static void -vgonel_reclaim_lowervp(struct vnode *vp) +void +vfs_notify_upper(struct vnode *vp, int event) { static struct vfsops vgonel_vfsops = { - .vfs_reclaim_lowervp = vgonel_reclaim_lowervp_vfs + .vfs_reclaim_lowervp = notify_lowervp_vfs_dummy, + .vfs_unlink_lowervp = notify_lowervp_vfs_dummy, }; struct mount *mp, *ump, *mmp; @@ -2792,7 +2793,17 @@ vgonel_reclaim_lowervp(struct vnode *vp) } TAILQ_INSERT_AFTER(&mp->mnt_uppers, ump, mmp, mnt_upper_link); MNT_IUNLOCK(mp); - VFS_RECLAIM_LOWERVP(ump, vp); + switch (event) { + case VFS_NOTIFY_UPPER_RECLAIM: + VFS_RECLAIM_LOWERVP(ump, vp); + break; + case VFS_NOTIFY_UPPER_UNLINK: + VFS_UNLINK_LOWERVP(ump, vp); + break; + default: + KASSERT(0, ("invalid event %d", event)); + break; + } MNT_ILOCK(mp); ump = TAILQ_NEXT(mmp, mnt_upper_link); TAILQ_REMOVE(&mp->mnt_uppers, mmp, mnt_upper_link); @@ -2839,7 +2850,7 @@ vgonel(struct vnode *vp) active = vp->v_usecount; oweinact = (vp->v_iflag & VI_OWEINACT); VI_UNLOCK(vp); - vgonel_reclaim_lowervp(vp); + vfs_notify_upper(vp, VFS_NOTIFY_UPPER_RECLAIM); /* * Clean out any buffers associated with the vnode. Modified: stable/9/sys/kern/vfs_syscalls.c ============================================================================== --- stable/9/sys/kern/vfs_syscalls.c Sat May 25 10:35:05 2013 (r250977) +++ stable/9/sys/kern/vfs_syscalls.c Sat May 25 11:05:00 2013 (r250978) @@ -1949,6 +1949,7 @@ restart: if (error) goto out; #endif + vfs_notify_upper(vp, VFS_NOTIFY_UPPER_UNLINK); error = VOP_REMOVE(nd.ni_dvp, vp, &nd.ni_cnd); #ifdef MAC out: @@ -3947,6 +3948,7 @@ restart: return (error); goto restart; } + vfs_notify_upper(vp, VFS_NOTIFY_UPPER_UNLINK); error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); vn_finished_write(mp); out: Modified: stable/9/sys/sys/mount.h ============================================================================== --- stable/9/sys/sys/mount.h Sat May 25 10:35:05 2013 (r250977) +++ stable/9/sys/sys/mount.h Sat May 25 11:05:00 2013 (r250978) @@ -630,7 +630,7 @@ typedef int vfs_mount_t(struct mount *mp typedef int vfs_sysctl_t(struct mount *mp, fsctlop_t op, struct sysctl_req *req); typedef void vfs_susp_clean_t(struct mount *mp); -typedef void vfs_reclaim_lowervp_t(struct mount *mp, struct vnode *lowervp); +typedef void vfs_notify_lowervp_t(struct mount *mp, struct vnode *lowervp); struct vfsops { vfs_mount_t *vfs_mount; @@ -648,7 +648,8 @@ struct vfsops { vfs_extattrctl_t *vfs_extattrctl; vfs_sysctl_t *vfs_sysctl; vfs_susp_clean_t *vfs_susp_clean; - vfs_reclaim_lowervp_t *vfs_reclaim_lowervp; + vfs_notify_lowervp_t *vfs_reclaim_lowervp; + vfs_notify_lowervp_t *vfs_unlink_lowervp; }; vfs_statfs_t __vfs_statfs; @@ -713,6 +714,12 @@ vfs_statfs_t __vfs_statfs; mtx_assert(&Giant, MA_OWNED); \ } while (0) +#define VFS_UNLINK_LOWERVP(MP, VP) do { \ + if (*(MP)->mnt_op->vfs_unlink_lowervp != NULL) { \ + (*(MP)->mnt_op->vfs_unlink_lowervp)((MP), (VP)); \ + } \ +} while (0) + #define VFS_KNOTE_LOCKED(vp, hint) do \ { \ if (((vp)->v_vflag & VV_NOKNOTE) == 0) \ @@ -725,6 +732,9 @@ vfs_statfs_t __vfs_statfs; VN_KNOTE((vp), (hint), 0); \ } while (0) +#define VFS_NOTIFY_UPPER_RECLAIM 1 +#define VFS_NOTIFY_UPPER_UNLINK 2 + #include /* @@ -803,6 +813,7 @@ int vfs_modevent(module_t, int, void *); void vfs_mount_error(struct mount *, const char *, ...); void vfs_mountroot(void); /* mount our root filesystem */ void vfs_mountedfrom(struct mount *, const char *from); +void vfs_notify_upper(struct vnode *, int); void vfs_oexport_conv(const struct oexport_args *oexp, struct export_args *exp); void vfs_ref(struct mount *); From owner-svn-src-stable-9@FreeBSD.ORG Sat May 25 15:17:59 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 1BF9B53F; Sat, 25 May 2013 15:17:59 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0C61F663; Sat, 25 May 2013 15:17:59 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4PFHwWb076462; Sat, 25 May 2013 15:17:58 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4PFHwgl076459; Sat, 25 May 2013 15:17:58 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201305251517.r4PFHwgl076459@svn.freebsd.org> From: Eitan Adler Date: Sat, 25 May 2013 15:17:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250983 - in stable/9: etc/periodic/daily tools/build/mk X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 May 2013 15:17:59 -0000 Author: eadler Date: Sat May 25 15:17:58 2013 New Revision: 250983 URL: http://svnweb.freebsd.org/changeset/base/250983 Log: MFC r250533: Unconditionally install 210.backup-aliases as many MTAs other than sendmail support the use of /etc/aliases. PR: conf/176098 Modified: stable/9/etc/periodic/daily/Makefile stable/9/tools/build/mk/OptionalObsoleteFiles.inc Directory Properties: stable/9/etc/ (props changed) stable/9/tools/build/ (props changed) Modified: stable/9/etc/periodic/daily/Makefile ============================================================================== --- stable/9/etc/periodic/daily/Makefile Sat May 25 13:59:40 2013 (r250982) +++ stable/9/etc/periodic/daily/Makefile Sat May 25 15:17:58 2013 (r250983) @@ -6,6 +6,7 @@ FILES= 100.clean-disks \ 110.clean-tmps \ 120.clean-preserve \ 200.backup-passwd \ + 210.backup-aliases \ 220.backup-pkgdb \ 330.news \ 400.status-disks \ @@ -51,7 +52,6 @@ FILES+= 140.clean-rwho \ .if ${MK_SENDMAIL} != "no" FILES+= 150.clean-hoststat \ - 210.backup-aliases \ 440.status-mailq \ 460.status-mail-rejects \ 500.queuerun Modified: stable/9/tools/build/mk/OptionalObsoleteFiles.inc ============================================================================== --- stable/9/tools/build/mk/OptionalObsoleteFiles.inc Sat May 25 13:59:40 2013 (r250982) +++ stable/9/tools/build/mk/OptionalObsoleteFiles.inc Sat May 25 15:17:58 2013 (r250983) @@ -3415,7 +3415,6 @@ OLD_FILES+=usr/share/man/man8/rtquery.8. .if ${MK_SENDMAIL} == no OLD_FILES+=etc/periodic/daily/150.clean-hoststat -OLD_FILES+=etc/periodic/daily/210.backup-aliases OLD_FILES+=etc/periodic/daily/440.status-mailq OLD_FILES+=etc/periodic/daily/460.status-mail-rejects OLD_FILES+=etc/periodic/daily/500.queuerun From owner-svn-src-stable-9@FreeBSD.ORG Sat May 25 17:16:32 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 14A537F8; Sat, 25 May 2013 17:16:32 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E1266AFA; Sat, 25 May 2013 17:16:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4PHGV18018370; Sat, 25 May 2013 17:16:31 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4PHGVSD018369; Sat, 25 May 2013 17:16:31 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201305251716.r4PHGVSD018369@svn.freebsd.org> From: Hans Petter Selasky Date: Sat, 25 May 2013 17:16:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250987 - stable/9/sys/dev/sound/usb X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 May 2013 17:16:32 -0000 Author: hselasky Date: Sat May 25 17:16:31 2013 New Revision: 250987 URL: http://svnweb.freebsd.org/changeset/base/250987 Log: MFC r250763 and r250765: Fix some USB audio device issues. PR: usb/178722 Modified: stable/9/sys/dev/sound/usb/uaudio.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/sound/usb/uaudio.c ============================================================================== --- stable/9/sys/dev/sound/usb/uaudio.c Sat May 25 17:09:58 2013 (r250986) +++ stable/9/sys/dev/sound/usb/uaudio.c Sat May 25 17:16:31 2013 (r250987) @@ -868,6 +868,7 @@ uaudio_attach(device_t dev) struct usb_attach_arg *uaa = device_get_ivars(dev); struct uaudio_softc *sc = device_get_softc(dev); struct usb_interface_descriptor *id; + usb_error_t err; device_t child; sc->sc_play_chan.priv_sc = sc; @@ -925,6 +926,19 @@ uaudio_attach(device_t dev) if (sc->sc_play_chan.num_alt > 0) { uint8_t x; + + /* + * Need to set a default alternate interface, else + * some USB audio devices might go into an infinte + * re-enumeration loop: + */ + err = usbd_set_alt_interface_index(sc->sc_udev, + sc->sc_play_chan.usb_alt[0].iface_index, + sc->sc_play_chan.usb_alt[0].iface_alt_index); + if (err) { + DPRINTF("setting of alternate index failed: %s!\n", + usbd_errstr(err)); + } for (x = 0; x != sc->sc_play_chan.num_alt; x++) { device_printf(dev, "Play: %d Hz, %d ch, %s format, " "2x8ms buffer.\n", @@ -938,6 +952,19 @@ uaudio_attach(device_t dev) if (sc->sc_rec_chan.num_alt > 0) { uint8_t x; + + /* + * Need to set a default alternate interface, else + * some USB audio devices might go into an infinte + * re-enumeration loop: + */ + err = usbd_set_alt_interface_index(sc->sc_udev, + sc->sc_rec_chan.usb_alt[0].iface_index, + sc->sc_rec_chan.usb_alt[0].iface_alt_index); + if (err) { + DPRINTF("setting of alternate index failed: %s!\n", + usbd_errstr(err)); + } for (x = 0; x != sc->sc_rec_chan.num_alt; x++) { device_printf(dev, "Record: %d Hz, %d ch, %s format, " "2x8ms buffer.\n", @@ -5565,7 +5592,6 @@ umidi_open(struct usb_fifo *fifo, int ff } /* clear stall first */ mtx_lock(&chan->mtx); - usbd_xfer_set_stall(chan->xfer[UMIDI_TX_TRANSFER]); chan->write_open_refcount++; sub->write_open = 1; @@ -5664,9 +5690,6 @@ umidi_probe(device_t dev) mtx_lock(&chan->mtx); - /* clear stall first */ - usbd_xfer_set_stall(chan->xfer[UMIDI_RX_TRANSFER]); - /* * NOTE: At least one device will not work properly unless the * BULK IN pipe is open all the time. This might have to do @@ -5771,8 +5794,11 @@ tr_setup: break; default: /* Error */ + + DPRINTF("error=%s\n", usbd_errstr(error)); + if (error != USB_ERR_CANCELLED) { - /* try clear stall first */ + /* try to clear stall first */ usbd_xfer_set_stall(xfer); goto tr_setup; }