說明System Call
更新記錄
item | note |
---|---|
20160613 | 第一版 |
目錄
system call
- 通過library使用方式如下圖
- Invoking the system call handler and executing a system call,來源
- 出處-系统调用
- 一般app都是通過library來呼叫kernl的system call
- ex. unistd.h (unix standard)
- 也可以直接呼叫kernl的system call
- ex.使用ioctl
linux kernel system call
於kernel, arch/arm/include/asm/unistd.h內有定義system call number
system call number
1 |
|
cpu system table">比對cpu system table
name | register r7 |
---|---|
restart_syscall | 0x900000 |
exit | 0x900001 |
fork | 0x900002 |
read | 0x900003 |
write | 0x900004 |
通過ioctl的參數傳遞
- 來源 ldd3 chapter5
- 系統呼叫需檢查所有的參數,以確保它們是有效且合法的
系統提供了兩個方法來進行必要的檢查,及在kernel space及user space之間進行所需要的複製
copy_to_user: Copy a block of data into user space.
1 | unsigned long copy_to_user ( void __user * to, |
parameter | description |
---|---|
to | Destination address,in user space |
from | Source address, in kernel space |
n | Number of bytes to copy. |
- copy_from_user: Copy a block of data from user space.
1 | unsigned long copy_from_user ( void * to, |
parameter | description |
---|---|
to | Destination address, in kernel space |
from | Source address, in user space |
n | Number of bytes to copy. |