aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-01-29 11:40:17 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2022-01-29 16:29:18 -0800
commit57c812cc3e17ecf5df887029221fe3f2d0cd7ea0 (patch)
tree7ebcaabf1250934c4a3b416f7fee12706718e622 /tests
parentcp: fix comment typo (diff)
downloadcoreutils-57c812cc3e17ecf5df887029221fe3f2d0cd7ea0.tar.gz
coreutils-57c812cc3e17ecf5df887029221fe3f2d0cd7ea0.zip
mv: when installing to dir use dir-relative names
When the destination for mv is a directory, use functions like openat to access the destination files, when such functions are available. This should be more efficient and should avoid some race conditions. Likewise for 'install'. * src/cp.c (must_be_working_directory, target_directory_operand) (target_dirfd_valid): Move from here ... * src/system.h: ... to here, so that install and mv can use them. Make them inline so GCC doesn’t complain. * src/install.c (lchown) [HAVE_LCHOWN]: Remove; no longer needed. (need_copy, copy_file, change_attributes, change_timestamps) (install_file_in_file, install_file_in_dir): New args for directory-relative names. All uses changed. Continue to pass full names as needed, for diagnostics and for lower-level functions that do not support directory-relative names. (install_file_in_dir): Update *TARGET_DIRFD as needed. (main): Handle target-directory in the new, cp-like way. * src/mv.c (remove_trailing_slashes): Remove static var; now local. (do_move): New args for directory-relative names. All uses changed. Continue to pass full names as needed, for diagnostics and for lower-level functions that do not support directory-relative names. (movefile): Remove; no longer needed. (main): Handle target-directory in the new, cp-like way. * tests/install/basic-1.sh: * tests/mv/diag.sh: Adjust to match new diagnostic wording.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/install/basic-1.sh2
-rwxr-xr-xtests/mv/diag.sh4
2 files changed, 3 insertions, 3 deletions
diff --git a/tests/install/basic-1.sh b/tests/install/basic-1.sh
index 83bec639b..690d591e5 100755
--- a/tests/install/basic-1.sh
+++ b/tests/install/basic-1.sh
@@ -131,7 +131,7 @@ EOF
touch sub4/file_exists || framework_failure_
ginstall -t sub4/file_exists -Dv file >out 2>&1 && fail=1
compare - out <<\EOF || fail=1
-ginstall: target 'sub4/file_exists' is not a directory
+ginstall: failed to access 'sub4/file_exists': Not a directory
EOF
# Ensure that -D with an already existing directory for -t's option argument
diff --git a/tests/mv/diag.sh b/tests/mv/diag.sh
index 92410699f..c0a558548 100755
--- a/tests/mv/diag.sh
+++ b/tests/mv/diag.sh
@@ -39,8 +39,8 @@ mv: missing file operand
Try 'mv --help' for more information.
mv: missing destination file operand after 'no-file'
Try 'mv --help' for more information.
-mv: target 'f1' is not a directory
-mv: target 'f2' is not a directory
+mv: target 'f1': Not a directory
+mv: target directory 'f2': Not a directory
EOF
compare exp out || fail=1