From owner-freebsd-fs@FreeBSD.ORG Mon Sep 5 06:46:13 2005 Return-Path: X-Original-To: freebsd-fs@freebsd.org Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9B8D516A41F for ; Mon, 5 Sep 2005 06:46:13 +0000 (GMT) (envelope-from phk@phk.freebsd.dk) Received: from haven.freebsd.dk (haven.freebsd.dk [130.225.244.222]) by mx1.FreeBSD.org (Postfix) with ESMTP id 46A0043D45 for ; Mon, 5 Sep 2005 06:46:13 +0000 (GMT) (envelope-from phk@phk.freebsd.dk) Received: from phk.freebsd.dk (unknown [192.168.48.2]) by haven.freebsd.dk (Postfix) with ESMTP id 1EB70BC66; Mon, 5 Sep 2005 06:46:11 +0000 (UTC) To: Jeb Campbell From: "Poul-Henning Kamp" In-Reply-To: Your message of "Mon, 05 Sep 2005 01:44:33 CDT." <431BE951.4070101@c4solutions.net> Date: Mon, 05 Sep 2005 08:46:11 +0200 Message-ID: <51974.1125902771@phk.freebsd.dk> Sender: phk@phk.freebsd.dk Cc: freebsd-fs@freebsd.org Subject: Re: kernel newb -- read/write to a local file from in kernel X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Sep 2005 06:46:13 -0000 In message <431BE951.4070101@c4solutions.net>, Jeb Campbell writes: >I'm trying to learn about kernel programming and as a weekend project >I've started writing a Netgraph to file/dev module. > >The Netgraph stuff was pretty easy, but I'm at a loss on the file access >part as I've never done anything in-kernel. > >After much searching (most of it not knowing what I was looking for), I >think that I'm looking for something like "Vnode interface mechanics, >write to a local file" as taught in Mr. McKusick's "FreeBSD Kernel >Internals: An Intensive Code Walkthrough". > >I've looked at nullfs/null_vnops.c, but I think that is more of a >pass-through example. Does anyone know of any online code that shows >the process of opening a file/device for read/write? In the spirit of education I won't tell you "how to" but only "where to look": ktrace, coredumps and accounting all writes to files from the kernel. -- 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.