diff options
author | des <des@FreeBSD.org> | 2013-08-20 07:19:58 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2013-08-20 07:19:58 +0000 |
commit | 8501201ddfa94ba53490d55b57c052ea6c0a2872 (patch) | |
tree | ff35337803fb176e4d4f02dea831689bf2d23c3c /sbin | |
parent | 44099f40929de233e7b720595a5a90f410ec7bcd (diff) | |
download | FreeBSD-src-8501201ddfa94ba53490d55b57c052ea6c0a2872.zip FreeBSD-src-8501201ddfa94ba53490d55b57c052ea6c0a2872.tar.gz |
Fix the zeroing loop. I must have been drunk when I wrote this...
MFC after: 3 days
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fsck_ffs/fsutil.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c index abc987a..16ef819 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; |