Wrapper for open() and open64() and see that system calls by vi uses open64()

岁酱吖の 提交于 2019-12-23 02:43:19

问题


I have written wrappers for both open() and open64(). Now I run vi by preloading my wrapper library using LD_PRELOAD environment variable and I see that the open64() wrapper is used instead of the open(). But when I strace vi I see that the system calls made is to open() (of course including the other system calls). What is the issue here?


回答1:


The strace utility traces system calls (syscall) and open happens to be both a syscall and a library function. Both the open() and open64() library functions use the open syscall internally to request services from the kernel. It is my understanding that using open() with the O_LARGEFILE flag is equivalent to using open64() to support large files in 32-bit applications.


If the call to open64() were to call the open() function internally, your open() wrapper would not be called because you cannot interpose internal library function calls. They are resolved before runtime.




回答2:


Are you running on a 64 bit system? If so then this is no surprise. strace traces the actuall syscalls, not which functions in a library are called. On 64 bit systems open and open64 are implemented by the same syscall.



来源:https://stackoverflow.com/questions/5245306/wrapper-for-open-and-open64-and-see-that-system-calls-by-vi-uses-open64

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!