当我想打开一个没有缓冲区的文件时,我将包含头文件
fcntl.h
并编写如下程序:
#include <fcntl.h>
int main(){
int fd = open("path/to/onefile",O_RDONLY);
//some statements not important
close(fd);
return 0;
}
但是,谁实现这个功能很混乱
open
。open
的定义如下所示:
MOV rax, OPEN_NUM; // OPEN_NUM is a number of syscall
... // some instructions which set other related register
syscall // trigger syscall entry point
... // return from syscall
但是,哪里可以找到函数的定义
open
?
https://github.com/torvalds/linux/blob/master/fs/open.c#L1434你可以在linux源码树中找到源代码~