Date: Fri, 20 Mar 2020 19:52:22 +0100 From: Polytropon <freebsd@edvax.de> To: Arpan Palit <babupalit@gmail.com> Cc: freebsd-hackers@freebsd.org, freebsd-questions@freebsd.org, freebsd-drivers@freebsd.org Subject: Re: How to access a user space file from kernel space in FreeBSD. Message-ID: <20200320195222.4a5c5f3a.freebsd@edvax.de> In-Reply-To: <CAF3txfi1mNcmQEFDfOx01AA2aWza1Fteb7fisC%2BtWVQccoV77Q@mail.gmail.com> References: <CAF3txfi1mNcmQEFDfOx01AA2aWza1Fteb7fisC%2BtWVQccoV77Q@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 20 Mar 2020 20:10:02 +0530, Arpan Palit wrote: > 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) ? With the open() system call. See "man 2 open" for details. > ii). How to create a new user space file from driver(kernel space) ? With the creat() system call. See "man 2 creat" for details. > iii). How to get file parameters like size of the file ? With the stat() system call. See "man 2 stat" for details. > iv). How to read/write the files from the driver(kernel space) ? With the read() and write() system call. See "man 2 read" and "man 2 write" for details. If you have access to the standard C library (libc) from the driver, you can also use fopen(), fstat(), fread(), fwrite(), fgets(), fputs(), fscanf(), fprintf() et al. for file access. See the corresponding manual pages in section 3. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200320195222.4a5c5f3a.freebsd>