Adding system call of finding factorial of any number:
First of all we will download kernel for our linux by entering this line
-> wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.17.4.tar.xz
Next we will Extract files by typing
-> sudo tar -xf linux-4.17.4.tar.xz
After Extraction we will goto directory where syscall entry point name can be
written by typing
-> cd linux/arch/x86/entry/syscalls
After that we add our system call to directory by typing
-> gedit syscall_32.tbl
First we will add into x86 version
After that we will add into x64 directory by typing
-> gedit syscall_64.tbl
We will see a text file and add our sys call
Note: remember the number of your call in x64 directory, because we will need
it later
After that we will go back to linux folder by typing “cd .. “ and enter the kernel
directory where we will add our function by typing
-> ls kernel
-> gedit sys.c
This we open a text files and in the end we will add our function
After that go back to linux folder and type
-> sudo apt-get update (to get updates)
-> sudo apt-get upgrade (to install updates)
Then type
-> sudo make defconfig (to set to default configuration)
-> sudo apt-get install bison (to download bison if above codes gives error)
In the End type
-> sudo make
To compile the system the call we have added and other changes we have made
it will take 2-3 hours depending on your system
When compilation is done in any program or bash file to calculate the factorial
by using the number I said to remember from x64 directory and passing a
number to get the factorial