]> git.ipfire.org Git - thirdparty/coreutils.git/commit
cp,mv,install: improve EACCES targetdir messages
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 13 Apr 2022 06:56:41 +0000 (23:56 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 13 Apr 2022 06:57:15 +0000 (23:57 -0700)
commitf0a9f5e7da4393e8e8bf2959b3b8b65240805f75
treebcc4e60f76214f6a243a23322bfcc65a1e0ba1ce
parent197a570ff0a17db5c8e003645d154e57bddc70ce
cp,mv,install: improve EACCES targetdir messages

This improves on the fix for --target-directory diagnostics bugs on
Solaris 11.  Problem reported by Bruno Haible and Pádraig Brady; see:
https://lists.gnu.org/r/coreutils/2022-04/msg00044.html
Also, omit some unnecessary stat calls.
* gl/lib/targetdir.c (target_directory_operand): If !O_DIRECTORY,
do not bother calling open if stat failed with errno != EOVERFLOW.
Rename is_a_dir to try_to_open since that’s closer to what it means.
If the open failed with EACCES and we used O_SEARCH, look at stat
results to see whether errno should be ENOTDIR for better diagnostics.
Treat EOVERFLOW as an “I don’t know whether it’s a directory and
there’s no easy way to find out” rather than as an error.
gl/lib/targetdir.c