Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Jan 1998 17:57:13 +1030
From:      Greg Lehey <grog@lemis.com>
To:        dyson@FreeBSD.ORG
Cc:        Mike Smith <mike@smith.net.au>, doconnor@cain.gsoft.com.au, joelh@gnu.org, dag-erli@ifi.uio.no, hackers@FreeBSD.ORG
Subject:   Re: File I/O in kernel land (was: Re: 2nd warning: 2.2.6 BETA begins in 10 days!)
Message-ID:  <19980127175713.58429@lemis.com>
In-Reply-To: <199801270720.CAA00625@dyson.iquest.net>; from John S. Dyson on Tue, Jan 27, 1998 at 02:20:17AM -0500
References:  <199801270648.RAA01893@word.smith.net.au> <199801270720.CAA00625@dyson.iquest.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Jan 27, 1998 at 02:20:17AM -0500, John S. Dyson wrote:
> Mike Smith said:
>>
>> As Julian said, see how the code in the kernel handles reading executable
>> images.  It's moderately painful, but definitely the Right Way to do it.
>
> You should refer to the code in -current, because the older stuff had some
> problems.  Also, you can do vn_open, vn_read, vn_write,
> vn_close if you want to.  There are the options to do I/O to/from system
> space.  The only reason (that I know of) that the exec code doesn't use
> the vn_* calls is for efficiency reasons, so lots of stuff is bypassed
> and done slightly VMish as opposed to file I/Oish.
>
> I don't have lots of time to tutor, but what you should be able to do is:
>
> vn_open() to get the vnode.  It will return with a reference to the
> vnode.  That is approx equiv to an open file.  (Take a look at namei
> to figure out how to specify a filename.)
>
> vn_read/vn_write will properly read and write the file, also handling
> file datastructure locking.
>
> vn_close() to loose the file reference.

You also need to look at the uio and iov structures.  Amongst other
things, it describes macros which help make this interface bearable.
There's some stuff on this in part 9 of the manual.  I'm also working
on a document (along with trying to write the *(&*& stuff.  I'd supply
my files, but they deal with block device I/O, which isn't the general
case).

Now who was going to write buf(9)?

> I know that it seems to be complicated, but not really worse than doing
> I/O in user-land on VMS :-).

Or in WNT?

Greg



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