SlideShare a Scribd company logo
How To Add System Call In 
UBUNTU Operating System 
Presented 
by: 
Pratik 
Tambekar 
Guided 
by: 
Mr. T.R 
Ravi
CONTENTS 
WHY UBUNTU? 
INTRODUCTION 
WHAT IS KERNEL? 
WHAT IS SYSTEM CALL? 
HOW TO ADD SYSTEM CALL 
HOW TO REPLACES NEW KERNEL 
FILE WITH OLD KERNEL FILE 
REFRENCES
WHY UBUNTU? 
Free Ubuntu is and will always be free in the 
future. Ubuntu is developed by people all over the 
world embracing the principle of Free libre open-source 
software (FLOSS). This enables new 
software and updates to be available free of cost 
since they are written by volunteers and also the 
employees of Canonical, the parent company of 
Ubuntu. 
No Viruses While using Ubuntu, you do not need 
to worry about installing any anti-virus programs 
since Ubuntu is completely free of viruses.
CONT…. 
Community Support When you need help using 
your system, the community is available 
everywhere around you to support you at all times. 
All this are done voluntarily by people passionate 
about Ubuntu. 
Up to date software Ubuntu will always be up to 
date with updates released regularly to ensure that 
your system is secure and bug free. These regular 
updates will be always be available for free. 
Beautiful, Polished, Stable These are the goals of 
every Ubuntu release. Your Ubuntu is designed 
with the help of the community and experts after 
extensive discussion. Ubuntu is regularly user 
tested to ensure that it is easy and simple to use 
while preserving its elegance and polish.
INTRODUCTION 
 Ubuntu was founded by Mark Shuttleworth, a South 
African entrepreneur coming up with their first release 
Ubuntu 4.10 codenamed Warty Warthog in October 
2004. 
 Ubuntu is an African concept meaning “humanity 
toward others” 
 Sponsored by Canonical Ltd. Owned by South African 
billionaire Mark Shuttleworth. 
 Ubuntu is a Linux-based Operating System that is open 
sourced (free) 
 Pronounced (oo-BOON-too) 
 Strong focus on usability and ease of installation
