System calls

From WhitixDoc

Jump to: navigation, search

In Whitix, the system calls are the services provided by the kernel; it is essentially a kernel API. In general, these system functions are wrapped by C functions in the librtl library, but it is possible to use system calls directly.

Contents

Call method

Unlike in Linux, parameters are passed through the stack rather than registers. However, for a system call to succeed, several registers must contain certain values:

Register Value
eax System call index. See the list
ecx Number of bytes in argument stack
edx Address of argument stack.

With the argument stack laid out in the typical C way (last argument pushed first and so on), an int $0x30 is then issued. After the system call returns (if it does), a return value is placed in eax.

List

There is a list of system calls in kernel/sys.c and user/librtl/sysdefs.h. This is a complete list, with links to the description of each system function.

Filesystem

eax Name Source First arg. Second arg. Third arg. Fourth arg.
0 SysOpen fs/vfs/file.c char* int int -
1 SysCreateDir fs/vfs/dir.c char* int - -
2 SysClose fs/vfs/file.c int - - -
3 SysRemove fs/vfs/file.c char* - - -
4 SysRemoveDir fs/vfs/dir.c char* - - -
5 SysFileAccess fs/vfs/file.c char* int - -
6 SysFileDup fs/vfs/file.c int - - -
7 SysFileSync fs/vfs/file.c int - - -
8 SysFileSystemSync fs/vfs/vcache.c - - - -
9 SysTruncate fs/vfs/file.c int size_t - -
10 SysMove fs/vfs/file.c char* char* - -
11 SysWrite fs/vfs/file.c int char* size_t -
12 SysRead fs/vfs/file.c int char* size_t -
13 SysSeek fs/vfs/file.c int size_t int -
14 SysChangeDir fs/vfs/dir.c char* - - -
15 SysChangeRoot fs/vfs/dir.c char* - - -
16 SysMount fs/vfs/super.c char* char* char* void*
17 SysUnmount fs/vfs/super.c char* - - -
18 SysGetDirEntries fs/vfs/dir.c int void* size_t -
19 SysGetCurrDir fs/vfs/dir.c char* size_t - -
20 SysStat fs/vfs/file.c char* struct Stat* - -
21 SysStatFd fs/vfs/file.c int struct Stat* - -
22 SysIoCtl fs/vfs/file.c int unsigned long void* -
23 SysPoll fs/vfs/poll.c void* unsigned long int -
24 SysPipe fs/vfs/pipe.c int* - - -

Memory

Task management

Time

eax Name Source First arg.
41 SysGetTime arch/i386/kernel/time.c struct Time*

Network

eax Name Source First arg. Second arg. Third arg. Fourth arg.
42 SysSocketCreate net/socket.c int int int -
43 SysSocketBind net/socket.c int void* int -
44 SysSocketConnect net/socket.c int void* int -
This short article needs expansion or improvement. Why not help?

Miscellaenous

eax Name Source First arg.
51 SysShutdown kernel/reboot.c int
52 SysIoAccess arch/i386/kernel/ioperms.c int
Personal tools