Skip to content

Commit 7f3a359

Browse files
authored
cp: use FileInformation without dereference for symlink destination check to match GNU behaviour for test/nfs-removal-race (#10086)
* cp: use lstat for destination check to support LD_PRELOAD tests * fs: fix Windows is_symlink type mismatch and add explanatory comment * cp: use stat for dest existence check to support LD_PRELOAD
1 parent abd511a commit 7f3a359

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/uu/cp/src/cp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,8 +1390,8 @@ pub fn copy(sources: &[PathBuf], target: &Path, options: &Options) -> CopyResult
13901390
let dest = construct_dest_path(source, target, target_type, options)
13911391
.unwrap_or_else(|_| target.to_path_buf());
13921392

1393-
if fs::metadata(&dest).is_ok()
1394-
&& !fs::symlink_metadata(&dest)?.file_type().is_symlink()
1393+
if FileInformation::from_path(&dest, true).is_ok()
1394+
&& !fs::symlink_metadata(&dest).is_ok_and(|m| m.file_type().is_symlink())
13951395
// if both `source` and `dest` are symlinks, it should be considered as an overwrite.
13961396
|| fs::metadata(source).is_ok()
13971397
&& fs::symlink_metadata(source)?.file_type().is_symlink()

util/fetch-gnu.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ curl -L "${repo}/releases/download/v${ver}/coreutils-${ver}.tar.xz" | tar --stri
77
curl -L ${repo}/raw/refs/heads/master/tests/mv/hardlink-case.sh > tests/mv/hardlink-case.sh
88
curl -L ${repo}/raw/refs/heads/master/tests/mkdir/writable-under-readonly.sh > tests/mkdir/writable-under-readonly.sh
99
curl -L ${repo}/raw/refs/heads/master/tests/cp/cp-mv-enotsup-xattr.sh > tests/cp/cp-mv-enotsup-xattr.sh #spell-checker:disable-line
10+
curl -L ${repo}/raw/refs/heads/master/tests/cp/nfs-removal-race.sh > tests/cp/nfs-removal-race.sh
1011
curl -L ${repo}/raw/refs/heads/master/tests/csplit/csplit-io-err.sh > tests/csplit/csplit-io-err.sh
1112
# Avoid incorrect PASS
1213
curl -L ${repo}/raw/refs/heads/master/tests/runcon/runcon-compute.sh > tests/runcon/runcon-compute.sh

0 commit comments

Comments
 (0)