From owner-freebsd-hackers@FreeBSD.ORG Sun Aug 22 06:47:07 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 63C0016A4CE for ; Sun, 22 Aug 2004 06:47:07 +0000 (GMT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5936E43D3F for ; Sun, 22 Aug 2004 06:47:07 +0000 (GMT) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id 4D6465C912; Sat, 21 Aug 2004 23:47:07 -0700 (PDT) Date: Sat, 21 Aug 2004 23:47:07 -0700 From: Alfred Perlstein To: Poul-Henning Kamp Message-ID: <20040822064707.GF26612@elvis.mu.org> References: <20040821200205.GE26612@elvis.mu.org> <46719.1093120181@critter.freebsd.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <46719.1093120181@critter.freebsd.dk> User-Agent: Mutt/1.4.2.1i cc: hackers@freebsd.org Subject: Re: sysctl hacks X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Aug 2004 06:47:07 -0000 * Poul-Henning Kamp [040821 13:29] wrote: > In message <20040821200205.GE26612@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@mu.org cell: 408-480-4684