From owner-freebsd-arch@FreeBSD.ORG Fri Jan 4 16:05:17 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 D89DB16A469 for ; Fri, 4 Jan 2008 16:05:17 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.freebsd.org (Postfix) with ESMTP id 9B98113C457 for ; Fri, 4 Jan 2008 16:05:17 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (unknown [192.168.61.3]) by phk.freebsd.dk (Postfix) with ESMTP id 1A2AA17105; Fri, 4 Jan 2008 16:05:15 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.14.2/8.14.2) with ESMTP id m04G5FAn006533; Fri, 4 Jan 2008 16:05:15 GMT (envelope-from phk@critter.freebsd.dk) To: Julian Elischer From: "Poul-Henning Kamp" In-Reply-To: Your message of "Fri, 04 Jan 2008 08:00:42 PST." <477E582A.2060106@elischer.org> Date: Fri, 04 Jan 2008 16:05:15 +0000 Message-ID: <6532.1199462715@critter.freebsd.dk> Sender: phk@critter.freebsd.dk 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:05:17 -0000 In message <477E582A.2060106@elischer.org>, Julian Elischer writes: >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. No, you'd just expand the macro to a sysctl-function and declare the oid as such. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.