cp: omit unnecessary stat of destination
commit95d6754451e68451b1714034c69380d450c8385f
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 14 Jan 2022 16:51:13 +0000 (14 08:51 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 14 Jan 2022 22:09:25 +0000 (14 14:09 -0800)
tree08f2b526844fde0741086fd7f7840d1bca68c148
parent43fa191b5a2eb8d1ae28645306689019e81ad7b8
cp: omit unnecessary stat of destination

'cp A B' attempts to open B as a directory, to see whether to
write to B/A instead of to B.  In the common case where the
open fails with ENOENT, do not bother to stat B afterwards
since the stat should also fail with ENOENT.
* src/copy.c (copy_internal, copy): Change bool arg about
nonexistent destination to a 3-way int argument.  All callers changed.
(copy_internal): Do not bother to stat a destination already known
to not exist when following symlinks.
src/copy.c
src/copy.h
src/cp.c
src/install.c
src/mv.c