Home | History | Annotate | Download | only in gen
History log of /src/lib/libc/gen/opendir.c
RevisionDateAuthorComments
 1.39  26-Nov-2014  christos - Use O_DIRECTORY to open the file, so that we don't need to stat() after
that.
- Move the stat() call to fdopendir() and change it's error handling so that
it does not hide errors.
- According to POSIX, fdopendir() transfers ownership of the fd only on
success, so don't close it on failure. XXX: We still make it non-blocking
on failure, but that's nitpicking.

XXX: pullup-7?
 1.38  15-Oct-2011  christos branches: 1.38.20;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.37  26-Sep-2010  yamt fix rewinddir on nfs. fix PR/42879 (and probably PR/40229.)
 1.36  16-Sep-2010  yamt - remove a wrong _DIAGASSERT
- update comments
- whitespace
 1.35  11-Jan-2009  christos merge christos-time_t
 1.34  05-Dec-2008  ad Add fdopendir(), from Solaris/Linux.
 1.33  10-Jan-2008  elad branches: 1.33.12;
PR/35562: khorben at defora dot org: Potential denial of service when
listing files on an NFS share

Limit the number of retries as suggested in the PR.

Reviewed by and okay fvdl@.
 1.32  17-Jul-2007  christos branches: 1.32.4;
kill MFSNAMELEN
 1.31  17-May-2006  christos PR/24324: Arne H Juul: Re-implement seekdir/telldir using a pointer of
locations per directory instead of a global hash table to avoid memory
leak issues, and incorrect results.
 1.30  24-Jan-2006  christos rename __func to _func_unlocked, and add their prototypes in extern.h
instead of exposing them in dirent.h. More locking consistency fixes.
 1.29  24-Jan-2006  christos PR/32609: Tanaka Akira: seekdir blocks if pthread is linked
Do locking consistently to avoid recursive locks (like the bug reported in
this pr), and to avoid leaking locks on errors.
 1.28  13-Sep-2005  christos compat core reorg.
 1.27  19-Aug-2005  christos 64 bit inode changes
 1.26  19-Jan-2005  mycroft Also set FD_CLOEXEC in the union re-open case.
 1.25  21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.24  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.23  29-May-2003  nathanw Allocate and initialize dirp->dd_lock before calling telldir(), which
will try to lock it.

Addresses PR lib/21712.
 1.22  28-May-2003  christos add mutex locking for directories and readdir_r(3). Influenced by FreeBSD.
 1.21  02-Mar-2003  enami Fix realloc usage.
 1.20  22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.19  20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.18  16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.17  13-Nov-1998  christos delint
 1.16  27-Feb-1998  perry trivial changes to quiet lint.
 1.15  10-Oct-1997  fvdl Use getdents(). Read NFS directories in one go (just as union dirs, but
without removing double entries). This makes sure that we get a
consistent snapshot of the directory, and protects against any
'bad cookie' errors.
 1.14  21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.13  13-Jul-1997  christos Fix RCSID's
 1.12  25-Feb-1997  fvdl Check for both the filesystem name and the filesystem flags to determine
whether a directory is a union mount, and thus needs to have double
entries filtered out.
 1.11  20-Dec-1996  cgd string.h for prototypes
 1.10  18-Jun-1995  cgd branches: 1.10.4;
don't assume f_fstypename is larger than MFSNAMELEN or is nul-terminated
 1.9  12-Jun-1995  jtc Open with O_NONBLOCK, in case someone tries to open a blocking device
or a non-open fifo instead of a directory.
 1.8  25-Feb-1995  cgd clean up Id's on files previously imported...
 1.7  28-Dec-1994  mycroft branches: 1.7.2;
Format police, and a small patch for 64-bitness.
 1.6  28-Dec-1994  mycroft Repair a couple of things.
 1.5  28-Dec-1994  mycroft Mostly sync with CSRG.
 1.4  15-Sep-1994  pk Use getpagesize() in stead of CLBYTES.
 1.3  27-Jul-1994  jtc branches: 1.3.2;
Add RCS Id's
 1.2  27-Jul-1994  jtc Return NULL and set errno to ENOTDIR if opening a non-directory (POSIX.1,
Section 5.1.2.4). Rename _seekdir to __seekdir, as former is in the
user's namespace.
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3  02-Feb-1998  perry import lite-2
 1.1.1.2  27-Jul-1994  jtc opendir() & friends from 4.4lite.
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.2.2  27-Jul-1994  jtc Add RCS Id's
 1.3.2.1  27-Jul-1994  jtc file opendir.c was added on branch netbsd-1-0 on 1994-07-27 14:39:47 +0000
 1.7.2.2  02-May-1995  jtc #include "namespace.h"
 1.7.2.1  26-Apr-1995  jtc #include "namespace.h"
Added __weak_reference defns.
 1.10.4.1  16-Sep-1996  jtc snapshot namespace cleanup
 1.32.4.1  23-Mar-2008  matt sync with HEAD
 1.33.12.1  04-Jan-2009  christos merge with head.
 1.38.20.1  14-Apr-2015  snj Pull up following revision(s) (requested by christos in ticket #691):
lib/libc/gen/opendir.c: revision 1.39
- Use O_DIRECTORY to open the file, so that we don't need to stat() after
that.
- Move the stat() call to fdopendir() and change it's error handling so that
it does not hide errors.
- According to POSIX, fdopendir() transfers ownership of the fd only on
success, so don't close it on failure. XXX: We still make it non-blocking
on failure, but that's nitpicking.

RSS XML Feed