cfsd_maptbl.cc 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
*/
// -----------------------------------------------------------------
//
//
// Methods of the cfsd_maptbl classes.
#pragma ident "%Z%%M% %I% %E% SMI"
// Copyright (c) 1994 by Sun Microsystems, Inc.
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <synch.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "cfsd_maptbl.h"
// a zeroed out cid
//
// cfsd_maptbl::cfsd_maptbl
//
// Description:
// Constructor for the cfsd_maptbl class.
// Just does some setup not much else.
// Arguments:
// Returns:
// Preconditions:
{
dbug_enter("cfsd_maptbl::cfsd_maptbl");
i_fid = -1;
i_paoff = 0;
i_paend = 0;
i_palen = 0;
}
//
// cfsd_maptbl::~cfsd_maptbl
//
// Description:
// Destructor for the cfsd_maptbl class.
// Arguments:
// Returns:
// Preconditions:
{
dbug_enter("cfsd_maptbl::~cfsd_maptbl");
}
//
// cfsd_maptbl::i_domap
//
// Description:
// Maps in the specified section of the file.
// Arguments:
// off The offset to map in. Must be i_pagesize aligned.
// Returns:
// Returns 0 for success or an errno value on failure.
// Preconditions:
int
{
dbug_enter("cfsd_maptbl::i_domap");
dbug_precond(i_fid >= 0);
int xx;
// destroy old mapping if it exists
if (i_pa) {
// determine how far we have to move the map
// remove the map
if (xx == -1) {
}
i_palen = 0;
i_paoff = 0;
i_paend = 0;
}
// do the mapping
if (i_pa == MAP_FAILED) {
dbug_print("error",
("Could not map %s, error %d, off %d, len %d",
return (xx);
}
return (0);
}
//
// cfsd_maptbl::i_getaddr
//
// Description:
// Returns an address of a particular entry in the file.
// Arguments:
// index
// Returns:
// Returns NULL for a failure with the mapping file.
// Preconditions:
{
dbug_enter("cfsd_maptbl::i_getaddr");
// find the boundaries of the entry
// map the entry in if necessary
return (NULL);
}
// make an address and return it
return (pa);
}
//
// cfsd_maptbl::i_cidhashaddr
//
// Description:
// Finds the address of the specified cid by hashing to
// the appropriate entry. If the cid does not already
// exist in the file, then the address of where it should
// reside is returned.
// Arguments:
// cid
// addrp
// Returns:
// Returns 0 for success, 1 if entry not found, -1 if an
// error occurs in the mapping file.
// Preconditions:
int
{
dbug_enter("cfsd_maptbl::i_cidhashaddr");
int xx;
int index;
// get the index from the first hash function
// get the address of the entry
return (-1);
// check for match
return (0);
}
// check for not found
if (fileno == 0) {
return (1);
}
// get the index from the second hash function
// do a linear search for a match or empty entry
int start_index = index;
do {
// get the address of the entry
return (-1);
// check for match
return (0);
}
// check for not found
if (fileno == 0) {
return (1);
}
// move to the next entry
index++;
} while (start_index != index);
// table full, this is bad
return (-1);
}
//
// cfsd_maptbl::i_hash1
//
// Description:
// Hashes a cid into an index into the table.
// Arguments:
// cid
// Returns:
// Returns the index.
// Preconditions:
int
{
unsigned int xx;
unsigned int a, b;
#if 0
#else
b = a ^ cid.cid_fileno;
#endif
return (xx);
}
//
// cfsd_maptbl::i_hash2
//
// Description:
// Hashes a cid into an index into the table.
// Arguments:
// cid
// index
// Returns:
// Returns the index.
// Preconditions:
int
{
unsigned int xx;
unsigned int a, b, c, d;
#if 0
b = cid.cid_fileno ^ a ^ b;
xx = b % i_hash2mod;
#else
#endif
return (xx);
}
//
// cfsd_maptbl::maptbl_setup
//
// Description:
// Performs setup for the cfsd_maptbl class.
// This routine must be called before other routines are used.
// Arguments:
// filename
// Returns:
// Returns 0 for success or an errno value.
// Preconditions:
// precond(filename)
int
{
dbug_enter("cfsd_maptbl::maptbl_setup");
int xx;
// clean up from a previous setup
// get the page info
// get the size and type of file
if (xx) {
xx));
return (xx);
}
// sanity check, better be a regular file
return (xx);
}
// open the file
if (i_fid == -1) {
xx));
return (xx);
}
// determine number of entries
// set up modulo value for second hash function
// initialize statistic gathering
i_stat_requests = 0;
i_stat_probes = 0;
i_stat_mapmove = 0;
i_stat_mapdist = 0;
i_stat_filled = 0;
// zero the file
// map in a section of the file
if (xx)
return (xx);
// zero this section of the file
int cnt;
} else {
}
*lp++ = 0;
}
// return success
return (0);
}
//
// cfsd_maptbl::maptbl_teardown
//
// Description:
// Arguments:
// Returns:
// Preconditions:
void
{
dbug_enter("cfsd_maptbl::maptbl_teardown");
int xx;
if (i_pa) {
if (xx == -1) {
}
}
i_paoff = 0;
i_paend = 0;
i_palen = 0;
if (i_fid != -1) {
i_fid = -1;
}
}
//
// cfsd_maptbl::maptbl_get
//
// Description:
// Gets the mapping info for the specified cid.
// Arguments:
// cid
// valuep
// Returns:
// Returns 0 for success, 1 if entry not found, -1 if an
// error occurs in the mapping file.
// Preconditions:
// precond(valuep)
int
{
dbug_enter("cfsd_maptbl::maptbl_get");
if (i_entries == 0)
return (1);
int xx;
if (xx == 0)
return (xx);
}
//
// cfsd_maptbl::maptbl_set
//
// Description:
// Sets the mapping info for the cid.
// If insert is 1 then if the entry is not found it is put in the
// table.
// Arguments:
// valuep
// insert
// Returns:
// Returns 0 if mapping info placed in the table, 1 if entry
// is not found an insert is 0, -1 if an error occurs in the
// mapping file.
// Preconditions:
// precond(valuep)
int
{
dbug_enter("cfsd_maptbl::maptbl_set");
dbug_assert(i_entries > 0);
int xx;
if (xx == 1)
xx = 0;
}
return (xx);
}
//
// cfsd_maptbl::maptbl_dumpstats
//
// Description:
// Prints out various stats about the hashing.
// Arguments:
// Returns:
// Preconditions:
void
{
dbug_enter("cfsd_maptbl::maptbl_dumpstats");
if (i_stat_requests == 0)
return;
int xx;
double dd;
}