-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
Description
After encountering an error in do_pass, our implementation continues, and tries again to overwrite the file:
$ cargo build && LC_ALL=C fiu-run -x -c "enable_random name=posix/io/rw/write,probability=0.01" cargo run shred -vn3 foo
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.14s
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s
Running `target/debug/coreutils shred -vn3 foo`
shred: foo: pass 1/3 (random)...
shred: foo: File write pass failed: Invalid input
shred: foo: pass 2/3 (random)...
shred: foo: pass 3/3 (random)...
[$? = 1]However, the GNU implementation doesn't do that:
$ LC_ALL=C fiu-run -x -c "enable_random name=posix/io/rw/write,probability=0.01" shred -vn3 foo
shred: foo: pass 1/3 (random)...
shred: foo: error writing at offset 917504: Disk quota exceeded
[$? = 1]
$ LC_ALL=C fiu-run -x -c "enable_random name=posix/io/rw/write,probability=0.02" shred -vn3 foo
shred: foo: pass 1/3 (random)...
shred: foo: error writing at offset 131072: Interrupted system call
[$? = 1]
$ LC_ALL=C fiu-run -x -c "enable_random name=posix/io/rw/write,probability=0.02" shred -vn3 foo
shred: foo: pass 1/3 (random)...
shred: foo: pass 2/3 (random)...
shred: foo: error writing at offset 786432: Interrupted system call
[$? = 1]This seems to be due to the following code in fn wipe_file:
// Ignore failed writes; just keep trying
show_if_err!(
do_pass(&mut file, &pass_type, exact, size)
.map_err_context(|| format!("{}: File write pass failed", path.maybe_quote()))
);So apparently we do that intentionally, for some reason? But we shouldn't?
Ping @forticulous, do you know whether there was a good reason that we should do it like this? (In this case, we should probably document it in extensions.md.) Or maybe it should be changed to a regular error instead? (I'm pinging you because of eb64530)
Found while working on #5711