diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2018-10-23 19:10:21 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2018-10-23 19:11:12 -0700 |
commit | 1b01fe40918401a965651499b0ba37ff53be86a9 (patch) | |
tree | 7bff60c2b8856e06669fbe0580cf2ce506a45ca4 /lib/fts.c | |
parent | 0f0ee4a910a71e7d53d6e05b2bc8bc45afff96ac (diff) | |
download | gnulib-1b01fe40918401a965651499b0ba37ff53be86a9.tar.gz |
backupfile: new dir_fd args
New module opendirat with code taken from fts.
Use this module to let backupfile use a directory file descriptor.
* NEWS: Document the incompatible change.
* lib/backup-find.c (find_backup_file_name):
* lib/backup-rename.c (backup_file_rename):
New arg DIR_FD.
* lib/backupfile.c: Include stdint.h, for SIZE_MAX.
(SIZE_MAX): Remove.
Include opendirat.h rather than dirent--.h.
(check_extension): New args DIR_FD and BASE_MAX. All callers changed.
(numbered_backup): New args DIR_FD and PNEW_FD. All callers changed.
(backupfile_internal): New arg DIR_FD. All callers changed.
* lib/fts.c: Include opendirat.h.
(opendirat): Move to opendirat.c.
* lib/opendirat.c, lib/opendirat.h, modules/opendirat: New files.
* modules/backupfile (Depends-on): Remove dirfd, opendir.
Add opendirat.
* modules/fts (Depends-on): Remove fdopendir, openat-safer.
Add opendirat.
Diffstat (limited to 'lib/fts.c')
-rw-r--r-- | lib/fts.c | 26 |
1 files changed, 1 insertions, 25 deletions
@@ -73,6 +73,7 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; # include "fcntl--.h" # include "flexmember.h" # include "openat.h" +# include "opendirat.h" # include "same-inode.h" #endif @@ -294,31 +295,6 @@ fts_set_stat_required (FTSENT *p, bool required) : FTS_NO_STAT_REQUIRED); } -/* file-descriptor-relative opendir. */ -/* FIXME: if others need this function, move it into lib/openat.c */ -static DIR * -internal_function -opendirat (int fd, char const *dir, int extra_flags, int *pdir_fd) -{ - int open_flags = (O_RDONLY | O_CLOEXEC | O_DIRECTORY | O_NOCTTY - | O_NONBLOCK | extra_flags); - int new_fd = openat (fd, dir, open_flags); - DIR *dirp; - - if (new_fd < 0) - return NULL; - dirp = fdopendir (new_fd); - if (dirp) - *pdir_fd = new_fd; - else - { - int saved_errno = errno; - close (new_fd); - errno = saved_errno; - } - return dirp; -} - /* Virtual fchdir. Advance SP's working directory file descriptor, SP->fts_cwd_fd, to FD, and push the previous value onto the fd_ring. CHDIR_DOWN_ONE is true if FD corresponds to an entry in the directory |