problem with errno in readdir64_r() and readdir_r()

Kövesdi György kgy at teledigit.hu
Mon Mar 30 08:06:45 UTC 2009


> > If there is a bug you should provide a simlpe test case that raise the
> > problem.
This is my test program:

#include <stdio.h>
#include <dirent.h>
#include <errno.h>
int main()
{
    struct dirent entry, *ent_p=&entry;
    DIR* dir = opendir("./empty");
    int result;
    while (ent_p) {
        errno = EINVAL;
        result = readdir_r(dir, &entry, &ent_p);
        if (!result) printf("name: '%s'\n", entry.d_name);
        else printf("returned %d\n", result);
    }
    perror("result");
    closedir(dir);
    return 0;
}

It opens a directory called ./empty, which must be created before run:

$> mkdir ./empty

It is compiled natively this way:

$> gcc -Wall -o test test.c

The result is:

$> ./test
name: '.'
name: '..'
returned 22
result: Invalid argument

The error message depends on the value of the errno before the function 
readdir_r() is called.

Sorry for late answer.

Regards
K. Gy.








More information about the uClibc mailing list