Age | Commit message (Collapse) | Author |
|
(AD_mark_helper): Free malloc'd filename if hash_insert says
that string is already in the hash table.
|
|
being recorded.
* src/remove.c (remove_cwd_entries): Don't call cycle_check here.
(AD_push): Call it from here instead.
|
|
* src/remove.c (AD_stack_clear): New function.
(rm_1): Use it.
(AD_pop_and_chdir): Free *prev_dir just before longjmp.
|
|
|
|
fd_to_subdirp failure, not just when errno == EACCES.
* src/remove.c (remove_dir): Use unlinkat-with-AT_REMOVEDIR, not
rmdir, here, even though rmdir may happen to be adequate.
|
|
* src/remove.c (remove_cwd_entries): If we can't open a directory,
and the failure is not being ignored, try to remove the directory
with rmdir (aka unlinkat-with-AT_REMOVEDIR), in case it's empty.
Problem report and test case from Paul Eggert in
<http://article.gmane.org/gmane.comp.gnu.core-utils.bugs/7425>.
* tests/rm/empty-inacc: New test, for the above.
|
|
|
|
|
|
CYCLE_CHECK_REFLECT_CHDIR_UP, rather than open-coding it.
|
|
could cause the removal of that directory to fail with an erroneous
diagnostic about a directory cycle. Reported by Vineet Chadha.
(AD_pop_and_chdir): If the directory we're about to
leave (and try to rmdir) is the one whose dev_ino is being used to
detect a cycle, reset cycle_check_state.dev_ino to that of the parent.
|
|
|
|
(close_preserve_errno): New function.
(fd_to_subdirp): Don't print a diagnostic in this function.
Do it from the callers instead, unless rmdir succeeds.
(remove_cwd_entries, remove_dir): Adjust callers.
|
|
First off, the attribute should have been `volatile' (not static)
to avoid longjmp-related risk of clobber. Secondly, now there is
no longer any risk of a local variable being clobbered, so there's
no need for any attribute at all.
|
|
(AD_pop_and_chdir): Use gotos to avoid some duplication.
(AD_push): Rewrite an assertion so that the entire computation
goes away when assertions are turned off.
|
|
| O_NOFOLLOW too, for consistency with other dir-openers.
Use POSIX-preferred O_NONBLOCK rather than O_NDELAY.
(is_empty_dir): Likewise.
|
|
(OPEN_NO_FOLLOW_SYMLINK): Remove definition. Use O_NOFOLLOW in
place of all uses, since it is guaranteed (system.h) to be defined.
|
|
(OPENAT_CWD_RESTORE__ALLOW_FAILURE): Likewise.
(fd_to_subdirp): Remove openat_cwd_restore_allow_failure arg; its
value is now signified by whether cwd_errno is null.
(fd_to_subdirp, remove_dir, rm_1); Change cwd failure indicator from
pointer-to-bool to pointer-to-errno-value. All callers changed.
(rm_1): Don't bother setting a local cwd failure flag and then
ORing it into the caller's. Just set the caller's.
(rm): Use cwd failure errno value to print a slightly-better
diagnostic.
|
|
|
|
|
|
|
|
|
|
that provide openat (Solaris), and on systems like Linux+procfs
where our openat emulation code is reentrant. This also fixes a
few low-probability leaks and eliminates some code that could,
in very unusual circumstances, cause rm() (via a callee) to exit.
|
|
(AD_mark_current_as_unremovable): Likewise, but for a local.
(rm_1): Likewise.
|
|
(without -r) fails to remove a directory on a non-Linux system.
This change affects only newer Solaris systems (with priv_*
functions like priv_allocset). Reported by Keith Thompson.
|
|
|
|
when attempting to remove `/' with --preserve-root.
|
|
assignment out of an if-expression.
|
|
|
|
|
|
Remove inaccurate-but-harmless `const' attributes.
|
|
(DT_IS_DIR): Remove.
(DT_IS_KNOWN, DT_MUST_BE): New macros.
(remove_entry): Use them.
|
|
(UNLINK_CAN_UNLINK_DIRS): Remove.
(remove_entry): Use cannot_unlink_dirs () rather than
UNLINK_CAN_UNLINK_DIRS.
|
|
|
|
|
|
|
|
systems with a buggy readdir affecting file systems inaccessible
at configure time.
In some unusual circumstances `rm -r' would fail to remove --
or even consider -- all entries in a directory with more than 254
(SunOS) or 338 (Darwin) entries. This could cause trouble even on
other types of systems when using an affected file system via e.g.,
NFS. The underlying cause was a bug in readdir on those systems.
Coreutils-5.2.1 and earlier used a configure-time test designed
to detect precisely those problem systems, but it would detect
the problem and enable remove.c's work-around code only when its
configure-time test was run on a losing file system. Obviously,
it couldn't detect a problem if the offending file system wasn't
tested or even mounted at coreutils configure time. Now, rm itself
performs a minimal-cost run-time test to detect the problem.
(CONSECUTIVE_READDIR_UNLINK_THRESHOLD): Define.
(remove_cwd_entries): When readdir returns NULL for a directory from
which we've removed more than CONSECUTIVE_READDIR_UNLINK_THRESHOLD
entries, call rewinddir and then resume the readdir/unlink loop.
(UNLINK_CAN_UNLINK_DIRS): Rename from ROOT_CAN_UNLINK_DIRS.
|
|
|
|
the bottom of the active-directory stack was no longer
strictly necessary. This change removes that member and uses
the newer cwd_state parameter for the final restore_cwd.
(struct AD_ent) [u]: Remove now-unnecessary union.
[dev_ino]: Rename from `a'.
(AD_pop_and_chdir): Add a parameter to play the role of just-removed
bottom-of-stack cwd-state member.
(AD_pop_and_chdir): No longer return boolean. Adjust caller.
(AD_push_initial): Remove CWD parameter. Adjust caller.
|
|
(rm): Destroy the saved_cwd here (via cwd_state),
if necessary, not in remove_dir. Otherwise, removing multiple
`.'-relative nonempty directories no longer worked.
|
|
operating on too many command-line-specified nonempty directories.
(remove_dir): Destroy the `struct saved_cwd' on the
top of the stack before returning. This usually closes the file
descriptor that was used to return to the original working directory.
Reported by Cyril Bouthors in
http://article.gmane.org/gmane.comp.gnu.core-utils.bugs/3048
|
|
|
|
AD_push, prompt, remove_dir): Use bool when appropriate.
(top_dir, pop_dir, full_filename_):
Use size_t for sizes.
|
|
working directory, pretend we started from "/", not ".".
This avoids a bug on hosts like Solaris that don't let you
remove the working directory.
|
|
(top_dir): Remove now-unnecessary cast of obstack_base.
(pop_dir): Likewise.
(full_filename_): Likewise.
|
|
remove a symlink to a file on an off-line NFS-mounted partition.
Reported by David Howells in https://bugzilla.redhat.com/124699.
(write_protected_non_symlink): New function.
Don't invoke euidaccess on symlinks.
(prompt): Use write_protected_non_symlink rather than using
euidaccess directly, being careful not to call lstat twice for a file.
|
|
directory and with two or more command line arguments including an
absolute-named directory followed by a relative-named directory.
(struct cwd_state): Define.
(AD_pop_and_chdir): Redesign interface so that a restore_cwd failure
can be detected by the caller. Instead of returning a malloc'd
directory name, communicate it to caller via a new parameter, and
return an indication of whether restore_cwd failed. Update caller.
Eliminate an unnecessary call to AC_stack_top.
(remove_dir): Change type of cwd_state parameter to `struct cwd_state'
so we can now communicate to caller whether/how functions like
restore_cwd have failed. Update caller.
(rm_1): Fail if we've failed to restore the working directory
and the name of the next file to remove is `.'-relative.
(rm): Fail if the require_restore_cwd flag is true and we've
failed to restore the working directory.
|
|
|
|
|
|
|
|
(remove_dir): Use xmalloc, not XMALLOC.
(ds_init): Likewise.
|