summaryrefslogtreecommitdiff
path: root/dirent
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-01-16 06:26:38 +0000
committerUlrich Drepper <drepper@redhat.com>2005-01-16 06:26:38 +0000
commit125a8cf7ff1dadf295bd992d10a5115160be2409 (patch)
treea5ceb06fcede11e522d87bfbd134050b22a4c0be /dirent
parent805ed74c10b7399f6bbee89939a80ddec252abcb (diff)
downloadglibc-125a8cf7ff1dadf295bd992d10a5115160be2409.tar.gz
* sysdeps/unix/rewinddir.c: Reset filepos.
* dirent/tst-seekdir.c: Check telldir value after calling rewinddir. 2005-01-15 Ulrich Drepper <drepper@redhat.com> * elf/tst-auditmod1.c: Reduce duplication.
Diffstat (limited to 'dirent')
-rw-r--r--dirent/tst-seekdir.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/dirent/tst-seekdir.c b/dirent/tst-seekdir.c
index b833c30705..43808fecb5 100644
--- a/dirent/tst-seekdir.c
+++ b/dirent/tst-seekdir.c
@@ -11,8 +11,23 @@ main (int argc, char *argv[])
int i = 0;
int result = 0;
struct dirent *dp;
+ long int save0;
+ long int rewind;
dirp = opendir (".");
+ if (dirp == NULL)
+ {
+ printf ("opendir failed: %m\n");
+ return 1;
+ }
+
+ save0 = telldir (dirp);
+ if (save0 == -1)
+ {
+ printf ("telldir failed: %m\n");
+ result = 1;
+ }
+
for (dp = readdir (dirp); dp != NULL; dp = readdir (dirp))
{
/* save position 3 (after fourth entry) */
@@ -44,6 +59,19 @@ main (int argc, char *argv[])
for (dp = readdir (dirp); dp != NULL; dp = readdir (dirp))
printf ("%s\n", dp->d_name);
+ /* Check rewinddir */
+ rewinddir (dirp);
+ rewind = telldir (dirp);
+ if (rewind == -1)
+ {
+ printf ("telldir failed: %m\n");
+ result = 1;
+ }
+ else if (save0 != rewind)
+ {
+ printf ("rewinddir didn't reset directory stream\n");
+ result = 1;
+ }
closedir (dirp);
return result;