/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*/
#include "config.h"
#ifndef lint
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <errno.h>
#include <shqueue.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#endif
#include "db_int.h"
#include "shqueue.h"
#include "log.h"
#include "db_dispatch.h"
#include "txn.h"
#include "txn_auto.h"
#include "common_ext.h"
/*
* log_open --
*/
int
const char *path;
int mode;
{
int ret;
/* Validate arguments. */
#ifdef HAVE_SPINLOCKS
#else
#endif
return (ret);
/* Create and initialize the DB_LOG structure. */
return (ret);
goto err;
/*
* The log region isn't fixed size because we store the registered
* file names there. Make it fairly large so that we don't have to
* grow it.
*/
/* Map in the region. */
else
goto err;
goto err;
/*
* The LOG structure is first in the region, the rest of the region
* is free space.
*/
/* Initialize a created region. */
/* Initialize the LOG structure. */
/* Initialize LOG LSNs. */
}
/* Initialize thread information, mutex. */
goto err;
}
/*
* If doing recovery, try and recover any previous log files before
* releasing the lock.
*/
goto err;
return (0);
}
return (ret);
}
/*
* __log_panic --
* Panic a log.
*
* PUBLIC: void __log_panic __P((DB_ENV *));
*/
void
{
}
/*
* __log_recover --
* Recover a log.
*/
static int
{
/*
* Find a log file. If none exist, we simply return, leaving
* everything initialized to a new log.
*/
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.
*/
/* Set the cursor. Shouldn't fail, leave error messages on. */
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;
continue;
if (chk == DB_txn_ckp) {
found_checkpoint = 1;
}
}
/*
* We now know where the end of the log is. Set the first LSN that
* we want to return to an application and the LSN of the last known
* record on disk.
*/
/* Set up the current buffer information, too. */
/*
* It's possible that we didn't find a checkpoint because there wasn't
* one in the last log file. Start searching.
*/
/* Set the cursor. Shouldn't fail, leave error messages on. */
return (ret);
/*
* Read to the end of the file, saving checkpoints. Shouldn't
* fail, leave error messages on.
*/
continue;
if (chk == DB_txn_ckp) {
found_checkpoint = 1;
}
}
}
/*
* Reset the cursor lsn to the beginning of the log, so that an
* initial call to DB_NEXT does the right thing.
*/
/* If we never find a checkpoint, that's okay, just 0 it out. */
if (!found_checkpoint)
/*
* !!!
* The test suite explicitly looks for this string -- don't change
* it here unless you also change it there.
*/
"Finding last valid log LSN: file: %lu offset %lu",
return (0);
}
/*
* __log_find --
* Try to find a log file. If find_first is set, valp will contain
* the number of the first log file, else it will contain the number of
* the last log file.
*
* PUBLIC: int __log_find __P((DB_LOG *, int, int *));
*/
int
int find_first, *valp;
{
const char *dir;
char **names, *p, *q;
*valp = 0;
/* Find the directory name. */
return (ret);
if ((q = __db_rpath(p)) == NULL)
else {
*q = '\0';
dir = p;
}
/* Get the list of file names. */
__os_freestr(p);
if (ret != 0) {
return (ret);
}
/*
* Search for a valid log file name, return a value of 0 on
* failure.
*
* XXX
* Assumes that atoi(3) returns a 32-bit number.
*/
continue;
if (find_first) {
continue;
} else
continue;
}
/* Discard the list. */
return (0);
}
/*
* log_valid --
* Validate a log file.
*
* PUBLIC: int __log_valid __P((DB_LOG *, u_int32_t, int));
*/
int
int set_persist;
{
char *fname;
/* Try to open the log file. */
return (ret);
}
/* Try to read the header. */
if (ret == 0)
(void)__os_close(fd);
goto err;
}
(void)__os_close(fd);
/* Validate the header. */
"Ignoring log file: %s: magic number %lx, not %lx",
goto err;
}
"Ignoring log file: %s: unsupported log version %lu",
goto err;
}
/*
* If we're going to use this log file, set the region's persistent
* information based on the headers.
*/
if (set_persist) {
}
ret = 0;
return (ret);
}
/*
* log_close --
* Close a log.
*/
int
{
u_int32_t i;
/* We may have opened files as part of XA; if so, close them. */
/* Discard the per-thread pointer. */
}
/* Close the region. */
/* Close open files, release allocated memory. */
for (i = 0; i < dblp->dbentry_cnt; i++)
}
return (ret);
}
/*
* log_unlink --
* Exit a log.
*/
int
const char *path;
int force;
{
int ret;
return (ret);
return (ret);
}
/*
* log_stat --
* Return LOG statistics.
*/
int
DB_LOG_STAT **gspp;
{
int ret;
return (ret);
/* Copy out the global statistics. */
return (0);
}