problem with errno in readdir64_r() and readdir_r()

Filippo ARCIDIACONO filippo.arcidiacono at st.com
Mon Mar 30 14:39:32 UTC 2009


 

> -----Original Message-----
> From: Kövesdi György [mailto:kgy at teledigit.hu] 
> Sent: Monday, March 30, 2009 10:07 AM
> To: Carmelo AMOROSO
> Cc: Filippo ARCIDIACONO; uclibc at uclibc.org
> Subject: Re: problem with errno in readdir64_r() and readdir_r()
> 
> > > 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.
In my sh4 arch I got the following results:
# gcc -Wall -o test test.c 
# ./test
name: '.'
name: '..'
name: '..'
result: Invalid argument

> 
> Sorry for late answer.
> 
> Regards
> K. Gy.
> 
> 
> 
> 
> 
> 
> 



More information about the uClibc mailing list