Skip to content

mv: warn when the destination doesn't support xattrs - #15101

Merged
sylvestre merged 2 commits into
uutils:mainfrom
Cassian433:mv-warn-enotsup-xattr
Nov 7, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
Cassian433:mv-warn-enotsup-xattr

Conversation

@Cassian433

Copy link
Copy Markdown
Contributor

Closes #15079

Since the bump to GNU 9.12, the mv half of tests/cp/cp-mv-enotsup-xattr fails. GNU 9.12 mv, moving a file with xattrs onto a file system without xattr support, prints

mv: setting attributes for 'noxattr/a': Operation not supported

and exits 0. We print nothing, because rename_file_fallback in src/uu/mv/src/mv.rs copies through copy_xattrs_fd_ignore_unsupported, which drops ENOTSUP. That matched the old manual ("all but 'Operation not supported' warnings"), which #10083 followed. The 9.12 manual now says "Upon failure all warnings are emitted, but do not modify the exit status."

The file path now calls copy_xattrs_fd and hands the failures to a new show_xattr_failures_for. Any ENOTSUP/EOPNOTSUPP turns into a single setting attributes for 'DEST': ... line for the file. Other errors keep the per-attribute lines from #15049. A source with no xattrs still moves silently, and so does a file whose only xattr is a POSIX ACL, because GNU is quiet there as well. is_xattr_unsupported in uucore is now public, and the message is a new mv-error-setting-attributes key in en-US and fr-FR, mirroring cp's cp-error-setting-attributes.

I wasn't sure whether GNU prints one line per file or one per attribute, so I built 9.12 from the release tarball and ran its mv against a ramfs and a vfat loop mount. Three user.* attributes give one line. trusted.* and security.* (as root) give the same single line. An ACL alone gives nothing; an ACL plus a user.* attribute gives the line. Over 15 cases (one, three and no attributes, ACL only, ACL plus user, same fs, overwriting, dir/ as the target, a relative target) this branch matches GNU 9.12 on stderr and exit status. Main is missing 9 of those lines.

test_mv_xattr_enotsup_silent asserted the old silence, and it only hit the ENOTSUP case on kernels older than 6.6, where /dev/shm refuses user xattrs. I replaced it with test_mv_xattr_enotsup_warns_once. It mounts a ramfs with sudo -E --non-interactive mount the way test_cp_reflink_always_override does, and skips when that fails. It moves files with one and with three attributes and expects exactly one warning line for each. Then it checks that a file with no xattrs and one with only an ACL move silently, and that a same-fs move stays quiet. It unmounts before asserting. Because it needs sudo, CI runs it on the Linux runners and skips it elsewhere. Locally (Linux 7.0, ext4 to ramfs) it passes on this branch and fails on main with an empty stderr. The rest of test_mv and test_cp pass, and clippy is clean.

cp-mv-enotsup-xattr should flip to PASS.

The directory paths (rename_dir_fallback and the per-file copy inside a moved directory) are being reworked in #14971, so I left them alone. The same goes for rename_symlink_fallback, which on main is also reached from the directory copy. GNU warns on those paths too, so they can follow once #14971 lands. The branch merges cleanly with #14971 and #13334.

@Cassian433
Cassian433 force-pushed the mv-warn-enotsup-xattr branch from f332d6b to 3d437ad Compare October 5, 2026 19:34
@codspeed

codspeed Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning, 1 note

⚠️ 121 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

✅ 401 untouched benchmarks
⏩ 70 skipped benchmarks1


Comparing Cassian433:mv-warn-enotsup-xattr (6999998) with main (e03b9f6)2

Open in CodSpeed

Footnotes

  1. 70 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. ↩

  2. No successful run was found on main (382c50e) during the generation of this report, so e03b9f6 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Comment thread src/uu/mv/src/mv.rs Outdated
target_os = "android",
target_os = "netbsd"
))]
fn show_xattr_failures_for(to: &Path, failed: Vec<(OsString, io::Error)>) {

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.

could this be merged into show_xattr_failures with an optional path, rather than adding a second helper with a near-identical name?

/// distinct on the BSDs).
#[cfg(unix)]
fn is_xattr_unsupported(err: &std::io::Error) -> bool {
pub fn is_xattr_unsupported(err: &std::io::Error) -> bool {

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.

copy_xattrs_fd_ignore_unsupported no longer has any callers after this change, could you please remove it?

Comment thread tests/by-util/test_mv.rs Outdated
};
// user::rw-, user:0:r--, group::r--, mask::r--, other::---. The named user
// keeps the kernel from folding it into the mode bits.
let acl: &[u8] = &[

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 raw ACL bytes are hard to check, could we use setfacl -m u:0:r instead and skip if it's missing?

@sylvestre

Copy link
Copy Markdown
Contributor

sorry but it needs to be rebased, and a bunch of jobs are failing

@sylvestre
sylvestre force-pushed the mv-warn-enotsup-xattr branch from 3d437ad to a3f0a09 Compare November 4, 2026 07:31
Copilot AI balanced review requested due to automatic review settings November 4, 2026 07:31

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@sylvestre
sylvestre force-pushed the mv-warn-enotsup-xattr branch from a3f0a09 to 73e3257 Compare November 4, 2026 07:32
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/cp/cp-mv-enotsup-xattr is no longer failing!

Copilot AI balanced review requested due to automatic review settings November 4, 2026 08:45

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@sylvestre
sylvestre force-pushed the mv-warn-enotsup-xattr branch from d46364c to 38c0ac2 Compare November 4, 2026 08:51
Should make test cp/cp-mv-enotsup-xattr pass

Co-authored-by: Cassian433 <[email protected]>
@sylvestre
sylvestre force-pushed the mv-warn-enotsup-xattr branch from 38c0ac2 to 8277e6e Compare November 5, 2026 06:58
Copilot AI balanced review requested due to automatic review settings November 5, 2026 06:59

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Copilot AI balanced review requested due to automatic review settings November 6, 2026 17:34

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@sylvestre
sylvestre merged commit 9fecc8a into uutils:main Nov 7, 2026
233 of 235 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

RenjiSann added a commit to RenjiSann/coreutils that referenced this pull request Nov 9, 2026
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: no warning when the destination file system doesn't support xattrs (GNU cp-mv-enotsup-xattr, 9.12)

3 participants