sysctl hacks
Alfred Perlstein
alfred at freebsd.org
Sat Aug 21 23:47:07 PDT 2004
* Poul-Henning Kamp <phk at phk.freebsd.dk> [040821 13:29] wrote:
> In message <20040821200205.GE26612 at elvis.mu.org>, Alfred Perlstein writes:
> >I'm doing some work that requires that I have a sysctl structure
> >be passed around, but inside that structure are several pointers I
> >may need to dereference.
> >
> >Basically:
> >
> >struct mysysctldata {
> > .... (data here)
> > void *moredata;
> > size_t morelen;
> >};
> >
> >What is the proper way of sysctl'ing IN the data from moredata?
> >
> >I need to make a copy of the sysctl req, but... I'm not sure what
> >to initialize the 'lock' member to.
>
> Just use the SYSCTL_IN() and ..._OUT() functions.
:(
I wasn't clear.
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?
--
- Alfred Perlstein
- Research Engineering Development Inc.
- email: bright at mu.org cell: 408-480-4684
More information about the freebsd-hackers
mailing list