diff options
author | Jim Meyering <jim@meyering.net> | 2006-11-12 17:35:38 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2006-11-12 17:35:38 +0000 |
commit | 7f01591aadb13b59cb04f9ad42400eb7ea1c6e19 (patch) | |
tree | 999bfb5f230fed1381aca5e7f5a1d72b4cb6e3f6 /lib/fts_.h | |
parent | 42a01df09d7f13f15a54e0c4b09d121c5bf7ac66 (diff) | |
download | gnulib-7f01591aadb13b59cb04f9ad42400eb7ea1c6e19.tar.gz |
Make fts (in FTS_CWDFD mode) more efficient by caching a few open
file descriptors. This also averts a failure on systems with
native openat support when a traversed directory lacks "x" access.
* lib/fts_.h: Include "i-ring.h"
(struct FTS) [fts_fd_ring]: New member.
* lib/fts.c (RESTORE_INITIAL_CWD): Also call fd_ring_clear.
(FCHDIR): Add parentheses.
(fd_ring_check, fd_ring_print) [!FTS_DEBUG]: Define away.
(cwd_advance_fd): Add a 3rd parameter. Adjust all callers.
When descending, rather than simply closing the previous
fts_cwd_fd value, push that file descriptor onto the ring.
(same_fd, fd_ring_print, fd_ring_check) [FTS_DEBUG]: New functions.
(fts_open): Initialize the new fd_ring member.
(fts_close): Clear the ring.
(fts_safe_changedir): When possible, use our new fd_ring to skip
the diropen and fstat and dev/ino comparison that would normally
accompany a virtual `chdir ("..")'.
* modules/fts (Depends-on): Add i-ring.
* modules/i-ring: New module.
* lib/i-ring.c, lib/i-ring.h, lib/i-ring-test.c: New files.
* m4/i-ring.m4: New file.
Diffstat (limited to 'lib/fts_.h')
-rw-r--r-- | lib/fts_.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/fts_.h b/lib/fts_.h index 7e6a404eda..d5b047412f 100644 --- a/lib/fts_.h +++ b/lib/fts_.h @@ -65,6 +65,7 @@ # include <stddef.h> # include <sys/types.h> # include <sys/stat.h> +# include "i-ring.h" typedef struct { struct _ftsent *fts_cur; /* current node */ @@ -163,7 +164,12 @@ typedef struct { but it's not appropriate for programs like du. */ struct cycle_check_state *state; } fts_cycle; + # endif + /* A stack of the file descriptors corresponding to the + most-recently traversed parent directories. + Currently used only in FTS_CWDFD mode. */ + I_ring fts_fd_ring; } FTS; typedef struct _ftsent { |