syscall、sys_open 或 open 哪个是?
我认为 sys_open 是规范的系统调用,
即那些以 sys_ 为前缀的系统调用。
但是 strace
应该记录所有系统调用,输出 open
作为系统调用(非前缀版本),我很困惑......
哪一个是系统调用? ?
I think sys_open
is the canonical syscall,
that is,those prefixed with sys_
.
but strace
which is supposed to log all syscalls, outputs open
as the syscall(non prefixed version),and I'm confused...
Which one is syscall at all??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
引用 Brian W. Kernighan 和 Rob Pike,摘自“UNIX 编程环境”,第 44 页:
该系统调用称为
read
,为了让程序员变得简单,C 标准库中的相应函数具有相同的名称。另一方面,只有少数人(即那些破解内核的人)对 sys_read 这个名称感兴趣。它的名字只是被认为是操作系统的一个实现细节。
Quoting Brian W. Kernighan and Rob Pike, from “The UNIX Programming Environment”, page 44:
The system call is called
read
, and to make things simple for the programmer, the corresponding function from the C Standard Library has the same name.The name
sys_read
, on the other hand, is only interesting to a few people, namely those who hack the kernel. Its name is just considered an implementation detail of the operating system.我假设您在这里谈论的是 C 或 C++。任何相关语言标准均未强制要求
sys_open()
和open()
为“系统调用”。然而,在大多数(所有?)*NIX(包括 Linux、Mac OS X、BSD 等)上,open()
是一个系统调用。据我所知,
sys_open()
是 Linux 所独有的,并且是作为open()
之上的一层实现的。I'm assuming you're talking about C or C++, here. Neither
sys_open()
noropen()
is mandated by any relevant language standard to be a "system call." However, on most (all?) *NIXes (including Linux, Mac OS X, BSD, etc.)open()
is a system call.To my knowledge,
sys_open()
is unique to Linux, and is implemented as a layer on top ofopen()
.