if ((ret = __db_seek(fd, 0, 0, incr - __DB_VMPAGESIZE, SEEK_CUR)) != 0) goto err; if ((ret = __db_write(fd, buf, sizeof(buf), &nw)) != 0) goto err; if (nw != sizeof(buf)) goto eio; } return (0);
if (!F_ISSET(infop, REGION_CANGROW)) return (EINVAL);
__db_rgrow(dbenv, fd, incr)	DB_ENV *dbenv;	int fd;	size_t incr;{	size_t i;	ssize_t nw;	int mmap_init_needed, ret;	char buf[__DB_VMPAGESIZE];	/* Seek to the end of the region. */	if ((ret = __db_seek(fd, 0, 0, 0, SEEK_END)) != 0)		goto err;	/* Write nuls to the new bytes. */	memset(buf, 0, sizeof(buf));	/*	 * Historically, some systems required that all of the bytes of the	 * region be written before it could be mmapped and accessed randomly.	 *	 * Windows/95 doesn't have that problem, but it leaves file contents	 * uninitialized.  Win/NT apparently initializes them.	 */#ifdef MMAP_INIT_NEEDED	mmap_init_needed = 1;#else	mmap_init_needed = __os_oldwin();#endif	if (mmap_init_needed)		/* Extend the region by writing each new page. */		for (i = 0; i < incr; i += __DB_VMPAGESIZE) {			if ((ret = __db_write(fd, buf, sizeof(buf), &nw)) != 0)				goto err;			if (nw != sizeof(buf))				goto eio;		}	else {		/*		 * Extend the region by writing the last page.		 *		 * Round off the increment to the next page boundary.		 */		incr += __DB_VMPAGESIZE - 1;		incr -= incr % __DB_VMPAGESIZE;		/* Write the last page, not the page after the last. */		if ((ret =		    __db_seek(fd, 0, 0, incr - __DB_VMPAGESIZE, SEEK_CUR)) != 0)			goto err;		if ((ret = __db_write(fd, buf, sizeof(buf), &nw)) != 0)			goto err;		if (nw != sizeof(buf))			goto eio;	}	return (0);eio:	ret = EIO;err:	__db_err(dbenv, "region grow: %s", strerror(ret));	return (ret);}