Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2111033
  • 博文数量: 413
  • 博客积分: 10926
  • 博客等级: 上将
  • 技术积分: 3862
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-09 18:14
文章分类

全部博文(413)

文章存档

2015年(5)

2014年(1)

2013年(5)

2012年(6)

2011年(138)

2010年(85)

2009年(42)

2008年(46)

2007年(26)

2006年(59)

分类: LINUX

2007-11-09 12:10:37

Following is about system call table for Linux 2.2 kernel. For those about 2.6, please refer to


Linux System Call Table

The following table lists the system calls for the Linux 2.2 kernel. It could also be thought of as an API for the interface between user space and kernel space. My motivation for making this table was to make programming in assembly language easier when using only system calls and not the C library (for more information on this topic, go to ). On the left are the numbers of the system calls. This number will be put in register %eax. On the right of the table are the types of values to be put into the remaining registers before calling the software interrupt 'int 0x80'. After each syscall, an integer is returned in %eax.

For convenience, the kernel source file where each system call is located is linked to in the column labelled "Source". In order to use the hyperlinks, you must first copy this page to your own machine because the links take you directly to the source code on your system. You must have the kernel source installed (or linked from) under '/usr/src/linux' for this to work.

%eaxNameSource %ebx%ecx%edx%esx%edi
1sys_exit int----
2sys_fork ----
3sys_read unsigned intchar *--
4sys_write unsigned intconst char *--
5sys_open const char *intint--
6sys_close unsigned int----
7sys_waitpid pid_tunsigned int *int--
8sys_creat const char *int---
9sys_link const char *const char *---
10sys_unlink const char *----
11sys_execve ----
12sys_chdir const char *----
13sys_time int *----
14sys_mknod const char *intdev_t--
15sys_chmod const char *---
16sys_lchown const char *--
18sys_stat char *---
19sys_lseek unsigned intunsigned int--
20sys_getpid -----
21sys_mount char *char *char *--
22sys_oldumount char *----
23sys_setuid ----
24sys_getuid -----
25sys_stime int *----
26sys_ptrace longlonglonglong-
27sys_alarm unsigned int----
28sys_fstat unsigned int---
29sys_pause -----
30sys_utime char *---
33sys_access const char *int---
34sys_nice int----
36sys_sync -----
37sys_kill intint---
38sys_rename const char *const char *---
39sys_mkdir const char *int---
40sys_rmdir const char *----
41sys_dup unsigned int----
42sys_pipe unsigned long *----
43sys_times ----
45sys_brk unsigned long----
46sys_setgid ----
47sys_getgid -----
48sys_signal int---
49sys_geteuid -----
50sys_getegid -----
51sys_acct const char *----
52sys_umount char *int---
54sys_ioctl unsigned intunsigned intunsigned long--
55sys_fcntl unsigned intunsigned intunsigned long--
57sys_setpgid ---
59sys_olduname ----
60sys_umask int----
61sys_chroot const char *----
62sys_ustat dev_t---
63sys_dup2 unsigned intunsigned int---
64sys_getppid -----
65sys_getpgrp -----
66sys_setsid -----
67sys_sigaction intconst --
68sys_sgetmask -----
69sys_ssetmask int----
70sys_setreuid ---
71sys_setregid ---
72sys_sigsuspend intint--
73sys_sigpending ----
74sys_sethostname char *int---
75sys_setrlimit unsigned int---
76sys_getrlimit unsigned int---
77sys_getrusage int---
78sys_gettimeofday ---
79sys_settimeofday ---
80sys_getgroups int---
81sys_setgroups int---
82old_select ----
83sys_symlink const char *const char *---
84sys_lstat char *---
85sys_readlink const char *char *int--
86sys_uselib const char *----
87sys_swapon const char *int---
88sys_reboot intintintvoid *-
89old_readdir unsigned intvoid *unsigned int--
90old_mmap ----
91sys_munmap unsigned long---
92sys_truncate const char *unsigned long---
93sys_ftruncate unsigned intunsigned long---
94sys_fchmod unsigned int---
95sys_fchown unsigned int--
96sys_getpriority intint---
97sys_setpriority intintint--
99sys_statfs const char *---
100sys_fstatfs unsigned int---
101sys_ioperm unsigned longunsigned longint--
102sys_socketcall intunsigned long *---
103sys_syslog intchar *int--
104sys_setitimer int--
105sys_getitimer int---
106sys_newstat char *---
107sys_newlstat char *---
108sys_newfstat unsigned int---
109sys_uname ----
110sys_iopl unsigned long----
111sys_vhangup -----
112sys_idle -----
113sys_vm86old unsigned long---
114sys_wait4 unsigned long *int options-
115sys_swapoff const char *----
116sys_sysinfo ----
117sys_ipc intintintvoid *
118sys_fsync unsigned int----
119sys_sigreturn unsigned long----
120sys_clone ----
121sys_setdomainname char *int---
122sys_newuname ----
123sys_modify_ldt intvoid *unsigned long--
124sys_adjtimex ----
125sys_mprotect unsigned longunsigned long--
126sys_sigprocmask int--
127sys_create_module const char *---
128sys_init_module const char *---
129sys_delete_module const char *----
130sys_get_kernel_syms ----
131sys_quotactl intconst char *int-
132sys_getpgid ----
133sys_fchdir unsigned int----
134sys_bdflush intlong---
135sys_sysfs intunsigned longunsigned long--
136sys_personality unsigned long----
138sys_setfsuid ----
139sys_setfsgid ----
140sys_llseek unsigned intunsigned longunsigned longunsigned int
141sys_getdents unsigned intvoid *unsigned int--
142sys_select int
143sys_flock unsigned intunsigned int---
144sys_msync unsigned longint--
145sys_readv unsigned longunsigned long--
146sys_writev unsigned longunsigned long--
147sys_getsid ----
148sys_fdatasync unsigned int----
149sys_sysctl ----
150sys_mlock unsigned long---
151sys_munlock unsigned long---
152sys_mlockall int----
153sys_munlockall -----
154sys_sched_setparam ---
155sys_sched_getparam ---
156sys_sched_setscheduler int--
157sys_sched_getscheduler ----
158sys_sched_yield -----
159sys_sched_get_priority_max int----
160sys_sched_get_priority_min int----
161sys_sched_rr_get_interval ---
162sys_nanosleep ---
163sys_mremap unsigned longunsigned longunsigned longunsigned long-
164sys_setresuid --
165sys_getresuid --
166sys_vm86 ----
167sys_query_module const char *intchar *
168sys_poll unsigned intlong--
169sys_nfsservctl intvoid *void *--
170sys_setresgid --
171sys_getresgid --
172sys_prctl intunsigned longunsigned longunsigned longunsigned long
173sys_rt_sigreturn unsigned long----
174sys_rt_sigaction int-
175sys_rt_sigprocmask int-
176sys_rt_sigpending ---
177sys_rt_sigtimedwait -
178sys_rt_sigqueueinfo intint--
179sys_rt_sigsuspend ---
180sys_pread unsigned intchar *-
181sys_pwrite unsigned intconst char *-
182sys_chown const char *--
183sys_getcwd char *unsigned long---
184sys_capget ---
185sys_capset ---
186sys_sigaltstack ---
187sys_sendfile intint-
190sys_vfork ----

