How to access a user space file from kernel space in FreeBSD.

John-Mark Gurney jmg at funkthat.com
Fri Mar 20 19:39:47 UTC 2020


Arpan Palit wrote this message on Fri, Mar 20, 2020 at 20:10 +0530:
> Hi all,
> 
> I am working on (kernel)driver ioctl implementation for file read/write,
> where I need to know what are API's which can expose to read,write and
> close user space file from kernel space. In general I need to know the
> answer for the below questions.
> 
> i).   How to open a user space file from driver(kernel space) ?
> ii).  How to create a new user space file from driver(kernel space) ?
> iii). How to get file parameters like size of the file ?
> iv). How to read/write the files from the driver(kernel space) ?

The core dumping routines do something similar, so you can look at
that code:
https://svnweb.freebsd.org/base/head/sys/kern/kern_sig.c?annotate=358856

Are you trying to open/write a file on behalf of a process? or just need
to access the file system from your driver?

If you're just needing this to load firmware for a device, you should
look at the firmware(9) infrastructure that already exists:
https://www.freebsd.org/cgi/man.cgi?query=firmware&manpath=FreeBSD+12.1-RELEASE+and+Ports

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."


More information about the freebsd-drivers mailing list