6

That is, how do you know

how many parameters a specific syscall expects,

which register each parameter should be in,

and finally what each parameter means?

Is there a man alike command to tell you that?

Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
new_perl
  • 7,345
  • 11
  • 42
  • 72

3 Answers3

3

see also: What are the calling conventions for UNIX & Linux system calls on x86-64

What you are looking for is the kernel ABI, I can't find the official site, but there is a blog with info like this.

In x64 with int 80h call, it is:

value   storage
syscall nr  rax
arg 1   rdi
arg 2   rsi
arg 3   rdx
arg 4   r10
arg 5   r9
arg 6   r8
Community
  • 1
  • 1
J-16 SDiZ
  • 26,473
  • 4
  • 65
  • 84
2

Linux man-pages project (of course C-centric)

muixirt
  • 126
  • 4
1

There is no manual for system calls that I know of, it's something you have to dig into the source code for.

This header file is useful, as it has many of the system calls prototyped with arguments:

include/linux/syscalls.h

It conains definitions, like:

asmlinkage long sys_getresuid(uid_t __user *ruid, uid_t __user *euid, uid_t __user *suid);
asmlinkage long sys_getresgid(gid_t __user *rgid, gid_t __user *egid, gid_t __user *sgid);
asmlinkage long sys_getpgid(pid_t pid);
asmlinkage long sys_getpgrp(void);
asmlinkage long sys_getsid(pid_t pid);
asmlinkage long sys_getgroups(int gidsetsize, gid_t __user *grouplist);

The arch syscalls header file has the rest of the system calls, one that are arch dependant:

arch/x86/include/asm/syscalls.h

(these files are as of 2.6.32 - earlier / later versions of the kernels may have different file/directory names).

Keep in mind that the internals of the linux kernel change fairly often, and there isn't a whole lot of effort put into keeping a stable ABI between major kernel versions. So, you'll have to look at the kernel source code of the kernel you're currently running, and don't expect it to automatically compile on any other kernel version.

Corey Henderson
  • 7,239
  • 1
  • 39
  • 43
  • AFAIK `syscalls.h` only contains info about the number of each syscall, not about which registers it expects the parameters in. – new_perl Dec 23 '11 at 02:09
  • You're thinking of a different file. I've updated the answer with an example of whats in this file. – Corey Henderson Dec 23 '11 at 03:29
  • While internals of the Linux kernel may change often, the api that the kernel provides for userspace (aka syscalls) is really stable. – muixirt Dec 23 '11 at 20:02