简体   繁体   English

拨打系统电话的不同方式

[英]Different ways to call system calls

I observed that system call "stat" is behaving differently with calls 我观察到系统调用“ stat”与调用的行为有所不同

stat()

syscall(__NR_stat) 

I do not understand why same system call is behaving differently just because way to call it is changed? 我不明白为什么同一系统调用的行为方式不同,仅仅是因为调用方式发生了变化?

The stat() provided by a C library on Linux today is usually implemented on top of the kernel 's sys_stat64() . 今天,Linux上的C库提供的stat()通常在内核的sys_stat64()之上实现。

This is one of the many cases where the man page should be your first reference: 在许多情况下, 手册页应该是您的第一个参考:

  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().

You may also want to obtain the source package for your installed C library and look through it for the actual implementation of the wrapper. 您可能还需要获取已安装的C库的源程序包,并仔细查看它以寻找包装程序的实际实现。

If it is C code, then you should realize, that you have some syntax errors. 如果是C代码,那么您应该意识到自己有一些语法错误。 But anyway, on platforms there may be different values of __NR_stat marcro. 但是无论如何,在平台上,__ NR_stat marcro的值可能不同。 To find out this, you have to see /usr/include/unistd.h file. 要找出这一点,您必须查看/usr/include/unistd.h文件。 And who knows what's the sequencies of calling these functions? 谁知道调用这些函数的顺序是什么? Please, give us more information. 请给我们更多信息。

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

相关问题 加快对依赖耗时系统调用的程序的测试的方法 - Ways to speed up testing of programs that rely on time consuming system calls 是否有系统调用函数,其定义调用另一个系统调用函数? - Is there a system call function whose definition calls another system call function? 在 Linux 上跟踪 libc 和系统调用函数调用? - Trace libc and system call function calls on Linux? 为什么系统调用使用不同的堆栈? - Why do system calls use a different stack? 为什么Linux系统调用跨架构不同 - Why are linux system calls different across architectures 确保在所有先前的系统调用之后运行系统调用 - Making sure system call is run after all previous system calls Linux中的每个Shell命令是否都会在后端调用系统调用 - Does Every Shell command in linux calls a system call at the back end 为什么mkdir()和rmdir()POSIX系统调用不同的头文件? - Why are the mkdir() and rmdir() POSIX system calls in different header files? 多个system()调用在不同的线程/进程中工作吗? - Does multiple system() calls works in different thread/processes? 通过两种不同的方式用相同的参数调用fopen后,返回值不同 - The return value is different after call fopen with same arguments by two different ways
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM