

Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!


[email protected] http://www.bigfoot.com/~jialong_he
System call is the services provided by Linux kernel. In C programming, it often uses functions defined in libc which provides a wrapper for many system calls. Manual page section 2 provides more information about system calls. To get an overview, use “man 2 intro” in a command shell.
It is also possible to invoke syscall() function directly. Each system call has a function number defined in <syscall.h> or <unistd.h>. Internally, system call is invokded by software interrupt 0x80 to transfer control to the kernel. System call table is defined in Linux kernel source file “arch/i386/kernel/entry.S ”.
#include <syscall.h> #include <unistd.h> #include <stdio.h> #include <sys/types.h>
int main(void) {
long ID1, ID2; /-----------------------------/ /* direct system call / / SYS_getpid (func no. is 20) / /-----------------------------*/ ID1 = syscall(SYS_getpid); printf ("syscall(SYS_getpid)=%ld\n", ID1);
/-----------------------------/ /* "libc" wrapped system call / / SYS_getpid (Func No. is 20) / /-----------------------------*/ ID2 = getpid(); printf ("getpid()=%ld\n", ID2);
return(0); }
1 exit terminate the current process^ kernel/exit.c
2 fork create a child process arch/i386/kernel/process.c
3 read read from a file descriptor^ fs/read_write.c 4 write write to a file descriptor fs/read_write.c
5 open open a file or device^ fs/open.c
6 close close a file descriptor^ fs/open.c
7 waitpid wait for process termination^ kernel/exit.c
8 creat
create a file or device ("man 2 open" for information)
fs/open.c
9 link make a new name for a file fs/namei.c
10 unlink delete a name and possibly the file it refers to^ fs/namei.c 11 execve execute program arch/i386/kernel/process.c
12 chdir change working directory^ fs/open.c 13 time get time in seconds^ kernel/time.c
14 mknod create a special or ordinary file^ fs/namei.c
15 chmod change permissions of a file^ fs/open.c 16 lchown change ownership of a file fs/open.c
18 stat get file status^ fs/stat.c 19 lseek reposition read/write file offset fs/read_write.c
20 getpid get process identification^ kernel/sched.c 21 mount mount filesystems^ fs/super.c
22 umount unmount filesystems^ fs/super.c 23 setuid set real user ID^ kernel/sys.c
24 getuid get real user ID kernel/sched.c
25 stime set system time and date^ kernel/time.c
26 ptrace
allows a parent process to control the execution of a child process
arch/i386/kernel/ptrace.c
27 alarm set an alarm clock for delivery of a signal^ kernel/sched.c 28 fstat get file status^ fs/stat.c
29 pause suspend process until signal^ arch/i386/kernel/sys_i386.c
30 utime set file access and modification times^ fs/open.c 33 access check user's permissions for a file fs/open.c
34 nice change process priority^ kernel/sched.c 36 sync update the super block fs/buffer.c
37 kill send signal to a process^ kernel/signal.c 38 rename change the name or location of a file^ fs/namei.c
39 mkdir create a directory^ fs/namei.c 40 rmdir remove a directory^ fs/namei.c
41 dup duplicate an open file descriptor fs/fcntl.c
42 pipe create an interprocess channel^ arch/i386/kernel/sys_i386.c 43 times get process times kernel/sys.c
45 brk
change the amount of space allocated for the calling process's data segment
mm/mmap.c
46 setgid set real group ID^ kernel/sys.c
47 getgid get real group ID^ kernel/sched.c 48 sys_signal ANSI C signal handling^ kernel/signal.c
49 geteuid get effective user ID kernel/sched.c
50 getegid get effective group ID^ kernel/sched.c
51 acct enable or disable process accounting^ kernel/acct.c
52 umount2 unmount a file system fs/super.c
54 ioctl control device^ fs/ioctl.c
55 fcntl file control fs/fcntl.c
56 mpx (unimplemented)
57 setpgid set process group ID^ kernel/sys.c
58 ulimit (unimplemented)
59 olduname obsolete uname system call^ arch/i386/kernel/sys_i386.c
60 umask set file creation mask kernel/sys.c
61 chroot change root directory^ fs/open.c
62 ustat get file system statistics fs/super.c
63 dup2 duplicate a file descriptor^ fs/fcntl.c
64 getppid get parent process ID^ kernel/sched.c
65 getpgrp get the process group ID^ kernel/sys.c
66 setsid creates a session and sets the process group ID^ kernel/sys.c
67 sigaction POSIX signal handling functions^ arch/i386/kernel/signal.c
68 sgetmask ANSI C signal handling^ kernel/signal.c
69 ssetmask ANSI C signal handling kernel/signal.c
70 setreuid set real and effective user IDs^ kernel/sys.c
71 setregid set real and effective group IDs kernel/sys.c
72 sigsuspend
install a signal mask and suspend caller until signal
arch/i386/kernel/signal.c
73 sigpending examine signals that are blocked and pending^ kernel/signal.c
74 sethostname set hostname kernel/sys.c
75 setrlimit set maximum system resource con sumption^ kernel/sys.c
76 getrlimit get maximum system resource con sumption kernel/sys.c
77 getrusage get maximum system resource con sumption^ kernel/sys.c
78 gettimeofday get the date and time^ kernel/time.c
79 settimeofday set the date and time^ kernel/time.c
80 getgroups get list of supplementary group IDs^ kernel/sys.c
81 setgroups set list of supplementary group IDs^ kernel/sys.c
82 old_select sync. I/O multiplexing^ arch/i386/kernel/sys_i386.c
83 symlink make a symbolic link to a file fs/namei.c
84 lstat get file status^ fs/stat.c
85 readlink read the contents of a symbolic link fs/stat.c
86 uselib select shared library^ fs/exec.c
87 swapon start swapping to file/device^ mm/swapfile.c
88 reboot reboot or enable/disable Ctrl-Alt -Del^ kernel/sys.c
89 old_readdir read directory entry^ fs/readdir.c
90 old_mmap map pages of memory arch/i386/kernel/sys_i386.c
91 munmap unmap pages of memory^ mm/mmap.c
92 truncate set a file to a specified length fs/open.c
93 ftruncate set a file to a specified length^ fs/open.c 94 fchmod change access permission mode of file fs/open.c
95 fchown change owner and group of a file^ fs/open.c
96 getpriority get program scheduling priority^ kernel/sys.c
97 setpriority set program scheduling priority^ kernel/sys.c 98 profil execut ion time profile
99 statfs get file system statistics fs/open.c
100 fstatfs get file system statistics^ fs/open.c 101 ioperm set port input/output permissions arch/i386/kernel/ioport.c
102 socketcall socket system calls^ net/so cket.c
103 syslog read and/or clear kernel message ring buffer^ kernel/printk.c
104 setitimer set value of interval timer^ kernel/itimer.c 105 getitimer get value of interval timer^ kernel/itimer.c
106 sys_newstat get file status^ fs/stat.c
107 sys_newlstat get file status^ fs/stat.c 108 sys_newfstat get file status fs/stat.c
109 olduname get name and information about current kernel^ arch/i386/kernel/sys_i386.c 110 iopl change I/O privilege level arch/i386/kernel/ioport.c
111 vhangup virtually hangup the current tty^ fs/open.c 112 idle make process 0 idle^ arch/i386/kernel/process.c
113 vm86old enter virtual 8086 mode^ arch/i386/kernel/vm86.c
114 wait4 wait for process termination, BSD style^ kernel/exit.c 115 swapoff stop swapping to file/device mm/swapfile.c
116 sysinfo returns information on overall system statistics^ kernel/info.c 117 ipc System V IPC system calls arch/i386/kernel/sys_i386.c
118 fsync
synchronize a file's complete in-core state with that on disk
fs/buffer.c
119 sigreturn
return from signal handler and cleanup stack frame
arch/i386/kernel/signal.c
120 clone create a child process arch/i386/kernel/process.c
121 setdomainname set domain name^ kernel/sys.c 122 uname get name and information about current kernel kernel/sys.c
123 modify_ldt get or set ldt^ arch/i386/kernel/ldt.c
124 adjtimex tune kernel clock^ kernel/time.c
125 mprotect set protection of memory mapping^ mm/mprotect.c 126 sigprocmask POSIX signal handling functions^ kernel/signal.c
127 create_module create a loadable module entry^ kernel/module.c
128 init_module initialize a loadable module entry^ kernel/module.c 129 delete_module delete a loadable module entry kernel/module.c