-
Notifications
You must be signed in to change notification settings - Fork 4
/
kernsyscall.html
49 lines (44 loc) · 1.63 KB
/
kernsyscall.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<html>
<font face="helvetica">
<title>System Calls</title>
<body>
<p align=center><font size=+5>System Calls</font>
<hr>
<a href="contents.html">Contents</a>
<font size=+3>
<p>System call entry points are in <font face="monospace">include/linux/syscalls.h</font>
(with a lot of scary looking and grep-defying macros).
<p>Many of these will correspond fairly directly with some
glibc functions you're probably already familiar with:
<font face="monospace">open, close, read, write, chown,
kill, mount,</font> and so on.
<p>For example, the open() system call is defined in
<font face="monospace">fs/open.c</font> (using a macro
<font face="monospace">
SYSCALL_DEFINE3</font>
which is defined in <font face="monospace">include/linux/syscalls.h</font>):
<font face="monospace">
<pre>
SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)
{
long ret;
if (force_o_largefile())
flags |= O_LARGEFILE;
ret = do_sys_open(AT_FDCWD, filename, flags, mode);
[...]
</pre>
</font>
<p>If you're looking for a syscall entry point, you can grep for <font face="monospace">SYSCALL_DEFINE</font>.
For example, suppose you want to know where the "unlink" system call is defined:
<font face="monospace">
<pre>
[scameron@localhost linux-3.9-rc4]$ find . -name '*.c' -print | xargs grep SYSCALL_DEFINE | grep unlink
./ipc/mqueue.c:SYSCALL_DEFINE1(mq_unlink, const char __user *, u_name)
./fs/namei.c:SYSCALL_DEFINE3(unlinkat, int, dfd, const char __user *, pathname, int, flag)
./fs/namei.c:SYSCALL_DEFINE1(unlink, const char __user *, pathname)
[scameron@localhost linux-3.9-rc4]$
</pre>
</font>
</font>
</body>
</html>