Ubuntu Releases
Table of versions
Advantages and Disadvantages 
over windows. 
- Advantages: 
1) Not vulnerable to Windows malware/viruses 
2) Free 
3) Tends to run more efficiently than Windows 
4) Not subject to Microsoft's cripple ware. 
- Disadvantages: 
1) Won't run most Windows applications (especially 
games) 
2) Requires a higher than average nerd factor (not as 
user friendly) 
3) Doesn't work with all hardware (but neither does 
Windows!) 
4) Can be somewhat buggy
What is Kernel? 
The central module of an operating system. It is 
the part of the operating system that loads first, 
and it remains in main memory. Because it stays 
in memory, it is important for the kernel to be as 
small as possible while still providing all the 
essential services required by other parts of the 
operating system and applications. 
It acts as an interface between the user 
applications and the hardware. 
Typically, the kernel is responsible for memory 
management, process management, task 
management, I/O communication and disk 
management.
CONT.... 
Types of Kernels: 
Kernels may be classified mainly in two 
categories 
1) Monolithic 
2) Micro Kernel 
Linux follows the monolithic modular 
approach
CONT.... 
Monolithic kernel: 
In this type of kernel 
architecture, all the basic system services 
like process and memory management, 
interrupt handling etc were packaged into a 
single module in kernel space. This type of 
architecture led to some serious drawbacks 
like 
1) Size of kernel, which was huge. 
2) Poor maintainability, which means bug 
fixing or addition of new features resulted in 
recompilation of the whole kernel which could 
consume hours
CONT....
What is System Call? 
System calls are low level functions the 
operating system makes available to 
applications via a defined API (Application 
Programming Interface) 
System calls represent the interface the kernel 
presents to user applications. 
In Linux all low-level I/O is done by reading and 
writing file handles, regardless of what 
particular peripheral device is being 
accessed—a tape, a socket, even your 
terminal, they are all files. 
Low level I/O is performed by making system 
calls.
Anatomy of a System Call 
A System Call is an explicit request to the kernel 
made via a software interrupt. 
The interrupt call ‘0x80’ call to a system call 
handler (sometimes called the “call gate”). 
The system call handler in turns calls the system 
call interrupt service routine (ISR). 
To perform Linux system calls we have to do 
following: 
- Put the system call number in EAX register. 
- Set up the arguments to the system call in 
EBX,ECX, etc. 
- call the relevant interrupt (for DOS, 21h; for 
Linux, 80h). 
- The result is usually returned in EAX.
CONT…. 
There are six registers that are used for the 
arguments that the system call takes. The first 
argument goes in EBX, the second in ECX, then 
EDX, ESI, EDI, and finally EBP. If more then 6 
arguments needed (not likely), the EBX register 
must contain the memory location where the list 
of arguments is stored. 
basic system calls: 
◦ sys_open 
◦ sys_close 
◦ sys_read 
◦ sys_write 
◦ sys_Fork 
◦ sys_exit
CONT…. 
Sys_open - open a file 
system call number (in EAX): 5 
arguments: 
◦ EBX: The pathname of the file to open/create 
◦ ECX: set file access bits (can be OR’d togather): 
O_RDONLY open for reading only 
O_WRONLY open for writing only 
O_RDRW open for both reading and writing 
O_APPEND open for appending to the end of 
file 
O_TRUNC truncate to 0 length if file exists 
O_CREAT create the file if it doesn’t exist 
◦ EDX: set file permissions. 
Returns in EAX: file descriptor.
Error handling 
System calls set a global integer called 
errno on error. 
The constants that errno may be set to are 
(partial list): 
◦ EPERM operation not permitted. 
◦ ENOENT no such file or directory (not 
there). 
◦ EIO I/O error – EEXIST file already exists. 
◦ ENODEV no such device exists. 
◦ EINVAL invalid argument passed.
CONT…
Example
How to add a System Call 
Ubuntu 10.10 and using kernel version 
2.6.37.3 If you are using any other kernel 
version just replace 2.6.37.3 with your 
version. 
I am also assuming you have extracted the 
source code. 
Now let the new system call’s name be 
“add2”.
CONT…. 
1. Now you will find a “arch” folder in 
the source code folder. Open the file 
arch/x86/kernel/syscall_table_32.S in 
a text editor. Go to the end of the 
document and add this line 
.long sys_add2 /* my code */
CONT…. 
2. Now open 
arch/x86/include/asm/unistd_32.h 
and find out 
#define __NR_prlimit64 340 
 Add a new line after this: 
#define __NR_add2 341 
 Don’t just close yet. After 3-4 lines, 
you will find a line like
CONT…. 
#define NR_syscalls 341 
 Change it to 
#define NR_syscalls 342. 
3. Now edit 
arch/x86/include/asm/unistd_64.h 
 Find out: 
#define __NR_prlimit64 302 
__SYSCALL(__NR_prlimit64,sys_prli 
mit64)
CONT…. 
 Now after these two lines, add these 
two lines 
#define __NR_add2 303 
__SYSCALL(__NR_add2, sys_add2) 
4. Now again in the source folder you 
will find a folder named include. 
Open the file include/linux/syscalls.h 
and go to the end of the file. Before 
the line
CONT… 
#endif 
write this prototype definition line: 
asmlinkage long sys_add2(int i,int j); 
5. Now find out the kernel folder in the 
source directory. Create a new empty 
file in the kernel folder with the name 
“mysysteamcalls.c” . Add the following 
codes in the file:
CONT… 
#include<linux/linkage.h> 
asmlinkage long sys_add2(int i,int j) 
{ 
return i+j; 
} 
6. Now open the Makefile in this 
folder(/kernel/Makefile) and find out 
obj-y += groups.o
CONT… 
 Add a new line before this line : 
obj-y += mysysteamcalls.o 
 Ok, this is the edit you need to do to add 
a new system call. Now compile or 
recompile the source code and enjoy 
your new system call.
sample code to call the system 
call : 
#include <stdio.h> 
#include <linux/unistd.h> 
#include <sys/syscall.h> 
//comment the following line if you are using 
64 bit, this number is the same used 
previously 
#define sys_add2 341 
//comment the following line if you are using 
32 bit, this number is the same used 
previously
CONT… 
int main(void) 
{ 
int a,b,c; 
printf("Adding Two Numbers in Kernel Spacen"); 
printf("Input a: "); 
scanf("%d",&a); 
printf("Input b: "); 
scanf("%d", &b); 
c = syscall(sys_add2, a, b); 
printf("System call returned %dn", c); 
return 0; 
}
How to replaces new kernel file 
with old Kernel File: 
download the kernel from kernel.org 
http://www.kernel.org/pub/linux/kernel/ 
v3.0/linux-3.X.tar.bz2 
Extract the tarball to /usr/src/linux-3.X/ 
tar -xvf linux-3.X.tar.bz2 -C 
/usr/src/linux-3.X/ 
Change the directory to /usr/src/linux- 
3.x 
$ cd /usr/src/linux-3.x
CONT… 
Configure 
Lets configure our new Linux Kernel with the 
configuration of old kernel (which is already 
installed in our machine) 
$ sudo make oldconfig 
The new kernel is installed, however we need to 
say to the Ubuntu to use this new one. Just type in 
the shell: 
sudo update-initramfs -k 2.6.38.3 -u 
sudo update-grub 
Restart your computer. After loaded, type in the 
shell: 
uname -a
.deb Files 
linux-headers-2.6.34- 
02063415_2.6.34- 
02063415.201402101835_all.deb 
linux-headers-2.6.34-02063415- 
server_2.6.34- 
02063415.201402101835_amd64.deb 
linux-image-2.6.34-02063415- 
generic_2.6.34- 
02063415.201402101835_amd64.deb 
sudo dpkg -i linux*2.6.34-7.37*.deb 
sudo reboot
Refrences: 
http://www.kernel.org 
http://www.Ubuntu.com 
kernel.ubuntu.com/~kernel-ppa/ 
mainline/ 
https://wiki.ubuntu.com/Kernel/Mainlin 
eBuilds 
ubuntuforums.org 
www.ubuntu.com/support/community 
http://www.linuxquestions.org
Thank you

More Related Content

What's hot

101 1.3 runlevels , shutdown, and reboot
101 1.3 runlevels , shutdown, and reboot101 1.3 runlevels , shutdown, and reboot
101 1.3 runlevels , shutdown, and reboot
Acácio Oliveira
 
Chapter 1 Introduction to Operating System Concepts
Chapter 1 Introduction to Operating System ConceptsChapter 1 Introduction to Operating System Concepts
Chapter 1 Introduction to Operating System Concepts
MeenalJabde
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System Administration
Sreenatha Reddy K R
 
Chapter 2 Introduction to Unix Concepts
Chapter 2 Introduction to Unix ConceptsChapter 2 Introduction to Unix Concepts
Chapter 2 Introduction to Unix Concepts
MeenalJabde
 
Linux System Monitoring basic commands
Linux System Monitoring basic commandsLinux System Monitoring basic commands
Linux System Monitoring basic commands
Mohammad Rafiee
 
Chapter 3 Using Unix Commands
Chapter 3 Using Unix CommandsChapter 3 Using Unix Commands
Chapter 3 Using Unix Commands
MeenalJabde
 
Experimentos lab
Experimentos labExperimentos lab
Experimentos lab
George Madson Dias Santos
 
Implementation of Pipe in Linux
Implementation of Pipe in LinuxImplementation of Pipe in Linux
Implementation of Pipe in Linux
Tushar B Kute
 
