SlideShare ist ein Scribd-Unternehmen logo
1 von 34
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

Weitere ähnliche Inhalte

Was ist angesagt?

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 rebootAcá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 ConceptsMeenalJabde
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System AdministrationSreenatha 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 ConceptsMeenalJabde
 
Linux System Monitoring basic commands
Linux System Monitoring basic commandsLinux System Monitoring basic commands
Linux System Monitoring basic commandsMohammad Rafiee
 
Chapter 3 Using Unix Commands
Chapter 3 Using Unix CommandsChapter 3 Using Unix Commands
Chapter 3 Using Unix CommandsMeenalJabde
 
Implementation of Pipe in Linux
Implementation of Pipe in LinuxImplementation of Pipe in Linux
Implementation of Pipe in LinuxTushar B Kute
 
Process management in linux
Process management in linuxProcess management in linux
Process management in linuxMazenetsolution
 
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 GithubDevang Garach
 
Linux : Booting and runlevels
Linux : Booting and runlevelsLinux : Booting and runlevels
Linux : Booting and runlevelsJohn Ombagi
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scriptsPrashantTechment
 
Process and Threads in Linux - PPT
Process and Threads in Linux - PPTProcess and Threads in Linux - PPT
Process and Threads in Linux - PPTQUONTRASOLUTIONS
 
Linux for beginners
Linux for beginnersLinux for beginners
Linux for beginnersNitesh Nayal
 

Was ist angesagt? (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
 

Ähnlich wie How To Add System Call In Ubuntu OS

Ähnlich wie 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
 

Mehr von Pratik Tambekar

Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik TambekarPratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik TambekarPratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik TambekarPratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik TambekarPratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik TambekarPratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik TambekarPratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik TambekarPratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik TambekarPratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik TambekarPratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik TambekarPratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik TambekarPratik Tambekar
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik TambekarPratik Tambekar
 
Data Mining Concepts and Techniques
Data Mining Concepts and TechniquesData Mining Concepts and Techniques
Data Mining Concepts and TechniquesPratik Tambekar
 
What Is DATA MINING(INTRODUCTION)
What Is DATA MINING(INTRODUCTION)What Is DATA MINING(INTRODUCTION)
What Is DATA MINING(INTRODUCTION)Pratik Tambekar
 

Mehr von 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)
 

Kürzlich hochgeladen

Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 

Kürzlich hochgeladen (20)

Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 

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