shred: fix direct I/O failures for last write to file
commitc93d5b4aa7f675dabaebf5e4ee9583162e4c977d
authorPádraig Brady <P@draigBrady.com>
Thu, 7 Nov 2013 13:26:25 +0000 (7 13:26 +0000)
committerPádraig Brady <P@draigBrady.com>
Fri, 8 Nov 2013 13:33:50 +0000 (8 13:33 +0000)
tree4d2f9263b40382fb0c133cf5a46392595e3acae5
parentbf6bf52dce37832b03ecfbe1b3a3b104f532df42
shred: fix direct I/O failures for last write to file

Since direct I/O is now enabled with commit v8.21-139-gebaf961
we must handle the case where we write an odd size at the
end of a file (with --exact), or we specify an odd --size that
is larger than 64KiB, or in the very unlikely case of a device
with an odd size.  This issue was present since direct I/O
support was first added in v5.3.0, but latent since v6.0.
Theoretically this could have also been an issue after that on
systems which didn't have alignment constraints, but did have
size constraints for direct I/O.

* src/shred.c (dopass): On the first pass for a file, always
retry a write that fails with EINVAL, so we handle direct I/O
failure at either the start or end of the file.  Adjust the comment
as the original case is out of date and implicitly handled
by this more general fix.
* tests/misc/shred-exact.sh: Add a test case.
* NEWS: Add a "bug fix" entry for shred since there are
two related issues now fixed.
NEWS
src/shred.c
tests/misc/shred-exact.sh