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. 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). 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 cheers luigiReceived on Fri Jun 27 2014 - 07:47:05 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:50 UTC