frv: resurrect port somehow, totally untested
[uclibc-ng.git] / test / misc / bug-readdir1.c
bloba8594a82eace619245941062571add8a15aafe20
1 #include <dirent.h>
2 #include <errno.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6 #include <sys/types.h>
9 int
10 main (void)
12 DIR *dirp;
13 struct dirent* ent;
15 /* open a dir stream */
16 dirp = opendir ("/tmp");
17 if (dirp == NULL)
19 if (errno == ENOENT)
20 exit (0);
22 perror ("opendir");
23 exit (1);
26 /* close the directory file descriptor, making it invalid */
27 if (close (dirfd (dirp)) != 0)
29 puts ("could not close directory file descriptor");
30 /* This is not an error. It is not guaranteed this is possible. */
31 return 0;
34 ent = readdir (dirp);
36 return ent != NULL || errno != EBADF;