2014-10-30 25 views
0

我觀察到的系統調用「STAT」與電話不同的方式來調用系統調用

stat() 

syscall(__NR_stat) 

我不明白,爲什麼同一個系統調用行爲不同只是 因爲方法來調用它改變了行爲不同?

+0

具體有什麼區別? – tangrs 2014-10-30 11:14:41

回答

0

如果是C代碼,那麼你應該認識到,你有一些語法錯誤。 但無論如何,在平臺上可能會有__NR_stat marcro的不同值。爲了找出這個問題,你必須看到/usr/include/unistd.h文件。誰知道調用這些函數的順序是什麼? 請給我們更多的信息。

1

Linux上的C庫提供的stat()通常在內核的sys_stat64()之上實現。

這是在許多情況下,man page應該是你的第一參考之一:

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庫,並通過它查找實際執行包裝。