# x86 Linux syscalls

I’ve tried to keep this down to a semi-reasonable length, rather than just dump all 337+311 here...
Several of those commented out will no doubt want uncommenting. Always try using libc before resorting to these.

### 32 bit

# | Name | Registers
--- | --- | ---
|  | eax | ebx | ecx | edx | esi | edi
1 | sys_exit | 0x01 | int error_code | - | - | - | -
2 | sys_fork | 0x02 | struct pt_regs * | - | - | - | -
3 | sys_read | 0x03 | uint fd | char *buf | size_t count | - | -
4 | sys_write | 0x04 | uint fd | const char *buf | size_t count | - | -
5 | sys_open | 0x05 | const char *filename | int flags | int mode | - | -
6 | sys_close | 0x06 | uint fd | - | - | - | -
12 | sys_chdir | 0x0c | const char *filename | - | - | - | -
13 | sys_time | 0x0d | time_t *tloc | - | - | - | -
38 | sys_rename | 0x26 | const char *oldname | const char *newname | - | - | -
39 | sys_mkdir | 0x27 | const char *pathname | int mode | - | - | -
40 | sys_rmdir | 0x28 | const char *pathname | - | - | - | -
41 | sys_dup | 0x29 | uint fildes | - | - | - | -
42 | sys_pipe | 0x2a | int *fildes | - | - | - | -
43 | sys_times | 0x2b | struct tms *tbuf | - | - | - | -
45 | sys_brk | 0x2d | ulong brk | - | - | - | -
54 | sys_ioctl | 0x36 | uint fd | uint cmd | ulong arg | - | -
67 | sys_sigaction | 0x43 | int sig | const struct old_sigaction *act | struct old_sigaction *oact | - | -
78 | sys_gettimeofday | 0x4e | struct timeval *tv | struct timezone *tz | - | - | -
142 | sys_select | 0x8e | int n | fd_set *inp | fd_set *outp | fd_set *exp | struct timeval *tvp
162 | sys_nanosleep | 0xa2 | struct timespec *rqtp | struct timespec *rmtp | - | - | -
163 | sys_mremap | 0xa3 | ulong addr | ulong old_len | ulong new_len | ulong flags | ulong new_addr
183 | sys_getcwd | 0xb7 | char *buf | ulong size | - | - | -
240 | sys_futex | 0xf0 | - | - | - | - | -
252 | sys_exit_group | 0xfc | int error_code | - | - | - | -
268 | sys_statfs64 | 0x10c | const char *path | size_t sz | struct statfs64 *buf | - | -

Generated from Linux kernel 2.6.35.4

### 64 bit

rax | System call | rdi | rsi | rdx | rcx | r8 | r9
--- | --- | --- | --- | --- | --- | --- | ---
0 | sys_read | uint fd | char *buf | size_t count |  |  |
1 | sys_write | uint fd | const char *buf | size_t count |  |  |
2 | sys_open | const char *filename | int flags | int mode |  |  |
3 | sys_close | uint fd |  |  |  |  |
4 | sys_stat | const char *filename | struct stat *statbuf |  |  |  |
5 | sys_fstat | uint fd | struct stat *statbuf |  |  |  |
6 | sys_lstat | const char *filename | struct stat *statbuf |  |  |  |
7 | sys_poll | struct poll_fd *ufds | uint nfds | long timeout_msecs |  |  |
8 | sys_lseek | uint fd | off_t offset | uint origin |  |  |
9 | sys_mmap | ulong addr | ulong len | ulong prot | ulong flags | ulong fd | ulong off
10 | sys_mprotect | ulong start | size_t len | ulong prot |  |  |
11 | sys_munmap | ulong addr | size_t len |  |  |  |
12 | sys_brk | ulong brk |  |  |  |  |
13 | sys_rt_sigaction | int sig | const struct sigaction *act | struct sigaction *oact | size_t sigsetsize |  |
14 | sys_rt_sigprocmask | int how sigset_t *nset | sigset_t *oset | size_t sigsetsize |  |  |
15 | sys_rt_sigreturn | ulong __unused |  |  |  |  |
16 | sys_ioctl | uint fd | uint cmd | ulong arg |  |  |
35 | sys_nanosleep | struct timespec *rqtp | struct timespec *rmtp |  |  |  |
39 | sys_getpid |  |  |  |  |  |
40 | sys_sendfile | int out_fd | int in_fd | off_t *offset | size_t count |  |
41 | sys_socket | int family | int type | int protocol |  |  |
42 | sys_connect | int fd | struct sockaddr *uservaddr | int addrlen |  |  |
43 | sys_accept | int fd | struct sockaddr *upeer_sockaddr | int *upeer_addrlen |  |  |
44 | sys_sendto | int fd | void *buff | size_t len | unsigned flags | struct sockaddr *addr | int addr_len
45 | sys_recvfrom | int fd | void *ubuf | size_t size | unsigned flags | struct sockaddr *addr | int *addr_len
46 | sys_sendmsg | int fd | struct msghdr *msg | unsigned flags |  |  |
47 | sys_recvmsg | int fd | struct msghdr *msg | uint flags |  |  |
48 | sys_shutdown | int fd | int how |  |  |  |
49 | sys_bind | int fd | struct sokaddr *umyaddr | int addrlen |  |  |
50 | sys_listen | int fd | int backlog |  |  |  |
51 | sys_getsockname | int fd | struct sockaddr *usockaddr | int *usockaddr_len |  |  |
52 | sys_getpeername | int fd | struct sockaddr *usockaddr | int *usockaddr_len |  |  |
53 | sys_socketpair | int family | int type | int protocol | int *usockvec |  |
54 | sys_setsockopt | int fd | int level | int optname | char *optval | int optlen |
55 | sys_getsockopt | int fd | int level | int optname | char *optval | int *optlen |
56 | sys_clone | ulong clone_flags | ulong newsp | void *parent_tid | void *child_tid |  |
57 | sys_fork |  |  |  |  |  |
58 | sys_vfork |  |  |  |  |  |
59 | sys_execve | const char *filename | const char *const argv[] | const char *const envp[] |  |  |
60 | sys_exit | int error_code |  |  |  |  |
61 | sys_wait4 | pid_t upid | int *stat_addr | int options | struct rusage *ru |  |
73 | sys_flock | uint fd | uint cmd |  |  |  |
79 | sys_getcwd | char *buf | ulong size |  |  |  |
80 | sys_chdir | const char *filename |  |  |  |  |
82 | sys_rename | const char *oldname | const char *newname |  |  |  |
83 | sys_mkdir | const char *pathname | int mode |  |  |  |
84 | sys_rmdir | const char *pathname |  |  |  |  |
96 | sys_gettimeofday | struct timeval *tv | struct timezone *tz |  |  |  |
201 | sys_time | time_t *tloc |  |  |  |  |
202 | sys_futex | u32 *uaddr | int op | u32 val | struct timespec *utime | u32 *uaddr2 | u32 val3
231 | sys_exit_group | int error_code |  |  |  |  |