: this syscall takes six arguments, so it can't fit into the five registers %ebx - %edi; the last parameter (not shown) is of type 'long'. This syscall requires a special call method where a pointer is put in %ebx which points to an array containing the six arguments.

I will now explain exactly where in the kernel source that I got the information in the table above. I do this because 1) changes in the source are bound to happen, 2) you might be curious, or 3) I might've made an error.

System Call Numbers

For the numbers of the syscalls, look in for sys_call_table. The syscall numbers are offsets into that table. Several spots in the table are occupied by the syscall sys_ni_syscall. This is a placeholder that either replaces an obsolete syscall or reserves a spot for future syscalls.

Incidentally, the system calls are called from the function system_call in the same file; in particular, they are called with the assembly instruction 'call *SYMBOL_NAME(sys_call_table)(,%eax,4)'. The part '*SYMBOL_NAME(sys_call_table)' just gets replaced by a symbol name in sys_call_table. SYMBOL_NAME is a macro defined in , and it just replaces itself with its argument.

Typedefs

Here are the typedef declarations in the prototypes above:

:
#ifdef __SMP__
typedef struct { volatile int counter; } atomic_t;
#else
typedef struct { int counter; } atomic_t;
#endif
:typedef char * __kernel_caddr_t;
:typedef __kernel_caddr_t caddr_t;
:
typedef struct __user_cap_header_struct {
      version;
     int pid;
} *cap_user_header_t;
:
typedef struct __user_cap_data_struct {
      effective;
      permitted;
      inheritable;
} *cap_user_data_t;
:typedef long __kernel_clock_t;
:typedef __kernel_clock_t clock_t;
dev_t :typedef unsigned short __kernel_dev_t;
:typedef __kernel_dev_t dev_t;
include/linux/posix_types.h
#define __FD_SETSIZE 1024
#define __NFDBITS (8 * sizeof(unsigned long))
#define __FDSET_LONGS (__FD_SETSIZE/__NFDBITS)
(==> __FDSET_LONGS == 32)

typedef struct {
     unsigned long fds_bits [__FDSET_LONGS];
} __kernel_fd_set;
:typedef __kernel_fd_set fd_set;
:typedef unsigned short __kernel_gid_t;
:typedef __kernel_gid_t gid_t;
:typedef int __kernel_daddr_t;
:
typedef struct {
     int __val[2];
} __kernel_fsid_t;

:typedef unsigned long __kernel_ino_t;
:typedef unsigned int __kernel_size_t;
:typedef long long __kernel_loff_t;
:typedef __kernel_loff_t loff_t;
:typedef unsigned short __kernel_mode_t;
:typedef __kernel_mode_t mode_t;
:typedef long __kernel_off_t; :typedef __kernel_off_t off_t;
:typedef unsigned long old_sigset_t;
:typedef int __kernel_pid_t;
:typedef __kernel_pid_t pid_t;
:typedef void (*__sighandler_t)(int);
:
#define SI_MAX_SIZE 128
#define SI_PAD_SIZE ((SI_MAX_SIZE/sizeof(int)) - 3)
(==> SI_PAD_SIZE == 29)

typedef struct siginfo {
     int si_signo;
     int si_errno;
     int si_code;

     union {
          int _pad[SI_PAD_SIZE];

          /* kill() */
          struct {
                _pid; /* sender's pid */
                _uid; /* sender's uid */
          } _kill;

          /* POSIX.1b timers */
          struct {
               unsigned int _timer1;
               unsigned int _timer2;
          } _timer;

          /* POSIX.1b signals */
          struct {
                _pid; /* sender's pid */
                _uid; /* sender's uid */
               sigval_t _sigval;
          } _rt;

          /* SIGCHLD */
          struct {
                _pid; /* which child */
                _uid; /* sender's uid */
               int _status; /* exit code */
                _utime;
                _stime;
          } _sigchld;

          /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
          struct {
               void *_addr; /* faulting insn/memory ref. */
          } _sigfault;

          /* SIGPOLL */
          struct {
               int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
               int _fd;
          } _sigpoll;
     } _sifields;
} siginfo_t;
:typedef unsigned long sigset_t;
:typedef unsigned int __kernel_size_t;
:typedef __kernel_size_t size_t;
:typedef int __kernel_ssize_t;
:typedef __kernel_ssize_t ssize_t;
:
typedef struct sigaltstack {
     void *ss_sp;
     int ss_flags;
      ss_size;
} stack_t;
:typedef long __kernel_suseconds_t;
:typedef __kernel_suseconds_t suseconds_t;
:typedef long __kernel_time_t; :typedef __kernel_time_t time_t;
:typedef unsigned short __kernel_uid_t;
:typedef __kernel_uid_t uid_t;
:typedef unsigned int uint;
:typedef unsigned int __u32;

 

Struct Declarations

Here are the struct declarations for the table at the top:

:
struct exception_table_entry {
     unsigned long insn, fixup;
};
:
struct iovec {
     void *iov_base;
      iov_len; };
