Solved

Adding a new system call

Posted on 2006-07-11
4
215 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
[X]
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
  • 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
Linux , how can I inspect a tar GZ file 3 165
Installing rpm without root access 1 71
what does "puppet agent -t" do ? 2 348
Issues with Ports in Linux (Hyper-V Guest) 2 110
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…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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