Skip to content

mv: keep copying xattrs after one fails on a cross-device move - #14629

Open
krosci wants to merge 1 commit into
uutils:mainfrom
krosci:mv-copy-xattr-continue-on-error
Open

krosci wants to merge 1 commit into
uutils:mainfrom
krosci:mv-copy-xattr-continue-on-error

Conversation

@krosci

@krosci krosci commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

When a cross-device move copies a file or directory that carries several xattrs, a single rejected attribute (e.g. one larger than the destination filesystem allows) used to abort the copy loop, silently dropping every remaining xattr, and the move reported success. GNU mv reports the failing attribute on stderr, copies on through the others, and still exits 0.

copy_xattrs*/apply_xattrs* in uucore now report each failing attribute, keep copying the rest, and return the first error. mv no longer aborts the directory path on a reported failure. cp uses a silent marker so the already-reported per-attribute diagnostics are not echoed a second time.

Fixes #14598.

Comment thread src/uu/cp/src/cp.rs Outdated
#[error("{}", translate!("cp-error-not-all-files-copied"))]
NotAllFilesCopied,

/// Extended-attribute copying failed, but every failure was already

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it can be a one line comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Comment thread src/uu/cp/src/cp.rs Outdated

// If copying xattrs failed, propagate that error now with context.
//
// `copy_xattrs*` already reported each failing attribute on stderr, so

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, doesn't have to be that long

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@krosci
krosci requested a review from sylvestre September 16, 2026 23:14
@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/df/skip-rootfs. tests/df/skip-rootfs is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/id/smack. tests/id/smack is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/mkdir/smack-root. tests/mkdir/smack-root is passing on 'main'. Maybe you have to rebase?

@krosci
krosci force-pushed the mv-copy-xattr-continue-on-error branch 5 times, most recently from c11d4b9 to 7018e7c Compare September 20, 2026 10:33
@codspeed

codspeed Bot commented Sep 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 377 untouched benchmarks
⏩ 54 skipped benchmarks1


Comparing krosci:mv-copy-xattr-continue-on-error (25ac6f2) with main (5eb255f)

Open in CodSpeed

Footnotes

  1. 54 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@sylvestre
sylvestre force-pushed the mv-copy-xattr-continue-on-error branch from 7018e7c to 9c3117a Compare September 20, 2026 19:29
} else {
"setting attribute"
};
show_error!("{action} {}: {}", attr_name.quote(), strip_errno(&err));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use translate!() for these two strings
also, GNU says "setting attribute 'user.x' for 'dest': ...", could you please check the LANG=C output and match it (the "for dest" part is missing here)?

Comment thread tests/by-util/test_mv.rs
/// failing `user.m_big` is rejected.
#[test]
#[cfg(target_os = "linux")]
fn test_mv_cross_device_dir_xattr_partial_failure_completes() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is ~90% the same as the one above, could be dedup, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I'm done!

Comment thread tests/by-util/test_mv.rs Outdated
assert_eq!(small_z_out.stdout, b"87654321");

let big_out = Command::new("getfattr")
.args(["-n", "user.m_big", "--only-values", "--absolute-names"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the getfattr + assert block is repeated 5 times in this file, a small helper please :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I'm done!

Comment thread tests/by-util/test_mv.rs Outdated
/// source. Returns `None` when this machine's filesystem combination cannot
/// produce that failure, in which case the test should be skipped.
#[cfg(target_os = "linux")]
fn tmpfs_to_target_failing_xattr_value(dest_dir: &Path) -> Option<String> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same probe as in the uucore unit test and test_cp, please share it (uutests?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, moved to uutests::util::tmpfs_to_target_failing_xattr_value.

Comment thread .github/workflows/GnuComment.yml Outdated
Comment thread build.rs
@krosci
krosci force-pushed the mv-copy-xattr-continue-on-error branch 3 times, most recently from c66613d to add8620 Compare September 21, 2026 12:53
@krosci
krosci force-pushed the mv-copy-xattr-continue-on-error branch from add8620 to 25ac6f2 Compare September 21, 2026 16:13

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mv: cross-device move drops the rest of the xattrs after one failure, and reports success

2 participants