mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
shred: avoid a data pass on empty files
* src/shred.c (do_wipefd): Don't increase the size written for an empty file up to a full block. Also increase the size to OFF_T_MAX in the edge case where we do overflow. * NEWS: Mention the shred improvements from recent changes. * tests/misc/shred-passes.sh: Adjust as we no longer write a BLKSIZE of data for empty files.
This commit is contained in:
1 parent
d0294ff3b9
commit
217618e8bf
3 files changed
+13
-10
No files matched your search
+5
-5
@@ -428,7 +428,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
|
||||
size_t soff; /* Offset into buffer for next write */
|
||||
ssize_t ssize; /* Return value from write */
|
||||
|
||||
/* Do nothing for --size=0 or regular empty files with --exact. */
|
||||
/* Do nothing for --size=0 or regular empty files. */
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
@@ -887,15 +887,15 @@ 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. */
|
||||
/* Round up to the nearest blocksize to clear slack space. */
|
||||
off_t remainder = size % ST_BLKSIZE (st);
|
||||
if (remainder != 0 || size == 0)
|
||||
if (remainder != 0)
|
||||
{
|
||||
off_t size_incr = ST_BLKSIZE (st) - remainder;
|
||||
if (! INT_ADD_OVERFLOW (size, size_incr))
|
||||
size += size_incr;
|
||||
else
|
||||
size = OFF_T_MAX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user