From owner-freebsd-testing@freebsd.org Fri Jun 19 17:47:10 2020 Return-Path: Delivered-To: freebsd-testing@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8C76B33448A for ; Fri, 19 Jun 2020 17:47:10 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49pR8G36tjz4Ydw; Fri, 19 Jun 2020 17:47:10 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from venus.codepro.be (venus.codepro.be [5.9.86.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx1.codepro.be", Issuer "Let's Encrypt Authority X3" (verified OK)) (Authenticated sender: kp) by smtp.freebsd.org (Postfix) with ESMTPSA id 4C4EE14ABE; Fri, 19 Jun 2020 17:47:10 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: by venus.codepro.be (Postfix, authenticated sender kp) id D8A7918D22; Fri, 19 Jun 2020 19:47:08 +0200 (CEST) From: "Kristof Provost" To: "John-Mark Gurney" Cc: freebsd-testing@freebsd.org Subject: Re: Querying kernel features Date: Fri, 19 Jun 2020 19:47:05 +0200 X-Mailer: MailMate (1.13.1r5671) Message-ID: <8B2AC268-7CA2-4FDA-BA58-FAEF7F0715BF@FreeBSD.org> In-Reply-To: <20200618231944.GB4213@funkthat.com> References: <6C6C4F2B-CD11-4777-A97C-D249C514DEEA@FreeBSD.org> <20200618231944.GB4213@funkthat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-testing@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Testing on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jun 2020 17:47:10 -0000 On 19 Jun 2020, at 1:19, John-Mark Gurney wrote: > Kristof Provost wrote this message on Thu, Jun 18, 2020 at 22:57 > +0200: >> Say that I have a test for an optional kernel feature (say ALTQ, or >> TMPFS) is there an elegant way of figuring out at runtime if it???s >> available? >> >> Doing `sysctl kern.conftxt | grep ALTQ` feels a little inelegant, and >> is >> begging for issues with incorrect matches. >> >> I???m tempted to add a sysctl node for ALTQ, but perhaps there???s a >> better way. Or perhaps this should be a general feature (so we???d >> have >> nodes like kernel.feature.tmpfs=1). > > Look at kern.features... There's a FEATURE macro to add entries to > that, but looks like there isn't any man page for it... > > sys/geom/eli/g_eli.c:FEATURE(geom_eli, "GEOM crypto module"); > Ah, thanks, that’s pretty much exactly what I was looking for. There is a man page for feature_present(3), which is a C function to check for the presence of a given feature. It does the sysctl for you. That’s not quite what I need (atf-sh make sysctl the easiest interface), but I figured I’d point out at least something is documented. Best regards, Kristof