sysctl hacks
Alfred Perlstein
alfred at freebsd.org
Sun Aug 22 00:28:47 PDT 2004
* John-Mark Gurney <gurney_j at resnet.uoregon.edu> [040822 00:18] wrote:
> Alfred Perlstein wrote this message on Sat, Aug 21, 2004 at 23:47 -0700:
> >
> > I have a sysctl node that takes a struct like so:
> >
> > struct mysysctldata {
> > .... (data here)
> > struct moredata * vc_ptr;
> > size_t len vc_len;
> > }
> >
> > If I use SYSCTL_IN(), then I can get "mysysctldata", but I only
> > get the pointer to "moredata", now I want to get a copy of
> > "moredata", what's a good way to do this?
> >
> > I have a macro that does this:
> >
> > #define VCTLTOREQ(vc, req) \
> > do { \
> > (req)->newptr = (vc)->vc_ptr; \
> > (req)->newlen = (vc)->vc_len; \
> > (req)->newidx = 0; \
> > } while (0)
> >
> > Is that right?
>
> After reading the sysctl code, it appears that you can't do that..
> SYSCTL_IN only lets you read serially from the buffer passed in... so
> you have to have all the data serially in userland... once you do a
> SYSCTL_IN of x bytes of data, the pointer is updated to skip those x,
> and the next call will read in the bytes following the first read...
>
> Hope this helps.
Yes, but you can update the sysctlreq struct's newptr, newlen and
newidx to point to the auxiliary data as my macro does, I just
wanted to make sure I wasn't missing some subtle point of the
how sysctl works.
--
- Alfred Perlstein
- Research Engineering Development Inc.
- email: bright at mu.org cell: 408-480-4684
More information about the freebsd-hackers
mailing list