I found a glitch in that previous patch, and installed the attached fixup.
>From 07af4e06f907308e356bb2a7e3b1c2eff6597255 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Thu, 3 Apr 2014 09:42:53 -0700
Subject: [PATCH] shred: shred one block even for empty files

* src/shred.c (do_wipefd): Shred one block of empty regular files.
This reverts an unintended part of the previous change.
---
 src/shred.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/shred.c b/src/shred.c
index 0a53a16..732d3af 100644
--- a/src/shred.c
+++ b/src/shred.c
@@ -887,8 +887,11 @@ do_wipefd (int fd, char const *qname, struct randint_source *s,
 
           if (! flags->exact)
             {
+              /* Round up to the nearest blocksize.  If the file is
+                 empty output a block anyway, in case the file system
+                 stores small files in the inode.  */
               off_t remainder = size % ST_BLKSIZE (st);
-              if (remainder != 0)
+              if (remainder != 0 || size == 0)
                 {
                   off_t size_incr = ST_BLKSIZE (st) - remainder;
                   if (! INT_ADD_OVERFLOW (size, size_incr))
-- 
1.9.0

Reply via email to