Solved

Adding a new system call

Posted on 2006-07-11
4
211 Views
Last Modified: 2010-04-21
Hi,
 
i added a system call into kernel on Fedora.How can i test my system call?
--------------------------------------------
asmlinkage long sys_first_system_call()
{
      printk("This is my first system call");
}
---------------------------------------------
will i have to add a first_system_call.h under /usr/include/linux ?
and what will have the header of my test code?
-------------------------------------------------
#include <linux/first_system_call.h>
#include <stdio.h>
int main ()
{
 first_system_call();
 return 0;
}
-------------------------------------------
is it right?
0
Comment
Question by:triptik
  • 2
4 Comments
 
LVL 24

Expert Comment

by:slyong
ID: 17087920
0
 
LVL 8

Expert Comment

by:manish_regmi
ID: 17087973

If you are using Red hat 9 and have not updated to 2.6 kernel versions, You can do it.
 
things are explained here
http://www.csee.umbc.edu/courses/undergraduate/CMSC421/fall02/burt/projects/howto_add_systemcall.html

what do you write in frist system_call.h??

using asm/unistd.h would be easy.

regards
Manish Regmi
0
 

Author Comment

by:triptik
ID: 17112800
&#304; did these changes :


/usr/src/linux-2.6.17.4/arch/i386/kernel/syscall_table.S

 .long sys_first_system_call   /* 317
---------------------------------------------------------------
/usr/src/include/asm/unistd.h

#define __NR_first_system_call  317
----------------------------------------------------------------
linux/fs/stat.c


asmlinkage long sys_first_system_call()
{
      printk("system call");
}
----------------------------------------------------------------
0
 
LVL 8

Accepted Solution

by:
manish_regmi earned 125 total points
ID: 17113047
So the user space program to call the system call will be:

#define __NR_first_system_call  317

#include <asm/unistd.h>

static _syscall0(long,mysyscall)

int main()
{
   mysyscall();
    return 0;
}

thats it.

remember, since you are just using printk you may not be able to see the string in graphical terminal. Try running on non gui terminal.

Also your c app will use headers from /usr/include and not from kernel source. so change there or just put it in your c file before including asm/unistd.h.

regards
Manish Regmi
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question