Date: Sun, 22 Aug 2004 00:28:47 -0700 From: Alfred Perlstein <alfred@freebsd.org> To: Poul-Henning Kamp <phk@phk.freebsd.dk>, hackers@freebsd.org Subject: Re: sysctl hacks Message-ID: <20040822072847.GG26612@elvis.mu.org> In-Reply-To: <20040822071820.GA29902@funkthat.com> References: <20040821200205.GE26612@elvis.mu.org> <46719.1093120181@critter.freebsd.dk> <20040822064707.GF26612@elvis.mu.org> <20040822071820.GA29902@funkthat.com>
next in thread | previous in thread | raw e-mail | index | archive | help
* John-Mark Gurney <gurney_j@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@mu.org cell: 408-480-4684
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040822072847.GG26612>
