summaryrefslogtreecommitdiff
path: root/lib/fdopendir.c
Commit message (Collapse)AuthorAgeFilesLines
* maint: Run 'make update-copyright'Paul Eggert2019-01-011-1/+1
|
* maint: Run 'make update-copyright'Paul Eggert2018-01-011-1/+1
|
* all: prefer https: URLsPaul Eggert2017-09-131-1/+1
|
* version-etc: new yearPaul Eggert2017-01-011-1/+1
| | | | | | | | | | * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
* opendir, closedir, dirfd, fdopendir: port to OS/2 kLIBCKO Myung-Hun2016-01-141-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | * lib/closedir.c (closedir): Unregister fd if closedir() succeeds. * lib/dirent.in.h (_gl_register_dirp_fd, _gl_unregister_dirp_fd): Declare on kLIBC. * lib/dirfd.c (struct dirp_fd_list): New. Structures to keep track of fd associated with dirp. (_gl_register_dirp_fd): New. Register fd associated with dirp to dirp_fd_list. (_gl_unregister_dirp_fd): New. Unregister fd with closing it. (dirfd): Implemented for kLIBC. * lib/fdopendir.c (fdopendir): Implemented for kLIBC. * lib/opendir.c (opendir): New. Register fd and dirp pair if open() succeeds. * m4/closedir.m4 (gl_FUNC_CLOSEDIR): Replace if OS/2. * m4/dirfd.m4 (gl_FUNC_DIRFD): Likewise. (REPLACE_DIRFD): Define to 1 if replaced. * m4/opendir.m4 (gl_FUNC_OPENDIR): Likewise. * modules/closedir (Depends-on): Add dirfd. * modules/dirfd (Depends-on): Add 'test $REPLACE_DIRFD = 1' to errno condition. (configure.ac): Add dirfd to LIBOBJS if $REPLACE_DIRFD = 1 as well. * modules/opendir (Depends-on): Add dirfd.
* version-etc: new yearPaul Eggert2016-01-011-1/+1
| | | | | | | | | | * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
* fdopendir: port better to MinGWPaul Eggert2015-03-191-1/+10
| | | | | | | * lib/fdopendir.c (fd_clone_opendir) [REPLACE_FCHDIR]: Use 'dup' if dirfd fails. Suggested by Eli Zaretskii in: http://lists.gnu.org/archive/html/bug-gnulib/2015-03/msg00033.html * modules/fdopendir (Depends-on): Add dirfd.
* fdopendir: fix typo in commentPaul Eggert2015-03-181-1/+1
| | | | * lib/fdopendir.c (fdopendir_with_dup): REPLACE_FCHDIR was misspelled.
* version-etc: new yearPaul Eggert2014-12-311-1/+1
| | | | | | * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright date. * all files: Run 'make update-copyright'.
* maint: update copyrightEric Blake2014-01-011-1/+1
| | | | | | I ran 'make update-copyright'. Signed-off-by: Eric Blake <eblake@redhat.com>
* maint: update all copyright year number rangesEric Blake2013-01-011-1/+1
| | | | | | Run "make update-copyright". Compare to commit 1602f0a from last year. Signed-off-by: Eric Blake <eblake@redhat.com>
* maint: update all copyright year number rangesJim Meyering2012-01-011-1/+1
| | | | Run "make update-copyright".
* maint: update almost all copyright ranges to include 2011Jim Meyering2011-01-011-1/+1
| | | | Run the new "make update-copyright" rule.
* fdopendir: fix bug on MacOS X when low on file descriptorsPaul Eggert2010-11-081-64/+60
| | | | | | | | | | | | | | | | * lib/fdopendir.c (REPLACE_FCHDIR): #define to 0 if not defined. (fdopendir_with_dup, fd_clone_opendir): Now have extra CWD arg. All callers changed. (fdopendir): Invoke save_cwd at the top level, not after using multiple dup() calls to use up file descriptors. Then retry fdopendir_with_dup. This avoids failure with EMFILE if FD is 1 less than the maximum number of open file descriptors, because save_cwd fails with errno == EMFILE. Problem reported by tsteven4 on Mac OS X 10.6.4 for tar 1.24 <http://lists.gnu.org/archive/html/bug-tar/2010-10/msg00084.html> <http://lists.gnu.org/archive/html/bug-tar/2010-11/msg00000.html> and for tar 1.25 <http://lists.gnu.org/archive/html/bug-tar/2010-11/msg00038.html>.
* fdopendir: fix C89 compilationChristian Weisgerber2010-10-261-1/+1
| | | | | * lib/fdopendir.c (fd_clone_opendir): Move declaration for older compilers.
* fdopendir: fix a bug on systems lacking openat and /proc supportJim Meyering2010-10-081-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OpenBSD 4.7 is one such system. The most noticeable effect was failure of any application making nontrivial use of fts: rm, du, chown, chmod etc. E.g., "mkdir -p a/b; ./rm -rf a" would fail with ./rm: traversal failed: `a': Bad file descriptor Debugging that, you see that even though FD 6 was closed just prior to the opendir call in fd_clone_opendir, its resulting dir->dd_fd was 8, rather than the expected value of 6: Breakpoint 3, fdopendir_with_dup (fd=6, older_dupfd=-1) at fdopendir.c:93 93 close (fd); (gdb) n 94 dir = fd_clone_opendir (dupfd); (gdb) n 95 saved_errno = errno; (gdb) p dir->dd_fd $11 = 8 Notice how it closes FD 6, then gets a DIR* pointer using FD 8. The problem is that on OpenBSD, fd_clone_opendir has to resort to using the old-style save/restore CWD mechanism, due to its lack of openat/proc support, and *that* would steal the FD (6) that opendir was supposed to use. The fix is to squirrel away the desired FD so that save_cwd uses a different one, and then free the dest FD right before calling opendir. That guarantees opendir will use the required file descriptor. * lib/fdopendir.c (fd_clone_opendir): Handle the above.
* fdopendir: preserve argument fd before returningPaul Eggert2010-09-131-11/+71
| | | | | | | | | | | * lib/fdopendir.c: Adjust comments to say POSIX, not Solaris. (fdopendir_with_dup, fd_clone_opendir): New static functions. (fdopendir): Use them, arranging for FD to be open to the same directory that it was when it started. (It might be temporarily closed while fdopendir is running, so this not thread- or signal-safe.) Be careful to do the right thing even when file descriptors are scarce and dup fails with errno == EMFILE. See <http://lists.gnu.org/archive/html/bug-gnulib/2010-09/msg00208.html>.
* update nearly all FSF copyright year lists to include 2010Jim Meyering2010-01-011-1/+1
| | | | | Use the same procedure as for 2009, outlined in http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/20081
* Use spaces for indentation, not tabs.Bruno Haible2009-12-101-11/+11
|
* fdopendir: fix GNU/Hurd bugEric Blake2009-10-061-9/+36
| | | | | | | | | | | | | | | | | fdopendir(open("file",O_RDONLY)) mistakenly succeeded, with subsequent readdir() failing with ENOTDIR. * m4/fdopendir.m4 (gl_FUNC_FDOPENDIR): Check for Hurd bug in allowing non-directory fds. * lib/fdopendir.c (rpl_fdopendir): Work around it. * m4/dirent_h.m4 (gl_DIRENT_H_DEFAULTS): New witness. * modules/dirent (Makefile.am): Substitute it. * lib/dirent.in.h (fdopendir): Declare replacement. * doc/posix-functions/fdopendir.texi (fdopendir): Document this. * tests/test-fdopendir.c (main): Test something other than /dev/null, since on Hurd that behaves like a directory. Signed-off-by: Eric Blake <ebb9@byu.net>
* dirent-safer: new moduleEric Blake2009-09-021-0/+4
| | | | | | | | | | | | | | * modules/dirent-safer: New file. * lib/dirent--.h: Likewise. * lib/dirent-safer.h: Likewise. * lib/opendir-safer.c: Likewise. * m4/dirent-safer.m4: Likewise. * MODULES.html.sh (Enhancements for POSIX:2008): Mention it. * modules/dirent-safer-tests: New test. * tests/test-dirent-safer.c: New file. * lib/fdopendir.c (includes): Ensure fdopendir is also safe. Signed-off-by: Eric Blake <ebb9@byu.net>
* fdopendir: optimize on mingwEric Blake2009-09-021-2/+10
| | | | | | | | | | * lib/unistd.in.h (_gl_directory_name): New prototype. * lib/fchdir.c (_gl_directory_name): Implement it. (fchdir): Use it to simplify implementation. * lib/fdopendir.c (fdopendir) [REPLACE_FCHDIR]: Use metadata from fchdir, when available, to avoid calling [f]chdir(). Signed-off-by: Eric Blake <ebb9@byu.net>
* fdopendir: split into its own moduleEric Blake2009-09-021-0/+95
* lib/openat.c (fdopendir): Move... * lib/fdopendir.c: ...into new file. * modules/fdopendir: New module. * m4/fdopendir.m4 (gl_FUNC_FDOPENDIR): New file. * modules/openat (Depends-on): Add fdopendir. * m4/openat.m4 (gl_FUNC_OPENAT): No longer need to check for fdopendir here. * modules/savedir (Depends-on): Only need fdopendir, not full openat. * lib/savedir.c (include): Use <dirent.h>, not "openat.h". * lib/openat.h (fdopendir): Drop prototype. * lib/dirent.in.h (fdopendir): Provide prototype. * m4/dirent_h.m4 (gl_DIRENT_H_DEFAULTS): Add replacements. * modules/dirent (Makefile.am): Substitute them. * MODULES.html.sh (File system functions): Mention it. * doc/posix-functions/fdopendir.texi (fdopendir): Likewise. * modules/fdopendir-tests: New file. * tests/test-fdopendir.c: Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>