Process management in linux
Process management in linuxProcess management in linux
Process management in linux
Mazenetsolution
 
Basics of Linux Commands, Git and Github
Basics of Linux Commands, Git and GithubBasics of Linux Commands, Git and Github
Basics of Linux Commands, Git and Github
Devang Garach
 
Linux startup
Linux startupLinux startup
Linux startup
Amin Hashemi
 
System Calls
System CallsSystem Calls
System Calls
Anil Kumar Pugalia
 
Linux : Booting and runlevels
Linux : Booting and runlevelsLinux : Booting and runlevels
Linux : Booting and runlevels
John Ombagi
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
PrashantTechment
 
Process and Threads in Linux - PPT
Process and Threads in Linux - PPTProcess and Threads in Linux - PPT
Process and Threads in Linux - PPT
QUONTRASOLUTIONS
 
Linux for beginners
Linux for beginnersLinux for beginners
Linux for beginners
Nitesh Nayal
 
System Calls
System CallsSystem Calls
System Calls
Anil Kumar Pugalia
 
Os notes
Os notesOs notes
Os notes
LakshmiSarvani6
 
Os lab final
Os lab finalOs lab final
Os lab final
LakshmiSarvani6
 
Completeosnotes
CompleteosnotesCompleteosnotes
Completeosnotes
LakshmiSarvani6
 

What's hot (20)

101 1.3 runlevels , shutdown, and reboot
101 1.3 runlevels , shutdown, and reboot101 1.3 runlevels , shutdown, and reboot
101 1.3 runlevels , shutdown, and reboot
 
Chapter 1 Introduction to Operating System Concepts
Chapter 1 Introduction to Operating System ConceptsChapter 1 Introduction to Operating System Concepts
Chapter 1 Introduction to Operating System Concepts
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System Administration
 
Chapter 2 Introduction to Unix Concepts
Chapter 2 Introduction to Unix ConceptsChapter 2 Introduction to Unix Concepts
Chapter 2 Introduction to Unix Concepts
 
Linux System Monitoring basic commands
Linux System Monitoring basic commandsLinux System Monitoring basic commands
Linux System Monitoring basic commands
 
Chapter 3 Using Unix Commands
Chapter 3 Using Unix CommandsChapter 3 Using Unix Commands
Chapter 3 Using Unix Commands
 
Experimentos lab
Experimentos labExperimentos lab
Experimentos lab
 
Implementation of Pipe in Linux
Implementation of Pipe in LinuxImplementation of Pipe in Linux
Implementation of Pipe in Linux
 
Process management in linux
Process management in linuxProcess management in linux
Process management in linux
 
Basics of Linux Commands, Git and Github
Basics of Linux Commands, Git and GithubBasics of Linux Commands, Git and Github
Basics of Linux Commands, Git and Github
 
Linux startup
Linux startupLinux startup
Linux startup
 
System Calls
System CallsSystem Calls
System Calls
 
Linux : Booting and runlevels
Linux : Booting and runlevelsLinux : Booting and runlevels
Linux : Booting and runlevels
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
 
Process and Threads in Linux - PPT
Process and Threads in Linux - PPTProcess and Threads in Linux - PPT
Process and Threads in Linux - PPT
 
Linux for beginners
Linux for beginnersLinux for beginners
Linux for beginners
 
System Calls
System CallsSystem Calls
System Calls
 
Os notes
Os notesOs notes
Os notes
 
Os lab final
Os lab finalOs lab final
Os lab final
 
Completeosnotes
CompleteosnotesCompleteosnotes
Completeosnotes
 

Similar to How To Add System Call In Ubuntu OS

Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
Bimal Jain
 
I Am Linux-Introductory Module on Linux
I Am Linux-Introductory Module on LinuxI Am Linux-Introductory Module on Linux
I Am Linux-Introductory Module on Linux
Sagar Kumar
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating System
MahakKasliwal
 
