From 90181a5926e96f34b5ffff21b81a2874a846ff6f Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Thu, 7 Nov 2013 12:32:29 +0000 Subject: shred: avoid data write pass with --size=0 * src/shred.c (dopass): Exit early to avoid redundant heap allocation, and more importantly avoiding a file sync when we're writting no data, as this can have side effects. Also with --verbose, this avoids printing of "pass status" which could be confusing as to whether data was actually written. * tests/misc/shred-passes.sh: Ensure the status for data passes are not written when not doing any data writes. --- tests/misc/shred-passes.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/misc/shred-passes.sh b/tests/misc/shred-passes.sh index cfdd68e98..938683bce 100755 --- a/tests/misc/shred-passes.sh +++ b/tests/misc/shred-passes.sh @@ -31,9 +31,21 @@ shred: f: removing shred: f: renamed to 0 shred: f: removed" > exp || framework_failure_ - shred -v -u f 2>out || fail=1 compare exp out || fail=1 +# Likewise but with --exact to bypass the +# data passes for the zero length file +touch f || framework_failure_ +echo "\ +shred: f: removing +shred: f: renamed to 0 +shred: f: removed" > exp || framework_failure_ + +shred -x -v -u f 2>out || fail=1 + +compare exp out || fail=1 + + Exit $fail -- cgit v1.2.3-54-g00ecf