From owner-freebsd-arch@FreeBSD.ORG Fri Jan 4 16:00:29 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E8AA16A41A for ; Fri, 4 Jan 2008 16:00:29 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outO.internet-mail-service.net (outO.internet-mail-service.net [216.240.47.238]) by mx1.freebsd.org (Postfix) with ESMTP id 6811513C469 for ; Fri, 4 Jan 2008 16:00:29 +0000 (UTC) (envelope-from julian@elischer.org) Received: from mx0.idiom.com (HELO idiom.com) (216.240.32.160) by out.internet-mail-service.net (qpsmtpd/0.40) with ESMTP; Fri, 04 Jan 2008 08:00:28 -0800 Received: from julian-mac.elischer.org (localhost [127.0.0.1]) by idiom.com (Postfix) with ESMTP id 075FE126E14; Fri, 4 Jan 2008 08:00:27 -0800 (PST) Message-ID: <477E582A.2060106@elischer.org> Date: Fri, 04 Jan 2008 08:00:42 -0800 From: Julian Elischer User-Agent: Thunderbird 2.0.0.9 (Macintosh/20071031) MIME-Version: 1.0 To: Poul-Henning Kamp References: <5064.1199443122@critter.freebsd.dk> In-Reply-To: <5064.1199443122@critter.freebsd.dk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: arch@freebsd.org Subject: Re: RFC: sysctl additional functions/macros X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jan 2008 16:00:29 -0000 Poul-Henning Kamp wrote: > In message <477D931D.4000303@elischer.org>, Julian Elischer writes: >> I would like to extend the current SYSCTL_INT() with >> SYSCTL_INT_CLAMPED() or similar, where you also supply a >> maximum acceptable value. (and maybe a clue as to what to say if it is >> a bad value). > > I'm not sure I think it is a good idea. > > Next you'll want SYSCTL_INT_BITMAP(), SYSCTL_INT_POWERS_OF_PI() and > so on. > > A much better idea would be to add a code argument to a version of > SYSCTL_INT(), so that people could write something like: > > SYSCTL_INT(_debug, OID_AUTO, foobar, ORD_WR, &foobar, 0, > "mumble desc mumble", > { > if (newval < 3 || newval > 70 || newval == 59) > return (EINVAL); > } > ) > I actually considered that already.. It has the advantage of being flexible.. but is more intrusive to implement. I think you'd have to extend the sysctl_oid structure.