Introduction to unix
Introduction to unixIntroduction to unix
Introduction to unix
Chandru Jangin
 
Linux Operating System
Linux Operating SystemLinux Operating System
Linux Operating System
KunalKewat1
 
Unix final
Unix finalUnix final
Unix final
MahakKasliwal
 
LINUX Device Drivers
LINUX Device DriversLINUX Device Drivers
LINUX Device Drivers
Partha Bhattacharya
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
Nishant Munjal
 
Introduction to Assembly Language Programming
Introduction to Assembly Language ProgrammingIntroduction to Assembly Language Programming
Introduction to Assembly Language Programming
Rahul P
 
Linux
LinuxLinux
CHAPTER 1 INTRODUCTION TO UNIX.pptx
CHAPTER 1 INTRODUCTION TO UNIX.pptxCHAPTER 1 INTRODUCTION TO UNIX.pptx
CHAPTER 1 INTRODUCTION TO UNIX.pptx
MahiDivya
 
3CS LSP UNIT 1-1.pdf
3CS LSP UNIT 1-1.pdf3CS LSP UNIT 1-1.pdf
3CS LSP UNIT 1-1.pdf
DeepakKumar783815
 
TinyOS installation Guide And Manual
TinyOS installation Guide And ManualTinyOS installation Guide And Manual
TinyOS installation Guide And Manual
Ankit Singh
 
Linux Device Driver’s
Linux Device Driver’sLinux Device Driver’s
Linux Device Driver’s
Rashmi Warghade
 
Architecture-of-Linux-operating-system.docx
Architecture-of-Linux-operating-system.docxArchitecture-of-Linux-operating-system.docx
Architecture-of-Linux-operating-system.docx
VivekGupta920049
 
os.ppt
os.pptos.ppt
os.ppt
banu236831
 
Unix notes
Unix notesUnix notes
Unix1
Unix1Unix1
Walking around linux kernel
Walking around linux kernelWalking around linux kernel
Walking around linux kernel
Dharshana Kasun Warusavitharana
 
Programming and problem solving 3
Programming and problem solving 3Programming and problem solving 3
Programming and problem solving 3
sushruth kamarushi
 

Similar to How To Add System Call In Ubuntu OS (20)

Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
 
I Am Linux-Introductory Module on Linux
I Am Linux-Introductory Module on LinuxI Am Linux-Introductory Module on Linux
I Am Linux-Introductory Module on Linux
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating System
 
Introduction to unix
Introduction to unixIntroduction to unix
Introduction to unix
 
Linux Operating System
Linux Operating SystemLinux Operating System
Linux Operating System
 
Unix final
Unix finalUnix final
Unix final
 
LINUX Device Drivers
LINUX Device DriversLINUX Device Drivers
LINUX Device Drivers
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
Introduction to Assembly Language Programming
Introduction to Assembly Language ProgrammingIntroduction to Assembly Language Programming
Introduction to Assembly Language Programming
 
Linux
LinuxLinux
Linux
 
CHAPTER 1 INTRODUCTION TO UNIX.pptx
CHAPTER 1 INTRODUCTION TO UNIX.pptxCHAPTER 1 INTRODUCTION TO UNIX.pptx
CHAPTER 1 INTRODUCTION TO UNIX.pptx
 
3CS LSP UNIT 1-1.pdf
3CS LSP UNIT 1-1.pdf3CS LSP UNIT 1-1.pdf
3CS LSP UNIT 1-1.pdf
 
TinyOS installation Guide And Manual
TinyOS installation Guide And ManualTinyOS installation Guide And Manual
TinyOS installation Guide And Manual
 
Linux Device Driver’s
Linux Device Driver’sLinux Device Driver’s
Linux Device Driver’s
 
Architecture-of-Linux-operating-system.docx
Architecture-of-Linux-operating-system.docxArchitecture-of-Linux-operating-system.docx
Architecture-of-Linux-operating-system.docx
 
