Undefined reference error while using custom system call


Staff member
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.

 #include &lt;linux/kernel.h&gt;

 asmlinkage long sys_fact(int a)
    int n;
    int c;
    for(n = 1;n &lt;= 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.

#include &lt;stdio.h&gt;
#include &lt;linux/kernel.h&gt;
#include &lt;sys/syscall.h&gt;
#include &lt;unistd.h&gt;

int main()
  int n;
  printf("Enter a number to calculate it's factorial\n");
  scanf("%d", &amp;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.

 make &amp;&amp; make modules_install &amp;&amp; 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).

 320    common  kexec_file_load     sys_kexec_file_load
 321    common  bpf                 sys_bpf
 322    64      execveat            stub_execveat
 323    common  fact                sys_fact