repo.or.cz
/
glibc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Update.
[glibc.git]
/
dirent
/
bug-readdir1.c
blob
f9c609cc984612bf954204af4e2096500455e944
1
#include <dirent.h>
2
#include <errno.h>
3
#include <errno.h>
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <sys/types.h>
7
8
9
int
10
main
(
void
)
11
{
12
DIR
*
dirp
;
13
struct
dirent
*
ent
;
14
15
/* open a dir stream */
16
dirp
=
opendir
(
"/tmp"
);
17
if
(
dirp
==
NULL
)
18
{
19
if
(
errno
==
ENOENT
)
20
exit
(
0
);
21
22
perror
(
"opendir"
);
23
exit
(
1
);
24
}
25
26
/* close the dir stream, making it invalid */
27
if
(
closedir
(
dirp
))
28
{
29
perror
(
"closedir"
);
30
exit
(
1
);
31
}
32
33
ent
=
readdir
(
dirp
);
34
35
return
ent
!=
NULL
||
errno
!=
EBADF
;
36
}