From owner-freebsd-current@FreeBSD.ORG Sun Nov 9 00:34:09 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B17A1065672 for ; Sun, 9 Nov 2008 00:34:09 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.freebsd.org (Postfix) with ESMTP id 0E5728FC08 for ; Sun, 9 Nov 2008 00:34:08 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (unknown [192.168.61.3]) by phk.freebsd.dk (Postfix) with ESMTP id 83F90170EA; Sun, 9 Nov 2008 00:34:07 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.14.3/8.14.3) with ESMTP id mA90Y6QM044714; Sun, 9 Nov 2008 00:34:07 GMT (envelope-from phk@critter.freebsd.dk) To: "David Christensen" From: "Poul-Henning Kamp" In-Reply-To: Your message of "Sat, 08 Nov 2008 16:28:11 PST." <5D267A3F22FD854F8F48B3D2B52381933936483700@IRVEXCHCCR01.corp.ad.broadcom.com> Date: Sun, 09 Nov 2008 00:34:06 +0000 Message-ID: <44713.1226190846@critter.freebsd.dk> Sender: phk@critter.freebsd.dk Cc: "freebsd-current@freebsd.org" Subject: Re: Dumping Large Binary Buffer Through Sysctl X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Nov 2008 00:34:09 -0000 In message <5D267A3F22FD854F8F48B3D2B52381933936483700@IRVEXCHCCR01.corp.ad.bro adcom.com>, "David Christensen" writes: >> >I'm looking for a way to dump a large binary debug buffer=3D20 >> >in a driver to a file. I've currently implemented this >> >with SYSCTL_ADD_OPAQUE() and it works fine but running the >> >"sysctl -a" command causes this buffer to be dumped which >> >is something of a pain. Is there a better way to do this? >>=20 >> Much better idea: memory map it, that way your driver does >> not even discover that userland peeks over its shoulder. > >I found the CTLFLAG_SKIP attribute which hides the sysctl and=20 >makes things a lot better. How do I "memory map" the buffer? >Can you give me a function name or point to an example where=20 >this is done so I can look into it further? You implemente a cdevsw->mmap() function that tells the kernel where it is, then in userland, you open the device and call mmap(2). See sys/kern/subr_devstat.c for an example. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.