Deleted Added
full compact
rewinddir.c (271263) rewinddir.c (282979)
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 271263 2014-09-08 14:45:58Z jhb $");
34__FBSDID("$FreeBSD: stable/10/lib/libc/gen/rewinddir.c 282979 2015-05-15 15:49:24Z julian $");
35
36#include "namespace.h"
37#include <sys/types.h>
38#include <dirent.h>
39#include <pthread.h>
40#include <unistd.h>
41#include "un-namespace.h"
42
43#include "libc_private.h"
44#include "gen-private.h"
45#include "telldir.h"
46
47void
48rewinddir(dirp)
49 DIR *dirp;
50{
51
52 if (__isthreaded)
53 _pthread_mutex_lock(&dirp->dd_lock);
35
36#include "namespace.h"
37#include <sys/types.h>
38#include <dirent.h>
39#include <pthread.h>
40#include <unistd.h>
41#include "un-namespace.h"
42
43#include "libc_private.h"
44#include "gen-private.h"
45#include "telldir.h"
46
47void
48rewinddir(dirp)
49 DIR *dirp;
50{
51
52 if (__isthreaded)
53 _pthread_mutex_lock(&dirp->dd_lock);
54 dirp->dd_flags &= ~__DTF_SKIPREAD; /* current contents are invalid */
54 if (dirp->dd_flags & __DTF_READALL)
55 _filldir(dirp, false);
56 else {
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);
64}
55 if (dirp->dd_flags & __DTF_READALL)
56 _filldir(dirp, false);
57 else {
58 (void) lseek(dirp->dd_fd, 0, SEEK_SET);
59 dirp->dd_seek = 0;
60 }
61 dirp->dd_loc = 0;
62 _reclaim_telldir(dirp);
63 if (__isthreaded)
64 _pthread_mutex_unlock(&dirp->dd_lock);
65}