Description
shred reports "No such file or directory" for a file that actually exists but whose metadata cannot be read because its parent directory lacks search permission.
In src/uu/shred/src/shred.rs, the pre-checks use Path::exists() and Path::is_file():
if !path.exists() {
return Err(... "No such file or directory" ...);
}
if !path.is_file() {
return Err(... "Not a file" ...);
}
Both return false for any metadata error, including a permission error, so an inaccessible file is misclassified as missing.
Reproduction
$ mkdir locked && touch locked/file && chmod 000 locked
$ target/debug/coreutils shred locked/file
shred: locked/file: No such file or directory # wrong
# GNU reports the real error instead:
$ shred locked/file
shred: locked/file: failed to open for writing: Permission denied
Expected
shred should surface the real error (a permission error), not claim the file does not exist.
This is the same Path::exists() misclassification as #9789 (chmod).
Description
shredreports "No such file or directory" for a file that actually exists but whose metadata cannot be read because its parent directory lacks search permission.In
src/uu/shred/src/shred.rs, the pre-checks usePath::exists()andPath::is_file():Both return
falsefor any metadata error, including a permission error, so an inaccessible file is misclassified as missing.Reproduction
Expected
shredshould surface the real error (a permission error), not claim the file does not exist.This is the same
Path::exists()misclassification as #9789 (chmod).