Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jun 2014 12:04:49 -0400
From:      Allan Jude <allanjude@freebsd.org>
To:        freebsd-current@freebsd.org
Subject:   Re: do we have a generic string-number sysctl mapping library ?
Message-ID:  <53AD9621.7070000@freebsd.org>
In-Reply-To: <20140627095029.GF50710@onelab2.iet.unipi.it>
References:  <20140627091459.GA50710@onelab2.iet.unipi.it> <alpine.BSF.2.11.1406271125540.11883@mail.fig.ol.no> <20140627095029.GF50710@onelab2.iet.unipi.it>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--rS7FrQpfdQNv5uuVHejWC7x3eS3O88pCK
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On 2014-06-27 05:50, Luigi Rizzo wrote:
> On Fri, Jun 27, 2014 at 11:27:56AM +0200, Trond Endrest?l wrote:
>> On Fri, 27 Jun 2014 11:14+0200, Luigi Rizzo wrote:
>>
>>> Hi,
>>> I have frequently found myself using sysctls to control some kernel
>>> feature where a string would be a better (and sometimes the only)
>>> option than using a numeric value, yet the internal representation
>>> should be numeric for speed and robustness.
>>> Examples are the kern.timecounter, the default scheduler in dummynet,=

>>> and now in netmap the selection between native and emulated mode.
>>> I am sure many of you can come up with other cases.
>>>
>>> I wonder if we have some support for that already in the sysctl code,=

>>> or i should build a generic one next time i need to do that.
>>
>> In C, according to sysctl(3) you could use sysctlnametomib().
>> I might have misinterpreted the problem domain.
>=20
> different problem. Example below:
> right now i have dev.netmap.admode which can assume integer values,
> i do not need a special handler, and the code in the kernel uses
> 1, 2 or "everything else" to decide what to do (resetting
> "everything else" to 0 opportunistically).
>=20
> I want to have a generic handler that accepts a set of predefined
> string values (specifically "any native emulated") and converts
> them to integers through some user-specificed mapping so the
> kernel can still do the quick tests but users don't have
> to remember what '2' means
>=20
> cheers
> luigi
> _______________________________________________
> freebsd-current@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.o=
rg"
>=20

If i understand what you are looking for, it sounds like what
vfs.zfs.vol.mode uses. the values are 0, 1 or 2, but can also be
assigned using the keywords 'geom', 'dev', or 'none'

--=20
Allan Jude


--rS7FrQpfdQNv5uuVHejWC7x3eS3O88pCK
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJTrZYkAAoJEJrBFpNRJZKfH20P/2gfWEpX2ZD+ScVk9QQjGHls
sb7jQHD/kemEAyHFR1Tr3uarpKHnmwF/4Zj+DgfYXaYe8p4Oj2CYmTUMKWkCsSEk
IEPOMCmUuRP2Uh8UHtYlFrHK5bZFaykrMVpRDWS0aISJQqONR0qANvlPmnmx+zsM
ds1V+oLmlsWNXmYB04UkLO7OfnkH0wjOgCZTLnE1DbMwreQkc1qwM2Wl5Ky0QmIJ
JvReTbomkWbXnS5/NeM6ux0suPiJq1dpABkXrgMVbQqLylrteAJOFzV6UYBbBbVZ
izVNk3m/PtM/EO6bFqFFo/CZs47JWgwU/LK7fCCOrqfJwXPLr8kVwm/5rqOUI/6r
4OVfnlhkbvSCq3i/Ss2XoDy6juu9VV/dflnrkzHqjcaVWTxabVEN+6c2jTBNklDP
Ug0WjGVufpphL4pxgNtIU5bJA8olr+UCa7l8kGde8pmJ+rKTjVcaaMCyYGI1xeb0
RH6BpcXG/ddN0JDSU7I4GmhTk7D8wIKw5VTeZuhQ3Rp5LgqGQGdfePws2+wHGpe+
KYswv0IkogETzkAUuZKOjZHvKjVxw4pzKL18x/DqjSp168knj/cLZ3Mp+mS8EK5m
HQ8PzTtHWpIGdb+f7wpnzddB8OyMcXqst/67bWa7PoXJG3ShzADo/XIQuX5vHMxy
qt0S3Z8o6Hbf4+ugYHZD
=lWOW
-----END PGP SIGNATURE-----

--rS7FrQpfdQNv5uuVHejWC7x3eS3O88pCK--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53AD9621.7070000>