• Home
  • Raw
  • Download

Lines Matching refs:dirstruct

147 static void free_cached_dir(struct dir_s *dirstruct)  in free_cached_dir()  argument
151 pthread_mutex_destroy(&(dirstruct->lock)); in free_cached_dir()
153 if (!dirstruct->dp) in free_cached_dir()
156 for (i=0; i < dirstruct->num; i++) { in free_cached_dir()
157 free(dirstruct->dp[i].d_name); in free_cached_dir()
159 free(dirstruct->dp); in free_cached_dir()
160 dirstruct->dp = 0; in free_cached_dir()
161 dirstruct->max = dirstruct->num = 0; in free_cached_dir()
191 struct dir_s *dirstruct; in alloc_dirstruct() local
195 dirstruct = malloc(sizeof(struct dir_s)); in alloc_dirstruct()
196 if (dirstruct) in alloc_dirstruct()
197 memset(dirstruct, 0, sizeof(struct dir_s)); in alloc_dirstruct()
198 dirstruct->dir = dir; in alloc_dirstruct()
199 pthread_mutex_init(&(dirstruct->lock), &mutexattr); in alloc_dirstruct()
200 return dirstruct; in alloc_dirstruct()
203 static void cache_dirstruct(struct dir_s *dirstruct) in cache_dirstruct() argument
208 while ((d = (*real_readdir64)(dirstruct->dir)) != NULL) { in cache_dirstruct()
209 if (dirstruct->num >= dirstruct->max) { in cache_dirstruct()
210 dirstruct->max += ALLOC_STEPSIZE; in cache_dirstruct()
212 dirstruct->max)); in cache_dirstruct()
213 dnew = realloc(dirstruct->dp, in cache_dirstruct()
214 dirstruct->max * sizeof(struct dir_s)); in cache_dirstruct()
217 dirstruct->dp = dnew; in cache_dirstruct()
219 ds = &dirstruct->dp[dirstruct->num++]; in cache_dirstruct()
225 dirstruct->num--; in cache_dirstruct()
232 qsort(dirstruct->dp, dirstruct->num, sizeof(struct dirent_s), ino_cmp); in cache_dirstruct()
236 free_cached_dir(dirstruct); in cache_dirstruct()
237 dirstruct->direct = 1; in cache_dirstruct()
243 struct dir_s *dirstruct; in opendir() local
254 dirstruct = alloc_dirstruct(dir); in opendir()
255 if (!dirstruct) { in opendir()
265 dirstruct->direct = 1; in opendir()
266 return (DIR *) dirstruct; in opendir()
269 cache_dirstruct(dirstruct); in opendir()
270 return ((DIR *) dirstruct); in opendir()
276 struct dir_s *dirstruct; in fdopendir() local
287 dirstruct = alloc_dirstruct(dir); in fdopendir()
288 if (!dirstruct) { in fdopendir()
298 dirstruct->dir = dir; in fdopendir()
299 dirstruct->direct = 1; in fdopendir()
300 return (DIR *) dirstruct; in fdopendir()
303 cache_dirstruct(dirstruct); in fdopendir()
304 return ((DIR *) dirstruct); in fdopendir()
309 struct dir_s *dirstruct = (struct dir_s *) dir; in closedir() local
312 if (dirstruct->dir) in closedir()
313 (*real_closedir)(dirstruct->dir); in closedir()
315 free_cached_dir(dirstruct); in closedir()
316 free(dirstruct); in closedir()
322 struct dir_s *dirstruct = (struct dir_s *) dir; in readdir() local
325 if (dirstruct->direct) in readdir()
326 return (*real_readdir)(dirstruct->dir); in readdir()
328 if (dirstruct->pos >= dirstruct->num) in readdir()
331 ds = &dirstruct->dp[dirstruct->pos++]; in readdir()
332 dirstruct->ret_dir.d_ino = ds->d_ino; in readdir()
333 dirstruct->ret_dir.d_off = ds->d_off; in readdir()
334 dirstruct->ret_dir.d_reclen = ds->d_reclen; in readdir()
335 dirstruct->ret_dir.d_type = ds->d_type; in readdir()
336 strncpy(dirstruct->ret_dir.d_name, ds->d_name, in readdir()
337 sizeof(dirstruct->ret_dir.d_name)); in readdir()
339 return (&dirstruct->ret_dir); in readdir()
344 struct dir_s *dirstruct = (struct dir_s *) dir; in readdir_r() local
347 if (dirstruct->direct) in readdir_r()
348 return (*real_readdir_r)(dirstruct->dir, entry, result); in readdir_r()
350 pthread_mutex_lock(&(dirstruct->lock)); in readdir_r()
351 if (dirstruct->pos >= dirstruct->num) { in readdir_r()
354 ds = &dirstruct->dp[dirstruct->pos++]; in readdir_r()
362 pthread_mutex_unlock(&(dirstruct->lock)); in readdir_r()
368 struct dir_s *dirstruct = (struct dir_s *) dir; in readdir64() local
371 if (dirstruct->direct) in readdir64()
372 return (*real_readdir64)(dirstruct->dir); in readdir64()
374 if (dirstruct->pos >= dirstruct->num) in readdir64()
377 ds = &dirstruct->dp[dirstruct->pos++]; in readdir64()
378 dirstruct->ret_dir64.d_ino = ds->d_ino; in readdir64()
379 dirstruct->ret_dir64.d_off = ds->d_off; in readdir64()
380 dirstruct->ret_dir64.d_reclen = ds->d_reclen; in readdir64()
381 dirstruct->ret_dir64.d_type = ds->d_type; in readdir64()
382 strncpy(dirstruct->ret_dir64.d_name, ds->d_name, in readdir64()
383 sizeof(dirstruct->ret_dir64.d_name)); in readdir64()
385 return (&dirstruct->ret_dir64); in readdir64()
392 struct dir_s *dirstruct = (struct dir_s *) dir; in readdir64_r() local
395 if (dirstruct->direct) in readdir64_r()
397 pthread_mutex_lock(&(dirstruct->lock)); in readdir64_r()
398 if (dirstruct->pos >= dirstruct->num) { in readdir64_r()
401 ds = &dirstruct->dp[dirstruct->pos++]; in readdir64_r()
410 pthread_mutex_unlock(&(dirstruct->lock)); in readdir64_r()
416 struct dir_s *dirstruct = (struct dir_s *) dir; in telldir() local
418 if (dirstruct->direct) in telldir()
419 return (*real_telldir)(dirstruct->dir); in telldir()
421 return ((off_t) dirstruct->pos); in telldir()
426 struct dir_s *dirstruct = (struct dir_s *) dir; in seekdir() local
428 if (dirstruct->direct) { in seekdir()
429 (*real_seekdir)(dirstruct->dir, offset); in seekdir()
433 dirstruct->pos = offset; in seekdir()
438 struct dir_s *dirstruct = (struct dir_s *) dir; in rewinddir() local
440 (*real_rewinddir)(dirstruct->dir); in rewinddir()
441 if (dirstruct->direct) in rewinddir()
444 pthread_mutex_lock(&(dirstruct->lock)); in rewinddir()
445 dirstruct->pos = 0; in rewinddir()
446 free_cached_dir(dirstruct); in rewinddir()
447 cache_dirstruct(dirstruct); in rewinddir()
448 pthread_mutex_unlock(&(dirstruct->lock)); in rewinddir()
453 struct dir_s *dirstruct = (struct dir_s *) dir; in dirfd() local
454 int fd = (*real_dirfd)(dirstruct->dir); in dirfd()