I have added a hello world system call to Linux kernel 3.16, then I compile and ran it. I called my system call by syscall
function but it did not print any thing and output of syscall
function was not -1.
This is my system call code:
#include <linux/kernel.h>
asmlinkage long sys_hello(void){
printk("hello world\n");
return 0;
}
and this my c program code to call my system call:
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#include <string.h>
#include <errno.h>
int main(void){
printf("function\n");
if(syscall(317)==-1){
printf("no\n");
}
else{
printf("yes\n");
}
return 0;
}
The output of c program is:
function
yes
How can I find my system call is added to kernel correctly?