Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Mar 2012 10:01:27 +0800
From:      Yong Fan <yong.fan@exar.com>
To:        John Baldwin <jhb@freebsd.org>, "freebsd-drivers@freebsd.org" <freebsd-drivers@freebsd.org>
Cc:        "drivers@FreeBSD.org" <drivers@freebsd.org>
Subject:   RE: operate file in kernel space
Message-ID:  <88AB8EB2D3F1D249AE07FAFFF17A396F0384CEFCAA@HZU1EXCH02.hq.exar.com>
In-Reply-To: <201203261014.30542.jhb@freebsd.org>
References:  <88AB8EB2D3F1D249AE07FAFFF17A396F0384CEFB5B@HZU1EXCH02.hq.exar.com> <201203261014.30542.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks your warm reply.
I will have a try.

Yongfan
Thanks

-----Original Message-----
From: John Baldwin [mailto:jhb@freebsd.org]
Sent: Monday, March 26, 2012 8:15 AM
To: freebsd-drivers@freebsd.org
Cc: Yong Fan; drivers@FreeBSD.org
Subject: Re: operate file in kernel space

On Sunday, March 25, 2012 10:41:09 pm Yong Fan wrote:
> Hi all,
>
> I want to operate file in kernel space.
> At present, I have found the following kernel routines, which operate fil=
e:
> Kern_open(), kern_close(), kern_readv() and kern_writev().
> Now, I have some doubt about these routines?
> 1 kern_open() doesn't return a file handle or file pointer?
> As we know, filp_open(), which is a Linux kernel routine, returns a file
pointer.
> ZwCreateFile(), which is a Windows kernel routine, returns a file handle.
>
> 2 how can I "seek" a file in kernel space?
> The function of "seek" routine is similar with generic_file_llseek()(Linu=
x)
or ZwSetInformationFile()(windows).

file descriptors in FreeBSD are generally tied to a file descriptor table (=
so
a process).  What you can do is locate a vnode directly (e.g. using namei()=
 to
do a pathname lookup) and then use vn_rdwr() to access the data in the file=
.
vn_rdwr() accepts a uio and you would manage your own "seek" location and t=
hat
gets set in the uio_offset of the uio you pass to vn_rdwr().

--
John Baldwin

The information and any attached documents contained in this message
may be confidential and/or legally privileged.  The message is
intended solely for the addressee(s).  If you are not the intended
recipient, you are hereby notified that any use, dissemination, or
reproduction is strictly prohibited and may be unlawful.  If you are
not the intended recipient, please contact the sender immediately by
return e-mail and destroy all copies of the original message.



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