summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2013-11-07 13:26:25 +0000
committerPádraig Brady <P@draigBrady.com>2013-11-08 13:33:50 +0000
commitc93d5b4aa7f675dabaebf5e4ee9583162e4c977d (patch)
tree4d2f9263b40382fb0c133cf5a46392595e3acae5 /tests
parentbf6bf52dce37832b03ecfbe1b3a3b104f532df42 (diff)
downloadcoreutils-c93d5b4aa7f675dabaebf5e4ee9583162e4c977d.tar.xz
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.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/misc/shred-exact.sh11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/misc/shred-exact.sh b/tests/misc/shred-exact.sh
index 0cdc91fc0..eb30a7d69 100755
--- a/tests/misc/shred-exact.sh
+++ b/tests/misc/shred-exact.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# make sure that neither --exact nor --zero gobbles a command line argument
+# Test functionality of --exact
# Copyright (C) 2000-2013 Free Software Foundation, Inc.
@@ -20,6 +20,7 @@
print_ver_ shred
+# make sure that neither --exact nor --zero gobbles a command line argument
for opt in --exact --zero; do
echo a > a || fail=1
echo bb > b || fail=1
@@ -33,4 +34,12 @@ for opt in --exact --zero; do
test -f c && fail=1
done
+
+# make sure direct I/O is handled appropriately at end of file
+# Create a 1MiB file as we'll probably not be using blocks larger than that
+# (i.e. we want to test failed writes not at the start).
+truncate -s1MiB file.slop || framework_failure_
+truncate -s+1 file.slop || framework_failure_
+shred --exact -n1 file.slop || fail=1
+
Exit $fail