]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Add getenv(9) boolean parsing functions
authorMitchell Horne <mhorne@FreeBSD.org>
Mon, 21 Sep 2020 15:24:44 +0000 (15:24 +0000)
committerMitchell Horne <mhorne@FreeBSD.org>
Mon, 21 Sep 2020 15:24:44 +0000 (15:24 +0000)
commitcba446e2c28589878f09214341629349df25a090
tree9c50f819e54963fe8e82ec2eb3452225f7070731
parentaea49d9fed9e24a5d7f5604262aa79fccc3f427e
Add getenv(9) boolean parsing functions

This adds the getenv_bool() function, to parse a boolean value from a
kernel environment variable or tunable. This works for traditional
boolean values like "0" and "1", and also "true" and "false"
(case-insensitive). These semantics do not yet apply to sysctls declared
using SYSCTL_BOOL with CTLFLAG_TUN (they still only parse 1 and 0).

Also added are two wrapper functions, getenv_is_true() and
getenv_is_false(). These are slightly simpler for callers wishing to
perform a single check of a configuration variable.

Reviewed by: jhb (slightly earlier version)
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26270
share/man/man9/Makefile
share/man/man9/getenv.9
sys/kern/kern_environment.c
sys/sys/kernel.h
sys/sys/systm.h