?
Solved

Adding a new system call

Posted on 2006-07-11
4
Medium Priority
?
219 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 375 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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 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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

850 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