システムコールと引数

linux-2.4.18 のソースからシステムコール番号とシステムコールの引数をまとめてみました。 レジスタに値をセットして、

       li    r0, 1
       li    r3, 0
       sc

のようにして呼び出します。返り値も引数の型もいろいろありますが、結局32ビットの値かアドレスです。

sys# type NAME arg1 (r3) arg2 (r4) arg3 (r5) arg4 (r6) arg5 (r7) arg6 (r8)
1 long sys_exit int error_code
2 int sys_fork struct pt_regs *regs
3 ssize_t sys_read unsigned int fd char * buf size_t count
4 ssize_t sys_write unsigned int fd const char * buf size_t count
5 long sys_open const char * filename int flags int mode
6 long sys_close unsigned int fd
8 long sys_creat const char * pathname int mode
9 long sys_link const char * oldname const char * newname
10 long sys_unlink const char * pathname
11 int sys_execve char *filenamei char **argv char **envp struct pt_regs *regs
12 long sys_chdir const char * filename
13 long sys_time int * tloc
14 long sys_mknod const char * filename int mode dev_t dev
15 long sys_chmod const char * filename mode_t mode
16 long sys_lchown16 const char * filename old_uid_t user old_gid_t group
19 off_t sys_lseek unsigned int fd off_t offset unsigned int origin
20 long sys_getpid void
21 long sys_mprotect unsigned long start size_t len unsigned long prot
22 long sys_oldumount char * name
23 long sys_setuid16 old_uid_t uid
24 long sys_getuid16 void
25 long sys_stime int * tptr
26 int sys_ptrace long request long pid long addr long data
27 unsigned long sys_alarm unsigned int seconds
29 int sys_pause void
30 long sys_utime char * filename struct utimbuf * times
33 long sys_access const char * filename int mode
34 long sys_nice int increment
36 long sys_sync void
37 long sys_kill int pid int sig
38 long sys_rename const char * oldname const char * newname
39 long sys_mkdir const char * pathname int mode
40 long sys_rmdir const char * pathname
41 long sys_dup unsigned int fildes
42 int sys_pipe unsigned long * fildes
43 long sys_times struct tms * tbuf
45 unsigned long sys_brk unsigned long brk
46 long sys_setgid16 old_gid_t gid
47 long sys_getgid16 void
49 long sys_geteuid16 void
50 long sys_getegid16 void
51 long sys_acct const char *name
52 long sys_umount char * name int flags
54 long sys_ioctl unsigned int fd unsigned int cmd unsigned long arg
55 long sys_fcntl unsigned int fd unsigned int cmd unsigned long arg
57 long sys_setpgid pid_t pid pid_t pgid
60 long sys_umask int mask
61 long sys_chroot const char * filename
62 long sys_ustat dev_t dev struct ustat * ubuf
63 long sys_dup2 unsigned int oldfd unsigned int newfd
64 long sys_getppid void
65 long sys_getpgrp void
66 long sys_setsid void
67 long sys_sgetmask void
70 long sys_setreuid16 old_uid_t ruid old_uid_t euid
71 long sys_setregid16 old_gid_t rgid old_gid_t egid
72 int sys_sigsuspend int restart unsigned long oldmask old_sigset_t mask struct pt_regs *regs
73 long sys_sigpending old_sigset_t *set
74 long sys_sethostname char *name int len
75 long sys_setrlimit unsigned int resource struct rlimit *rlim
76 long sys_old_getrlimit unsigned int resource struct rlimit *rlim
77 long sys_getrusage int who struct rusage *ru
78 long sys_gettimeofday struct timeval *tv struct timezone *tz
79 long sys_settimeofday struct timeval *tv struct timezone *tz
80 long sys_getgroups16 int gidsetsize old_gid_t *grouplist
81 long sys_setgroups16 int gidsetsize old_gid_t *grouplist
82 int old_select struct sel_arg_struct *arg
83 long sys_symlink const char * oldname const char * newname
85 long sys_readlink const char * path char * buf int bufsiz
86 long sys_uselib const char * library
87 long sys_swapon const char * specialfile int swap_flags
88 long sys_reboot int magic1 int magic2 unsigned int cmd void * arg
89 int old_readdir unsigned int fd void * dirent unsigned int count
90 int old_mmap struct mmap_arg_struct *arg
91 long sys_munmap unsigned long addr size_t len
92 long sys_truncate const char * path unsigned long length
93 long sys_ftruncate unsigned int fd unsigned long length
94 long sys_fchmod unsigned int fd mode_t mode
95 long sys_fchown16 unsigned int fd old_uid_t user old_gid_t group
96 long sys_getpriority int which int who
97 long sys_setpriority int which int who int niceval
99 long sys_statfs const char * path struct statfs * buf
100 long sys_fstatfs unsigned int fd struct statfs * buf
102 long sys_socketcall int call unsigned long *args
103 long sys_syslog int type char * buf int len
104 long sys_setitimer int which struct itimerval *value struct itimerval *ovalue
105 long sys_getitimer int which struct itimerval *value
106 long sys_newstat char * filename struct stat * statbuf
107 long sys_newlstat char * filename struct stat * statbuf
108 long sys_newfstat unsigned int fd struct stat * statbuf
111 int sys_vfork struct pt_regs *regs
114 long sys_wait4 pid_t pid unsigned int * stat_addr int options struct rusage * ru
115 long sys_swapoff const char * specialfile
116 long sys_sysinfo struct sysinfo *info
117 int sys_ipc uint call int first int second int third void *ptr long fifth
118 long sys_fsync unsigned int fd
119 int sys_sigreturn struct pt_regs *regs
120 int sys_clone unsigned long clone_flags unsigned long newsp struct pt_regs *regs
121 long sys_setdomainname char *name int len
122 long sys_newuname struct new_utsname * name
124 long sys_adjtimex struct timex *txc_p
125 unsigned long sys_mremap unsigned long addr unsigned long old_len unsigned long new_len unsigned long flags unsigned long new_addr
126 long sys_sigprocmask int how old_sigset_t *set old_sigset_t *oset
127 unsigned long sys_create_module const char *name_user size_t size
128 long sys_init_module const char *name_user struct module *mod_user
129 long sys_delete_module const char *name_user
130 long sys_get_kernel_syms struct kernel_sym *table
131 long sys_quotactl int cmd const char *special int id caddr_t addr
132 long sys_getpgid pid_t pid
133 long sys_fchdir unsigned int fd
134 long sys_bdflush int func long data
135 long sys_sysfs int option unsigned long arg1 unsigned long arg2
136 long sys_personality u_long personality
138 long sys_setfsuid16 old_uid_t uid
139 long sys_setfsgid16 old_gid_t gid
140 long sys_llseek unsigned int fd unsigned long offset_high unsigned long offset_low loff_t * result unsigned int origin
141 long sys_getdents unsigned int fd void * dirent unsigned int count
142 long sys_select int n fd_set *inp fd_set *outp fd_set *exp struct timeval *tvp
143 long sys_flock unsigned int fd unsigned int cmd
144 long sys_msync unsigned long start size_t len int flags
145 ssize_t sys_readv unsigned long fd const struct iovec * vector unsigned long count
146 ssize_t sys_writev unsigned long fd const struct iovec * vector unsigned long count
147 long sys_getsid pid_t pid
148 long sys_fdatasync unsigned int fd
150 long sys_mlock unsigned long start size_t len
151 long sys_munlock unsigned long start size_t len
152 long sys_mlockall int flags
153 long sys_munlockall void
154 long sys_sched_setparam pid_t pid struct sched_param *param
155 long sys_sched_getparam pid_t pid struct sched_param *param
156 long sys_sched_setscheduler pid_t pid int policy struct sched_param *param
157 long sys_sched_getscheduler pid_t pid
158 long sys_sched_yield void
159 long sys_sched_get_priority_max int policy
160 long sys_sched_get_priority_min int policy
161 long sys_sched_rr_get_interval pid_t pid struct timespec *interval
162 long sys_nanosleep struct timespec *rqtp struct timespec *rmtp
163 unsigned long sys_arm_mremap unsigned long addr unsigned long old_len unsigned long new_len unsigned long flags
164 long sys_setresuid16 old_uid_t ruid old_uid_t euid old_uid_t suid
165 long sys_getresuid16 old_uid_t *ruid old_uid_t *euid old_uid_t *suid
167 long sys_query_module const char *name_user int which char *buf size_t bufsize size_t *ret
168 long sys_poll struct pollfd * ufds unsigned int nfds long timeout
169 int sys_nfsservctl int cmd void *argp void *resp
170 long sys_setresgid16 old_gid_t rgid old_gid_t egid old_gid_t sgid
171 long sys_getresgid16 old_gid_t *rgid old_gid_t *egid old_gid_t *sgid
172 long sys_prctl int option unsigned long arg2 unsigned long arg3 unsigned long arg4 unsigned long arg5
173 int sys_rt_sigreturn struct pt_regs *regs
174 long sys_rt_sigaction int sig const struct sigaction *act struct sigaction *oact size_t sigsetsize
175 long sys_rt_sigprocmask int how sigset_t *set sigset_t *oset size_t sigsetsize
176 long sys_rt_sigpending sigset_t *set size_t sigsetsize
177 long sys_rt_sigtimedwait const sigset_t *uthese siginfo_t *uinfo const struct timespec *uts size_t sigsetsize
178 long sys_rt_sigqueueinfo int pid int sig siginfo_t *uinfo
179 int sys_rt_sigsuspend sigset_t *unewset size_t sigsetsize struct pt_regs *regs
180 ssize_t sys_pread unsigned int fd char * buf size_t count loff_t pos
181 ssize_t sys_pwrite unsigned int fd const char * buf size_t count loff_t pos
182 long sys_chown16 const char * filename old_uid_t user old_gid_t group
183 long sys_getcwd char *buf unsigned long size
184 long sys_capget cap_user_header_t header cap_user_data_t dataptr
185 long sys_capset cap_user_header_t header const cap_user_data_t data
186 int sys_sigaction int sig const struct old_sigaction *act struct old_sigaction *oact
187 ssize_t sys_sendfile int out_fd int in_fd off_t *offset size_t count
190 long sys_utimes char * filename struct timeval * utimes
191 long sys_getrlimit unsigned int resource struct rlimit *rlim
192 long sys_mmap2 unsigned long addr unsigned long len unsigned long prot unsigned long flags unsigned long fd unsigned long pgoff
193 long sys_truncate64 const char * path loff_t length
194 long sys_ftruncate64 unsigned int fd loff_t length
195 long sys_stat64 char * filename struct stat64 * statbuf long flags
196 long sys_lstat64 char * filename struct stat64 * statbuf long flags
197 long sys_fstat64 unsigned long fd struct stat64 * statbuf long flags
198 long sys_lchown const char * filename uid_t user gid_t group
199 long sys_getuid void
200 long sys_getgid void
201 long sys_geteuid void
202 long sys_getegid void
203 long sys_setreuid uid_t ruid uid_t euid
204 long sys_setregid gid_t rgid gid_t egid
205 long sys_getgroups int gidsetsize gid_t *grouplist
206 long sys_setgroups int gidsetsize gid_t *grouplist
207 long sys_fchown unsigned int fd uid_t user gid_t group
208 long sys_setresuid uid_t ruid uid_t euid uid_t suid
209 long sys_getresuid uid_t *ruid uid_t *euid uid_t *suid
210 long sys_setresgid gid_t rgid gid_t egid gid_t sgid
211 long sys_getresgid gid_t *rgid gid_t *egid gid_t *sgid
212 long sys_chown const char * filename uid_t user gid_t group
213 long sys_setuid uid_t uid
214 long sys_setgid gid_t gid
215 long sys_setfsuid uid_t uid
216 long sys_setfsgid gid_t gid
217 long sys_getdents64 unsigned int fd void * dirent unsigned int count
218 long sys_pivot_root const char *new_root const char *put_old
219 long sys_mincore unsigned long start size_t len unsigned char * vec
220 long sys_madvise unsigned long start size_t len int behavior
221 long sys_fcntl64 unsigned int fd unsigned int cmd unsigned long arg
224 long sys_gettid void
225 ssize_t sys_readahead int fd loff_t offset size_t count

