aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2013-08-20 07:19:58 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2013-08-20 07:19:58 +0000
commit8ce80d4bd44cb6d3b2ec398655ee7e321eb045e5 (patch)
treeff35337803fb176e4d4f02dea831689bf2d23c3c /sbin
parentb98940e5ebb28fc8667ebf21446306f19e2c467c (diff)
downloadsrc-8ce80d4bd44cb6d3b2ec398655ee7e321eb045e5.tar.gz
src-8ce80d4bd44cb6d3b2ec398655ee7e321eb045e5.zip
Fix the zeroing loop. I must have been drunk when I wrote this...
MFC after: 3 days
Notes
Notes: svn path=/head/; revision=254553
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fsck_ffs/fsutil.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c
index abc987afe20b..16ef8193fd89 100644
--- a/sbin/fsck_ffs/fsutil.c
+++ b/sbin/fsck_ffs/fsutil.c
@@ -629,6 +629,10 @@ blerase(int fd, ufs2_daddr_t blk, long size)
return;
}
+/*
+ * Fill a contiguous region with all-zeroes. Note ZEROBUFSIZE is by
+ * definition a multiple of dev_bsize.
+ */
void
blzero(int fd, ufs2_daddr_t blk, long size)
{
@@ -637,9 +641,8 @@ blzero(int fd, ufs2_daddr_t blk, long size)
if (fd < 0)
return;
- len = ZEROBUFSIZE;
if (zero == NULL) {
- zero = calloc(len, 1);
+ zero = calloc(ZEROBUFSIZE, 1);
if (zero == NULL)
errx(EEXIT, "cannot allocate buffer pool");
}
@@ -647,10 +650,7 @@ blzero(int fd, ufs2_daddr_t blk, long size)
if (lseek(fd, offset, 0) < 0)
rwerror("SEEK BLK", blk);
while (size > 0) {
- if (size > len)
- size = len;
- else
- len = size;
+ len = size > ZEROBUFSIZE ? ZEROBUFSIZE : size;
if (write(fd, zero, len) != len)
rwerror("WRITE BLK", blk);
blk += len / dev_bsize;