It looks like I've subverted things a little: the lib/ChangeLog entry for fts.c and openat.[ch] below correspond to a change I haven't yet committed. I think it's complete, but it's rather ambitious, and requires changes (albeit small) in every program that uses fts. So I'm taking my time.
I committed it (only the ChangeLog entry) by mistake when I made the version-etc.c change. I'll back it out of coreutils and gnulib now. Sorry about that. Paul Eggert <[EMAIL PROTECTED]> wrote: > I installed this to sync gnulib from coreutils. This is the biggest > change hunk; the changes all tend to depend on each other. It's still > mutating but I think this snapshot will work with other programs (it > works with GNU tar, anyway). > > The lchmod business is a bit tricky, since it uses chmod as a > substitute for lchmod. Callers are supposed to check that files are > not symbolic links before using lchmod, which obviously leads to race > conditions, but that's the best we can do on hosts that lack lchmod. > > 2006-01-09 Paul Eggert <[EMAIL PROTECTED]> ... > 2006-01-09 Jim Meyering <[EMAIL PROTECTED]> > > Sync from coreutils. > > Rewrite fts.c not to change the current working directory, > by using openat, fstatat, fdopendir, etc.. > > * lib/fts.c [! _LIBC]: Include "openat.h", "unistd--.h", and > "fcntl--.h". > [_LIBC] (fchdir): Don't undef or define; no longer used. > (FCHDIR): Define in terms of cwd_advance_fd rather than fchdir. > Now, this `function' always succeeds, and consumes its file descriptor > parameter -- so callers must not close such FDs. Update callers. > (diropen_fd, opendirat, cwd_advance_fd): New functions. > (diropen): Add parameter, SP. Adjust all callers. > Implement using diropen_fd, rather than open. > (fts_open): Initialize new member, fts_cwd_fd. > Remove fts_rft-setting code. > (fts_close): Close fts_cwd_fd, if necessary. > (__opendir2): Define in terms of opendir or opendirat, > depending on whether the FST_NOCHDIR flag is set. > (fts_build): Since fts_safe_changedir consumes its FD, and since > this code must do `closedir(dirp)', dup the dirfd(dirp) argument, > and close the dup'd file descriptor upon failure. > (fts_stat): Use fstatat(...AT_SYMLINK_NOFOLLOW) in place of lstat. > (fts_safe_changedir): Tweak semantics to reflect that this function > now calls cwd_advance_fd and hence consumes its FD argument. > * lib/fts_.h [struct FTS] (fts_cwd_fd): New member. > (fts_rft): Remove now-unused member. > > * lib/openat.c (fchownat): New function. > * lib/openat.h (fchmodat, fchownat): Declare. > (chmodat, lchmodat): Define convenience functions. > (chownat, lchownat): Likewise. ... _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib