Repository navigation
Conversation
A failed rename made shred exit immediately, so with -u a file in a directory without write permission aborted the run and later operands were never processed. Stop renaming at the first failure and let the unlink report the error as "failed to remove: <error>".
Collaborator
|
@fixfon Please open a specific issue for the work rather than referencing a tracker issue. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #14705 (GNU test
tests/shred/shred-remove)Summary
When
shred -ucould not rename a file (for example because its directory is not writable),wipe_nameprinted "Couldn't rename to ..." and calledstd::process::exit(1). The file was never unlinked and the remaining operands were skipped, soshred -u shr/f ok/gwith an unwritableshrleftok/gin place.Now
wipe_namestops renaming at the first failure and returns the last name that worked.do_removethen tries to unlink it, and the error is reported like GNU does:shred: shr/f: failed to remove: Permission denied. The run goes on with the next operand and still exits 1. The WipeSync path in the same function returns the I/O error instead of panicking onexpect.The
failed to remove filemessage is nowfailed to remove(en-US and fr-FR) to match GNU. Theshred-couldnt-renamestring is no longer used, so I removed it.test_shred_fail_no_permand the Linux-only/proc/self/memtest asserted the old rename message and are updated to the new output.How I tested
New test
test_shred_remove_in_unwritable_dir_keeps_going: a file in a read-only directory plus a second file. It checks the exact error, exit code 1, and that the second file is removed. It fails on main and passes now. It is skipped when running as root.Run locally:
cargo fmt --all -- --check,test_shred,cargo test -p uu_shredandcargo clippy --all-targets -- -D warnings. Tested on macOS (arm64), compared against GNU shred 9.12. The/proc/self/memexpectation is GNU 9.7 output on Linux.