Hi,
How could I open a file in kernel modules?I have found this solution
for a long time. I am a beginner,and holp same body told me just YES or
NO to my request.
First glance at that page suggested to me you might want to include linux/errno.h but maybe there's something else you need...
Thanks for answering why you were doing it - I was curious because I wouldn't have thought it was necessary often. But just for interest seems like a good reason ;-)
you have found?
see e.g. /usr/src/linux-2.6.8.1/sound/sound_firmware.c if you search another solution.
errno unresolved...
Thank you a lot. But now,I have new problem in load
modules's link time.
#gcc -I/usr/src/linux/include -D__KERNEL__ -DMODULE\
-D__KERNEL_SYSCALLS__ hello.c -c -o hello.o
#insmod ./hello.o
./hello.o: unresolved symbol errno
It is a quite obvious messages that the variable 'errno' is
unresolved.
Can anybody told me how to...
BTW,To open a file in kernel module mode just for my interest.
#define MODULE #define __KERNEL__ #define __KERNEL_SYSCALLS__ #include <linux/module.h> #include <linux/version.h> #include <linux/kernel.h> #include <linux/fs.h> #include <linux/mm.h> #include <linux/slab.h> #include <linux/unistd.h> int init_module(void){ int fn=0; printk("<1>Hello, world\n"); fn = open("/etc/inittab", 0, 0); if (fn == -1) { printk(KERN_INFO "Unable to load '%s'.\n", fn); return 0; } printk(KERN_INFO "LOAD File success!"); close(fn); return 0; } void cleanup_module(void) { printk("<1>Goodbye cruel world\n"); }Include errno.h?
Ah, so you are doing it by enabling system calls in kernel mode...
Have a look at this:
http://www.csee.umbc.edu/courses/undergraduate/CMSC421/fall02/burt/proje...
First glance at that page suggested to me you might want to include linux/errno.h but maybe there's something else you need...
Thanks for answering why you were doing it - I was curious because I wouldn't have thought it was necessary often. But just for interest seems like a good reason ;-)
Mark
Curious as to why?
Hi,
I'm just curious about why you want to do this...
Mark