Age | Commit message (Collapse) | Author |
|
|
|
|
|
to avoid leaks. Patch from glibc.
|
|
declares and sets cderrno.
|
|
|
|
by using openat, fstatat, fdopendir, etc..
[! _LIBC]: Include "openat.h" and "unistd--.h".
(HAVE_OPENAT_SUPPORT): Define.
[_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.
|
|
don't interpret all stat-fails+lstat-succeeds as indicating a
dangling symlink. That can also happen at least for ELOOP.
The fix: return FTS_SLNONE only when the stat errno is ENOENT.
|
|
own block, so pre-c99 compilers don't object.
|
|
|
|
would occur when an `active' directory is made inaccessible (e.g.,
via chmod a-x) during a traversal.
(fts_read): After a failed fchdir, update sp->fts_cur
before returning. Reproduce this failure by
mkdir -p a/b; cd a; chmod a-x . b
Reported by Stavros Passas.
|
|
(fts_open): Avoid function call in MAX macro use.
|
|
POSIX says that must fail.
|
|
|
|
|
|
Include fcntl--.h rather than unistd-safer.h
(fts_safe_changedir): Don't call fd_safer; no longer needed
now that we include fcntl--.h.
|
|
in comments or local variable names.
|
|
the configuration hassle isn't worth it.
Include inttypes.h and stdint.h unconditionally if FTS_DEBUG.
(LONGEST_MODIFIER, PRIuMAX): Remove.
|
|
so that unistd-safer.h (GPL'ed code) need not be included.
|
|
(setup_dir, free_dir): New functions.
(enter_dir, leave_dir): Define trivial
alternatives of _LGPL_PACKAGE. Move to fts-cycle.c if !_LGPL_PACKAGE.
(HT_INITIAL_SIZE, ENTER_DIR): Remove. All uses removed.
(LEAVE_DIR): Fix typo: pass Fts and Ent to leave_dir.
(struct Active_dir, AD_compare, AD_hash, enter_dir, leave_dir):
Move to fts-cycle.c.
(fts_open): Use setup_dir.
(fts_close): Use free_dir.
(fts_read): Have just one copy of the ENTER_DIR code rather than three.
This adds a label and some gotos, but the alternatives were messier.
Check for memory allocation failure when entering a dir.
(fts_stat) [_LGPL_PACKAGE]: Bring back glibc cycle detection code.
|
|
Spotted by Paul Eggert.
|
|
Do not include intprops.h; no longer needed.
Include cycle-check.h and hash.h, since fts_.h no longer does.
Remove unnecessary casts of closedir to void.
(fts_build): Use a simpler method (not involving TYPE_SIGNED) to
decide whether to decrement nlinks.
|
|
|
|
|
|
|
|
(fts_open): Don't cast a function value in a possibly-unsafe way.
(fts_compar): New function.
(fts_sort): Use it.
|
|
(fts_safe_changedir): Use fd_safer.
|
|
Mark parameter `sp' with ATTRIBUTE_UNUSED.
|
|
(TYPE_SIGNED): Remove.
|
|
to a failed fchdir or failed fts_safe_changedir call, set
`sp->fts_cur = p'. Do this by removing the explicit `return NULL;'
statements and setting p->fts_errno so execution falls through
to the common-case code below. Otherwise, after such a failure,
calling fts_close would attempt to free an already-freed buffer.
Reported by Luis Lopez Lopez in http://bugs.debian.org/276352.
|
|
rather than the unportable "u_short", and similarly for u_int.
|
|
|
|
(fts_open, fts_read, fts_children, fts_safe_changedir):
Use it, so that the code works even if the directory
is writeable but not readable.
|
|
(PRIuMAX) [!PRI_MACROS_BROKEN && !defined PRIuMAX]: New macro.
(find_matching_ancestor): Use it for dev_t and ino_t.
|
|
Include stdint.h if available, as Autoconf suggests.
(ALIGNBYTES, ALIGN): Remove; no longer needed now that fts_statp
is an array.
(fts_alloc, fts_palloc, fts_sort, fts_load, fts_build):
Use size_t for sizes.
(fts_stat, fts_safe_changedir, fts_debug, fts_read, fts_build,
fts_palloc):
Use bool when appropriate.
(SIZE_MAX, TYPE_SIGNED): New macros.
(fts_read): Use u_short for instructions.
(fts_build): Use ptrdiff_t for levels. Don't assume file name lengths
fit into int. Don't assume nlink_t is signed.
(find_matching_ancestor): Don't assume dev, ino fit in int.
(fts_stat): Use function prototype; required for bool arg.
(fts_sort): Detect integer overflow in size calculations.
(fts_alloc): Simplify allocation code, now that fts_statp is an array
and not a pointer.
|
|
stat, even if the user isn't interested in the results.
This prevents a core dump in cycle_check when FTS_NOSTAT is set.
|
|
|
|
|
|
|
|
[HAVE_INTTYPES_H]: Include <inttypes.h>.
(tdestroy, tfind, tsearch): Remove definitions.
(struct Active_dir): Rename from `known_object'.
(AD_compare, AD_hash): New functions.
(enter_dir, leave_dir): Rewrite to manipulate a hash table
rather than a tree.
(fts_open): Initialize hash table or cycle_state buffer.
(free_node): Remove function.
(find_matching_ancestor): Renamed/rewritten from look_up_active_dir.
(fts_cross_check): Adapt to use new data structure.
|
|
Add some framework (compiled out by default) to test it.
(Dprintf, ENTER_DIR, LEAVE_DIR): Define.
(add_object): Remove function. Rewritten as...
(enter_dir): New function.
(leave_dir, free_node): New functions.
(fts_read): Ensure that we call ENTER_DIR or LEAVE_DIR,
as appropriate, before returning.
(look_up_active_dir, fts_cross_check) [FTS_DEBUG]: New functions.
(fts_stat): Don't perform the cycle check here.
Now it's done via enter_dir.
|
|
encountered in a traversal fit in an `unsigned short',
and fix some portability bugs (don't depend on gcc).
Include "fts_.h", not <fts.h>.
(ALIGNBYTES) [!(__GNUC__ >= 2)]: Add a definition that works with
compilers that don't have __alignof__.
(MAX): Use a definition that doesn't depend on gcc.
(fts_build): Make `len' and `maxlen' be of type size_t, not int.
Test for overflow in a less type-dependent manner.
Test HAVE_STRUCT_DIRENT_D_TYPE, rather than
defined DT_DIR && defined _DIRENT_HAVE_D_TYPE.
(fts_palloc): Test for overflow in a less type-dependent manner.
(fts_safe_changedir): Use stat, not stat64.
Use fstat, not __fxstat64(_STAT_VER.
|
|
each sequence of spaces before a TAB character.
|
|
member to NULL before returning. From NetBSD.
|
|
before returning. From NetBSD.
|
|
(struct known_object): Define.
(object_compare, add_object, find_object): New functions, like
those in ftw.c.
(fts_open): Initialize new member.
(fts_close): Free memory allocated for new member.
(fts_stat): Detect a cycle in O(logN) time per directory processed.
|
|
Conditionalize inclusion of <sys/param.h>.
Conditionalize inclusion of <include/sys/stat.h> vs <sys/stat.h>.
Include autoconf-recommended block of dirent/NAMELEN-related
definitions and includes. Use NAMLEN throughout, rather than
_D_EXACT_NAMLEN.
[_LIBC] (close, closedir, fchdir, open, opendir): Define.
[_LIBC] (readdir, tdestroy, tfind, tsearch): Define.
Remove `__' prefix from all uses of the above. This will help
to merge *BSD changes.
[!_LIBC] (internal_function): Define.
[! _LIBC && ! LSTAT_FOLLOWS_SLASHED_SYMLINK]: Define lstat.
(__set_errno): Define if not already defined.
|
|
(fts_read): If fts_safe_changedir fails because it is not
able to chdir into a subdirectory, then inform the caller.
|
|
|
|
|