This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
implementation of opendir and readdir
- From: "Li, Yang" <YLi at ballytech dot com>
- To: "libc-help at sourceware dot org" <libc-help at sourceware dot org>
- Date: Wed, 4 Sep 2013 17:30:00 +0000
- Subject: implementation of opendir and readdir
- Authentication-results: sourceware.org; auth=none
Hi,
I am in the process of implementing some customized file system. I am wondering how the call stack works when a user calls opendir and readdir.
When I exam the source code:
glibc-2.18/dirent/readdir.c
I see the following:
----------------------------------------
struct dirent *
__readdir (DIR *dirp)
{
__set_errno (ENOSYS);
return NULL;
}
weak_alias (__readdir, readdir)
-------------------------------------------
Basically, the implementation just returned NULL>
There is a file under the linux kernel:
linux3.11/fs/readdir.c, which has some functions defined. The implementation varies according to the versions.
So my first question is, when a user called "readdir", which function is it actually linked to? How does the linker know not to link against "glibc" and link to some kernel provided library?
Now to the second question, "opendir" doesn't seem to be a linux system call at all. It is said to be using the "open" system call.
Similar, glibc-2.18/dirent/opendir.c just returned NULL.
So where are the actual source code for processing "opendir"?
Thanks
Yang Li
Senior Software Developer
Bally Technologies