ネットワーク関連のシステムコールは sys_socketcall (102) の第1引数に以下の表の先頭列に示す番号 (10進) を設定して呼び出します。 引数はメモリに格納して先頭アドレスを sys_socketcall の第2引数に設定します。

1 long sys_socket int family int type int protocol
2 long sys_bind int fd struct sockaddr *umyaddr int addrlen
3 long sys_connect int fd struct sockaddr *uservaddr int addrlen
4 long sys_listen int fd int backlog
5 long sys_accept int fd struct sockaddr *upeer_sockaddr int *upeer_addrlen
6 long sys_getsockname int fd struct sockaddr *usockaddr int *usockaddr_len
7 long sys_getpeername int fd struct sockaddr *usockaddr int *usockaddr_len
8 long sys_socketpair int family int type int protocol int usockvec[2]
9 long sys_send int fd void * buff size_t len unsigned flags
10 long sys_recv int fd void * ubuf size_t size unsigned flags
11 long sys_sendto int fd void * buff size_t len unsigned flags struct sockaddr *addr int addr_len
12 long sys_recvfrom int fd void * ubuf size_t size unsigned flags struct sockaddr *addr int *addr_len
13 long sys_shutdown int fd int how
14 long sys_setsockopt int fd int level int optname char *optval int optlen
15 long sys_getsockopt int fd int level int optname char *optval int *optlen
16 long sys_sendmsg int fd struct msghdr *msg unsigned flags
17 long sys_recvmsg int fd struct msghdr *msg unsigned int flags