On 8/22/2010 12:39 PM, Tapas Mishra wrote:
He he tried what you said. I wont 2 cents :) It did not worked
Ok. So you included linux/syscalls.h instead of sys/syscalls.h and still it cannot find "__NR_exit" symbol. Right? Or it compiled successfully but did not load. --snip-- sys/syscall.h: No such file or directory /home/tapas/LKP/pandora/temp/sample2/sample2.c: In function ‘init_module’: /home/tapas/LKP/pandora/temp/sample2/sample2.c:14: error: ‘__NR_exit’ undeclared (first use in this function) --snip-- From your previous errors, sys/syscall.h is not there. I'll second Mulyadi you have to use linux/syscalls.h or unistd.h or different header file which defines __NR_exit. And this part is only for unresolved symbol.
Following is new program #include<linux/kernel.h> #include<sys/syscalls.h> #include<linux/module.h> extern void *sys_table[]; asmlinkage int(*main_sys_exit)(int); asmlinkage int alt_exit_function(int err_code) { printk("Sys_exit called with err_code=%d\n",err_code); return main_sys_exit(err_code); } int init_module() { main_sys_exit=sys_table[__NR_exit]; sys_table[__NR_exit]=alt_exit_function; } void cleanup_module() { sys_table[__NR_exit]=main_sys_exit; } Following is way I compiled gcc -I /usr/include/ -Wall -DMODULE -D__KERNEL__ -DLINUX -c sample2.c and following are the errors http://pastebin.com/u3mPhfUf Then I compiled it also in following way gcc -I /usr/src/linux-headers-2.6.28-11-generic/include/linux/ -Wall -DMODULE -D__KERNEL__ -DLINUX -c sample2.c and got following errors http://pastebin.com/HzX0DBz1 . So 2 cents :) any how this is the original link where I was trying the code page 48 left hand column https://docs.google.com/fileview?id=0B2A4urYOAf6POTI1OGE1MjctM2UyMC00OGUzLThlNDUtZDBhOWFjY2Y1MDUz&hl=en Any more suggestions.
-- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