Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

Rep: Reputation: 0
Syscall problems


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 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
(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 "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!

Old 05-11-2009, 01:23 AM   #2
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, 09:00 PM   #3
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.

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 06:18 PM
how to use kill syscall shifter Programming 19 05-28-2007 11:04 AM
syscall hook robertos Linux - Kernel 15 03-09-2007 08:33 PM
syscall hook robertos Programming 4 03-06-2007 12:48 AM
Linux syscall 11 (execve) Genjix Programming 1 12-30-2004 12:38 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:37 AM.

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