cfsd_logfile.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1994-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Methods of the cfsd_maptbl classes.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <synch.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "cfsd.h"
#include "cfsd_logfile.h"
/*
* cfsd_logfile_create
*
* Description:
* Arguments:
* Returns:
* Preconditions:
*/
cfsd_logfile_create(void)
{
dbug_enter("cfsd_logfile_create");
logfile_object_p->i_cur_offset = 0;
dbug_leave("cfsd_logfile_create");
return (logfile_object_p);
}
/*
* cfsd_logfile_destroy
*
* Description:
* Arguments:
* Returns:
* Preconditions:
*/
void
{
dbug_enter("cfsd_logfile_destroy");
dbug_leave("cfsd_logfile_destroy");
}
/*
* logfile_domap
*
* Description:
* Maps in the specified section of the file.
* Arguments:
* off The offset to map in. Must be i_pagesize aligned.
* map 0 means use map_entry, 1 means use map_offset
* Returns:
* Returns 0 for success or an errno value on failure.
* Preconditions:
*/
int
{
int xx;
int len;
dbug_enter("logfile_domap");
/* destroy old mapping if it exists */
/* determine how far we have to move the map */
/* remove the map */
if (xx == -1) {
}
}
/* do the mapping */
dbug_print(("error",
"Could not map %s, error %d, off %d, len %d",
dbug_leave("logfile_domap");
return (xx);
}
dbug_leave("logfile_domap");
return (0);
}
/*
* logfile_getaddr
*
* Description:
* Returns an address of a particular offset in the file.
* The size of the item to map is i_maxmap
* This routine assumes that if we have to remap that i_maxmap
* will fit inside the default mapping size.
* Arguments:
* start offset in the file to map
* map 0 means use map_entry, 1 means use map_offset
* Returns:
* Returns NULL for a failure with the mapping file.
* Preconditions:
*/
{
dbug_enter("logfile_getaddr");
/* determine the end of the item */
/* map the entry in if necessary */
dbug_leave("logfile_getaddr");
return (NULL);
}
}
/* make an address and return it */
dbug_leave("logfile_getaddr");
return (pa);
}
/*
* logfile_setup
*
* Description:
* Sets up to use the specified file.
* Call this routine before using any of the other routines.
* Arguments:
* filename file to use
* maxmap max amount needed after a map
* Returns:
* Returns 0 for success or an errno value.
* Preconditions:
* precond(filename)
*/
int
{
int xx;
long *versionp;
dbug_enter("logfile_setup");
/* clean up from a previous setup */
sizeof (logfile_object_p->i_name));
/* get the page info */
/* open the file */
O_RDWR | O_NONBLOCK);
dbug_leave("logfile_setup");
return (xx);
}
/* get the size and type of file */
if (xx) {
} else {
}
dbug_leave("logfile_setup");
return (xx);
}
/* sanity check, better be a regular file */
dbug_leave("logfile_setup");
return (xx);
}
/* better not be too small */
dbug_leave("logfile_setup");
return (EINVAL);
}
/* initialize statistic gathering */
/* check the version number */
dbug_leave("logfile_setup");
return (EIO);
}
if (*versionp != CFS_DLOG_VERSION) {
*versionp, CFS_DLOG_VERSION));
dbug_leave("logfile_setup");
return (EINVAL);
}
/* return success */
dbug_leave("logfile_setup");
return (0);
}
/*
* logfile_teardown
*
* Description:
* Uninitializes the object.
* Call logfile_setup before using this object again.
* Arguments:
* Returns:
* Preconditions:
*/
void
{
int xx;
dbug_enter("logfile_teardown");
if (xx == -1) {
}
}
if (xx == -1) {
}
}
}
logfile_object_p->i_cur_offset = 0;
dbug_leave("logfile_teardown");
}
/*
* logfile_entry
*
* Description:
* Sets addrp to the address of the log entry at offset
* The mapping remains in effect until:
* a) this routine is called again
* b) logfile_teardown is called
* c) this object is destroyed
* Arguments:
* offset offset to start of entry
* entpp place to store address
* Returns:
* Returns 0 for success, 1 for EOF, -1 if a fatal error occurs.
* Preconditions:
* precond(addrp)
*/
int
{
dbug_enter("logfile_entry");
dbug_precond(offset >= sizeof (long));
/* check for eof */
dbug_leave("logfile_entry");
return (1);
}
/* get the address of the entry */
dbug_leave("logfile_entry");
return (-1);
}
/* sanity check, record should be alligned */
dbug_print(("error",
"Record at offset %d length is not alligned %d",
dbug_leave("logfile_entry");
return (-1);
}
/* sanity check record should a reasonable size */
dbug_print(("error",
"Record at offset %d has an invalid size %d", offset,
dbug_leave("logfile_entry");
return (-1);
}
/* preserve offset and pointer */
/* return success */
dbug_leave("logfile_entry");
return (0);
}
/*
* logfile_offset
*
* Description:
* Sets addrp to the address of the specified offset.
* The mapping remains in effect until:
* a) this routine is called again
* b) logfile_teardown is called
* c) this object is destroyed
* Arguments:
* offset offset into file, must be 0 <= offset < i_size
* addrp returns mapped address
* Returns:
* Returns 0 for success, -1 if a fatal error occurs.
* Preconditions:
* precond(addrp)
*/
int
{
dbug_enter("logfile_offset");
/* get the address for the offset */
dbug_leave("logfile_offset");
return (-1);
}
/* return success */
dbug_leave("logfile_offset");
return (0);
}
/*
* logfile_sync
*
* Description:
* Performs an fsync on the log file.
* Arguments:
* Returns:
* Returns 0 for success or an errno value on failure.
* Preconditions:
*/
int
{
int xx;
dbug_enter("logfile_sync");
dbug_leave("logfile_sync");
return (0);
}
if (xx) {
}
dbug_leave("logfile_sync");
return (xx);
}
/*
* logfile_dumpstats
*
* Description:
* Prints out various stats about the hashing.
* Arguments:
* Returns:
* Preconditions:
*/
void
{
int xx;
double dd;
dbug_enter("logfile_dumpstats");
if (logfile_object_p->i_stat_mapmove == 0) {
dbug_leave("logfile_dumpstats");
return;
}
dbug_leave("logfile_dumpstats");
}