[英]getnameinfo — what's syscall for it in Linux?
There's a function https://linux.die.net/man/3/getnameinfo How do I know what the syscall for it is? 有一个功能https://linux.die.net/man/3/getnameinfo我怎么知道它的系统调用是什么? There's no such a function in Linux syscall table.
Linux syscall表中没有这样的功能。 Or does exist only in that C library?
还是仅存在于该C库中?
getnameinfo
has no direct system call. getnameinfo
没有直接的系统调用。 It is a library function that performs a number of activities to fulfill the request. 它是一个库函数,它执行许多活动来满足请求。 For example, when looking up the host name, it will likely try to:
例如,当查找主机名时,它可能会尝试:
/etc/nsswitch.conf
and /etc/hosts
) /etc/nsswitch.conf
和/etc/hosts
) /etc/resolv.conf
) /etc/resolv.conf
) If you write a simple application using the getnameinfo
API correctly, you can then use the strace
utility to find out what system calls are being used. 如果正确使用
getnameinfo
API编写了一个简单的应用程序,则可以使用strace
实用程序来查找正在使用的系统调用。 There will be a lot of extra information, but if you study it carefully, you will see the relevant calls being made. 会有很多额外的信息,但是如果您仔细研究,将会看到相关的电话。 A few lines of the relevant output on my system:
我系统上相关输出的几行:
...
open("/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
...
open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
...
socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, 16) = 0
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.