繁体   English   中英

拨打系统电话的不同方式

[英]Different ways to call system calls

我观察到系统调用“ stat”与调用的行为有所不同

stat()

syscall(__NR_stat) 

我不明白为什么同一系统调用的行为方式不同,仅仅是因为调用方式发生了变化?

今天,Linux上的C库提供的stat()通常在内核的sys_stat64()之上实现。

在许多情况下, 手册页应该是您的第一个参考:

  Underlying kernel interface

   Over time, increases in the size of the stat structure have led to
   three successive versions of stat(): sys_stat() (slot __NR_oldstat),
   sys_newstat() (slot __NR_stat), and sys_stat64() (new in kernel 2.4;
   slot __NR_stat64).  The glibc stat() wrapper function hides these
   details from applications, invoking the most recent version of the
   system call provided by the kernel, and repacking the returned
   information if required for old binaries.  Similar remarks apply for
   fstat() and lstat().

您可能还需要获取已安装的C库的源程序包,并仔细查看它以寻找包装程序的实际实现。

如果是C代码,那么您应该意识到自己有一些语法错误。 但是无论如何,在平台上,__ NR_stat marcro的值可能不同。 要找出这一点,您必须查看/usr/include/unistd.h文件。 谁知道调用这些函数的顺序是什么? 请给我们更多信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM