From owner-svn-src-stable-7@FreeBSD.ORG Mon May 30 08:00:28 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D35921065675; Mon, 30 May 2011 08:00:28 +0000 (UTC) (envelope-from bcr@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C345F8FC18; Mon, 30 May 2011 08:00:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p4U80S8a066610; Mon, 30 May 2011 08:00:28 GMT (envelope-from bcr@svn.freebsd.org) Received: (from bcr@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p4U80Si7066608; Mon, 30 May 2011 08:00:28 GMT (envelope-from bcr@svn.freebsd.org) Message-Id: <201105300800.p4U80Si7066608@svn.freebsd.org> From: Benedict Reuschling Date: Mon, 30 May 2011 08:00:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222479 - stable/7/share/man/man7 X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 May 2011 08:00:28 -0000 Author: bcr (doc committer) Date: Mon May 30 08:00:28 2011 New Revision: 222479 URL: http://svn.freebsd.org/changeset/base/222479 Log: MFC r218699: Document TRYBROKEN in ports(7). PR: docs/153542 Submitted by: Eitan Adler Modified: stable/7/share/man/man7/ports.7 Directory Properties: stable/7/share/man/man7/ (props changed) Modified: stable/7/share/man/man7/ports.7 ============================================================================== --- stable/7/share/man/man7/ports.7 Mon May 30 07:58:49 2011 (r222478) +++ stable/7/share/man/man7/ports.7 Mon May 30 08:00:28 2011 (r222479) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 21, 2009 +.Dd February 14, 2009 .Dt PORTS 7 .Os .Sh NAME @@ -477,6 +477,9 @@ Of course, these ports may not work as e what you are doing and are sure about installing a forbidden port, then .Va NO_IGNORE lets you do it. +.It Va TRYBROKEN +If defined, attempt to build a port even if it is marked as +.Aq Va BROKEN . .It Va PORT_DBDIR Directory where the results of configuring .Va OPTIONS From owner-svn-src-stable-7@FreeBSD.ORG Mon May 30 08:05:28 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 55268106567A; Mon, 30 May 2011 08:05:28 +0000 (UTC) (envelope-from bcr@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 44FC98FC08; Mon, 30 May 2011 08:05:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p4U85SHv066851; Mon, 30 May 2011 08:05:28 GMT (envelope-from bcr@svn.freebsd.org) Received: (from bcr@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p4U85SSg066849; Mon, 30 May 2011 08:05:28 GMT (envelope-from bcr@svn.freebsd.org) Message-Id: <201105300805.p4U85SSg066849@svn.freebsd.org> From: Benedict Reuschling Date: Mon, 30 May 2011 08:05:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222481 - stable/7/share/man/man7 X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 May 2011 08:05:28 -0000 Author: bcr (doc committer) Date: Mon May 30 08:05:27 2011 New Revision: 222481 URL: http://svn.freebsd.org/changeset/base/222481 Log: MFC r222278: Add a description to the checksum target about not only being able to verify, but also having the ability to fetch distfiles that are missing or failed the checksum calculation PR: docs/138887 Submitted by: Radim Kolar (hsn at sendmail dot cz) Modified: stable/7/share/man/man7/ports.7 Directory Properties: stable/7/share/man/man7/ (props changed) Modified: stable/7/share/man/man7/ports.7 ============================================================================== --- stable/7/share/man/man7/ports.7 Mon May 30 08:04:47 2011 (r222480) +++ stable/7/share/man/man7/ports.7 Mon May 30 08:05:27 2011 (r222481) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 14, 2009 +.Dd May 25, 2011 .Dt PORTS 7 .Os .Sh NAME @@ -124,6 +124,8 @@ and .It Cm checksum Verify that the fetched distfile's checksum matches the one the port was tested against. +If the distfile's checksum does not match, it also fetches the distfiles +which are missing or failed the checksum calculation. Defining .Va NO_CHECKSUM will skip this step. From owner-svn-src-stable-7@FreeBSD.ORG Wed Jun 1 15:46:26 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A79321065747; Wed, 1 Jun 2011 15:46:26 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 97C6A8FC16; Wed, 1 Jun 2011 15:46:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p51FkQIb076141; Wed, 1 Jun 2011 15:46:26 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p51FkQ1S076139; Wed, 1 Jun 2011 15:46:26 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201106011546.p51FkQ1S076139@svn.freebsd.org> From: Matthew D Fleming Date: Wed, 1 Jun 2011 15:46:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222567 - stable/7/share/man/man9 X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jun 2011 15:46:26 -0000 Author: mdf Date: Wed Jun 1 15:46:26 2011 New Revision: 222567 URL: http://svn.freebsd.org/changeset/base/222567 Log: MFC r212364: Fix small errors in the sbuf(9) man page. Modified: stable/7/share/man/man9/sbuf.9 Directory Properties: stable/7/share/man/man9/ (props changed) Modified: stable/7/share/man/man9/sbuf.9 ============================================================================== --- stable/7/share/man/man9/sbuf.9 Wed Jun 1 15:46:12 2011 (r222566) +++ stable/7/share/man/man9/sbuf.9 Wed Jun 1 15:46:26 2011 (r222567) @@ -98,7 +98,7 @@ The .Nm family of functions allows one to safely allocate, construct and -release bounded null-terminated strings in kernel space. +release bounded NUL-terminated strings in kernel space. Instead of arrays of characters, these functions operate on structures called .Fa sbufs , @@ -289,7 +289,7 @@ overflowed. .Pp The .Fn sbuf_finish -function null-terminates the +function NUL-terminates the .Fa sbuf and marks it as finished, which means that it may no longer be modified using @@ -298,7 +298,10 @@ modified using .Fn sbuf_cpy , .Fn sbuf_printf or -.Fn sbuf_putc . +.Fn sbuf_putc , +until +.Fn sbuf_clear +is used to reset the sbuf. .Pp The .Fn sbuf_data @@ -309,7 +312,9 @@ functions return the actual string and i only works on a finished .Fa sbuf . .Fn sbuf_done -returns non-zero if the sbuf is finished. +returns non-zero if the +.Fa sbuf +is finished. .Sh NOTES If an operation caused an .Fa sbuf From owner-svn-src-stable-7@FreeBSD.ORG Wed Jun 1 16:07:14 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CFACF1065670; Wed, 1 Jun 2011 16:07:14 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BE9128FC18; Wed, 1 Jun 2011 16:07:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p51G7EoA076996; Wed, 1 Jun 2011 16:07:14 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p51G7EkO076993; Wed, 1 Jun 2011 16:07:14 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201106011607.p51G7EkO076993@svn.freebsd.org> From: Matthew D Fleming Date: Wed, 1 Jun 2011 16:07:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222569 - in stable/7/sys: kern sys X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jun 2011 16:07:14 -0000 Author: mdf Date: Wed Jun 1 16:07:14 2011 New Revision: 222569 URL: http://svn.freebsd.org/changeset/base/222569 Log: MFC r181462: Switch to simplified BSD license (with phk's approval), plus whitespace and style(9) cleanup. Modified: stable/7/sys/kern/subr_sbuf.c stable/7/sys/sys/sbuf.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/subr_sbuf.c ============================================================================== --- stable/7/sys/kern/subr_sbuf.c Wed Jun 1 15:48:43 2011 (r222568) +++ stable/7/sys/kern/subr_sbuf.c Wed Jun 1 16:07:14 2011 (r222569) @@ -1,5 +1,6 @@ /*- - * Copyright (c) 2000 Poul-Henning Kamp and Dag-Erling Coïdan Smørgrav + * Copyright (c) 2000-2008 Poul-Henning Kamp + * Copyright (c) 2000-2008 Dag-Erling Coïdan Smørgrav * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -11,19 +12,18 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ #include @@ -84,9 +84,11 @@ static MALLOC_DEFINE(M_SBUF, "sbuf", "st * Debugging support */ #if defined(_KERNEL) && defined(INVARIANTS) + static void _assert_sbuf_integrity(const char *fun, struct sbuf *s) { + KASSERT(s != NULL, ("%s called with a NULL sbuf pointer", fun)); KASSERT(s->s_buf != NULL, @@ -98,15 +100,20 @@ _assert_sbuf_integrity(const char *fun, static void _assert_sbuf_state(const char *fun, struct sbuf *s, int state) { + KASSERT((s->s_flags & SBUF_FINISHED) == state, ("%s called with %sfinished or corrupt sbuf", fun, (state ? "un" : ""))); } + #define assert_sbuf_integrity(s) _assert_sbuf_integrity(__func__, (s)) #define assert_sbuf_state(s, i) _assert_sbuf_state(__func__, (s), (i)) + #else /* _KERNEL && INVARIANTS */ + #define assert_sbuf_integrity(s) do { } while (0) #define assert_sbuf_state(s, i) do { } while (0) + #endif /* _KERNEL && INVARIANTS */ static int @@ -121,7 +128,6 @@ sbuf_extendsize(int size) else newsize += SBUF_MAXEXTENDINCR; } - return (newsize); } @@ -137,9 +143,8 @@ sbuf_extend(struct sbuf *s, int addlen) if (!SBUF_CANEXTEND(s)) return (-1); - newsize = sbuf_extendsize(s->s_size + addlen); - newbuf = (char *)SBMALLOC(newsize); + newbuf = SBMALLOC(newsize); if (newbuf == NULL) return (-1); bcopy(s->s_buf, newbuf, s->s_size); @@ -160,6 +165,7 @@ sbuf_extend(struct sbuf *s, int addlen) struct sbuf * sbuf_new(struct sbuf *s, char *buf, int length, int flags) { + KASSERT(length >= 0, ("attempt to create an sbuf of negative length (%d)", length)); KASSERT((flags & ~SBUF_USRFLAGMSK) == 0, @@ -167,14 +173,14 @@ sbuf_new(struct sbuf *s, char *buf, int flags &= SBUF_USRFLAGMSK; if (s == NULL) { - s = (struct sbuf *)SBMALLOC(sizeof *s); + s = SBMALLOC(sizeof(*s)); if (s == NULL) return (NULL); - bzero(s, sizeof *s); + bzero(s, sizeof(*s)); s->s_flags = flags; SBUF_SETFLAG(s, SBUF_DYNSTRUCT); } else { - bzero(s, sizeof *s); + bzero(s, sizeof(*s)); s->s_flags = flags; } s->s_size = length; @@ -184,7 +190,7 @@ sbuf_new(struct sbuf *s, char *buf, int } if (flags & SBUF_AUTOEXTEND) s->s_size = sbuf_extendsize(s->s_size); - s->s_buf = (char *)SBMALLOC(s->s_size); + s->s_buf = SBMALLOC(s->s_size); if (s->s_buf == NULL) { if (SBUF_ISDYNSTRUCT(s)) SBFREE(s); @@ -201,6 +207,7 @@ sbuf_new(struct sbuf *s, char *buf, int struct sbuf * sbuf_uionew(struct sbuf *s, struct uio *uio, int *error) { + KASSERT(uio != NULL, ("%s called with NULL uio pointer", __func__)); KASSERT(error != NULL, @@ -228,6 +235,7 @@ sbuf_uionew(struct sbuf *s, struct uio * void sbuf_clear(struct sbuf *s) { + assert_sbuf_integrity(s); /* don't care if it's finished or not */ @@ -243,6 +251,7 @@ sbuf_clear(struct sbuf *s) int sbuf_setpos(struct sbuf *s, int pos) { + assert_sbuf_integrity(s); assert_sbuf_state(s, 0); @@ -270,7 +279,6 @@ sbuf_bcat(struct sbuf *s, const void *bu if (SBUF_HASOVERFLOWED(s)) return (-1); - for (; len; len--) { if (!SBUF_HASROOM(s) && sbuf_extend(s, len) < 0) break; @@ -290,12 +298,12 @@ sbuf_bcat(struct sbuf *s, const void *bu int sbuf_bcopyin(struct sbuf *s, const void *uaddr, size_t len) { + assert_sbuf_integrity(s); assert_sbuf_state(s, 0); if (SBUF_HASOVERFLOWED(s)) return (-1); - if (len == 0) return (0); if (len > SBUF_FREESPACE(s)) { @@ -316,6 +324,7 @@ sbuf_bcopyin(struct sbuf *s, const void int sbuf_bcpy(struct sbuf *s, const void *buf, size_t len) { + assert_sbuf_integrity(s); assert_sbuf_state(s, 0); @@ -329,6 +338,7 @@ sbuf_bcpy(struct sbuf *s, const void *bu int sbuf_cat(struct sbuf *s, const char *str) { + assert_sbuf_integrity(s); assert_sbuf_state(s, 0); @@ -389,6 +399,7 @@ sbuf_copyin(struct sbuf *s, const void * int sbuf_cpy(struct sbuf *s, const char *str) { + assert_sbuf_integrity(s); assert_sbuf_state(s, 0); @@ -455,7 +466,7 @@ sbuf_printf(struct sbuf *s, const char * va_start(ap, fmt); result = sbuf_vprintf(s, fmt, ap); va_end(ap); - return(result); + return (result); } /* @@ -464,12 +475,12 @@ sbuf_printf(struct sbuf *s, const char * int sbuf_putc(struct sbuf *s, int c) { + assert_sbuf_integrity(s); assert_sbuf_state(s, 0); if (SBUF_HASOVERFLOWED(s)) return (-1); - if (!SBUF_HASROOM(s) && sbuf_extend(s, 1) < 0) { SBUF_SETFLAG(s, SBUF_OVERFLOWED); return (-1); @@ -485,6 +496,7 @@ sbuf_putc(struct sbuf *s, int c) int sbuf_trim(struct sbuf *s) { + assert_sbuf_integrity(s); assert_sbuf_state(s, 0); @@ -503,7 +515,8 @@ sbuf_trim(struct sbuf *s) int sbuf_overflowed(struct sbuf *s) { - return SBUF_HASOVERFLOWED(s); + + return (SBUF_HASOVERFLOWED(s)); } /* @@ -512,6 +525,7 @@ sbuf_overflowed(struct sbuf *s) void sbuf_finish(struct sbuf *s) { + assert_sbuf_integrity(s); assert_sbuf_state(s, 0); @@ -526,10 +540,11 @@ sbuf_finish(struct sbuf *s) char * sbuf_data(struct sbuf *s) { + assert_sbuf_integrity(s); assert_sbuf_state(s, SBUF_FINISHED); - return s->s_buf; + return (s->s_buf); } /* @@ -538,12 +553,13 @@ sbuf_data(struct sbuf *s) int sbuf_len(struct sbuf *s) { + assert_sbuf_integrity(s); /* don't care if it's finished or not */ if (SBUF_HASOVERFLOWED(s)) return (-1); - return s->s_len; + return (s->s_len); } /* @@ -560,7 +576,7 @@ sbuf_delete(struct sbuf *s) if (SBUF_ISDYNAMIC(s)) SBFREE(s->s_buf); isdyn = SBUF_ISDYNSTRUCT(s); - bzero(s, sizeof *s); + bzero(s, sizeof(*s)); if (isdyn) SBFREE(s); } @@ -572,5 +588,5 @@ int sbuf_done(struct sbuf *s) { - return(SBUF_ISFINISHED(s)); + return (SBUF_ISFINISHED(s)); } Modified: stable/7/sys/sys/sbuf.h ============================================================================== --- stable/7/sys/sys/sbuf.h Wed Jun 1 15:48:43 2011 (r222568) +++ stable/7/sys/sys/sbuf.h Wed Jun 1 16:07:14 2011 (r222569) @@ -1,5 +1,6 @@ /*- - * Copyright (c) 2000 Poul-Henning Kamp and Dag-Erling Coïdan Smørgrav + * Copyright (c) 2000-2008 Poul-Henning Kamp + * Copyright (c) 2000-2008 Dag-Erling Coïdan Smørgrav * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -11,19 +12,18 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. * * $FreeBSD$ */ @@ -43,7 +43,7 @@ struct sbuf { int s_len; /* current length of string */ #define SBUF_FIXEDLEN 0x00000000 /* fixed length buffer (default) */ #define SBUF_AUTOEXTEND 0x00000001 /* automatically extend buffer */ -#define SBUF_USRFLAGMSK 0x0000ffff /* mask of flags the user may specify */ +#define SBUF_USRFLAGMSK 0x0000ffff /* mask of flags the user may specify */ #define SBUF_DYNAMIC 0x00010000 /* s_buf must be freed */ #define SBUF_FINISHED 0x00020000 /* set by sbuf_finish() */ #define SBUF_OVERFLOWED 0x00040000 /* sbuf overflowed */ @@ -64,8 +64,10 @@ int sbuf_bcat(struct sbuf *, const voi int sbuf_bcpy(struct sbuf *, const void *, size_t); int sbuf_cat(struct sbuf *, const char *); int sbuf_cpy(struct sbuf *, const char *); -int sbuf_printf(struct sbuf *, const char *, ...) __printflike(2, 3); -int sbuf_vprintf(struct sbuf *, const char *, __va_list) __printflike(2, 0); +int sbuf_printf(struct sbuf *, const char *, ...) + __printflike(2, 3); +int sbuf_vprintf(struct sbuf *, const char *, __va_list) + __printflike(2, 0); int sbuf_putc(struct sbuf *, int); int sbuf_trim(struct sbuf *); int sbuf_overflowed(struct sbuf *); From owner-svn-src-stable-7@FreeBSD.ORG Wed Jun 1 16:34:26 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 845FC106564A; Wed, 1 Jun 2011 16:34:26 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 740168FC14; Wed, 1 Jun 2011 16:34:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p51GYQp5077929; Wed, 1 Jun 2011 16:34:26 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p51GYQUn077927; Wed, 1 Jun 2011 16:34:26 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201106011634.p51GYQUn077927@svn.freebsd.org> From: Matthew D Fleming Date: Wed, 1 Jun 2011 16:34:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222571 - stable/7/sys/kern X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jun 2011 16:34:26 -0000 Author: mdf Date: Wed Jun 1 16:34:26 2011 New Revision: 222571 URL: http://svn.freebsd.org/changeset/base/222571 Log: MFC r212180-r212184: Use math rather than iteration when the desired sbuf size is larger than SBUF_MAXEXTENDSIZE. Fix brain fart when converting an if statement into a KASSERT. Fix user-space libsbuf build. Why isn't CTASSERT available to user-space? Style(9) fixes and eliminate the use of min(). Use a better #if guard. Modified: stable/7/sys/kern/subr_sbuf.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/subr_sbuf.c ============================================================================== --- stable/7/sys/kern/subr_sbuf.c Wed Jun 1 16:34:18 2011 (r222570) +++ stable/7/sys/kern/subr_sbuf.c Wed Jun 1 16:34:26 2011 (r222571) @@ -56,7 +56,6 @@ static MALLOC_DEFINE(M_SBUF, "sbuf", "st #define KASSERT(e, m) #define SBMALLOC(size) malloc(size) #define SBFREE(buf) free(buf) -#define min(x,y) MIN(x,y) #endif /* _KERNEL */ /* @@ -116,18 +115,24 @@ _assert_sbuf_state(const char *fun, stru #endif /* _KERNEL && INVARIANTS */ +#ifdef CTASSERT +CTASSERT(powerof2(SBUF_MAXEXTENDSIZE)); +CTASSERT(powerof2(SBUF_MAXEXTENDINCR)); +#endif + static int sbuf_extendsize(int size) { int newsize; - newsize = SBUF_MINEXTENDSIZE; - while (newsize < size) { - if (newsize < (int)SBUF_MAXEXTENDSIZE) + if (size < (int)SBUF_MAXEXTENDSIZE) { + newsize = SBUF_MINEXTENDSIZE; + while (newsize < size) newsize *= 2; - else - newsize += SBUF_MAXEXTENDINCR; + } else { + newsize = roundup2(size, SBUF_MAXEXTENDINCR); } + KASSERT(newsize >= size, ("%s: %d < %d\n", __func__, newsize, size)); return (newsize); } @@ -184,11 +189,11 @@ sbuf_new(struct sbuf *s, char *buf, int s->s_flags = flags; } s->s_size = length; - if (buf) { + if (buf != NULL) { s->s_buf = buf; return (s); } - if (flags & SBUF_AUTOEXTEND) + if ((flags & SBUF_AUTOEXTEND) != 0) s->s_size = sbuf_extendsize(s->s_size); s->s_buf = SBMALLOC(s->s_size); if (s->s_buf == NULL) { @@ -284,7 +289,7 @@ sbuf_bcat(struct sbuf *s, const void *bu break; s->s_buf[s->s_len++] = *str++; } - if (len) { + if (len > 0) { SBUF_SETFLAG(s, SBUF_OVERFLOWED); return (-1); } @@ -308,7 +313,8 @@ sbuf_bcopyin(struct sbuf *s, const void return (0); if (len > SBUF_FREESPACE(s)) { sbuf_extend(s, len - SBUF_FREESPACE(s)); - len = min(len, SBUF_FREESPACE(s)); + if (SBUF_FREESPACE(s) < len) + len = SBUF_FREESPACE(s); } if (copyin(uaddr, s->s_buf + s->s_len, len) != 0) return (-1); @@ -345,12 +351,12 @@ sbuf_cat(struct sbuf *s, const char *str if (SBUF_HASOVERFLOWED(s)) return (-1); - while (*str) { + while (*str != '\0') { if (!SBUF_HASROOM(s) && sbuf_extend(s, strlen(str)) < 0) break; s->s_buf[s->s_len++] = *str++; } - if (*str) { + if (*str != '\0') { SBUF_SETFLAG(s, SBUF_OVERFLOWED); return (-1); } @@ -376,7 +382,8 @@ sbuf_copyin(struct sbuf *s, const void * len = SBUF_FREESPACE(s); /* XXX return 0? */ if (len > SBUF_FREESPACE(s)) { sbuf_extend(s, len); - len = min(len, SBUF_FREESPACE(s)); + if (SBUF_FREESPACE(s) < len) + len = SBUF_FREESPACE(s); } switch (copyinstr(uaddr, s->s_buf + s->s_len, len + 1, &done)) { case ENAMETOOLONG: @@ -440,9 +447,11 @@ sbuf_vprintf(struct sbuf *s, const char * terminating nul. * * vsnprintf() returns the amount that would have been copied, - * given sufficient space, hence the min() calculation below. + * given sufficient space, so don't over-increment s_len. */ - s->s_len += min(len, SBUF_FREESPACE(s)); + if (SBUF_FREESPACE(s) < len) + len = SBUF_FREESPACE(s); + s->s_len += len; if (!SBUF_HASROOM(s) && !SBUF_CANEXTEND(s)) SBUF_SETFLAG(s, SBUF_OVERFLOWED); @@ -486,7 +495,7 @@ sbuf_putc(struct sbuf *s, int c) return (-1); } if (c != '\0') - s->s_buf[s->s_len++] = c; + s->s_buf[s->s_len++] = c; return (0); } @@ -503,7 +512,7 @@ sbuf_trim(struct sbuf *s) if (SBUF_HASOVERFLOWED(s)) return (-1); - while (s->s_len && isspace(s->s_buf[s->s_len-1])) + while (s->s_len > 0 && isspace(s->s_buf[s->s_len-1])) --s->s_len; return (0); From owner-svn-src-stable-7@FreeBSD.ORG Wed Jun 1 17:40:59 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B5038106566B; Wed, 1 Jun 2011 17:40:59 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A20158FC12; Wed, 1 Jun 2011 17:40:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p51HexNC080120; Wed, 1 Jun 2011 17:40:59 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p51HexUB080115; Wed, 1 Jun 2011 17:40:59 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201106011740.p51HexUB080115@svn.freebsd.org> From: Matthew D Fleming Date: Wed, 1 Jun 2011 17:40:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222575 - in stable/7: share/man/man9 sys/kern sys/sys X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jun 2011 17:40:59 -0000 Author: mdf Date: Wed Jun 1 17:40:59 2011 New Revision: 222575 URL: http://svn.freebsd.org/changeset/base/222575 Log: MFC r212365, r212367: r212365: Refactor sbuf code so that most uses of sbuf_extend() are in a new sbuf_put_byte(). This makes it easier to add drain functionality when a buffer would overflow as there are fewer code points. r212367: Add drain functionality to sbufs. The drain is a function that is called when the sbuf internal buffer is filled. For kernel sbufs with a drain, the internal buffer will never be expanded. For userland sbufs with a drain, the internal buffer may still be expanded by sbuf_[v]printf(3). Sbufs now have three basic uses: 1) static string manipulation. Overflow is marked. 2) dynamic string manipulation. Overflow triggers string growth. 3) drained string manipulation. Overflow triggers draining. In all cases the manipulation is 'safe' in that overflow is detected and managed. Note that r212367 had to be minorly re-implemented to dynamically allocate space for a function pointer, a void * argument, and an int error, to not break the ABI/KBI. Modified: stable/7/share/man/man9/Makefile stable/7/share/man/man9/sbuf.9 stable/7/sys/kern/subr_sbuf.c stable/7/sys/sys/sbuf.h Directory Properties: stable/7/share/man/man9/ (props changed) stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/share/man/man9/Makefile ============================================================================== --- stable/7/share/man/man9/Makefile Wed Jun 1 17:36:52 2011 (r222574) +++ stable/7/share/man/man9/Makefile Wed Jun 1 17:40:59 2011 (r222575) @@ -965,6 +965,7 @@ MLINKS+=sbuf.9 sbuf_bcat.9 \ sbuf.9 sbuf_overflowed.9 \ sbuf.9 sbuf_printf.9 \ sbuf.9 sbuf_putc.9 \ + sbuf.9 sbuf_set_drain.9 \ sbuf.9 sbuf_setpos.9 \ sbuf.9 sbuf_trim.9 \ sbuf.9 sbuf_vprintf.9 Modified: stable/7/share/man/man9/sbuf.9 ============================================================================== --- stable/7/share/man/man9/sbuf.9 Wed Jun 1 17:36:52 2011 (r222574) +++ stable/7/share/man/man9/sbuf.9 Wed Jun 1 17:40:59 2011 (r222575) @@ -43,6 +43,7 @@ .Nm sbuf_printf , .Nm sbuf_vprintf , .Nm sbuf_putc , +.Nm sbuf_set_drain , .Nm sbuf_trim , .Nm sbuf_overflowed , .Nm sbuf_finish , @@ -54,6 +55,8 @@ .Sh SYNOPSIS .In sys/types.h .In sys/sbuf.h +.Ft typedef\ int ( sbuf_drain_func ) ( void\ *arg, const\ char\ *data, int\ len ) ; +.Pp .Ft struct sbuf * .Fn sbuf_new "struct sbuf *s" "char *buf" "int length" "int flags" .Ft struct sbuf * @@ -80,11 +83,13 @@ .Fn sbuf_vprintf "struct sbuf *s" "const char *fmt" "va_list ap" .Ft int .Fn sbuf_putc "struct sbuf *s" "int c" +.Ft void +.Fn sbuf_set_drain "struct sbuf *s" "sbuf_drain_func *func" "void *arg" .Ft int .Fn sbuf_trim "struct sbuf *s" .Ft int .Fn sbuf_overflowed "struct sbuf *s" -.Ft void +.Ft int .Fn sbuf_finish "struct sbuf *s" .Ft char * .Fn sbuf_data "struct sbuf *s" @@ -224,6 +229,51 @@ to the at the current position. .Pp The +.Fn sbuf_set_drain +function sets a drain function +.Fa func +for the +.Fa sbuf , +and records a pointer +.Fa arg +to be passed to the drain on callback. +The drain function cannot be changed while +.Fa sbuf_len +is non-zero. +.Pp +The registered drain function +.Vt sbuf_drain_func +will be called with the argument +.Fa arg +provided to +.Fn sbuf_set_drain , +a pointer +.Fa data +to a byte string that is the contents of the sbuf, and the length +.Fa len +of the data. +If the drain function exists, it will be called when the sbuf internal +buffer is full, or on behalf of +.Fn sbuf_finish . +The drain function may drain some or all of the data, but must drain +at least 1 byte. +The return value from the drain function, if positive, indicates how +many bytes were drained. +If negative, the return value indicates the negative error code which +will be returned from this or a later call to +.Fn sbuf_finish . +The returned drained length cannot be zero. +To do unbuffered draining, initialize the sbuf with a two-byte buffer. +The drain will be called for every byte added to the sbuf. +The +.Fn sbuf_bcopyin , +.Fn sbuf_copyin , +.Fn sbuf_trim , +and +.Fn sbuf_data +functions cannot be used on an sbuf with a drain. +.Pp +The .Fn sbuf_copyin function copies a NUL-terminated string from the specified userland address into the @@ -289,10 +339,17 @@ overflowed. .Pp The .Fn sbuf_finish -function NUL-terminates the +function will call the attached drain function if one exists until all +the data in the .Fa sbuf -and marks it as finished, which means that it may no longer be -modified using +is flushed. +If there is no attached drain, +.Fn sbuf_finish +NUL-terminates the +.Fa sbuf . +In either case it marks the +.Fa sbuf +as finished, which means that it may no longer be modified using .Fn sbuf_setpos , .Fn sbuf_cat , .Fn sbuf_cpy , @@ -305,12 +362,21 @@ is used to reset the sbuf. .Pp The .Fn sbuf_data -and -.Fn sbuf_len -functions return the actual string and its length, respectively; +function returns the actual string; .Fn sbuf_data only works on a finished .Fa sbuf . +The +.Fn sbuf_len function returns the length of the string. +For an +.Fa sbuf +with an attached drain, +.Fn sbuf_len +returns the length of the un-drained data. +.Fn sbuf_done +returns non-zero if the +.Fa sbuf +is finished. .Fn sbuf_done returns non-zero if the .Fa sbuf @@ -329,6 +395,22 @@ size of its storage buffer using .Fn sbuf_setpos , or it is reinitialized to a sufficiently short string using .Fn sbuf_cpy . +.Pp +Drains in user-space will not always function as indicated. +While the drain function will be called immediately on overflow from +the +.Fa sbuf_putc , +.Fa sbuf_bcat , +.Fa sbuf_cat +functions, +.Fa sbuf_printf +and +.Fa sbuf_vprintf +currently have no way to determine whether there will be an overflow +until after it occurs, and cannot do a partial expansion of the format +string. +Thus when using libsbuf the buffer may be extended to allow completion +of a single printf call, even though a drain is attached. .Sh RETURN VALUES The .Fn sbuf_new @@ -372,6 +454,14 @@ The function returns \-1 if copying string from userland failed, and number of bytes copied otherwise. +The +.Fn sbuf_finish +function returns ENOMEM if the sbuf overflowed before being finished, +or returns the error code from the drain if one is attached. +When used as +.Xr sbuf_finish 3 , +.Fn sbuf_finish +will return \-1 and set errno on error instead. .Sh SEE ALSO .Xr printf 3 , .Xr strcat 3 , @@ -396,6 +486,8 @@ Additional improvements were suggested b .An Justin T. Gibbs Aq gibbs@FreeBSD.org . Auto-extend support added by .An Kelly Yancey Aq kbyanc@FreeBSD.org . +Drain functionality added by +.An Matthew Fleming Aq mdf@FreeBSD.org . .Pp This manual page was written by .An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org . Modified: stable/7/sys/kern/subr_sbuf.c ============================================================================== --- stable/7/sys/kern/subr_sbuf.c Wed Jun 1 17:36:52 2011 (r222574) +++ stable/7/sys/kern/subr_sbuf.c Wed Jun 1 17:40:59 2011 (r222575) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #ifdef _KERNEL #include +#include #include #include #include @@ -40,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #else /* _KERNEL */ #include +#include #include #include #include @@ -48,6 +50,12 @@ __FBSDID("$FreeBSD$"); #include +struct sbuf_drain { + sbuf_drain_func *s_func; /* drain function */ + void *s_arg; /* user-supplied drain argument */ + int s_error; /* current error code */ +}; + #ifdef _KERNEL static MALLOC_DEFINE(M_SBUF, "sbuf", "string buffers"); #define SBMALLOC(size) malloc(size, M_SBUF, M_WAITOK) @@ -246,6 +254,8 @@ sbuf_clear(struct sbuf *s) SBUF_CLEARFLAG(s, SBUF_FINISHED); SBUF_CLEARFLAG(s, SBUF_OVERFLOWED); + if (s->s_drain != NULL) + s->s_drain->s_error = 0; s->s_len = 0; } @@ -272,27 +282,125 @@ sbuf_setpos(struct sbuf *s, int pos) } /* + * Set up a drain function and argument on an sbuf to flush data to + * when the sbuf buffer overflows. + */ +void +sbuf_set_drain(struct sbuf *s, sbuf_drain_func *func, void *ctx) +{ + + assert_sbuf_state(s, 0); + assert_sbuf_integrity(s); + KASSERT((s->s_drain != NULL && func == s->s_drain->s_func) || + s->s_len == 0, + ("Cannot change drain to %p on non-empty sbuf %p", func, s)); + if (func == NULL) { + SBFREE(s->s_drain); + s->s_drain = NULL; + return; + } + if (s->s_drain == NULL) { + s->s_drain = SBMALLOC(sizeof(*s->s_drain)); + if (s->s_drain == NULL) + return; + } + s->s_drain->s_func = func; + s->s_drain->s_arg = ctx; + s->s_drain->s_error = 0; +} + +/* + * Call the drain and process the return. + */ +static int +sbuf_drain(struct sbuf *s) +{ + int len; + + KASSERT(s->s_len > 0, ("Shouldn't drain empty sbuf %p", s)); + len = s->s_drain->s_func(s->s_drain->s_arg, s->s_buf, s->s_len); + if (len < 0) { + s->s_drain->s_error = -len; + SBUF_SETFLAG(s, SBUF_OVERFLOWED); + return (s->s_drain->s_error); + } + + KASSERT(len > 0, ("Drain must either error or work!")); + s->s_len -= len; + /* + * Fast path for the expected case where all the data was + * drained. + */ + if (s->s_len == 0) + return (0); + /* + * Move the remaining characters to the beginning of the + * string. + */ + memmove(s->s_buf, s->s_buf + len, s->s_len); + return (0); +} + +/* + * Append a byte to an sbuf. This is the core function for appending + * to an sbuf and is the main place that deals with extending the + * buffer and marking overflow. + */ +static void +sbuf_put_byte(int c, struct sbuf *s) +{ + + assert_sbuf_integrity(s); + assert_sbuf_state(s, 0); + + if (SBUF_HASOVERFLOWED(s)) + return; + if (SBUF_FREESPACE(s) <= 0) { + /* + * If there is a drain, use it, otherwise extend the + * buffer. + */ + if (s->s_drain != NULL) + (void)sbuf_drain(s); + else if (sbuf_extend(s, 1) < 0) + SBUF_SETFLAG(s, SBUF_OVERFLOWED); + if (SBUF_HASOVERFLOWED(s)) + return; + } + s->s_buf[s->s_len++] = c; +} + +/* + * Append a non-NUL character to an sbuf. This prototype signature is + * suitable for use with kvprintf(9). + */ +static void +sbuf_putc_func(int c, void *arg) +{ + + if (c != '\0') + sbuf_put_byte(c, arg); +} + +/* * Append a byte string to an sbuf. */ int sbuf_bcat(struct sbuf *s, const void *buf, size_t len) { const char *str = buf; + const char *end = str + len; assert_sbuf_integrity(s); assert_sbuf_state(s, 0); if (SBUF_HASOVERFLOWED(s)) return (-1); - for (; len; len--) { - if (!SBUF_HASROOM(s) && sbuf_extend(s, len) < 0) - break; - s->s_buf[s->s_len++] = *str++; - } - if (len > 0) { - SBUF_SETFLAG(s, SBUF_OVERFLOWED); - return (-1); - } + for (; str < end; str++) { + sbuf_put_byte(*str, s); + if (SBUF_HASOVERFLOWED(s)) + return (-1); + } return (0); } @@ -306,6 +414,8 @@ sbuf_bcopyin(struct sbuf *s, const void assert_sbuf_integrity(s); assert_sbuf_state(s, 0); + KASSERT(s->s_drain == NULL, + ("Nonsensical copyin to sbuf %p with a drain", s)); if (SBUF_HASOVERFLOWED(s)) return (-1); @@ -352,13 +462,9 @@ sbuf_cat(struct sbuf *s, const char *str return (-1); while (*str != '\0') { - if (!SBUF_HASROOM(s) && sbuf_extend(s, strlen(str)) < 0) - break; - s->s_buf[s->s_len++] = *str++; - } - if (*str != '\0') { - SBUF_SETFLAG(s, SBUF_OVERFLOWED); - return (-1); + sbuf_put_byte(*str, s); + if (SBUF_HASOVERFLOWED(s)) + return (-1); } return (0); } @@ -374,6 +480,8 @@ sbuf_copyin(struct sbuf *s, const void * assert_sbuf_integrity(s); assert_sbuf_state(s, 0); + KASSERT(s->s_drain == NULL, + ("Nonsensical copyin to sbuf %p with a drain", s)); if (SBUF_HASOVERFLOWED(s)) return (-1); @@ -417,11 +525,28 @@ sbuf_cpy(struct sbuf *s, const char *str /* * Format the given argument list and append the resulting string to an sbuf. */ +#ifdef _KERNEL +int +sbuf_vprintf(struct sbuf *s, const char *fmt, va_list ap) +{ + + assert_sbuf_integrity(s); + assert_sbuf_state(s, 0); + + KASSERT(fmt != NULL, + ("%s called with a NULL format string", __func__)); + + (void)kvprintf(fmt, sbuf_putc_func, s, 10, ap); + if (SBUF_HASOVERFLOWED(s)) + return (-1); + return (0); +} +#else /* !_KERNEL */ int sbuf_vprintf(struct sbuf *s, const char *fmt, va_list ap) { va_list ap_copy; - int len; + int error, len; assert_sbuf_integrity(s); assert_sbuf_state(s, 0); @@ -432,13 +557,32 @@ sbuf_vprintf(struct sbuf *s, const char if (SBUF_HASOVERFLOWED(s)) return (-1); + /* + * For the moment, there is no way to get vsnprintf(3) to hand + * back a character at a time, to push everything into + * sbuf_putc_func() as was done for the kernel. + * + * In userspace, while drains are useful, there's generally + * not a problem attempting to malloc(3) on out of space. So + * expand a userland sbuf if there is not enough room for the + * data produced by sbuf_[v]printf(3). + */ + + error = 0; do { va_copy(ap_copy, ap); len = vsnprintf(&s->s_buf[s->s_len], SBUF_FREESPACE(s) + 1, fmt, ap_copy); va_end(ap_copy); - } while (len > SBUF_FREESPACE(s) && - sbuf_extend(s, len - SBUF_FREESPACE(s)) == 0); + + if (SBUF_FREESPACE(s) >= len) + break; + /* Cannot print with the current available space. */ + if (s->s_drain != NULL && s->s_len > 0) + error = sbuf_drain(s); + else + error = sbuf_extend(s, len - SBUF_FREESPACE(s)); + } while (error == 0); /* * s->s_len is the length of the string, without the terminating nul. @@ -462,6 +606,7 @@ sbuf_vprintf(struct sbuf *s, const char return (-1); return (0); } +#endif /* _KERNEL */ /* * Format the given arguments and append the resulting string to an sbuf. @@ -485,17 +630,9 @@ int sbuf_putc(struct sbuf *s, int c) { - assert_sbuf_integrity(s); - assert_sbuf_state(s, 0); - + sbuf_putc_func(c, s); if (SBUF_HASOVERFLOWED(s)) return (-1); - if (!SBUF_HASROOM(s) && sbuf_extend(s, 1) < 0) { - SBUF_SETFLAG(s, SBUF_OVERFLOWED); - return (-1); - } - if (c != '\0') - s->s_buf[s->s_len++] = c; return (0); } @@ -508,6 +645,8 @@ sbuf_trim(struct sbuf *s) assert_sbuf_integrity(s); assert_sbuf_state(s, 0); + KASSERT(s->s_drain == NULL, + ("%s makes no sense on sbuf %p with drain", __func__, s)); if (SBUF_HASOVERFLOWED(s)) return (-1); @@ -531,16 +670,32 @@ sbuf_overflowed(struct sbuf *s) /* * Finish off an sbuf. */ -void +int sbuf_finish(struct sbuf *s) { + int error = 0; assert_sbuf_integrity(s); assert_sbuf_state(s, 0); + if (s->s_drain != NULL) { + error = s->s_drain->s_error; + while (s->s_len > 0 && error == 0) + error = sbuf_drain(s); + } else if (SBUF_HASOVERFLOWED(s)) + error = ENOMEM; s->s_buf[s->s_len] = '\0'; SBUF_CLEARFLAG(s, SBUF_OVERFLOWED); SBUF_SETFLAG(s, SBUF_FINISHED); +#ifdef _KERNEL + return (error); +#else + /*XXX*/if (error) { + errno = error; + return (-1); + } else + return (0); +#endif } /* @@ -552,6 +707,8 @@ sbuf_data(struct sbuf *s) assert_sbuf_integrity(s); assert_sbuf_state(s, SBUF_FINISHED); + KASSERT(s->s_drain == NULL, + ("%s makes no sense on sbuf %p with drain", __func__, s)); return (s->s_buf); } @@ -565,6 +722,8 @@ sbuf_len(struct sbuf *s) assert_sbuf_integrity(s); /* don't care if it's finished or not */ + KASSERT(s->s_drain == NULL, + ("%s makes no sense on sbuf %p with drain", __func__, s)); if (SBUF_HASOVERFLOWED(s)) return (-1); @@ -584,6 +743,8 @@ sbuf_delete(struct sbuf *s) if (SBUF_ISDYNAMIC(s)) SBFREE(s->s_buf); + if (s->s_drain != NULL) + SBFREE(s->s_drain); isdyn = SBUF_ISDYNSTRUCT(s); bzero(s, sizeof(*s)); if (isdyn) Modified: stable/7/sys/sys/sbuf.h ============================================================================== --- stable/7/sys/sys/sbuf.h Wed Jun 1 17:36:52 2011 (r222574) +++ stable/7/sys/sys/sbuf.h Wed Jun 1 17:40:59 2011 (r222575) @@ -33,12 +33,16 @@ #include +struct sbuf; +struct sbuf_drain_data; +typedef int (sbuf_drain_func)(void *, const char *, int); + /* * Structure definition */ struct sbuf { char *s_buf; /* storage buffer */ - void *s_unused; /* binary compatibility. */ + struct sbuf_drain *s_drain; /* drain function and data */ int s_size; /* size of storage buffer */ int s_len; /* current length of string */ #define SBUF_FIXEDLEN 0x00000000 /* fixed length buffer (default) */ @@ -69,9 +73,10 @@ int sbuf_printf(struct sbuf *, const c int sbuf_vprintf(struct sbuf *, const char *, __va_list) __printflike(2, 0); int sbuf_putc(struct sbuf *, int); +void sbuf_set_drain(struct sbuf *, sbuf_drain_func *, void *); int sbuf_trim(struct sbuf *); int sbuf_overflowed(struct sbuf *); -void sbuf_finish(struct sbuf *); +int sbuf_finish(struct sbuf *); char *sbuf_data(struct sbuf *); int sbuf_len(struct sbuf *); int sbuf_done(struct sbuf *); From owner-svn-src-stable-7@FreeBSD.ORG Wed Jun 1 17:51:28 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 22ACD1065797; Wed, 1 Jun 2011 17:51:28 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 11CBE8FC0C; Wed, 1 Jun 2011 17:51:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p51HpR1G080571; Wed, 1 Jun 2011 17:51:27 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p51HpROC080569; Wed, 1 Jun 2011 17:51:27 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201106011751.p51HpROC080569@svn.freebsd.org> From: Matthew D Fleming Date: Wed, 1 Jun 2011 17:51:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222577 - stable/7/sys/kern X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jun 2011 17:51:28 -0000 Author: mdf Date: Wed Jun 1 17:51:27 2011 New Revision: 222577 URL: http://svn.freebsd.org/changeset/base/222577 Log: MFC r212478: (originally by kan@) Add missing pointer increment to sbuf_cat. Modified: stable/7/sys/kern/subr_sbuf.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/subr_sbuf.c ============================================================================== --- stable/7/sys/kern/subr_sbuf.c Wed Jun 1 17:51:18 2011 (r222576) +++ stable/7/sys/kern/subr_sbuf.c Wed Jun 1 17:51:27 2011 (r222577) @@ -462,7 +462,7 @@ sbuf_cat(struct sbuf *s, const char *str return (-1); while (*str != '\0') { - sbuf_put_byte(*str, s); + sbuf_put_byte(*str++, s); if (SBUF_HASOVERFLOWED(s)) return (-1); } From owner-svn-src-stable-7@FreeBSD.ORG Wed Jun 1 18:27:13 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 943CC1065676; Wed, 1 Jun 2011 18:27:13 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 81AE58FC12; Wed, 1 Jun 2011 18:27:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p51IRDsM081856; Wed, 1 Jun 2011 18:27:13 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p51IRDbG081849; Wed, 1 Jun 2011 18:27:13 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201106011827.p51IRDbG081849@svn.freebsd.org> From: Matthew D Fleming Date: Wed, 1 Jun 2011 18:27:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222580 - in stable/7: share/man/man9 sys/dev/cxgb sys/kern sys/sys X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jun 2011 18:27:13 -0000 Author: mdf Date: Wed Jun 1 18:27:13 2011 New Revision: 222580 URL: http://svn.freebsd.org/changeset/base/222580 Log: Partial MFC of r212370. np@ requested this functionality so I kept in the cxgb change, but otherwise MFC'd only the new function sbuf_new_for_sysctl(9) and none of the changed code. MFC r217830: Document sbuf_new_for_sysctl(9). Partial MFC of r217916: Explicitly wire the user buffer rather than doing it implicitly in sbuf_new_for_sysctl(9). This allows using an sbuf with a SYSCTL_OUT drain for extremely large amounts of data where the caller knows that appropriate references are held, and sleeping is not an issue. Modified: stable/7/share/man/man9/Makefile stable/7/share/man/man9/sbuf.9 stable/7/sys/dev/cxgb/cxgb_sge.c stable/7/sys/kern/kern_sysctl.c stable/7/sys/kern/subr_sbuf.c stable/7/sys/sys/sysctl.h Directory Properties: stable/7/share/man/man9/ (props changed) stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/share/man/man9/Makefile ============================================================================== --- stable/7/share/man/man9/Makefile Wed Jun 1 18:26:59 2011 (r222579) +++ stable/7/share/man/man9/Makefile Wed Jun 1 18:27:13 2011 (r222580) @@ -962,6 +962,7 @@ MLINKS+=sbuf.9 sbuf_bcat.9 \ sbuf.9 sbuf_finish.9 \ sbuf.9 sbuf_len.9 \ sbuf.9 sbuf_new.9 \ + sbuf.9 sbuf_new_for_sysctl.9 \ sbuf.9 sbuf_overflowed.9 \ sbuf.9 sbuf_printf.9 \ sbuf.9 sbuf_putc.9 \ Modified: stable/7/share/man/man9/sbuf.9 ============================================================================== --- stable/7/share/man/man9/sbuf.9 Wed Jun 1 18:26:59 2011 (r222579) +++ stable/7/share/man/man9/sbuf.9 Wed Jun 1 18:27:13 2011 (r222580) @@ -25,13 +25,14 @@ .\" .\" $FreeBSD$ .\" -.Dd May 17, 2009 +.Dd January 25, 2011 .Dt SBUF 9 .Os .Sh NAME .Nm sbuf , .Nm sbuf_new , .Nm sbuf_new_auto , +.Nm sbuf_new_for_sysctl , .Nm sbuf_clear , .Nm sbuf_setpos , .Nm sbuf_bcat , @@ -99,6 +100,9 @@ .Fn sbuf_done "struct sbuf *s" .Ft void .Fn sbuf_delete "struct sbuf *s" +.In sys/sysctl.h +.Ft struct sbuf * +.Fn sbuf_new_for_sysctl "struct sbuf *s" "char *buf" "int length" "struct sysctl_req *req" .Sh DESCRIPTION The .Nm @@ -169,6 +173,15 @@ and .Dv SBUF_AUTOEXTEND . .Pp The +.Fn sbuf_new_for_sysctl +function will set up an sbuf with a drain function to use +.Fn SYSCTL_OUT +when the internal buffer fills. +Note that if the various functions which append to an sbuf are used while +a non-sleepable lock is held, the user buffer should be wired using +.Fn sysctl_wire_old_buffer . +.Pp +The .Fn sbuf_delete function clears the .Fa sbuf Modified: stable/7/sys/dev/cxgb/cxgb_sge.c ============================================================================== --- stable/7/sys/dev/cxgb/cxgb_sge.c Wed Jun 1 18:26:59 2011 (r222579) +++ stable/7/sys/dev/cxgb/cxgb_sge.c Wed Jun 1 18:27:13 2011 (r222580) @@ -3070,7 +3070,6 @@ t3_dump_rspq(SYSCTL_HANDLER_ARGS) struct sge_rspq *rspq; struct sge_qset *qs; int i, err, dump_end, idx; - static int multiplier = 1; struct sbuf *sb; struct rsp_desc *rspd; uint32_t data[4]; @@ -3095,8 +3094,10 @@ t3_dump_rspq(SYSCTL_HANDLER_ARGS) err = t3_sge_read_rspq(qs->port->adapter, rspq->cntxt_id, data); if (err) return (err); -retry_sbufops: - sb = sbuf_new(NULL, NULL, QDUMP_SBUF_SIZE*multiplier, SBUF_FIXEDLEN); + err = sysctl_wire_old_buffer(req, 0); + if (err) + return (err); + sb = sbuf_new_for_sysctl(NULL, NULL, QDUMP_SBUF_SIZE, req); sbuf_printf(sb, " \n index=%u size=%u MSI-X/RspQ=%u intr enable=%u intr armed=%u\n", (data[0] & 0xffff), data[0] >> 16, ((data[2] >> 20) & 0x3f), @@ -3119,13 +3120,11 @@ retry_sbufops: rspd->rss_hdr.rss_hash_val, be32toh(rspd->flags), be32toh(rspd->len_cq), rspd->intr_gen); } - if (sbuf_overflowed(sb)) { - sbuf_delete(sb); - multiplier++; - goto retry_sbufops; - } - sbuf_finish(sb); - err = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1); + + err = sbuf_finish(sb); + /* Output a trailing NUL. */ + if (err == 0) + err = SYSCTL_OUT(req, "", 1); sbuf_delete(sb); return (err); } @@ -3136,7 +3135,6 @@ t3_dump_txq_eth(SYSCTL_HANDLER_ARGS) struct sge_txq *txq; struct sge_qset *qs; int i, j, err, dump_end; - static int multiplier = 1; struct sbuf *sb; struct tx_desc *txd; uint32_t *WR, wr_hi, wr_lo, gen; @@ -3163,10 +3161,10 @@ t3_dump_txq_eth(SYSCTL_HANDLER_ARGS) err = t3_sge_read_ecntxt(qs->port->adapter, qs->rspq.cntxt_id, data); if (err) return (err); - - -retry_sbufops: - sb = sbuf_new(NULL, NULL, QDUMP_SBUF_SIZE*multiplier, SBUF_FIXEDLEN); + err = sysctl_wire_old_buffer(req, 0); + if (err) + return (err); + sb = sbuf_new_for_sysctl(NULL, NULL, QDUMP_SBUF_SIZE, req); sbuf_printf(sb, " \n credits=%u GTS=%u index=%u size=%u rspq#=%u cmdq#=%u\n", (data[0] & 0x7fff), ((data[0] >> 15) & 1), (data[0] >> 16), @@ -3193,13 +3191,10 @@ retry_sbufops: WR[j], WR[j + 1], WR[j + 2], WR[j + 3]); } - if (sbuf_overflowed(sb)) { - sbuf_delete(sb); - multiplier++; - goto retry_sbufops; - } - sbuf_finish(sb); - err = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1); + err = sbuf_finish(sb); + /* Output a trailing NUL. */ + if (err == 0) + err = SYSCTL_OUT(req, "", 1); sbuf_delete(sb); return (err); } @@ -3210,7 +3205,6 @@ t3_dump_txq_ctrl(SYSCTL_HANDLER_ARGS) struct sge_txq *txq; struct sge_qset *qs; int i, j, err, dump_end; - static int multiplier = 1; struct sbuf *sb; struct tx_desc *txd; uint32_t *WR, wr_hi, wr_lo, gen; @@ -3234,8 +3228,10 @@ t3_dump_txq_ctrl(SYSCTL_HANDLER_ARGS) return (EINVAL); } -retry_sbufops: - sb = sbuf_new(NULL, NULL, QDUMP_SBUF_SIZE*multiplier, SBUF_FIXEDLEN); + err = sysctl_wire_old_buffer(req, 0); + if (err != 0) + return (err); + sb = sbuf_new_for_sysctl(NULL, NULL, QDUMP_SBUF_SIZE, req); sbuf_printf(sb, " qid=%d start=%d -> end=%d\n", qs->idx, txq->txq_dump_start, (txq->txq_dump_start + txq->txq_dump_count) & 255); @@ -3255,13 +3251,10 @@ retry_sbufops: WR[j], WR[j + 1], WR[j + 2], WR[j + 3]); } - if (sbuf_overflowed(sb)) { - sbuf_delete(sb); - multiplier++; - goto retry_sbufops; - } - sbuf_finish(sb); - err = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1); + err = sbuf_finish(sb); + /* Output a trailing NUL. */ + if (err == 0) + err = SYSCTL_OUT(req, "", 1); sbuf_delete(sb); return (err); } Modified: stable/7/sys/kern/kern_sysctl.c ============================================================================== --- stable/7/sys/kern/kern_sysctl.c Wed Jun 1 18:26:59 2011 (r222579) +++ stable/7/sys/kern/kern_sysctl.c Wed Jun 1 18:27:13 2011 (r222580) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1585,3 +1586,28 @@ userland_sysctl(struct thread *td, int * } return (error); } + +/* + * Drain into a sysctl struct. The user buffer should be wired if a page + * fault would cause issue. + */ +static int +sbuf_sysctl_drain(void *arg, const char *data, int len) +{ + struct sysctl_req *req = arg; + int error; + + error = SYSCTL_OUT(req, data, len); + KASSERT(error >= 0, ("Got unexpected negative value %d", error)); + return (error == 0 ? len : -error); +} + +struct sbuf * +sbuf_new_for_sysctl(struct sbuf *s, char *buf, int length, + struct sysctl_req *req) +{ + + s = sbuf_new(s, buf, length, SBUF_FIXEDLEN); + sbuf_set_drain(s, sbuf_sysctl_drain, req); + return (s); +} Modified: stable/7/sys/kern/subr_sbuf.c ============================================================================== --- stable/7/sys/kern/subr_sbuf.c Wed Jun 1 18:26:59 2011 (r222579) +++ stable/7/sys/kern/subr_sbuf.c Wed Jun 1 18:27:13 2011 (r222580) @@ -324,8 +324,8 @@ sbuf_drain(struct sbuf *s) SBUF_SETFLAG(s, SBUF_OVERFLOWED); return (s->s_drain->s_error); } - - KASSERT(len > 0, ("Drain must either error or work!")); + KASSERT(len > 0 && len <= s->s_len, + ("Bad drain amount %d for sbuf %p", len, s)); s->s_len -= len; /* * Fast path for the expected case where all the data was Modified: stable/7/sys/sys/sysctl.h ============================================================================== --- stable/7/sys/sys/sysctl.h Wed Jun 1 18:26:59 2011 (r222579) +++ stable/7/sys/sys/sysctl.h Wed Jun 1 18:27:13 2011 (r222580) @@ -703,6 +703,9 @@ void sysctl_lock(void); void sysctl_unlock(void); int sysctl_wire_old_buffer(struct sysctl_req *req, size_t len); +struct sbuf; +struct sbuf *sbuf_new_for_sysctl(struct sbuf *, char *, int, + struct sysctl_req *); #else /* !_KERNEL */ #include From owner-svn-src-stable-7@FreeBSD.ORG Sat Jun 4 11:30:13 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4A15A106564A; Sat, 4 Jun 2011 11:30:13 +0000 (UTC) (envelope-from bcr@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 201DF8FC13; Sat, 4 Jun 2011 11:30:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p54BUDK2008251; Sat, 4 Jun 2011 11:30:13 GMT (envelope-from bcr@svn.freebsd.org) Received: (from bcr@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p54BUDFv008249; Sat, 4 Jun 2011 11:30:13 GMT (envelope-from bcr@svn.freebsd.org) Message-Id: <201106041130.p54BUDFv008249@svn.freebsd.org> From: Benedict Reuschling Date: Sat, 4 Jun 2011 11:30:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222678 - stable/7/share/man/man4 X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Jun 2011 11:30:13 -0000 Author: bcr (doc committer) Date: Sat Jun 4 11:30:12 2011 New Revision: 222678 URL: http://svn.freebsd.org/changeset/base/222678 Log: MFC r222447: Mention that jumbo frame support is disabled on PCIe VT6130/VT6132 controllers because of TX MAC hangs when trying to send a frame that is larger than 4K (see r200759). PR: docs/156742 Submitted by: Michael Moll (kvedulv at kvedulv dot de) Reviewed by: yongari@ Modified: stable/7/share/man/man4/vge.4 Directory Properties: stable/7/share/man/man4/ (props changed) Modified: stable/7/share/man/man4/vge.4 ============================================================================== --- stable/7/share/man/man4/vge.4 Sat Jun 4 11:28:44 2011 (r222677) +++ stable/7/share/man/man4/vge.4 Sat Jun 4 11:30:12 2011 (r222678) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 23, 2010 +.Dd May 29, 2011 .Dt VGE 4 .Os .Sh NAME @@ -66,13 +66,14 @@ The MAC supports TCP/IP hardware checksums (IPv4 only), TCP large send, VLAN tag insertion and stripping, as well as VLAN filtering, a 64-entry CAM filter and a 64-entry VLAN filter, 64-bit multicast hash filter, 4 separate transmit DMA queues, flow control -and jumbo frames up to 16K in size. +and jumbo frames (not on VT6130/VT6132) up to 16K in size. The Velocity family controllers have a 16K receive FIFO and 48K transmit FIFO. .Pp The .Nm driver takes advantage of the controller's checksum offload and VLAN -tagging features, as well as the jumbo frame and CAM filter support. +tagging features, as well as the jumbo frame (except VT6130/VT6132) and CAM +filter support. The CAM filter is used for multicast address filtering to provide 64 perfect multicast address filter support. If it is necessary for the interface to join more than 64 multicast @@ -81,6 +82,8 @@ groups, the driver will switch over to u The jumbo frame support can be enabled by setting the interface MTU to any value larger than the default of 1500 bytes, up to a maximum of 9000 bytes. +Jumbo frames are disabled on the VT6130/VT6132 controllers because the TX +MAC will hang when trying to send a frame that is larger than 4K. The receive and transmit checksum offload support can be toggled on and off using the .Xr ifconfig 8