:
struct itimerval {
      it_interval; /* timer interval */
      it_value; /* current value */
};
:
struct kernel_sym {
     unsigned long value;
     char name[60];
};
:
struct mmap_arg_struct {
     unsigned long addr;
     unsigned long len;
     unsigned long prot;
     unsigned long flags;
     unsigned long fd;
     unsigned long offset;
};
:
struct module {
     unsigned long size_of_struct; /* sizeof(module) */
      *next;
     const char *name;
     unsigned long size;
     union {
           usecount;
          long pad;
     } uc;
     unsigned long flags; /* AUTOCLEAN et al */
     unsigned nsyms;
     unsigned ndeps;

      *syms;
      *deps;
      *refs;
     int (*init)(void);
     void (*cleanup)(void);
     const *ex_table_start;
     const *ex_table_end;
/* Members past this point are extensions to the basic
module support and are optional. Use mod_opt_member()
to examine them. */
     const *persist_start;
     const *persist_end;
     int (*can_unload)(void);
};
:
struct module_persist; /* yes, it's empty */
:
struct module_ref {
      *dep; /* "parent" pointer */
      *ref; /* "child" pointer */
      *next_ref;
};
:
struct module_symbol {
     unsigned long value;
     const char *name;
};
:
struct new_utsname {
     char sysname[65];
     char nodename[65];
     char release[65];
     char version[65];
     char machine[65];
     char domainname[65];
};
:
struct __old_kernel_stat {
     unsigned short st_dev;
     unsigned short st_ino;
     unsigned short st_mode;
     unsigned short st_nlink;
     unsigned short st_uid;
     unsigned short st_gid;
     unsigned short st_rdev;
     unsigned long st_size;
     unsigned long st_atime;
     unsigned long st_mtime;
     unsigned long st_ctime;
};
:
struct oldold_utsname {
     char sysname[9];
     char nodename[9];
     char release[9];
     char version[9];
     char machine[9];
};
:
struct old_sigaction {
      sa_handler;
      sa_mask;
     unsigned long sa_flags;
     void (*sa_restorer)(void);
};
:
struct old_utsname {
     char sysname[65];
     char nodename[65];
     char release[65];
     char version[65];
     char machine[65];
};
:
struct pollfd {
     int fd;
     short events;
     short revents;
};
:
struct pt_regs {
     long ebx;
     long ecx;
     long edx;
     long esi;
     long edi;
     long ebp;
     long eax;
     int xds;
     int xes;
     long orig_eax;
     long eip;
     int xcs;
     long eflags;
     long esp;
     int xss;
};
:
struct revectored_struct {
     unsigned long __map[8];
};
:
struct rlimit {
     long rlim_cur;
     long rlim_max;
};
:
struct rusage {
      ru_utime; /* user time used */
      ru_stime; /* system time used */
     long ru_maxrss; /* maximum resident set size */
     long ru_ixrss; /* integral shared memory size */
     long ru_idrss; /* integral unshared data size */
     long ru_isrss; /* integral unshared stack size */
     long ru_minflt; /* page reclaims */
     long ru_majflt; /* page faults */
     long ru_nswap; /* swaps */
     long ru_inblock; /* block input operations */
     long ru_oublock; /* block output operations */
     long ru_msgsnd; /* messages sent */
     long ru_msgrcv; /* messages received */
     long ru_nsignals; /* signals received */
     long ru_nvcsw; /* voluntary context switches */
     long ru_nivcsw; /* involuntary '' */
};
:
struct sched_param {
     int sched_priority;
};
:
struct sel_arg_struct {
     unsigned long n;
      *inp, *outp, *exp;
      *tvp;
};
:
struct sigaction {
      sa_handler;
     unsigned long sa_flags;
     void (*sa_restorer)(void);
      sa_mask; /* mask last for extensibility */
};
:
struct stat {
     unsigned short st_dev;
     unsigned short __pad1;
     unsigned long st_ino;
     unsigned short st_mode;
     unsigned short st_nlink;
     unsigned short st_uid;
     unsigned short st_gid;
     unsigned short st_rdev;
     unsigned short __pad2;
     unsigned long st_size;
     unsigned long st_blksize;
     unsigned long st_blocks;
     unsigned long st_atime;
     unsigned long __unused1;
     unsigned long st_mtime;
     unsigned long __unused2;
     unsigned long st_ctime;
     unsigned long __unused3;
     unsigned long __unused4;
     unsigned long __unused5;
:
struct statfs {
     long f_type;
     long f_bsize;
     long f_blocks;
     long f_bfree;
     long f_bavail;
     long f_files;
     long f_ffree;
      f_fsid;
     long f_namelen;
     long f_spare[6];
};
include/linux/sysctl.h
struct __sysctl_args {
     int *name;
     int nlen;
     void *oldval;
      *oldlenp;
     void *newval;
      newlen;
     unsigned long __unused[4];
};
:
struct sysinfo {
     long uptime; /* Seconds since boot */
     unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
     unsigned long totalram; /* Total usable main memory size */
     unsigned long freeram; /* Available memory size */
     unsigned long sharedram; /* Amount of shared memory */
     unsigned long bufferram; /* Memory used by buffers */
     unsigned long totalswap; /* Total swap space size */
     unsigned long freeswap; /* swap space still available */
     unsigned short procs; /* Number of current processes */
     char _f[22]; /* Pads structure to 64 bytes */
};
:
struct timex {
     unsigned int modes; /* mode selector */
     long offset; /* time offset (usec) */
     long freq; /* frequency offset (scaled ppm) */
     long maxerror; /* maximum error (usec) */
     long esterror; /* estimated error (usec) */
     int status; /* clock command/status */
     long constant; /* pll time constant */
     long precision; /* clock precision (usec) (read only) */
     long tolerance; /* clock frequency tolerance (ppm)
      * (read only)
      */
      time; /* (read only) */
     long tick; /* (modified) usecs between clock ticks */
     long ppsfreq; /* pps frequency (scaled ppm) (ro) */
     long jitter; /* pps jitter (us) (ro) */
     int shift; /* interval duration (s) (shift) (ro) */
     long stabil; /* pps stability (scaled ppm) (ro) */
     long jitcnt; /* jitter limit exceeded (ro) */
     long calcnt; /* calibration intervals (ro) */
     long errcnt; /* calibration errors (ro) */
     long stbcnt; /* stability limit exceeded (ro) */

