Date: Tue, 20 Aug 2013 07:19:58 +0000 (UTC) From: Dag-Erling Smørgrav <des@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254553 - head/sbin/fsck_ffs Message-ID: <201308200719.r7K7JwQh080408@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: des Date: Tue Aug 20 07:19:58 2013 New Revision: 254553 URL: http://svnweb.freebsd.org/changeset/base/254553 Log: Fix the zeroing loop. I must have been drunk when I wrote this... MFC after: 3 days Modified: head/sbin/fsck_ffs/fsutil.c Modified: head/sbin/fsck_ffs/fsutil.c ============================================================================== --- head/sbin/fsck_ffs/fsutil.c Tue Aug 20 07:15:16 2013 (r254552) +++ head/sbin/fsck_ffs/fsutil.c Tue Aug 20 07:19:58 2013 (r254553) @@ -629,6 +629,10 @@ blerase(int fd, ufs2_daddr_t blk, long s 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 si 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 si 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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308200719.r7K7JwQh080408>