str_conf.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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This module provides the framework that manage STREAMS modules.
* fmodsw_alloc() is called from modconf.c as a result of a module calling
* mod_install() and fmodsw_free() is called as the result of the module
* calling mod_remove().
* fmodsw_find() will find the fmodsw_impl_t structure relating to a named
* module. There is no equivalent of driver major numbers for modules; the
* the database of fmodsw_impl_t structures is purely keyed by name and
* is hence a hash table to keep lookup cost to a minimum.
*/
/*
* fmodsw_hash is the hash table that will be used to map module names to
* their fmodsw_impl_t structures. The hash function requires that the value is
* a power of 2 so this definition specifies the log of the hash table size.
*/
#define FMODSW_LOG_HASHSZ 8
/*
* Hash table and associated reader-writer lock
*
* NOTE: Because the lock is global data, it is initialized to zero and hence
* a call to rw_init() is not required. Similarly all the pointers in
* the hash table will be implicitly initialized to NULL.
*/
static krwlock_t fmodsw_lock;
/*
* Debug code:
*
* This is not conditionally compiled since it may be useful to third
* parties when developing new modules.
*/
#define BUFSZ 512
#define FMODSW_INIT 0x00000001
#define FMODSW_REGISTER 0x00000002
#define FMODSW_UNREGISTER 0x00000004
#define FMODSW_FIND 0x00000008
/* PRINTFLIKE2 */
static void
{
char *ptr;
if (fmodsw_debug_flags & flag) {
}
}
/*
* Local functions:
*/
#define FMODSW_HASH(_key) \
{ \
\
if (*p1++ == '\0') { \
goto _match; \
} \
} \
}
static int
{
fmodsw_impl_t **pp;
fmodsw_impl_t *p;
return (0);
return (EEXIST);
}
static int
{
fmodsw_impl_t **pp;
fmodsw_impl_t *p;
return (ENOENT);
if (p->f_ref > 0)
return (EBUSY);
*fpp = p;
return (0);
}
static int
{
fmodsw_impl_t *p;
int rc = 0;
*fpp = p;
#ifdef DEBUG
if (p != NULL)
p->f_hits++;
#endif /* DEBUG */
return (rc);
}
/*
* Exported functions:
*/
int
{
int len;
int err;
return (EINVAL);
return (ENOMEM);
goto failed;
goto failed;
}
return (0);
name);
return (err);
}
int
fmodsw_unregister(const char *name)
{
int err;
goto failed;
}
name);
return (0);
"'%s'\n", name);
return (err);
}
{
int id;
if (flags & FMODSW_HOLD) {
}
return (fp);
}
if (flags & FMODSW_LOAD) {
goto try_again;
}
}
return (NULL);
}
void
{
}