Avoid the need for euidaccess and/or lstat on every directory entry
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 25 Mar 2007 07:52:57 +0000 (09:52 +0200)
committerJim Meyering <jim@meyering.net>
Sun, 25 Mar 2007 07:52:57 +0000 (09:52 +0200)
commit1efda4faf3878d180a13a94cadc690f2a95090b1
treeeccdf744921edfb7b4eea958a2fd2c76e26af4be
parentde730249777c65b2c75502b00159400eda8dacf9
Avoid the need for euidaccess and/or lstat on every directory entry
with 'rm -r dir' (without -f), if we are root, or if we are removing
a directory tree that is full of symbolic links.
* bootstrap.conf (gnulib_modules): Add write-any-file.
* src/copy.c: Include write-any-file.h.
(UNWRITABLE): Remove macro, replacing with....
(writable_destination): New function, which uses can_write_any_file
to avoid the need for euidaccess when we are privileged.
(overwrite_prompt, abandon_move): Use it.
* src/remove.c: Include write-any-file.h.
(D_TYPE): New macro.
(DT_UNKNOWN, DT_DIR, DT_LNK) [!HAVE_STRUCT_DIRENT_D_TYPE]: New macros.
(write_protected_non_symlink): Don't bother to stat if we can write
any file.
(prompt): New arg PDIRENT_TYPE.  All callers changed.
Use readdir dirent type to avoid the need for 'lstat' on each directory
entry in cases like 'rm -r dir', if we are root, or if the tree is
full of symbolic links.
(DT_IS_KNOWN, DT_MUST_BE): Remove.
(remove_entry): New arg DIRENT_TYPE_ARG.  All callers changed.
ChangeLog
bootstrap.conf
src/copy.c
src/remove.c