Linux System Call Quick Reference

ADVERTISEMENT

LINUX System Call Quick Reference
create a file or device ("man 2 open" for
fs/open.c
8
creat
information)
Jialong He
make a new name for a file
fs/namei.c
9
link
delete a name and possibly the file it refers to
fs/namei.c
10
unlink
execute program
arch/i386/kernel/process.c
11
execve
Introduction
change working directory
fs/open.c
12
chdir
System call is the services provided by Linux kernel. In C programming, it often uses functions defined in libc
get time in seconds
kernel/time.c
13
time
which provides a wrapper for many system calls. Manual page section 2 provides more information about
create a special or ordinary file
fs/namei.c
14
mknod
system calls. To get an overview, use “man 2 intro” in a command shell.
change permissions of a file
fs/open.c
15
chmod
It is also possible to invoke syscall() function directly. Each system call has a function number defined in
change ownership of a file
fs/open.c
16
lchown
<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 ”.
get file status
fs/stat.c
18
stat
System Call Example
reposition read/write file offset
fs/read_write.c
19
lseek
get process identification
kernel/sched.c
20
getpid
#include <syscall.h>
#include <unistd.h>
mount filesystems
fs/super.c
21
mount
#include <stdio.h>
unmount filesystems
fs/super.c
22
umount
#include <sys/types.h>
set real user ID
kernel/sys.c
23
setuid
int main(void) {
get real user ID
kernel/sched.c
24
getuid
long ID1, ID2;
set system time and date
kernel/time.c
25
stime
/*-----------------------------*/
allows a parent process to control the execution of
arch/i386/kernel/ptrace.c
/* direct system call
*/
26
ptrace
a child process
/* SYS_getpid (func no. is 20) */
/*-----------------------------*/
set an alarm clock for delivery of a signal
kernel/sched.c
27
alarm
ID1 = syscall(SYS_getpid);
get file status
fs/stat.c
28
fstat
printf ("syscall(SYS_getpid)=%ld\n", ID1);
suspend process until signal
arch/i386/kernel/sys_i386.c
29
pause
/*-----------------------------*/
set file access and modification times
fs/open.c
30
utime
/* "libc" wrapped system call
*/
/* SYS_getpid (Func No. is 20) */
check user's permissions for a file
fs/open.c
33
access
/*-----------------------------*/
change process priority
kernel/sched.c
34
nice
ID2 = getpid();
printf ("getpid()=%ld\n", ID2);
update the super block
fs/buffer.c
36
sync
send signal to a process
kernel/signal.c
37
kill
return(0);
}
change the name or location of a file
fs/namei.c
38
rename
create a directory
fs/namei.c
39
mkdir
System Call Quick Reference
remove a directory
fs/namei.c
40
rmdir
No Func Name Description
Source
duplicate an open file descriptor
fs/fcntl.c
41
dup
create an interprocess channel
arch/i386/kernel/sys_i386.c
42
pipe
terminate the current process
kernel/exit.c
1
exit
get process times
kernel/sys.c
43
times
create a child process
arch/i386/kernel/process.c
2
fork
change the amount of space allocated for the
mm/mmap.c
45
brk
read from a file descriptor
fs/read_write.c
3
read
calling process's data segment
write to a file descriptor
fs/read_write.c
4
write
set real group ID
kernel/sys.c
46
setgid
open a file or device
fs/open.c
5
open
get real group ID
kernel/sched.c
47
getgid
close a file descriptor
fs/open.c
ANSI C signal handling
kernel/signal.c
6
close
48
sys_signal
wait for process termination
kernel/exit.c
7
waitpid
get effective user ID
kernel/sched.c
49
geteuid
get effective group ID
kernel/sched.c
50
getegid

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 3