[pso] #include <sys/syscall.h>

Alin Popescu alinpopescu at live.com
Mon Mar 15 11:34:16 EET 2010


Salut!

Incerc sa compilez exemplul de mai jos cu Makefile si cu Kbuild ca in  
laborator, dar nu reusesc.
Folosesc masina virtuala pusa la dispozitie pe site. Problema este ca nu  
poate include <sys/syscall.h>,
desi acesta exitsta in /usr/include.

Am incercat si optiunea cu -I/usr/include, dar degeaba.
Exemplul este luat de pe http://www.linuxjournal.com/article/4378.

#include <linux/kernel.h>
#include <linux/module.h>
#include <sys/syscall.h>

extern void *sys_call_table[];


asmlinkage int (*original_sys_exit)(int);

asmlinkage int our_fake_exit_function(int error_code)
{

         /*print message on console every time we
          *are called*/
         printk("HEY! sys_exit called with error_code=%d\n",error_code);

         /*call the original sys_exit*/
         return original_sys_exit(error_code);
}

/*this function is called when the module is
  *loaded (initialization)*/
int init_module()
{
         /*store reference to the original sys_exit*/
         original_sys_exit=sys_call_table[__NR_exit];

         /*manipulate sys_call_table to call our
          *fake exit function instead
          *of sys_exit*/
         sys_call_table[__NR_exit]=our_fake_exit_function;
}


/*this function is called when the module is
  *unloaded*/
void cleanup_module()
{

         /*make __NR_exit point to the original
          *sys_exit when our module
          *is unloaded*/
         sys_call_table[__NR_exit]=original_sys_exit;

}

/root/intercept.c:3:25: error: sys/syscall.h: No such file or directory
/root/intercept.c: In function 'init_module':
/root/intercept.c:26: error: '__NR_exit' undeclared (first use in this  
function)
/root/intercept.c:26: error: (Each undeclared identifier is reported only  
once
/root/intercept.c:26: error: for each function it appears in.)
/root/intercept.c:32: warning: no return statement in function returning  
non-void
/root/intercept.c: In function 'cleanup_module':
/root/intercept.c:43: error: '__NR_exit' undeclared (first use in this  
function)
make[2]: *** [/root/intercept.o] Error 1
make[1]: *** [_module_/root] Error 2
make[1]: Leaving directory `/usr/src/linux-2.6.31.6'
make: *** [kbuild] Error 2


-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


More information about the pso mailing list