     int :32; int :32; int :32; int :32;
     int :32; int :32; int :32; int :32;
     int :32; int :32; int :32; int :32;
};
:
struct timespec {
      tv_sec; /* seconds */
     long tv_nsec; /* nanoseconds */
};
:
struct timeval {
      tv_sec; /* seconds */
      tv_usec; /* microseconds */
};
:
struct timezone {
     int tz_minuteswest; /* minutes west of Greenwich */
     int tz_dsttime; /* type of dst correction */
};
include/linux/times.h
struct tms {
      tms_utime;
      tms_stime;
      tms_cutime;
      tms_cstime;
};
:
struct ustat {
      f_tfree;
      f_tinode;
     char f_fname[6];
     char f_fpack[6];
};
:
struct utimbuf {
      actime;
      modtime;
};
:
struct vm86plus_info_struct {
     unsigned long force_return_for_pic:1;
     unsigned long vm86dbg_active:1;
     unsigned long vm86dbg_TFpendig:1;
     unsigned long unused:28;
     unsigned long is_vm86pus:1;
     unsigned char vm86dbg_intxxtab[32];
};
:
struct vm86plus_struct {
      regs;
     unsigned long flags;
     unsigned long screen_bitmap;
     unsigned long cpu_type;
      int_revectored;
      int21_revectored;
      vm86plus;
};
:
struct vm86_regs {
/* normal regs, with special meaning for the segment descriptors.. */
     long ebx;
     long ecx;
     long edx;
     long esi;
     long edi;
     long ebp;
     long eax;
     long __null_ds;
     long __null_es;
     long __null_fs;
     long __null_gs;
     long orig_eax;
     long eip;
     unsigned short cs, __csh;
     long eflags;
     long esp;
     unsigned short ss, __ssh;
/* these are specific to v86 mode: */
     unsigned short es, __esh;
     unsigned short ds, __dsh;
     unsigned short fs, __fsh;
     unsigned short gs, __gsh;
};
:
struct vm86_struct {
      regs;
     unsigned long flags;
     unsigned long screen_bitmap;
     unsigned long cpu_type;
      int_revectored;
      int21_revectored;
};
阅读(1312) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~