ZERO_LSN(lp->c_lsn);
ZERO_LSN(lp->chkpt_lsn);
__log_recover(dblp)	DB_LOG *dblp;{	DBT dbt;	DB_LSN lsn;	LOG *lp;	u_int32_t chk;	int cnt, found_checkpoint, ret;	lp = dblp->lp;	/*	 * Find a log file.  If none exist, we simply return, leaving	 * everything initialized to a new log.	 */	if ((ret = __log_find(dblp, 0, &cnt)) != 0)		return (ret);	if (cnt == 0)		return (0);	/*	 * We have the last useful log file and we've loaded any persistent	 * information.  Pretend that the log is larger than it can possibly	 * be, and read the last file, looking for the last checkpoint and	 * the log's end.	 */	lp->lsn.file = cnt + 1;	lp->lsn.offset = 0;	lsn.file = cnt;	lsn.offset = 0;	/* Set the cursor.  Shouldn't fail, leave error messages on. */	memset(&dbt, 0, sizeof(dbt));	if ((ret = __log_get(dblp, &lsn, &dbt, DB_SET, 0)) != 0)		return (ret);	/*	 * Read to the end of the file, saving checkpoints.  This will fail	 * at some point, so turn off error messages.	 */	found_checkpoint = 0;	while (__log_get(dblp, &lsn, &dbt, DB_NEXT, 1) == 0) {		if (dbt.size < sizeof(u_int32_t))			continue;		memcpy(&chk, dbt.data, sizeof(u_int32_t));		if (chk == DB_txn_ckp) {			lp->c_lsn = lsn;			found_checkpoint = 1;		}	}	/*	 * We know where the end of the log is.  Since that record is on disk,	 * it's also the last-synced LSN.	 */	lp->lsn = lsn;	lp->lsn.offset += dblp->c_len;	lp->s_lsn = lp->lsn;	/* Set up the current buffer information, too. */	lp->len = dblp->c_len;	lp->b_off = 0;	lp->w_off = lp->lsn.offset;	/*	 * It's possible that we didn't find a checkpoint because there wasn't	 * one in the last log file.  Start searching.	 */	while (!found_checkpoint && cnt > 1) {		lsn.file = --cnt;		lsn.offset = 0;		/* Set the cursor.  Shouldn't fail, leave error messages on. */		if ((ret = __log_get(dblp, &lsn, &dbt, DB_SET, 0)) != 0)			return (ret);		/*		 * Read to the end of the file, saving checkpoints.  Shouldn't		 * fail, leave error messages on.		 */		while (__log_get(dblp, &lsn, &dbt, DB_NEXT, 0) == 0) {			if (dbt.size < sizeof(u_int32_t))				continue;			memcpy(&chk, dbt.data, sizeof(u_int32_t));			if (chk == DB_txn_ckp) {				lp->c_lsn = lsn;				found_checkpoint = 1;			}		}	}	/* If we never find a checkpoint, that's okay, just 0 it out. */	if (!found_checkpoint)		ZERO_LSN(lp->c_lsn);	__db_err(dblp->dbenv,	    "Recovering the log: last valid LSN: file: %lu offset %lu",	    (u_long)lp->lsn.file, (u_long)lp->lsn.offset);	return (0);}