Querying kernel features

Enji Cooper yaneurabeya at gmail.com
Fri Jun 19 21:55:28 UTC 2020


> On Jun 19, 2020, at 10:47 AM, Kristof Provost <kp at FreeBSD.org> wrote:
> 
> 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.

There are some convenience macros in tests/freebsd_test_suite/macros.h . I’ll work on adding some atf-sh available functions for the lot (seeing as there isn’t really any good documentation for it anywhere).
HTH,
-Enji


More information about the freebsd-testing mailing list