From owner-freebsd-hackers@FreeBSD.ORG Sun Aug 22 07:28:47 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 5C6DD16A4CE for ; Sun, 22 Aug 2004 07:28:47 +0000 (GMT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 509AC43D3F for ; Sun, 22 Aug 2004 07:28:47 +0000 (GMT) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id 478105C90A; Sun, 22 Aug 2004 00:28:47 -0700 (PDT) Date: Sun, 22 Aug 2004 00:28:47 -0700 From: Alfred Perlstein To: Poul-Henning Kamp , hackers@freebsd.org Message-ID: <20040822072847.GG26612@elvis.mu.org> References: <20040821200205.GE26612@elvis.mu.org> <46719.1093120181@critter.freebsd.dk> <20040822064707.GF26612@elvis.mu.org> <20040822071820.GA29902@funkthat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040822071820.GA29902@funkthat.com> User-Agent: Mutt/1.4.2.1i 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 07:28:47 -0000 * John-Mark Gurney [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