summaryrefslogtreecommitdiff
path: root/src/shred.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2014-04-03 09:42:53 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2014-04-03 09:43:20 -0700
commit7c3e6be6d70a944fa2cda1f256d01c0fa8928f0b (patch)
treedbe0c450f35353c2df9cb0d13817bbf152317550 /src/shred.c
parent88545ad025b4d9083502889b9f8de9e5ca0b766d (diff)
downloadcoreutils-7c3e6be6d70a944fa2cda1f256d01c0fa8928f0b.tar.xz
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.
Diffstat (limited to 'src/shred.c')
-rw-r--r--src/shred.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/shred.c b/src/shred.c
index 0a53a16be..732d3afb1 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))