[go: up one dir, main page]

0% found this document useful (0 votes)
27 views5 pages

Adding System Call of Finding Factorial of Any Number:: - Wget

The document provides instructions for adding a new system call in Linux to find the factorial of a number. The steps include: 1. Downloading and extracting the Linux kernel source code. 2. Navigating to the syscall entry point directory and adding the new system call to the syscall tables for x86 and x64 architectures. 3. Adding the C function code to implement the system call inside the kernel source code. 4. Recompiling the kernel after making configuration changes and installing necessary packages. 5. The new system call can then be invoked from programs using the number assigned to it in the x64 syscall table.

Uploaded by

Usama Zaki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views5 pages

Adding System Call of Finding Factorial of Any Number:: - Wget

The document provides instructions for adding a new system call in Linux to find the factorial of a number. The steps include: 1. Downloading and extracting the Linux kernel source code. 2. Navigating to the syscall entry point directory and adding the new system call to the syscall tables for x86 and x64 architectures. 3. Adding the C function code to implement the system call inside the kernel source code. 4. Recompiling the kernel after making configuration changes and installing necessary packages. 5. The new system call can then be invoked from programs using the number assigned to it in the x64 syscall table.

Uploaded by

Usama Zaki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

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

You might also like