1 --- telldir.c.orig 2009-11-08 14:02:31.000000000 -0800
2 +++ telldir.c 2009-11-08 14:02:24.000000000 -0800
3 @@ -50,7 +50,9 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/tel
4 * cookie may be used only once before it is freed. This option
5 * is used to avoid having memory usage grow without bound.
9 +#endif /* !__DARWIN_UNIX03 */
12 * return a pointer into a directory
13 @@ -61,14 +63,41 @@ telldir(dirp)
19 + _pthread_mutex_lock(&dirp->dd_lock);
20 + LIST_FOREACH(lp, &dirp->dd_td->td_locq, loc_lqe) {
22 +#if __DARWIN_64_BIT_INO_T
23 + (lp->loc_seek == dirp->dd_td->seekoff)
24 +#else /* !__DARWIN_64_BIT_INO_T */
25 + (lp->loc_seek == dirp->dd_seek)
26 +#endif /* __DARWIN_64_BIT_INO_T */
27 + && (lp->loc_loc == dirp->dd_loc))
30 + if ((lp = (struct ddloc *)malloc(sizeof(struct ddloc))) == NULL) {
32 + _pthread_mutex_unlock(&dirp->dd_lock);
35 +#else /* !__DARWIN_UNIX03 */
36 if ((lp = (struct ddloc *)malloc(sizeof(struct ddloc))) == NULL)
39 _pthread_mutex_lock(&dirp->dd_lock);
40 +#endif /* __DARWIN_UNIX03 */
41 lp->loc_index = dirp->dd_td->td_loccnt++;
42 +#if __DARWIN_64_BIT_INO_T
43 + lp->loc_seek = dirp->dd_td->seekoff;
44 +#else /* !__DARWIN_64_BIT_INO_T */
45 lp->loc_seek = dirp->dd_seek;
46 +#endif /* __DARWIN_64_BIT_INO_T */
47 lp->loc_loc = dirp->dd_loc;
48 LIST_INSERT_HEAD(&dirp->dd_td->td_locq, lp, loc_lqe);
51 +#endif /* __DARWIN_UNIX03 */
53 _pthread_mutex_unlock(&dirp->dd_lock);
54 return (lp->loc_index);
55 @@ -92,23 +121,34 @@ _seekdir(dirp, loc)
59 - if (lp->loc_loc == dirp->dd_loc && lp->loc_seek == dirp->dd_seek)
60 + if (lp->loc_loc == dirp->dd_loc &&
61 +#if __DARWIN_64_BIT_INO_T
62 + lp->loc_seek == dirp->dd_td->seekoff
63 +#else /* !__DARWIN_64_BIT_INO_T */
64 + lp->loc_seek == dirp->dd_seek
65 +#endif /* __DARWIN_64_BIT_INO_T */
68 (void) lseek(dirp->dd_fd, (off_t)lp->loc_seek, SEEK_SET);
69 +#if __DARWIN_64_BIT_INO_T
70 + dirp->dd_td->seekoff = lp->loc_seek;
71 +#else /* !__DARWIN_64_BIT_INO_T */
72 dirp->dd_seek = lp->loc_seek;
73 +#endif /* __DARWIN_64_BIT_INO_T */
75 while (dirp->dd_loc < lp->loc_loc) {
76 dp = _readdir_unlocked(dirp, 0);
83 LIST_REMOVE(lp, loc_lqe);
88 +#ifndef BUILDING_VARIANT
90 * Reclaim memory for telldir cookies which weren't used.
92 @@ -127,3 +167,4 @@ _reclaim_telldir(dirp)
94 LIST_INIT(&dirp->dd_td->td_locq);
96 +#endif /* !BUILDING_VARIANT */