LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   add new system call (https://www.linuxquestions.org/questions/programming-9/add-new-system-call-306814/)

linux_lover2005 03-27-2005 08:42 PM

add new system call
 
Hello all,
How to resolve new system call number assignments. On Fedora Core 1 i got next
.long SYMBOL_NAME(sys_myservice) /*259*/
number in entry.S
Also for include/asm/unistd.h gives me
#define __NR_myservice 259
Then in user space include/asm/unistd.h i got next number as 271.
I proceed with 271 no. but got results that no syscall is defined.I have successfully implemented new system call given in
http://fossil.wpi.edu/docs/howto_add_systemcall.html
on RH9 system. But now i want same thing to be implemeted on Fedora Core 1 but i am getting following strace results.

[root@localhost root]# strace ./user-app
execve("./user-app", ["./user-app"], [/* 41 vars */]) = 0
uname({sys="Linux", node="localhost.localdomain",...}) = 0
set_tid_address(0) = -1 ENOSYS (Function not implemented)
brk(0) = 0x80495bc
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=84369, ...}) = 0
old_mmap(NULL, 84369, PROT_READ, MAP_PRIVATE, 3, 0) =0x40000000
close(3) = 0
open("/lib/i686/libc.so.6", O_RDONLY) = 3
read(3,"\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0
\\\1\000"..., 512) =512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1564716,...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40015000
old_mmap(NULL, 1287652, PROT_READ|PROT_EXEC,
MAP_PRIVATE, 3, 0) = 0x40016000
old_mmap(0x4014b000, 12288, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x135000) = 0x4014b000
old_mmap(0x4014e000, 9700, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4014e000
close(3) = 0
munmap(0x40000000, 84369) = 0
utimes("string", {3221223448, 134513588}) = -1 ENOSYS (Function not implemented)
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++

Now please help me how can i then assign
sys_call_table no.?

btmiller 03-27-2005 09:28 PM

I'm pretty sure that the syscall number in user space and the syscall number in the kernel are supposed to match up. The program traps into kernel space (via int 0x80) with the system call number, which is how the kernel knows which system call to execute. Try calling your syscall via an indirect syscall (using number 259, see syscall(2) for more details), and see if that doesn't work...

Cappuccino 10-14-2006 01:37 AM

I think the header file /linux-2.x/include/linux/sys.h in your case has the line #define NR_syscalls 270 which probably accounts for the total number of system calls already defined which may not conform with the entries in unistd.h .... try giving the value 271 to your system call entry in the unistd.h header file and see if it works.


All times are GMT -5. The time now is 07:57 PM.