冗余 Linux 内核系统调用
我目前正在开发一个项目,该项目挂钩各种系统调用并将内容写入日志,具体取决于调用的是哪个系统调用。 因此,例如,当我更改文件的权限时,我会向日志文件写入一个小条目来跟踪旧权限和新权限。 然而,我在确定我应该观看的确切位置时遇到了一些困难。 对于上面的示例,strace 告诉我“chmod”命令使用系统调用 sys_fchmodat()。 但是,还有 sys_chmod() 和 sys_fchmod()。
我确信内核开发人员知道他们在做什么,但我想知道:所有这些(看似)冗余的系统调用的意义是什么?对于哪些系统调用的用途有什么规则吗? (即“at”系统调用或前缀为“f”的系统调用是否意味着执行特定操作?)
I'm currently working on a project that hooks into various system calls and writes things to a log, depending on which one was called. So, for example, when I change the permissions of a file, I write a little entry to a log file that tracks the old permission and new permission. However, I'm having some trouble pinning down exactly where I should be watching. For the above example, strace tells me that the "chmod" command uses the system call sys_fchmodat(). However, there's also a sys_chmod() and a sys_fchmod().
I'm sure the kernel developers know what they're doing, but I wonder: what is the point of all these (seemingly) redundant system calls, and is there any rule on which ones are used for what? (i.e. are the "at" syscalls or ones prefixed with "f" meant to do something specific?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
历史记录:-)
一旦创建了系统调用,就无法更改,因此当需要新功能时,就会创建新的系统调用。 (当然,这意味着创建新的系统调用之前有一个非常高的门槛)。
History :-)
Once a system call has been created it can't ever be changed, therefore when new functionality is required a new system call is created. (Of course this means there's a very high bar before a new system call is created).
是的,有一些命名规则。
Yes, there are some naming rules.