Ale*_*02o 6 linux x86-64 nasm system-calls
我找到了用于x86-64模式的系统调用列表(带有参数):http : //filippo.io/linux-syscall-table/, 但是在哪里可以获取此系统调用的详细说明?
例如,在下面的示例中,除0102o(rw,create)外,哪些标志可用于“打开”系统调用,在其他情况下:只读,仅写等。
SECTION .data
message: db 'Hello, world!',0x0a
length: equ $-message
fname db "result"
fd dq 0
SECTION .text
global _start
_start:
mov rax, 2 ; 'open' syscall
mov rdi, fname ; file name
mov rsi, 0102o ; read and write mode, create if not
mov rdx, 0666o ; permissions set
syscall
mov [fd], rax
mov rax, 1 ; 'write' syscall
mov rdi, [fd] ; file descriptor
mov rsi, message ; message address
mov rdx, length ; message string length
syscall
mov rax, 3 ; 'close' syscall
mov rdi, [fd] ; file descriptor
syscall
mov rax, 60
mov rdi, 0
syscall
Run Code Online (Sandbox Code Playgroud)
基于源(可能是) https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/fs/open.c 如何理解它,其中(所有列表为开放式) )可以使用标志吗?
系统调用的文档位于手册页的第 2 部分和/或源代码的注释中。
手册页开头如下:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
Run Code Online (Sandbox Code Playgroud)
参数标志必须包含以下访问模式之一:O_RDONLY、 O_WRONLY或O_RDWR。这些请求分别以只读、只写或读/写方式打开文件。
此外,零个或多个文件创建标志和文件状态标志可以在flags中进行按位或运算。文件创建标志为O_CREAT、O_EXCL、O_NOCTTY和O_TRUNC。
这些值可以在系统头文件中轻松查找。
| 归档时间: |
|
| 查看次数: |
3420 次 |
| 最近记录: |