os.ppt
os.pptos.ppt
os.ppt
 
Unix notes
Unix notesUnix notes
Unix notes
 
Unix1
Unix1Unix1
Unix1
 
Walking around linux kernel
Walking around linux kernelWalking around linux kernel
Walking around linux kernel
 
Programming and problem solving 3
Programming and problem solving 3Programming and problem solving 3
Programming and problem solving 3
 

More from Pratik Tambekar

ASP DOT NET
ASP DOT NETASP DOT NET
ASP DOT NET
Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
Pratik Tambekar
 
Data Mining Concepts and Techniques
Data Mining Concepts and TechniquesData Mining Concepts and Techniques
Data Mining Concepts and Techniques
Pratik Tambekar
 
What Is DATA MINING(INTRODUCTION)
What Is DATA MINING(INTRODUCTION)What Is DATA MINING(INTRODUCTION)
What Is DATA MINING(INTRODUCTION)
Pratik Tambekar
 
Distributed Transaction
Distributed TransactionDistributed Transaction
Distributed Transaction
Pratik Tambekar
 
World Wide Web(WWW)
World Wide Web(WWW)World Wide Web(WWW)
World Wide Web(WWW)
Pratik Tambekar
 

More from Pratik Tambekar (17)

ASP DOT NET
ASP DOT NETASP DOT NET
ASP DOT NET
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
 
Data Mining Concepts and Techniques
Data Mining Concepts and TechniquesData Mining Concepts and Techniques
Data Mining Concepts and Techniques
 
What Is DATA MINING(INTRODUCTION)
What Is DATA MINING(INTRODUCTION)What Is DATA MINING(INTRODUCTION)
What Is DATA MINING(INTRODUCTION)
 
Distributed Transaction
Distributed TransactionDistributed Transaction
Distributed Transaction
 
World Wide Web(WWW)
World Wide Web(WWW)World Wide Web(WWW)
World Wide Web(WWW)
 

Recently uploaded

Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
mahammadsalmanmech
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
PauloRodrigues104553
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
Wearable antenna for antenna applications
Wearable antenna for antenna applicationsWearable antenna for antenna applications
Wearable antenna for antenna applications
Madhumitha Jayaram
 

Recently uploaded (20)

Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
Wearable antenna for antenna applications
Wearable antenna for antenna applicationsWearable antenna for antenna applications
Wearable antenna for antenna applications
 

How To Add System Call In Ubuntu OS

  • 1. How To Add System Call In UBUNTU Operating System Presented by: Pratik Tambekar Guided by: Mr. T.R Ravi
  • 2. CONTENTS WHY UBUNTU? INTRODUCTION WHAT IS KERNEL? WHAT IS SYSTEM CALL? HOW TO ADD SYSTEM CALL HOW TO REPLACES NEW KERNEL FILE WITH OLD KERNEL FILE REFRENCES
  • 3. WHY UBUNTU? Free Ubuntu is and will always be free in the future. Ubuntu is developed by people all over the world embracing the principle of Free libre open-source software (FLOSS). This enables new software and updates to be available free of cost since they are written by volunteers and also the employees of Canonical, the parent company of Ubuntu. No Viruses While using Ubuntu, you do not need to worry about installing any anti-virus programs since Ubuntu is completely free of viruses.
  • 4. CONT…. Community Support When you need help using your system, the community is available everywhere around you to support you at all times. All this are done voluntarily by people passionate about Ubuntu. Up to date software Ubuntu will always be up to date with updates released regularly to ensure that your system is secure and bug free. These regular updates will be always be available for free. Beautiful, Polished, Stable These are the goals of every Ubuntu release. Your Ubuntu is designed with the help of the community and experts after extensive discussion. Ubuntu is regularly user tested to ensure that it is easy and simple to use while preserving its elegance and polish.
  • 5. INTRODUCTION  Ubuntu was founded by Mark Shuttleworth, a South African entrepreneur coming up with their first release Ubuntu 4.10 codenamed Warty Warthog in October 2004.  Ubuntu is an African concept meaning “humanity toward others”  Sponsored by Canonical Ltd. Owned by South African billionaire Mark Shuttleworth.  Ubuntu is a Linux-based Operating System that is open sourced (free)  Pronounced (oo-BOON-too)  Strong focus on usability and ease of installation
  • 8. Advantages and Disadvantages over windows. - Advantages: 1) Not vulnerable to Windows malware/viruses 2) Free 3) Tends to run more efficiently than Windows 4) Not subject to Microsoft's cripple ware. - Disadvantages: 1) Won't run most Windows applications (especially games) 2) Requires a higher than average nerd factor (not as user friendly) 3) Doesn't work with all hardware (but neither does Windows!) 4) Can be somewhat buggy
  • 9. What is Kernel? The central module of an operating system. It is the part of the operating system that loads first, and it remains in main memory. Because it stays in memory, it is important for the kernel to be as small as possible while still providing all the essential services required by other parts of the operating system and applications. It acts as an interface between the user applications and the hardware. Typically, the kernel is responsible for memory management, process management, task management, I/O communication and disk management.
  • 10. CONT.... Types of Kernels: Kernels may be classified mainly in two categories 1) Monolithic 2) Micro Kernel Linux follows the monolithic modular approach
  • 11. CONT.... Monolithic kernel: In this type of kernel architecture, all the basic system services like process and memory management, interrupt handling etc were packaged into a single module in kernel space. This type of architecture led to some serious drawbacks like 1) Size of kernel, which was huge. 2) Poor maintainability, which means bug fixing or addition of new features resulted in recompilation of the whole kernel which could consume hours
  • 13. What is System Call? System calls are low level functions the operating system makes available to applications via a defined API (Application Programming Interface) System calls represent the interface the kernel presents to user applications. In Linux all low-level I/O is done by reading and writing file handles, regardless of what particular peripheral device is being accessed—a tape, a socket, even your terminal, they are all files. Low level I/O is performed by making system calls.
  • 14. Anatomy of a System Call A System Call is an explicit request to the kernel made via a software interrupt. The interrupt call ‘0x80’ call to a system call handler (sometimes called the “call gate”). The system call handler in turns calls the system call interrupt service routine (ISR). To perform Linux system calls we have to do following: - Put the system call number in EAX register. - Set up the arguments to the system call in EBX,ECX, etc. - call the relevant interrupt (for DOS, 21h; for Linux, 80h). - The result is usually returned in EAX.
  • 15. CONT…. There are six registers that are used for the arguments that the system call takes. The first argument goes in EBX, the second in ECX, then EDX, ESI, EDI, and finally EBP. If more then 6 arguments needed (not likely), the EBX register must contain the memory location where the list of arguments is stored. basic system calls: ◦ sys_open ◦ sys_close ◦ sys_read ◦ sys_write ◦ sys_Fork ◦ sys_exit
  • 16. CONT…. Sys_open - open a file system call number (in EAX): 5 arguments: ◦ EBX: The pathname of the file to open/create ◦ ECX: set file access bits (can be OR’d togather): O_RDONLY open for reading only O_WRONLY open for writing only O_RDRW open for both reading and writing O_APPEND open for appending to the end of file O_TRUNC truncate to 0 length if file exists O_CREAT create the file if it doesn’t exist ◦ EDX: set file permissions. Returns in EAX: file descriptor.
  • 17. Error handling System calls set a global integer called errno on error. The constants that errno may be set to are (partial list): ◦ EPERM operation not permitted. ◦ ENOENT no such file or directory (not there). ◦ EIO I/O error – EEXIST file already exists. ◦ ENODEV no such device exists. ◦ EINVAL invalid argument passed.
  • 20. How to add a System Call Ubuntu 10.10 and using kernel version 2.6.37.3 If you are using any other kernel version just replace 2.6.37.3 with your version. I am also assuming you have extracted the source code. Now let the new system call’s name be “add2”.
  • 21. CONT…. 1. Now you will find a “arch” folder in the source code folder. Open the file arch/x86/kernel/syscall_table_32.S in a text editor. Go to the end of the document and add this line .long sys_add2 /* my code */
  • 22. CONT…. 2. Now open arch/x86/include/asm/unistd_32.h and find out #define __NR_prlimit64 340  Add a new line after this: #define __NR_add2 341  Don’t just close yet. After 3-4 lines, you will find a line like
  • 23. CONT…. #define NR_syscalls 341  Change it to #define NR_syscalls 342. 3. Now edit arch/x86/include/asm/unistd_64.h  Find out: #define __NR_prlimit64 302 __SYSCALL(__NR_prlimit64,sys_prli mit64)
  • 24. CONT….  Now after these two lines, add these two lines #define __NR_add2 303 __SYSCALL(__NR_add2, sys_add2) 4. Now again in the source folder you will find a folder named include. Open the file include/linux/syscalls.h and go to the end of the file. Before the line
  • 25. CONT… #endif write this prototype definition line: asmlinkage long sys_add2(int i,int j); 5. Now find out the kernel folder in the source directory. Create a new empty file in the kernel folder with the name “mysysteamcalls.c” . Add the following codes in the file:
  • 26. CONT… #include<linux/linkage.h> asmlinkage long sys_add2(int i,int j) { return i+j; } 6. Now open the Makefile in this folder(/kernel/Makefile) and find out obj-y += groups.o
  • 27. CONT…  Add a new line before this line : obj-y += mysysteamcalls.o  Ok, this is the edit you need to do to add a new system call. Now compile or recompile the source code and enjoy your new system call.
  • 28. sample code to call the system call : #include <stdio.h> #include <linux/unistd.h> #include <sys/syscall.h> //comment the following line if you are using 64 bit, this number is the same used previously #define sys_add2 341 //comment the following line if you are using 32 bit, this number is the same used previously
  • 29. CONT… int main(void) { int a,b,c; printf("Adding Two Numbers in Kernel Spacen"); printf("Input a: "); scanf("%d",&a); printf("Input b: "); scanf("%d", &b); c = syscall(sys_add2, a, b); printf("System call returned %dn", c); return 0; }
  • 30. How to replaces new kernel file with old Kernel File: download the kernel from kernel.org http://www.kernel.org/pub/linux/kernel/ v3.0/linux-3.X.tar.bz2 Extract the tarball to /usr/src/linux-3.X/ tar -xvf linux-3.X.tar.bz2 -C /usr/src/linux-3.X/ Change the directory to /usr/src/linux- 3.x $ cd /usr/src/linux-3.x
  • 31. CONT… Configure Lets configure our new Linux Kernel with the configuration of old kernel (which is already installed in our machine) $ sudo make oldconfig The new kernel is installed, however we need to say to the Ubuntu to use this new one. Just type in the shell: sudo update-initramfs -k 2.6.38.3 -u sudo update-grub Restart your computer. After loaded, type in the shell: uname -a
  • 32. .deb Files linux-headers-2.6.34- 02063415_2.6.34- 02063415.201402101835_all.deb linux-headers-2.6.34-02063415- server_2.6.34- 02063415.201402101835_amd64.deb linux-image-2.6.34-02063415- generic_2.6.34- 02063415.201402101835_amd64.deb sudo dpkg -i linux*2.6.34-7.37*.deb sudo reboot
  • 33. Refrences: http://www.kernel.org http://www.Ubuntu.com kernel.ubuntu.com/~kernel-ppa/ mainline/ https://wiki.ubuntu.com/Kernel/Mainlin eBuilds ubuntuforums.org www.ubuntu.com/support/community http://www.linuxquestions.org