# How to open a file with KLD



## victormenegusso (Aug 24, 2011)

Hello, everybody, 
I would like to know how to open a file using kld, and be able to write the same. Because I can not use the system call

I create a Character Device, where have information, my KLD read a Character Device and write the information on file .txt for example.

Thanks:stud


----------



## lockfile (Aug 26, 2011)

Check out ftp.FreeBSD.org, in the doc nodes there are files there in a subnode I think will get you started. It has a tutorial and a little driver skeleton. "Driver" or similar....


----------



## victormenegusso (Aug 29, 2011)

Hi lockfile, i find a folder 'drivers', but just have a .sh, not .c

thanks


----------



## victormenegusso (Sep 7, 2011)

I try to use open() from fcntl.h but it does not work.


----------



## victormenegusso (Sep 9, 2011)

I find:


```
int kern_open(struct thread *td, char *path, enum uio_seg pathseg,int flags, int mode);
int kern_readv(struct thread *td, int fd, struct uio *auio);
int kern_writev(struct thread *td, int fd, struct uio *auio);
```
Link
http://fxr.watson.org/fxr/source/sys/syscallsubr.h?v=FREEBSD82;


----------

