diff options
author | Eric Blake <ebb9@byu.net> | 2009-10-06 06:58:08 -0600 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2009-10-06 22:06:49 -0600 |
commit | dfbec8be94ca116ce40c04f88302329505dbb745 (patch) | |
tree | e25ce6c31551b711f784d927aa215860370c4d04 /tests/test-fdopendir.c | |
parent | 48b0feac54dce2caf46cc53dd160e699737ff52a (diff) | |
download | gnulib-dfbec8be94ca116ce40c04f88302329505dbb745.tar.gz |
fdopendir: fix GNU/Hurd bug
fdopendir(open("file",O_RDONLY)) mistakenly succeeded, with
subsequent readdir() failing with ENOTDIR.
* m4/fdopendir.m4 (gl_FUNC_FDOPENDIR): Check for Hurd bug in
allowing non-directory fds.
* lib/fdopendir.c (rpl_fdopendir): Work around it.
* m4/dirent_h.m4 (gl_DIRENT_H_DEFAULTS): New witness.
* modules/dirent (Makefile.am): Substitute it.
* lib/dirent.in.h (fdopendir): Declare replacement.
* doc/posix-functions/fdopendir.texi (fdopendir): Document this.
* tests/test-fdopendir.c (main): Test something other than
/dev/null, since on Hurd that behaves like a directory.
Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'tests/test-fdopendir.c')
-rw-r--r-- | tests/test-fdopendir.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/test-fdopendir.c b/tests/test-fdopendir.c index 003a279725..330544c5d6 100644 --- a/tests/test-fdopendir.c +++ b/tests/test-fdopendir.c @@ -45,12 +45,13 @@ main () int fd; /* A non-directory cannot be turned into a directory stream. */ - fd = open ("/dev/null", O_RDONLY); + fd = open ("test-fdopendir.tmp", O_RDONLY | O_CREAT, 0600); ASSERT (0 <= fd); errno = 0; ASSERT (fdopendir (fd) == NULL); ASSERT (errno == ENOTDIR); ASSERT (close (fd) == 0); + ASSERT (unlink ("test-fdopendir.tmp") == 0); /* A bad fd cannot be turned into a stream. */ errno = 0; |