Subject: Re: Reading sysctl values in the kernel
To: Andrew Brown <atatat@atatdot.net>
From: Alan Ritter <rittera@cc.wwu.edu>
List: tech-kern
Date: 07/24/2005 18:33:48
Hello,

>>          sysctl_createv(&sc->sysctllog, 0, NULL, NULL,
>>                  CTLFLAG_READWRITE|CTLFLAG_OWNDESC, CTLTYPE_STRING,
>>                  vals->nc_cfgkey, vals->nc_cfgdesc, NULL,
>>                        0, vals->nc_val, strlen(vals->nc_val),
>>                        ndis_node->sysctl_num, CTL_CREATE, CTL_EOL);
>
> that works.  okay, so you have "n" children and not "1".
>
> i note, however, that you're telling the sysctl subsystem to copy (and
> "own") the description, but not the data actually being instrumented.
> since these are writeable values, i presume you're taking care that
> the space for the data is not going to be reused accidentally?

The "vals" structure here is a pointer into an array of structures
(ndis_regvals[]) which is staticly initialized in ndis_driver_data.h,
which is the file generated from the Windows .sys and .inf files using the
ndiscvt utility (probably more information than you wanted :-)  Anyway, I
don't think it would get re-used for anything, but I should go through the
rest of the NDIS code, and make sure.

> also,
> the space alloted for each "value" is only as large as the space you
> indicate here (via the strlen() call).

does sysctl_createv() allocate space to store the sysctl_data
(sysctl_un.scu_data.sud_data) field in?  I took a brief look at the source
for sysctl_createv() and it didn't seem like it.  Maybe there's something
I'm missing here.

Anyway thanks again, I'm really glad that the dynamic sysctl interface is
there for me to use :-)