Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 06 Feb 2005 04:33:35 -0700
From:      Scott Long <scottl@freebsd.org>
To:        Ashwin Chandra <ashcs@ucla.edu>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Opening and wriiting to file in Kern
Message-ID:  <4206008F.2060100@freebsd.org>
In-Reply-To: <001301c50c3e$1a8003b0$58e243a4@ash>
References:  <001301c50c3e$1a8003b0$58e243a4@ash>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4206008F.2060100>