From owner-freebsd-current@FreeBSD.ORG Fri Jun 27 16:04:32 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id ACD36E02 for ; Fri, 27 Jun 2014 16:04:32 +0000 (UTC) Received: from mx1.scaleengine.net (beauharnois2.bhs1.scaleengine.net [142.4.218.15]) by mx1.freebsd.org (Postfix) with ESMTP id 6E2F72EDE for ; Fri, 27 Jun 2014 16:04:32 +0000 (UTC) Received: from [192.168.1.2] (senat1-01.HML3.ScaleEngine.net [209.51.186.5]) (Authenticated sender: allanjude.freebsd@scaleengine.com) by mx1.scaleengine.net (Postfix) with ESMTPSA id 1D22918D04 for ; Fri, 27 Jun 2014 16:04:25 +0000 (UTC) Message-ID: <53AD9621.7070000@freebsd.org> Date: Fri, 27 Jun 2014 12:04:49 -0400 From: Allan Jude User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: freebsd-current@freebsd.org Subject: Re: do we have a generic string-number sysctl mapping library ? References: <20140627091459.GA50710@onelab2.iet.unipi.it> <20140627095029.GF50710@onelab2.iet.unipi.it> In-Reply-To: <20140627095029.GF50710@onelab2.iet.unipi.it> X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="rS7FrQpfdQNv5uuVHejWC7x3eS3O88pCK" X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jun 2014 16:04:32 -0000 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--