From owner-freebsd-hackers@FreeBSD.ORG Sun Feb 6 11:33:48 2005 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 1637516A4CE for ; Sun, 6 Feb 2005 11:33:48 +0000 (GMT) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5280F43D46 for ; Sun, 6 Feb 2005 11:33:47 +0000 (GMT) (envelope-from scottl@freebsd.org) Received: from [192.168.254.12] (g4.samsco.home [192.168.254.12]) (authenticated bits=0) by pooker.samsco.org (8.13.1/8.13.1) with ESMTP id j16BWuhO071680; Sun, 6 Feb 2005 04:32:56 -0700 (MST) (envelope-from scottl@freebsd.org) Message-ID: <4206008F.2060100@freebsd.org> Date: Sun, 06 Feb 2005 04:33:35 -0700 From: Scott Long User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7) Gecko/20040514 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ashwin Chandra References: <001301c50c3e$1a8003b0$58e243a4@ash> In-Reply-To: <001301c50c3e$1a8003b0$58e243a4@ash> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=3.8 tests=ALL_TRUSTED autolearn=failed version=3.0.2 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on pooker.samsco.org cc: freebsd-hackers@freebsd.org Subject: Re: Opening and wriiting to file in Kern 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, 06 Feb 2005 11:33:48 -0000 Ashwin Chandra wrote: > Does anyone know the correct calls to open a file, write to it, and close it, IN *kernel* mode. > > Ash There is no common API for doing this, which is pretty much on purpose. First, you need to ask yourself why your task needs it done in the kernel and not in userland. If you mist do this, the general set of steps are: 1. use namei() to convert a pathname to a vnode 2. Use vn_open(), vn_rdwr(), and vn_close() to operate on the vnode. 3. Observe proper vnode locking and reference counting with vref(), vn_lock(), and vput() Scott