I need to replace a standard system call (e.g. SYS_mkdir) with my own implementation.
As I read in some sources, including this question on Stackoverflow, the sys_call_table is not exported symbol since kernel version 2.6.
I tried the following code:
#include <linux/module.h> #include <linux/kernel.h> #include <linux/unistd.h> #include <asm/syscall.h> int (*orig_mkdir)(const char *path); .... int init_module(void) { orig_mkdir=sys_call_table[__NR_mkdir]; sys_call_table[__NR_mkdir]=own_mkdir; printk("sys_mkdir replaced\n"); return(0); } .... Unfortunately I receive compiler error:
error: assignment of read-only location ‘sys_call_table[83]’ How can I replace the system call?
EDIT: Is there any solution without kernel patching?
char*then assign