c - Error compiling Linux kernel module using custom system calls -
c - Error compiling Linux kernel module using custom system calls -
i'll walk through step step
first edit 3 files in linux kernel directory
open linux_directory/arch/x86/syscalls/syscall_64.tbl
, add together custom calls i'm implementing – using appropriate format
declare them here: linux_directory/include/linux/syscalls.h
– using appropriate format:
open linux_directory/makefile
, add together directory i'm storing new scheme calls core-y
line:
core-y := usr/ my_system_call_directory/
here's i'm having issues. within linux_directory/my_system_call_directory
add together c file custom scheme phone call definitions , corresponding makefile
. leave definitions empty because within c file kernel module declare extern function (my custom scheme call) , define separate function set extern function:
extern long (*start_shuttle)(void); long my_start_shuttle(void) { // stuff here } int init_module(void) { // stuff here start_shuttle = my_start_shuttle; // more stuff }
after recompiling kernel seek make
kernel module , no definition start_shuttle
error.
is because left definition start_shuttle
blank in my_system_call_directory
? should match my_start_shuttle
defined in kernel module or there special i'm supposed add? i'm asking dumb questions in advance because takes long machine recompile linux , i'm not sure change. thanks
figured out. slow me, have utilize wrapper , stub.
so example, in my_system_call_directory
, in c
file new scheme phone call definitions, need this:
#include <linux/linkage.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/export.h> // initialize stub function null long (*start_shuttle)(void) = null; export_symbol(start_shuttle); // wrapper asmlinkage long sys_start_shuttle(void) { if (start_shuttle) homecoming start_shuttle(); else homecoming -enosys; }
c linux linux-kernel system-calls kernel-module
Comments
Post a Comment