summaryrefslogtreecommitdiff
path: root/src/remove.c
AgeCommit message (Collapse)Author
2005-06-02Don't use "path" or "filename".Paul Eggert
2005-05-19(AD_mark_helper, AD_mark_current_as_unremovable):Jim Meyering
Remove inaccurate-but-harmless `const' attributes.
2005-05-16Fix Cygwin porting problem reported by Eric Blake.Paul Eggert
(DT_IS_DIR): Remove. (DT_IS_KNOWN, DT_MUST_BE): New macros. (remove_entry): Use them.
2005-05-14Include unlinkdir.h.Paul Eggert
(UNLINK_CAN_UNLINK_DIRS): Remove. (remove_entry): Use cannot_unlink_dirs () rather than UNLINK_CAN_UNLINK_DIRS.
2005-05-14Update FSF postal mail address.Jim Meyering
2005-05-14Update FSF postal mail address.Jim Meyering
2005-05-13fix grammar typo in commentJim Meyering
2005-05-13* NEWS: `rm -r' now removes all of the files it should, even onJim Meyering
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.
2005-03-28(ds_init): Add `void' to make this an ANSI-style function declaration.Jim Meyering
2004-11-24Since the changes of 2004-05-22, the u.saved_cwd member atJim Meyering
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.
2004-10-21Correct my patch of 2004-10-18.Jim Meyering
(rm): Destroy the saved_cwd here (via cwd_state), if necessary, not in remove_dir. Otherwise, removing multiple `.'-relative nonempty directories no longer worked.
2004-10-18Plug a leak that would cause rm or a cross-device mv to fail whenJim Meyering
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
2004-09-22(struct dirstack_state) [current_arg_jumpbuf]: Improve the comment.Jim Meyering
2004-07-30(right_justify), full_filename_, AD_pop_and_chdir,Paul Eggert
AD_push, prompt, remove_dir): Use bool when appropriate. (top_dir, pop_dir, full_filename_): Use size_t for sizes.
2004-07-28(remove_dir): If we can't save the state of thePaul Eggert
working directory, pretend we started from "/", not ".". This avoids a bug on hosts like Solaris that don't let you remove the working directory.
2004-06-20Include yesno.h.Jim Meyering
(top_dir): Remove now-unnecessary cast of obstack_base. (pop_dir): Likewise. (full_filename_): Likewise.
2004-06-02rm (without -f) could hang unnecessarily when attempting toJim Meyering
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.
2004-05-29rm -r would get a failed assertion when run from an inaccessibleJim Meyering
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.
2004-05-28(push_dir): Merge declaration and adjacent assignment into a single statement.Jim Meyering
2004-05-28tweak a commentJim Meyering
2004-05-28(AD_mark_helper): Eliminate unnecessary comparison.Jim Meyering
2004-05-22(rm): Use free rather than XFREE.Jim Meyering
(remove_dir): Use xmalloc, not XMALLOC. (ds_init): Likewise.
2004-05-14(AD_pop_and_chdir): Eliminate an unnecessary call to AC_stack_top.Jim Meyering
2004-05-12(AD_pop_and_chdir): Move lstat-`.' into if-blockJim Meyering
where the result is used. This avoids one unnecessary lstat call per command line argument.
2004-05-10(AD_push): Don't use errno in diagnostic about `changed dev/ino'.Jim Meyering
2004-05-08Fix bug where "rm" gave up too easily, reported by Dan Jacobsen inJim Meyering
<http://mail.gnu.org/archive/html/bug-coreutils/2004-05/msg00013.html>. (remove_entry): Check for errno values like ENOENT that show the file cannot be directory, instead of for errno values like EPERM that show the file might be a directory. This is necessary because, when a single unlink() call has multiple reasons to fail, it can set errno to any of those reasons; it's only the rare errno value like ENOENT that excludes all the other possible reasons to fail even when the file is a directory. (remove_cwd_entries): Don't attempt chdir if the file is known to not be a directory. (remove_dir): Use the same method that remove_cwd_entries uses (for some reason they differed). Don't assert that saved_errno must be EPERM; it might be just about anything.
2004-04-27(rm): Add `extern' keyword.Jim Meyering
2004-04-20(is_empty_dir): Clarify comment.Jim Meyering
2004-04-18(full_filename_): Don't leak upon failed realloc.Jim Meyering
2004-04-18(readdir_ignoring_dotdirs): Move function to system.h, renaming it. Update ↵Jim Meyering
uses.
2004-04-17(ds_init, ds_free): Declare functions to be `static'.Jim Meyering
2004-04-09undo last changeJim Meyering
2004-04-09Don't include "file-type.h", now that system.h does.Jim Meyering
2004-03-21(ds_free): Plug a small leak.Jim Meyering
2003-11-09Include "root-dev-ino.h".Jim Meyering
(remove_cwd_entries): Remove now-obsolete FIXME comment. (remove_dir): Support rm's new --preserve-root option.
2003-09-08Add a comment.Jim Meyering
2003-09-07(D_INO, ENABLE_CYCLE_CHECK) [D_INO_IN_DIRENT]:Jim Meyering
Don't define. These symbols are no longer used.
2003-07-27(prompt) [! recursive]: Don't prompt about unwritableJim Meyering
directories, as required by POSIX. Reported by Karl Berry.
2003-07-12(remove_dir): Give a diagnostic upon failed save_cwd,Jim Meyering
now that that function no longer calls `error'.
2003-07-12It appears that the `#pragma alloca' included via "system.h" isJim Meyering
adequate, since join.c uses alloca, yet lacked an in-file #pragma. Remove `#pragma alloca'.
2003-05-04(HAVE_WORKING_READDIR): Define to 0 if not defined.Jim Meyering
(IF_READDIR_NEEDS_REWINDDIR): Remove. (remove_cwd_entries): Rewrite to avoid IF_READDIR_NEEDS_REWINDDIR, which was a bit weird because it couldn't be emulated by a function.
2003-05-02Work around nasty readdir bug with Darwin6.5 and hfs file system.Jim Meyering
(IF_READDIR_NEEDS_REWINDDIR): Define. [! HAVE_WORKING_READDIR] (remove_cwd_entries): If readdir has just returned NULL and there has been at least one successful unlink or rmdir call since the opendir or previous rewinddir, then call rewinddir and reiterate the loop.
2003-05-02Factor out common code.Jim Meyering
(readdir_ignoring_dotdirs): New function. (is_empty_dir): Use it here. (remove_cwd_entries): Use it here.
2003-04-13(is_empty_dir): Don't closedir (NULL).Jim Meyering
2003-03-30(is_empty_dir): Don't let a failing closedirJim Meyering
clobber errno. Spotted by Arnold Robbins.
2003-03-16(rm): Put two local variables in static storage,Jim Meyering
so they can't be clobbered by the potential longjmp.
2003-03-09(AD_stack_pop): Cast sizeof... to int before changing its sign.Jim Meyering
This avoids a warning from gcc on 64-bit systems. (pop_dir): Reverse order of sign change and cast, to be consistent with the above.
2003-03-04(AD_pop_and_chdir): Call error here, now that restore_cwd no longer does it.Jim Meyering
2003-03-03(remove_cwd_entries): Include the full filename ofJim Meyering
the offending file, not just the basename.
2003-03-03(remove_cwd_entries) [!ROOT_CAN_UNLINK_DIRS]: Give anJim Meyering
accurate diagnostic when failing to remove a file owned by some other user. Reported by Ivo Timmermans via Michael Stone. This fixes Debian bug# 178471.