I'm trying to import new system call in the kernel 3.19. I've followed the tutorial given <a href="https://tssurya.wordpress.com/2014/08/19/adding-a-hello-world-system-call-to-linux-kernel-3-16-0/" rel="nofollow">here</a>!
This is my simple code to implement factorial calculation via system call.
I'm getting Undefined reference to sys_fact error when I try to compile the C code.
The program in which I'm using this system call is as follows.
My system is 64 bit ubuntu 14.04 and I've followed above mentioned tutorial according to my system.
Also, I've combined following commands while installing kernel, and I think this is the reason it did not gave error while installation of kernel.
Kernel installation took 2-3 hours, and I'm frustrated now.
Please help!!
Edits I made to syscall_64.tbl(final four entries).
This is my simple code to implement factorial calculation via system call.
Code:
#include <linux/kernel.h>
asmlinkage long sys_fact(int a)
{
int n;
int c;
for(n = 1;n <= a;n++)
c = c * n;
printk(KERN_INFO "Factorial calculated!\n");
return((long) c);
}
I'm getting Undefined reference to sys_fact error when I try to compile the C code.
The program in which I'm using this system call is as follows.
Code:
#include <stdio.h>
#include <linux/kernel.h>
#include <sys/syscall.h>
#include <unistd.h>
int main()
{
int n;
printf("Enter a number to calculate it's factorial\n");
scanf("%d", &n);
printf("Factorial of %d = %d\n", n, sys_fact(9));
return 0;
}
My system is 64 bit ubuntu 14.04 and I've followed above mentioned tutorial according to my system.
Also, I've combined following commands while installing kernel, and I think this is the reason it did not gave error while installation of kernel.
Code:
make && make modules_install && make install
Kernel installation took 2-3 hours, and I'm frustrated now.
Please help!!
Edits I made to syscall_64.tbl(final four entries).
Code:
320 common kexec_file_load sys_kexec_file_load
321 common bpf sys_bpf
322 64 execveat stub_execveat
323 common fact sys_fact