Calling the open() or fopen() function from kernel module?

Hi everyone,
Ever since I discovered how to go about [thread=16446]creating device nodes,[/thread] I have come a long way with my device driver. Now, I have a few more questions.

My device driver needs to access some character tables (currently) stored in a file. For the sake of this example, let us say the file is stored at this location: /usr/local/share/chartables.chr.

But there seems to be no way to open that file from within my device driver. If I include the files listed in the open() page, I get an error that I implicitly declared open in the function where I used open. So how may I open the file?

If I cannot use open() or fopen() in my kernel module, are there other ways to get the table across to the driver? I was thinking of using ioctl(), but I don't know if that would be a good alternative?

I look forward to any replies.

All the best,

Peter.
 
In most cases, you want to create a simple userland program that will open the file, load the data and then pass required information to your driver, using either sysctl or via device file. Opening the files by the kernel is sometimes done (e.g. kernel linker, alq(9), ktrace), but it should be used only when neccessary.
 
Back
Top