]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
shred: shred one block even for empty files
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 3 Apr 2014 16:42:53 +0000 (09:42 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 3 Apr 2014 16:43:20 +0000 (09:43 -0700)
* src/shred.c (do_wipefd): Shred one block of empty regular files.
This reverts an unintended part of the previous change.

src/shred.c

index 0a53a16beea7ea991d53f22e639fc245ad565c3e..732d3afb1ac99140c320c63872211a8865812e37 100644 (file)
@@ -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))