From owner-freebsd-hackers@FreeBSD.ORG Sat May 5 19:50:36 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CAF3D16A401 for ; Sat, 5 May 2007 19:50:36 +0000 (UTC) (envelope-from dds@aueb.gr) Received: from mx-out.forthnet.gr (mx-out.forthnet.gr [193.92.150.103]) by mx1.freebsd.org (Postfix) with ESMTP id 4AA3113C458 for ; Sat, 5 May 2007 19:50:35 +0000 (UTC) (envelope-from dds@aueb.gr) Received: from mx-av-04.forthnet.gr (mx-av.forthnet.gr [193.92.150.27]) by mx-out-02.forthnet.gr (8.14.0/8.14.0) with ESMTP id l45JTJb1008730; Sat, 5 May 2007 22:29:19 +0300 Received: from MX-IN-03.forthnet.gr (mx-in-03.forthnet.gr [193.92.150.26]) by mx-av-04.forthnet.gr (8.14.1/8.14.1) with ESMTP id l45JTJTF020513; Sat, 5 May 2007 22:29:19 +0300 Received: from [192.168.136.18] (ppp124-213.adsl.forthnet.gr [193.92.231.213]) by MX-IN-03.forthnet.gr (8.14.1/8.14.1) with ESMTP id l45JTCgU003885; Sat, 5 May 2007 22:29:12 +0300 Authentication-Results: MX-IN-03.forthnet.gr from=dds@aueb.gr; sender-id=neutral; spf=neutral In-Reply-To: <463CCE1E.1080906@geri.cc.fer.hr> References: <463CCE1E.1080906@geri.cc.fer.hr> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Diomidis Spinellis Date: Sat, 5 May 2007 22:29:08 +0300 To: Sonja Milicic X-Mailer: Apple Mail (2.752.2) Cc: freebsd-hackers@freebsd.org Subject: Re: Writing to a file X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2007 19:50:36 -0000 On May 5, 2007, at 9:34 PM, Sonja Milicic wrote: > I'm working on an IO logging utility for FreeBSD as my GSoC > project, and > I have some questions about writing a kernel functions that would open > an existing or create a new file (with the file name as a parameter, > returns a vnode * for the file) and write data to that file (with > pointer to data as parameter). I've found some functions in existing > code that do similar things and might help me understand how to > solve my > problem, but as there isn't much documentation out there I still don't > understand a lot of things. So, could anyone please give me a detailed > explanation of how to open a file in kernel and write to it - best > data > types to use, functions, what to look out for, maybe a link to > tutorial > or manual that deals with this (if such a thing exists), etc.? A good strategy for dealing with such questions is to look for code that does a task similar to the one you want to implement. Two kernel subsystems that come to my mind is the kernel logging facility, which writes data to a user space process via a socket, and the process accounting facility, which writes data to an already opened file. There are reasons (performance, flexibility) why these two facilities have been designed in this way, and it would be a good idea to see whether some of their design decisions are also applicable to your problem. Diomidis Spinellis - http://www.spinellis.gr