2

On OSX 10.9 (a 64 bit OS) I run the command

sudo dtruss pwd

to get the list of system calls performed by the pwd command. I see that the system call stat64 is executed several times like this:

stat64("/usr/lib/system/libsystem_kernel.dylib\0", 0x7FFF5F7B4E28, 0x7FFF5F7B5CC0)       = 0 0

Now, in both the online POSIX standard documentation and Apple documentation, I see that stat64 takes 2 parameters. Why does it take 3 parameters in my case?

UndefinedBehavior
  • 836
  • 1
  • 11
  • 20

1 Answers1

1

The C library call stat64 is just a wrapper(and this) around the system call. They don't have to match in the number of arguments although in the case of linux for example it seems like they mostly do(I can't find a similar reference for BSD), although a notable exception would be fork which is implemented as a call to the clone system call.

Update

I can not find the equivalent for OSX but if we look at the syscalls man page for Linux is says:

Over time, changes to the interfaces of some system calls have been necessary. One reason for such changes was the need to increase the size of structures or scalar values passed to the system call. Because of these changes, there are now various groups of related system calls (e.g., truncate(2) and truncate64(2)) which perform similar tasks, but which vary in details such as the size of their arguments. (As noted earlier, applications are generally unaware of this: the glibc wrapper functions do some work to ensure that the right system call is invoked, and that ABI compatibility is preserved for old binaries.) Examples of systems calls that exist in multiple versions are the following:

Community
  • 1
  • 1
Shafik Yaghmour
  • 154,301
  • 39
  • 440
  • 740
  • This is definitely a good point, but still there is something that escapes me. According to 'man dtruss', the dtruss command shows details of the system calls, so stat64 system call seems to take 3 arguments; but according to 'man 2 stat', stat and stat64 system calls (section 2 of man is about system calls) take only 2 arguments. Which one is lying? Or rather: what am I missing here? Moreover section 3 of man (which is about C library functions) doesn't contain a page about stat/stat64 (but this could be just a shortcoming of the manual itself). – UndefinedBehavior Feb 02 '14 at 23:00
  • @UndefinedBehavior updated my answer, I did not receive a notification of your comment, which is odd. – Shafik Yaghmour Feb 03 '14 at 03:47