rewinddir.c (256281) | rewinddir.c (270002) |
---|---|
1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#if defined(LIBC_SCCS) && !defined(lint) 31static char sccsid[] = "@(#)rewinddir.c 8.1 (Berkeley) 6/8/93"; 32#endif /* LIBC_SCCS and not lint */ 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#if defined(LIBC_SCCS) && !defined(lint) 31static char sccsid[] = "@(#)rewinddir.c 8.1 (Berkeley) 6/8/93"; 32#endif /* LIBC_SCCS and not lint */ 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: stable/10/lib/libc/gen/rewinddir.c 235647 2012-05-19 12:44:27Z gleb $"); | 34__FBSDID("$FreeBSD: stable/10/lib/libc/gen/rewinddir.c 270002 2014-08-14 20:20:21Z jhb $"); |
35 | 35 |
36#include "namespace.h" |
|
36#include <sys/types.h> 37#include <dirent.h> | 37#include <sys/types.h> 38#include <dirent.h> |
39#include <pthread.h> 40#include <unistd.h> 41#include "un-namespace.h" |
|
38 | 42 |
43#include "libc_private.h" |
|
39#include "gen-private.h" 40#include "telldir.h" 41 42void 43rewinddir(dirp) 44 DIR *dirp; 45{ 46 | 44#include "gen-private.h" 45#include "telldir.h" 46 47void 48rewinddir(dirp) 49 DIR *dirp; 50{ 51 |
47 _seekdir(dirp, dirp->dd_rewind); 48 dirp->dd_rewind = telldir(dirp); | 52 if (__isthreaded) 53 _pthread_mutex_lock(&dirp->dd_lock); 54 if (dirp->dd_flags & __DTF_READALL) 55 _filldir(dirp, false); 56 else if (dirp->dd_seek != 0) { 57 (void) lseek(dirp->dd_fd, 0, SEEK_SET); 58 dirp->dd_seek = 0; 59 } 60 dirp->dd_loc = 0; 61 _reclaim_telldir(dirp); 62 if (__isthreaded) 63 _pthread_mutex_unlock(&dirp->dd_lock); |
49} | 64} |