aboutsummaryrefslogtreecommitdiff
path: root/io/tst-fstatat.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-01-22 00:57:24 +0000
committerUlrich Drepper <drepper@redhat.com>2006-01-22 00:57:24 +0000
commitbdc7e223aaced59cd03436e1518845db011fba4b (patch)
tree51323b0689ccb4fa33978808e61009e2231f31ae /io/tst-fstatat.c
parentb2680b0331f23ae44f259ecf6c0016e5644c36b6 (diff)
downloadglibc-bdc7e223aaced59cd03436e1518845db011fba4b.tar
glibc-bdc7e223aaced59cd03436e1518845db011fba4b.tar.gz
glibc-bdc7e223aaced59cd03436e1518845db011fba4b.tar.bz2
glibc-bdc7e223aaced59cd03436e1518845db011fba4b.zip
* sysdeps/unix/sysv/linux/renameat.c (__atfct_seterrno_2): Correcty
return EBADF for non-existing file descriptors. * sysdeps/unix/sysv/linux/openat.c (__atfct_seterrno): Likewise. * io/tst-openat.c (do_test): Add some more tests. * io/tst-faccessat.c (do_test): Likewise. * io/tst-renameat.c (do_test): Likewise. * io/tst-fstatat.c (do_test): Likewise. * io/tst-fchmodat.c (do_test): Likewise. * io/tst-fchownat.c (do_test): Likewise.
Diffstat (limited to 'io/tst-fstatat.c')
-rw-r--r--io/tst-fstatat.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/io/tst-fstatat.c b/io/tst-fstatat.c
index 6ddf30d87b..5493102167 100644
--- a/io/tst-fstatat.c
+++ b/io/tst-fstatat.c
@@ -97,6 +97,20 @@ do_test (void)
puts ("file created");
struct stat64 st1;
+
+ /* Before closing the file, try using this file descriptor to open
+ another file. This must fail. */
+ if (fstatat64 (fd, "some-file", &st1, 0) != -1)
+ {
+ puts ("fstatatat using descriptor for normal file worked");
+ return 1;
+ }
+ if (errno != ENOTDIR)
+ {
+ puts ("error for fstatat using descriptor for normal file not ENOTDIR ");
+ return 1;
+ }
+
if (fstat64 (fd, &st1) != 0)
{
puts ("fstat64 failed");
@@ -137,7 +151,38 @@ do_test (void)
return 1;
}
+ /* Create a file descriptor which is closed again right away. */
+ int dir_fd2 = dup (dir_fd);
+ if (dir_fd2 == -1)
+ {
+ puts ("dup failed");
+ return 1;
+ }
+ close (dir_fd2);
+
+ if (fstatat64 (dir_fd2, "some-file", &st1, 0) != -1)
+ {
+ puts ("fstatat64 using closed descriptor worked");
+ return 1;
+ }
+ if (errno != EBADF)
+ {
+ puts ("error for fstatat using closed descriptor not EBADF ");
+ return 1;
+ }
+
close (dir_fd);
+ if (fstatat64 (-1, "some-file", &st1, 0) != -1)
+ {
+ puts ("fstatat64 using invalid descriptor worked");
+ return 1;
+ }
+ if (errno != EBADF)
+ {
+ puts ("error for fstatat using invalid descriptor not EBADF ");
+ return 1;
+ }
+
return 0;
}