Repository navigation
mv: report specific errors instead of generic permission denied on cross-device fallback - #16057
afnan-mojumder wants to merge 1 commit into
Conversation
c53e8fa to
e249b0f
Compare
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
|
File moves across devices match GNU 9.12 now, nice. Directories still lose the real error, though. Moving a dir from ext4 into a read-only (0555) dir on tmpfs gives |
|
Thanks for catching this @fixfon! There were two issues at play here for directories:
We've updated this to:
|
|
Thanks, 797c4f5 fixes what I saw earlier: moving a directory across filesystems into a read-only target now reports "cannot create directory ...: Permission denied", and an unreadable file inside it is named in the error, both matching GNU 9.12. The remaining differences I noticed (the mode of a copied unreadable subdirectory, and the wording when the target directory is not empty) are the same on main, so they seem out of scope here. |
|
Thanks for verifying and confirming the GNU 9.12 parity @fixfon! I've also pushed a clean |
2d3b68c to
c30b8d5
Compare
|
GNU testsuite comparison: |
c30b8d5 to
5c84d83
Compare
5c84d83 to
ebeaae0
Compare
…oss-device fallback
Previously, rename_file_fallback unconditionally mapped errors during
cross-device fallback moves to translate!("mv-error-permission-denied"),
causing misleading errors such as "Permission denied" when the disk is full
(ENOSPC), or missing contextual path information (e.g. "cannot open ... for
reading", "cannot create regular file ...", "cannot remove ...").
Additionally, when moving directories across devices, rename_dir_fallback
previously attempted to open the destination directory for applying xattrs
before checking if copy_dir_contents succeeded, and directory/entry errors were
reported against the top-level move rather than the failing path.
- Introduce RenameError to distinguish raw I/O errors from pre-formatted
diagnostics, and preserve synthetic non-OS I/O messages as-is.
- Report accurate GNU Coreutils-compatible messages for cross-device fallback
failures (unreadable source, unwritable dest dir, ENOSPC, unremovable source
or target, cannot create directory, cannot access subdirectory).
- Unify regular file copying in copy_regular_file so fallback paths use
fd-pinned safe copying while preserving xattrs and setuid/setgid rules.
- Handle declined interactive prompts cleanly without printing empty errors.
- Add regression tests covering cross-device file and directory permission
failures.
Fixes uutils#15939
Closes uutils#9458
ebeaae0 to
b7a7b08
Compare
Fixes #15939
Closes #9458
Description
Previously,
rename_file_fallbackunconditionally converted any error during cross-device fallback moves totranslate!("mv-error-permission-denied"). This resulted in misleading error messages (e.g. reporting "Permission denied" when a destination filesystem is full withENOSPC, or omitting the target file path in errors).This PR introduces
RenameErrorto distinguish raw I/O errors from pre-formatted diagnostics, propagating specific GNU Coreutils-compatible messages:mv: Permission deniedmv: cannot open '<src>' for reading: Permission denied(matching GNU coreutils)mv: Permission deniedmv: cannot create regular file '<dst>': Permission denied(matching GNU coreutils)mv: Permission deniedmv: cannot remove '<src>': Permission denied(matching GNU coreutils)mv: Permission deniedmv: inter-device move failed: '<src>' to '<dst>'; unable to remove target: Permission denied(matching GNU coreutils)ENOSPC) on destination:mv: Permission deniedmv: error writing '<dst>': No space left on device(matching GNU coreutils)rename(2)errors:mv: cannot move '<src>' to '<dst>': <err>(matching GNU coreutils)Translations updated for
en-USandfr-FR.Tests
tests/by-util/test_mv.rs:test_mv_cross_device_source_unreadabletest_mv_cross_device_dest_directory_unwritabletest_mv_cross_device_source_directory_unwritablecargo test --package uu_mvandcargo test --test tests test_mv(all 154 passed).cargo fmt -- --checkandcargo clippy --package uu_mv --all-targets -- -D warnings.AI disclosure: Written with an AI coding assistant and verified locally.