Results 1 to 6 of 6
Hi,
I am writing a simple kernel module which is to open() a file, read() some information from it, and close() it. As far as I know, all three of ...
- 10-06-2008 #1Just Joined!
- Join Date
- Oct 2008
- Posts
- 3
kernel module development problem
Hi,
I am writing a simple kernel module which is to open() a file, read() some information from it, and close() it. As far as I know, all three of these functions are system calls and are provided by the kernel. Compiler warns me:
"sdlm.c:10: warning: implicit declaration of function `open'
sdlm.c:14: warning: implicit declaration of function `read'
sdlm.c:16: warning: implicit declaration of function `close'",
but builds the .ko module.
When sdlm.ko is inserted, an error occurs:
sdlm: Unknown symbol read
sdlm: Unknown symbol open
sdlm: Unknown symbol close
Please help me, what's the problem?
here is my code:
Code:#include <linux/module.h> #include <linux/kernel.h> #include <linux/unistd.h> #include <linux/fcntl.h> int init_module() { int fd; printk(KERN_INFO "SDL start"); fd = open("/var/license.dat", O_RDWR, S_IRWXU); if (fd != -1) { char banner[200] = ""; read(fd, banner, 199); printk(KERN_NOTICE "License data: `%s`", banner); close(fd); } else printk(KERN_NOTICE "License file not found"); return 0; } void cleanup_module() { printk(KERN_INFO "SDL exit"); }
- 10-06-2008 #2
You can't use C library functions in the kernel.
Also this should be posted int the kernel section of this forum.
- 10-06-2008 #3Just Joined!
- Join Date
- Oct 2008
- Posts
- 3
but those functions are not library functions, they are system calls and they are defined in <linux/unistd.h> file in kernel sources

OK then, one more question, how can I manage with files from kernel space?
- 10-06-2008 #4
I posted a very similar question in this forum under the kernel section. The posting is called "Writing to a file from a kernel module???". You should check it out...Hope this helps...Gerard4143
- 10-07-2008 #5Just Joined!
- Join Date
- Oct 2008
- Posts
- 3
thank you Gerard, but I still believe this is possible...
- 10-07-2008 #6
Of course its possible...but is it worth the effort to hack this functionality into the kernel. With that said, if you do find a solution post it I'd like to see it...Geard4143


Reply With Quote