Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Jun 2020 19:47:05 +0200
From:      "Kristof Provost" <kp@FreeBSD.org>
To:        "John-Mark Gurney" <jmg@funkthat.com>
Cc:        freebsd-testing@freebsd.org
Subject:   Re: Querying kernel features
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>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8B2AC268-7CA2-4FDA-BA58-FAEF7F0715BF>