This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

implementation of opendir and readdir


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]