seekdir.diff

mbalmer, 05/02/2008 09:14 AM

Download (1.56 KB)

View differences:

readdir.c Fri May 2 10:27:18 2008
51 51
 * get next entry in a directory.
52 52
 */
53 53
struct dirent *
54
_readdir_unlocked(DIR *dirp)
54
_readdir_unlocked(DIR *dirp, int skipdeleted)
55 55
{
56 56
	struct dirent *dp;
57 57
	long dummy;
......
73 73
		if (_DIRENT_DIRSIZ(dp) > dirp->dd_len + 1 - dirp->dd_loc)
74 74
			return (NULL);
75 75
		dirp->dd_loc += _DIRENT_DIRSIZ(dp);
76
		if (dp->d_ino == 0)
76
		if (dp->d_ino == 0 && skipdeleted)
77 77
			continue;
78 78
		if (dp->d_type == DT_WHT && (dirp->dd_flags & DTF_HIDEW))
79 79
			continue;
......
88 88

  
89 89
	if (__isthreaded)
90 90
		_pthread_mutex_lock((pthread_mutex_t *)&dirp->dd_lock);
91
	dp = _readdir_unlocked(dirp);
91
	dp = _readdir_unlocked(dirp, 0);
92 92
	if (__isthreaded)
93 93
		_pthread_mutex_unlock((pthread_mutex_t *)&dirp->dd_lock);
94 94

  
......
105 105
	errno = 0;
106 106
	if (__isthreaded)
107 107
		_pthread_mutex_lock((pthread_mutex_t *)&dirp->dd_lock);
108
	if ((dp = _readdir_unlocked(dirp)) != NULL)
108
	if ((dp = _readdir_unlocked(dirp, 0)) != NULL)
109 109
		memcpy(entry, dp, _DIRENT_MINSIZ(dp));
110 110
	if (__isthreaded)
111
		_pthread_mutex_unlock((pthread_mutex_t *)&dirp->dd_lock);
111
		_pthread_mutex_unlock((pthread_mutex_t *)&dirp->dd_lock, 0);
112 112

  
113 113
	if (errno != 0) {
114 114
		if (dp == NULL) {
115
-- telldir.c.orig	Fri May  2 10:25:58 2008
115
++ telldir.c	Fri May  2 10:26:02 2008
......
148 148
	 * load a new buffer or for dd_loc to not match directly.
149 149
	 */
150 150
	while (dirp->dd_loc < lp->loc_loc && dirp->dd_seek == lp->loc_seek) {
151
		dp = _readdir_unlocked(dirp);
151
		dp = _readdir_unlocked(dirp, 1);
152 152
		if (dp == NULL)
153 153
			break;
154 154
	}