哪里位于glibc的源系统调用 [英] Where are syscalls located in glibc source
问题描述
所以我一直在寻找通过Linux的glibc源,我没有看到它实际上做任何事情。以下是从 IO / chdir.c
,但它表明许多源文件的。这里发生了什么?显然,我失去了一些东西。秘诀是什么,它在哪里进行系统调用或实际做点什么?
stub_warning
是一些旧的疯狂。 __ set_errno
似乎是一个简单的宏,设置错误号
。虽然我找到一万个用法 weak_alias
我没有看到它的任何地方定义。
是否有有益的指导,了解glibc的是如何工作的地方吗?
的#include<&errno.h中GT;
#包括LT&;&STDDEF.H GT;
#包括LT&;&unistd.h中GT;/ *将当前目录切换到路径。 * /
INT
__chdir(路径)
为const char *路径;
{
如果(路径== NULL)
{
__set_errno(EINVAL);
返回-1;
} __set_errno(ENOSYS);
返回-1;
}
stub_warning(CHDIR)weak_alias(__chdir,CHDIR)
#包括LT&;存根tag.h>
什么你发现是它没有实现对系统的存根功能。你需要在 sysdeps看
树的实际执行情况。以下可能感兴趣的:
-
sysdeps / UNIX / SYSV / Linux的
-
sysdeps / POSIX
-
sysdeps / I386
(或x86_64的
或任何你的CPU拱)
So I was looking through the linux glibc source and I don't see where it actually does anything. The following is from io/chdir.c
but it is indicative of many of the source files. What's going on here? Obviously I am missing something. What's the secret, where does it make a system call or actually do something?
stub_warning
is some legacy craziness. __set_errno
seems to be a simple macro that sets errno
. And while I find a million usages of weak_alias
I don't see it defined anywhere.
Is there a helpful guide to understanding how glibc works somewhere?
#include <errno.h>
#include <stddef.h>
#include <unistd.h>
/* Change the current directory to PATH. */
int
__chdir (path)
const char *path;
{
if (path == NULL)
{
__set_errno (EINVAL);
return -1;
}
__set_errno (ENOSYS);
return -1;
}
stub_warning (chdir)
weak_alias (__chdir, chdir)
#include <stub-tag.h>
What you've found is a stub function for systems it's not implemented on. You need to look under the sysdeps
tree for the actual implementation. The following may be of interest:
sysdeps/unix/sysv/linux
sysdeps/posix
sysdeps/i386
(orx86_64
or whatever your cpu arch is)
这篇关于哪里位于glibc的源系统调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!