This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Hi! seekdir does not update dirp->filepos, so if there is no intervening readdir call, following telldir will return position before seekdir call, not after it. If _DIRENT_HAVE_D_OFF is not defined, telldir will give bogus answers from that point onwards until closedir. 2001-08-07 Jakub Jelinek <jakub@redhat.com> * sysdeps/unix/seekdir.c (seekdir): Set dirp->filepos. * dirent/tst-seekdir.c (main): Check whether telldir right after seekdir returns 2nd argument given to seekdir. --- libc/dirent/tst-seekdir.c.jj Mon Jan 8 12:58:05 2001 +++ libc/dirent/tst-seekdir.c Tue Aug 7 16:57:33 2001 @@ -7,8 +7,8 @@ main (int argc, char *argv[]) { DIR * dirp; - long int save3 = 0; - int i = 0; + long int save3 = 0, cur; + int i = 0, result = 0; struct dirent *dp; dirp = opendir("."); @@ -31,12 +31,18 @@ main (int argc, char *argv[]) /* go back to saved entry */ seekdir (dirp, save3); + /* check whether telldir equals to save3 now */ + cur = telldir (dirp); + if (cur != save3) + { + printf ("seekdir (d, %ld); telldir (d) == %ld\n", save3, cur); + result = 1; + } /* print remaining files (3-last) */ for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) printf("%s\n", dp->d_name); - closedir (dirp); - return 0; + return result; } --- libc/sysdeps/unix/seekdir.c.jj Mon Jul 9 14:58:32 2001 +++ libc/sysdeps/unix/seekdir.c Tue Aug 7 16:59:04 2001 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1995-1997, 1999, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -33,5 +33,6 @@ seekdir (dirp, pos) (void) __lseek(dirp->fd, pos, SEEK_SET); dirp->size = 0; dirp->offset = 0; + dirp->filepos = pos; __libc_lock_unlock (dirp->lock); } Jakub
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |