2010-03-09 Jeff Johnston <jjohnstn@redhat.com>
* libc/posix/telldir.c (dd_loccnt): Change start index to be 1 instead of 0. (_seekdir): A loc of 0 now means rewind dir.
This commit is contained in:
parent
e8190d8fbf
commit
fab7d5988a
@ -1,3 +1,9 @@
|
|||||||
|
2010-03-09 Jeff Johnston <jjohnstn@redhat.com>
|
||||||
|
|
||||||
|
* libc/posix/telldir.c (dd_loccnt): Change start index to be 1
|
||||||
|
instead of 0.
|
||||||
|
(_seekdir): A loc of 0 now means rewind dir.
|
||||||
|
|
||||||
2010-03-08 Craig Howland <howland@LGSInnovations.com>
|
2010-03-08 Craig Howland <howland@LGSInnovations.com>
|
||||||
|
|
||||||
* libm/common/s_rint.c: Fix error when integral part had 18 bits and
|
* libm/common/s_rint.c: Fix error when integral part had 18 bits and
|
||||||
|
@ -67,7 +67,7 @@ struct ddloc {
|
|||||||
#define NDIRHASH 32 /* Num of hash lists, must be a power of 2 */
|
#define NDIRHASH 32 /* Num of hash lists, must be a power of 2 */
|
||||||
#define LOCHASH(i) ((i)&(NDIRHASH-1))
|
#define LOCHASH(i) ((i)&(NDIRHASH-1))
|
||||||
|
|
||||||
static long dd_loccnt; /* Index of entry for sequential readdir's */
|
static long dd_loccnt = 1; /* Index of entry for sequential readdir's */
|
||||||
static struct ddloc *dd_hash[NDIRHASH]; /* Hash list heads for ddlocs */
|
static struct ddloc *dd_hash[NDIRHASH]; /* Hash list heads for ddlocs */
|
||||||
__LOCK_INIT(static, dd_hash_lock);
|
__LOCK_INIT(static, dd_hash_lock);
|
||||||
|
|
||||||
@ -123,35 +123,42 @@ _DEFUN(_seekdir, (dirp, loc),
|
|||||||
#ifdef HAVE_DD_LOCK
|
#ifdef HAVE_DD_LOCK
|
||||||
__lock_acquire(dd_hash_lock);
|
__lock_acquire(dd_hash_lock);
|
||||||
#endif
|
#endif
|
||||||
prevlp = &dd_hash[LOCHASH(loc)];
|
if (loc != 0) {
|
||||||
lp = *prevlp;
|
prevlp = &dd_hash[LOCHASH(loc)];
|
||||||
while (lp != NULL) {
|
lp = *prevlp;
|
||||||
if (lp->loc_index == loc)
|
while (lp != NULL) {
|
||||||
break;
|
if (lp->loc_index == loc)
|
||||||
prevlp = &lp->loc_next;
|
break;
|
||||||
lp = lp->loc_next;
|
prevlp = &lp->loc_next;
|
||||||
}
|
lp = lp->loc_next;
|
||||||
if (lp == NULL) {
|
}
|
||||||
|
if (lp == NULL) {
|
||||||
#ifdef HAVE_DD_LOCK
|
#ifdef HAVE_DD_LOCK
|
||||||
__lock_release(dd_hash_lock);
|
__lock_release(dd_hash_lock);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (lp->loc_loc == dirp->dd_loc && lp->loc_seek == dirp->dd_seek)
|
if (lp->loc_loc == dirp->dd_loc && lp->loc_seek == dirp->dd_seek)
|
||||||
goto found;
|
goto found;
|
||||||
(void) lseek(dirp->dd_fd, lp->loc_seek, 0);
|
(void) lseek(dirp->dd_fd, lp->loc_seek, 0);
|
||||||
dirp->dd_seek = lp->loc_seek;
|
dirp->dd_seek = lp->loc_seek;
|
||||||
dirp->dd_loc = 0;
|
dirp->dd_loc = 0;
|
||||||
while (dirp->dd_loc < lp->loc_loc) {
|
while (dirp->dd_loc < lp->loc_loc) {
|
||||||
dp = readdir(dirp);
|
dp = readdir(dirp);
|
||||||
if (dp == NULL)
|
if (dp == NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
found:
|
found:
|
||||||
#ifdef SINGLEUSE
|
#ifdef SINGLEUSE
|
||||||
*prevlp = lp->loc_next;
|
*prevlp = lp->loc_next;
|
||||||
free((caddr_t)lp);
|
free((caddr_t)lp);
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
// loc 0 means rewinding
|
||||||
|
(void) lseek(dirp->dd_fd, 0, 0);
|
||||||
|
dirp->dd_seek = 0;
|
||||||
|
dirp->dd_loc = 0;
|
||||||
|
}
|
||||||
#ifdef HAVE_DD_LOCK
|
#ifdef HAVE_DD_LOCK
|
||||||
__lock_release(dd_hash_lock);
|
__lock_release(dd_hash_lock);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user