/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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
*/
/*
*/
#include <dlfcn.h>
#include <link.h>
#include <dirent.h>
#include <libintl.h>
#include <sys/systeminfo.h>
#include <synch.h>
#include <string.h>
#include <dirent.h>
#include <atomic.h>
#include "libshare.h"
#include "libshare_impl.h"
/*
* load_and_check(path, libname, type)
*
* dlopen the library and check to see if a valid libshare v2
* library of the correct type. If it is, load it and link it together
* as appropriate.
*
* The pi_init() routine is also called to give the plugin a chance
* to do any required initialization.
*/
static void
{
void *dlhandle;
salog_error(0, "Error loading libshare plugin: %s: %s",
return;
}
salog_error(0, "Error loading libshare plugin: %s: %s",
return;
}
"Error loading libshare plugin: %s", path);
return;
}
"Error loading libshare plugin: %s", path);
return;
}
switch (type) {
case SA_PLUGIN_FS:
pi_lock = &sa_fs_lock;
pi_list = &sa_fs_list;
break;
case SA_PLUGIN_PROTO:
pi_lock = &sa_proto_lock;
pi_list = &sa_proto_list;
break;
case SA_PLUGIN_CACHE:
pi_lock = &sa_cache_lock;
pi_list = &sa_cache_list;
break;
default:
"Error loading libshare plugin: %s", path);
return;
}
"Error initializing libshare plugin: %s", path);
return;
}
/*
* add plugin to list
*/
}
/*
* plugin_load(type)
*
* find (and load) all modules of given type
*/
static void
{
char *root;
#if defined(_LP64)
#endif
(void) mutex_lock(&sa_plugins_lock);
goto unlock_and_return;
switch (type) {
case SA_PLUGIN_FS:
break;
case SA_PLUGIN_PROTO:
break;
case SA_PLUGIN_CACHE:
break;
default:
goto unlock_and_return;
}
#if defined(_LP64)
isa[0] = '\0';
#else
#endif
"saplugin_load: %s", root);
goto unlock_and_return;
}
sizeof (PLUGIN_LIB_PREFIX) - 1) == 0) {
if (strlen(plugin_root) +
"Error loading libshare plugin %s/%s",
continue;
}
}
}
/*
* mark plugin type as loaded regardless of success.
* This will prevent continuous attempts to load
* bad or non-existent plugins.
*/
(void) mutex_unlock(&sa_plugins_lock);
}
/*
* saplugin_unload
*
* Unload all plugin modules of the given type.
*/
static void
{
(void) mutex_lock(&sa_plugins_lock);
goto unlock_and_return;
switch (pi_type) {
case SA_PLUGIN_FS:
pi_lock = &sa_fs_lock;
pi_list = &sa_fs_list;
break;
case SA_PLUGIN_PROTO:
pi_lock = &sa_proto_lock;
pi_list = &sa_proto_list;
break;
case SA_PLUGIN_CACHE:
pi_lock = &sa_cache_lock;
pi_list = &sa_cache_list;
break;
default:
goto unlock_and_return;
}
/*
* call pi_fini() routine to give
* plugin a chance to cleanup.
*/
}
}
(void) mutex_unlock(&sa_plugins_lock);
}
/*
* saplugin_unload_all
*
* Unload all loaded plugin modules.
* Called from _sa_fini() when libshare.so is unloaded.
*/
void
saplugin_unload_all(void)
{
}
/*
* saplugin_find_ops
*
* return ops table for specified plugin
*/
{
/*
* load the plugin if not yet loaded
*/
switch (type) {
case SA_PLUGIN_FS:
pi_lock = &sa_fs_lock;
pi_list = &sa_fs_list;
break;
case SA_PLUGIN_PROTO:
pi_lock = &sa_proto_lock;
pi_list = &sa_proto_list;
break;
case SA_PLUGIN_CACHE:
pi_lock = &sa_cache_lock;
pi_list = &sa_cache_list;
break;
default:
return (NULL);
}
break;
}
else
return (NULL);
}
int
{
int i;
int plugin_cnt = 0;
return (0);
(void) rw_rdlock(&sa_proto_lock);
plugin_cnt++;
}
(void) rw_unlock(&sa_proto_lock);
return (0);
}
for (i = 0, plugin = sa_proto_list;
}
(void) rw_unlock(&sa_proto_lock);
return (plugin_cnt);
}
/*
* saplugin_next_ops
*
* Return pointer to next plugin in the list of type specified
* If ops == NULL return first plugin in the list.
*/
{
/*
* load the plugin if not yet loaded
*/
switch (type) {
case SA_PLUGIN_FS:
pi_lock = &sa_fs_lock;
pi_list = &sa_fs_list;
break;
case SA_PLUGIN_PROTO:
pi_lock = &sa_proto_lock;
pi_list = &sa_proto_list;
break;
case SA_PLUGIN_CACHE:
pi_lock = &sa_cache_lock;
pi_list = &sa_cache_list;
break;
default:
return (NULL);
}
} else {
break;
}
}
}
else
return (NULL);
}