LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 05-11-2009, 12:20 AM   #1
RepSTOSW
LQ Newbie
 
Registered: May 2009
Posts: 5

Rep: Reputation: 0
Syscall problems


Hi,

I'm very new to linux kernel development, but I have a few years of programming experience (not much C though).

I'm trying to get a syscall to work in user mode linux (version 2.6.29.1). I found a couple of tutorials on how to do it, but the file- and catalogue-structures doesn't really match, so I've tried to add code as best I could to make it work in my linux version.

The following additions have been made by me:
* In arch/x86/kernel/syscall_table_32.S
long sys_mycall

* In arch/x86/include/asm/unistd_32.h
#define __NR_mycall 333

* In arch/x86/include/asm/syscalls.h
asmlinkage long sys_mycall();

* In kernel\sys_ni.c
cond_syscall(sys_mycall);
(don't know why I would need this line, but it doesn't compile without it)

* In arch/x86/kernel/Makefile
obj-y += mycall.o

* In arch/x86/kernel/mycall.c
#include <asm/linkage.h>

asmlinkage long sys_mycall()
{
kprint("Hello world!\n");
return 1234;
}


I then run the kernel in user mode and try to call my syscall:

* testmycall.c
#include<stdio.h>
#include "testmycall.h"

int main(void)
{
printf("Output: %d \n", syscall(333));
}


I get the output -1 and it doesn't print my hello world message :,(
Now I'm stuck and don't really know how to proceed or what could be wrong with my syscall code.
Help would be much appreciated!


Thanks in advance!

/Magnus
 
Old 05-11-2009, 12:23 AM   #2
RepSTOSW
LQ Newbie
 
Registered: May 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Oh, this went into the wrong forum category :/ Sorry about that..
 
Old 05-11-2009, 08:00 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.


http://www.linuxquestions.org/questi...oblems-725116/



Next time please report your post and request for it to be
moved rather than double-posting
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
i need help in understanding syscall tonyr81 Linux - Kernel 4 05-27-2008 05:18 PM
how to use kill syscall shifter Programming 19 05-28-2007 10:04 AM
syscall hook robertos Linux - Kernel 15 03-09-2007 07:33 PM
syscall hook robertos Programming 4 03-05-2007 11:48 PM
Linux syscall 11 (execve) Genjix Programming 1 12-29-2004 11:38 PM


All times are GMT -5. The time now is 06:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration