]> git.ipfire.org Git - thirdparty/coreutils.git/commit
mv: when installing to dir use dir-relative names
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 29 Jan 2022 19:40:17 +0000 (11:40 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 30 Jan 2022 00:29:18 +0000 (16:29 -0800)
commit57c812cc3e17ecf5df887029221fe3f2d0cd7ea0
tree7ebcaabf1250934c4a3b416f7fee12706718e622
parent534cfbb4482791a7dede896b60ca9f3a7e18703f
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.
NEWS
src/cp.c
src/install.c
src/mv.c
src/system.h
tests/install/basic-1.sh
tests/mv/diag.sh