Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Adding a new system call

Posted on 2006-07-11
4
213 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
read a word from a file in linux shell script 4 79
Error while installing rpm 1 85
Linux : adding the new user with password option, 11 112
rolling back version of firefox 1 12
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 demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

808 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