Pregunta

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?

¿Fue útil?

Solución

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:

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top