Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Kernel Questions

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 13th April 2009, 08:21
anas.nss anas.nss is offline
Junior Member
 
Join Date: Apr 2009
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
 
Post Steps for creating syscsll with compiling the kernel in opensue 11.0

---------------------------------------------------------------------------------
Steps to make own system call and compiling kernel
---------------------------------------------------------------------------------


Make own system call
----------------------------------------------------------------------
1) cd KERNELSOURSE/usr/src/linux 2.6.x.x.x/include/asm-x86

2) vi unistd_32.h

Add your own systemcall as the last entry

#define __NR_yoursyscallname 327
NB:327 if previous entry is 326

3) cd KERNELSOURSE/usr/src/linux 2.6.x.x.x/arch/x86/kernel

4) vi syscall_table_32.c
add entry
.long sys_yoursyscallname 327

5) cd KERNELSOURSE/usr/src/linux 2.6.x.x.x/kernel

6) vi sys.c

write yourown systemm call in this file

eg:

asmlinkage long sys_yoursyscallname(char __user *name)
{
printk(KERN_EMERG"\nEntered name is:%s\n",name);
return 0;
}
--------------------------------------------------------------------------------------------------------------
In order to execute your system call you must add it to kernel image.
For that compilation of kernel needed.
--------------------------------------------------------------------------------------------------------------

1) Go to usr/src directory in kernel sourse

2) make mrproper //only first time

3) copy configuration file


cp arch/x86/defconfig_32 ./.config
4) make clean

5) make cloneconfig
Uses settings for already running kernel

OR
make oldconfig
Expert level

6)[optional] make menuconfig
menudrivel configuration

7) make

8) make modules_install

9) make install


-----------------------------------------------------------------------------------


Reboot the system oopen in your new kernel

------------------------------------------------------------------------------------

create a new file for calling your own system call



eg:

1) vi callmysyscall.c

/************************************************** **********************/
/*callmysyscall.c */
/************************************************** **********************/

#define _GNU_SOURCE /* or _BSD_SOURCE or _SVID_SOURCE */
#include <unistd.h>
#include <sys/syscall.h> /* For SYS_xxx definitions */
int main()
{
int a;
syscall(__NR_yoursyscallname,arguments to systemcall[specific to our example a string name]);
return 0;
}



2) cc callmysyscall.c

3) ./a.out

*4) dmesg NB: 4)Specific to our example

To see the output





Eg:-

/************************************************** **********************/
/*callmysyscall.c */
/************************************************** **********************/

#define _GNU_SOURCE /* or _BSD_SOURCE or _SVID_SOURCE */
#include <unistd.h>
#include <stdio.h>
#include <sys/syscall.h> /* For SYS_xxx definitions */
int main(int argc,char* argv[])
{
int a;
if(argc!=2)
{
printf("Usage:Give command<space>Your name\n");
return 0;
}
syscall(__NR_pname_in_dmesg,argv[1]);
return 0;
}
Reply With Quote
Sponsored Links
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ispconfig IE7 Xen aurelius Installation/Configuration 8 19th October 2008 11:46
Google Apps dayjahone General 19 29th March 2008 18:25
High Availability Samba cluster - DRBD + Heartbeat djalex Server Operation 58 25th May 2007 20:38
WG311v2 almost working with Edgy (w/o ndiswrapper) need help with the rest caudata Server Operation 11 13th November 2006 21:02
KErnel not showing all my memory Jorem Kernel Questions 8 13th April 2006 13:59


All times are GMT +2. The time now is 00:16.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.