opendir.c (235647) | opendir.c (241046) |
---|---|
1/*- 2 * Copyright (c) 1983, 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[] = "@(#)opendir.c 8.8 (Berkeley) 5/1/95"; 32#endif /* LIBC_SCCS and not lint */ 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1983, 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[] = "@(#)opendir.c 8.8 (Berkeley) 5/1/95"; 32#endif /* LIBC_SCCS and not lint */ 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/lib/libc/gen/opendir.c 235647 2012-05-19 12:44:27Z gleb $"); | 34__FBSDID("$FreeBSD: head/lib/libc/gen/opendir.c 241046 2012-09-29 11:54:34Z jilles $"); |
35 36#include "namespace.h" 37#include <sys/param.h> 38#include <sys/mount.h> 39#include <sys/stat.h> 40 41#include <dirent.h> 42#include <errno.h> --- 151 unchanged lines hidden (view full) --- 194 /* 195 * Re-open the directory. 196 * This has the effect of rewinding back to the 197 * top of the union stack and is needed by 198 * programs which plan to fchdir to a descriptor 199 * which has also been read -- see fts.c. 200 */ 201 if (flags & DTF_REWIND) { | 35 36#include "namespace.h" 37#include <sys/param.h> 38#include <sys/mount.h> 39#include <sys/stat.h> 40 41#include <dirent.h> 42#include <errno.h> --- 151 unchanged lines hidden (view full) --- 194 /* 195 * Re-open the directory. 196 * This has the effect of rewinding back to the 197 * top of the union stack and is needed by 198 * programs which plan to fchdir to a descriptor 199 * which has also been read -- see fts.c. 200 */ 201 if (flags & DTF_REWIND) { |
202 if ((fd2 = _open(name, O_RDONLY | O_DIRECTORY)) == -1) { | 202 if ((fd2 = _open(name, O_RDONLY | O_DIRECTORY | 203 O_CLOEXEC)) == -1) { |
203 saved_errno = errno; 204 free(buf); 205 free(dirp); 206 errno = saved_errno; 207 return (NULL); 208 } 209 (void)_dup2(fd2, fd); 210 _close(fd2); --- 105 unchanged lines hidden --- | 204 saved_errno = errno; 205 free(buf); 206 free(dirp); 207 errno = saved_errno; 208 return (NULL); 209 } 210 (void)_dup2(fd2, fd); 211 _close(fd2); --- 105 unchanged lines hidden --- |