plugin.c revision 25a68471b9ababbc21cfdbbb2866014f34f419ec
/*
* 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
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libshare.h>
#include "libshare_impl.h"
#include <dlfcn.h>
#include <link.h>
#include <dirent.h>
#include <libintl.h>
#include <sys/systeminfo.h>
/*
* protocol plugin interface
*
* finds plugins and makes them accessible. This is only "used" by
* libshare.so.
*/
struct sa_proto_plugin *sap_proto_list;
static struct sa_proto_handle sa_proto_handle;
void proto_plugin_fini();
/*
* proto_plugin_init()
*
* Initialize the protocol specific plugin modules.
*
* /usr/lib/fs/nfs/libshare_nfs.so. The protocol specific directory
* would have a modules with name libshare_<proto>.so. If one is
* found, initialize it and add to the internal list of
* protocols. These are used for protocol specifici operations.
*/
int
{
struct sa_proto_plugin *proto;
int num_protos = 0;
int err;
struct sa_plugin_ops *plugin_ops;
void *dlhandle;
/*
* libshare_*.so
*/
char path[MAXPATHLEN];
#if defined(_LP64)
isa[0] = '\0';
#else
isa[0] = '\0';
#endif
"%s/%s/%s/libshare_%s.so.1", SA_LIB_DIR,
/*
* If file doesn't exist, don't try to map it
*/
continue;
plugin_ops = (struct sa_plugin_ops *)
proto = (struct sa_proto_plugin *)
num_protos++;
} else {
ret = SA_NO_MEMORY;
}
} else {
"Error in plugin for protocol %s: %s\n"),
}
}
}
(char **)calloc(num_protos, sizeof (char *));
sizeof (struct sa_plugin_ops *));
int i;
struct sa_proto_plugin *tmp;
for (i = 0, tmp = sap_proto_list;
i < num_protos;
err = 0;
/*
* Only include if the init
* succeeded or was NULL
*/
sa_proto_handle.sa_ops[i] =
sa_proto_handle.sa_proto[i] =
i++;
}
}
}
} else {
/*
* There was an error, so cleanup prior to return of failure.
*/
}
return (ret);
}
/*
* proto_plugin_fini()
*
* Uninitialize all the plugin modules.
*/
void
{
/*
* Free up all the protocols, calling their fini, if there is
* one.
*/
while (sap_proto_list != NULL) {
struct sa_proto_plugin *next;
}
}
}
}
/*
* find_protocol(proto)
*
* Search the plugin list for the specified protocol and return the
* ops vector. NULL if protocol is not defined.
*/
static struct sa_plugin_ops *
find_protocol(char *proto)
{
int i;
for (i = 0; i < sa_proto_handle.sa_num_proto; i++) {
return (sa_proto_handle.sa_ops[i]);
}
}
return (NULL);
}
/*
* sa_proto_share(proto, share)
*
* Activate a share for the specified protocol.
*/
int
{
int ret = SA_INVALID_PROTOCOL;
return (ret);
}
/*
* sa_proto_unshare(proto, path)
*
* Deactivate (unshare) the path for this protocol.
*/
int
{
int ret = SA_INVALID_PROTOCOL;
return (ret);
}
/*
* sa_proto_valid_prop(proto, prop, opt)
*
* Check to see if the specified prop is valid for this protocol.
*/
int
{
int ret = 0;
return (ret);
}
/*
* sa_proto_valid_space(proto, space)
*
* Check if space is valid optionspace for proto.
* Protocols that don't implement this don't support spaces.
*/
int
{
int ret = 0;
return (ret);
}
/*
* sa_proto_space_alias(proto, space)
*
* If the name for space is an alias, return its proper name. This is
* used to translate "default" values into proper form.
*/
char *
{
return (ret);
}
/*
* sa_proto_security_prop(proto, token)
*
* Check to see if the property name in token is a valid named
* optionset property.
*/
int
{
int ret = 0;
return (ret);
}
/*
* sa_proto_legacy_opts(proto, grouup, options)
*
* Have the protocol specific parser parse the options string and add
* an appropriate optionset to group.
*/
int
{
int ret = SA_INVALID_PROTOCOL;
return (ret);
}
/*
* sa_proto_legacy_format(proto, group, hier)
*
* Return a legacy format string representing either the group's
* properties or the groups hierarchical properties.
*/
char *
{
return (ret);
}
void
sa_format_free(char *str)
{
}
/*
* sharectl related API functions
*/
/*
* sa_proto_get_properties(proto)
*
* Return the set of properties that are specific to the
* but only the protocol module knows which ones for sure.
*/
sa_proto_get_properties(char *proto)
{
return (props);
}
/*
* sa_proto_set_property(proto, prop)
*
* Update the protocol specifiec property.
*/
int
{
return (ret);
}
/*
* sa_valid_protocol(proto)
*
* Check to see if the protocol specified is defined by a
* plugin. Returns true (1) or false (0)
*/
int
sa_valid_protocol(char *proto)
{
}
/*
* Return the current operational status of the protocol
*/
char *
sa_get_protocol_status(char *proto)
{
return (ret);
}
/*
* sa_proto_update_legacy(proto, share)
*
* Update the protocol specific legacy files if necessary for the
* specified share.
*/
int
{
int ret = SA_NOT_IMPLEMENTED;
}
return (ret);
}
/*
* sa_delete_legacy(proto, share)
*
* Remove the specified share from the protocol specific legacy files.
*/
int
{
} else {
else
}
return (ret);
}