6185db853e024a486ff8837e6784dd290d866112dougm * CDDL HEADER START
6185db853e024a486ff8837e6784dd290d866112dougm * The contents of this file are subject to the terms of the
6185db853e024a486ff8837e6784dd290d866112dougm * Common Development and Distribution License (the "License").
6185db853e024a486ff8837e6784dd290d866112dougm * You may not use this file except in compliance with the License.
6185db853e024a486ff8837e6784dd290d866112dougm * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
6185db853e024a486ff8837e6784dd290d866112dougm * See the License for the specific language governing permissions
6185db853e024a486ff8837e6784dd290d866112dougm * and limitations under the License.
6185db853e024a486ff8837e6784dd290d866112dougm * When distributing Covered Code, include this CDDL HEADER in each
6185db853e024a486ff8837e6784dd290d866112dougm * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
6185db853e024a486ff8837e6784dd290d866112dougm * If applicable, add the following below this CDDL HEADER, with the
6185db853e024a486ff8837e6784dd290d866112dougm * fields enclosed by brackets "[]" replaced with your own identifying
6185db853e024a486ff8837e6784dd290d866112dougm * information: Portions Copyright [yyyy] [name of copyright owner]
6185db853e024a486ff8837e6784dd290d866112dougm * CDDL HEADER END
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
6185db853e024a486ff8837e6784dd290d866112dougm * Use is subject to license terms.
549ec3fff108310966327d1dc9004551b63210b7dougm#define MAXISALEN 257 /* based on sysinfo(2) man page */
6185db853e024a486ff8837e6784dd290d866112dougm * protocol plugin interface
6185db853e024a486ff8837e6784dd290d866112dougm * finds plugins and makes them accessible. This is only "used" by
8d7e41661dc4633488e93b13363137523ce59977jose borrego * Returns true if name is "." or "..", otherwise returns false.
8d7e41661dc4633488e93b13363137523ce59977jose borrego if ((name[1] == '\0') || (name[1] == '.' && name[2] == '\0'))
6185db853e024a486ff8837e6784dd290d866112dougm * proto_plugin_init()
6185db853e024a486ff8837e6784dd290d866112dougm * Initialize the protocol specific plugin modules.
8d7e41661dc4633488e93b13363137523ce59977jose borrego * Walk /usr/lib/fs/\* for libshare_*.so modules, for example,
8d7e41661dc4633488e93b13363137523ce59977jose borrego * /usr/lib/fs/nfs/libshare_nfs.so. A protocol specific directory
8d7e41661dc4633488e93b13363137523ce59977jose borrego * would have modules with names of the form libshare_<proto>.so.
8d7e41661dc4633488e93b13363137523ce59977jose borrego * For each protocol found, initialize it and add it to the internal
8d7e41661dc4633488e93b13363137523ce59977jose borrego * list of protocols. These are used for protocol specific operations.
549ec3fff108310966327d1dc9004551b63210b7dougm#if defined(_LP64)
8d7e41661dc4633488e93b13363137523ce59977jose borrego if (sysinfo(SI_ARCHITECTURE_64, isa, MAXISALEN) == -1)
8d7e41661dc4633488e93b13363137523ce59977jose borrego * If file doesn't exist, don't try to map it
8d7e41661dc4633488e93b13363137523ce59977jose borrego if ((dlhandle = dlopen(path, RTLD_FIRST|RTLD_LAZY)) == NULL) {
8d7e41661dc4633488e93b13363137523ce59977jose borrego "Error in plugin for protocol %s: %s\n"),
8d7e41661dc4633488e93b13363137523ce59977jose borrego "Error in plugin ops for protocol %s: %s\n"),
25a68471b9ababbc21cfdbbb2866014f34f419ecdougm sizeof (struct sa_plugin_ops *));
25a68471b9ababbc21cfdbbb2866014f34f419ecdougm * Only include if the init
25a68471b9ababbc21cfdbbb2866014f34f419ecdougm * succeeded or was NULL
c5f58477f1b190d049c5f4fedeed36e5cc22a1c7dougm * There was an error, so cleanup prior to return of failure.
6185db853e024a486ff8837e6784dd290d866112dougm * proto_plugin_fini()
25a68471b9ababbc21cfdbbb2866014f34f419ecdougm * Uninitialize all the plugin modules.
0fd7766084e66e6e9fda9eb800b67bbf965d4bffgwr * Protocols may call this framework during _fini
0fd7766084e66e6e9fda9eb800b67bbf965d4bffgwr * (the smbfs plugin is known to do this) so do
0fd7766084e66e6e9fda9eb800b67bbf965d4bffgwr * two passes: 1st call _fini; 2nd free, dlclose.
6185db853e024a486ff8837e6784dd290d866112dougm * find_protocol(proto)
6185db853e024a486ff8837e6784dd290d866112dougm * Search the plugin list for the specified protocol and return the
6185db853e024a486ff8837e6784dd290d866112dougm * ops vector. NULL if protocol is not defined.
6185db853e024a486ff8837e6784dd290d866112dougmstatic struct sa_plugin_ops *
c5f58477f1b190d049c5f4fedeed36e5cc22a1c7dougm if (strcmp(proto, sa_proto_handle.sa_proto[i]) == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm * sa_proto_share(proto, share)
6185db853e024a486ff8837e6784dd290d866112dougm * Activate a share for the specified protocol.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sa_proto_unshare(proto, share)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Deactivate (unshare) the share for this protocol.
ecd6cf800b63704be73fb264c3f5b6e0dafc068dmarkssa_proto_unshare(sa_share_t share, char *proto, char *path)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sa_proto_share_resource(char *proto, sa_resource_t resource)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * For protocols that actually enable at the resource level, do the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * protocol specific resource enable. If it doesn't, return an error.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Note that the resource functions are optional so can return
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SA_NOT_SUPPORTED.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsa_proto_share_resource(char *proto, sa_resource_t resource)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sa_proto_unshare_resource(char *proto, sa_resource_t resource)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * For protocols that actually disable at the resource level, do the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * protocol specific resource disable. If it doesn't, return an error.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsa_proto_unshare_resource(char *proto, sa_resource_t resource)
687915e946710e354e302fa654bf53bf38b57cc6dougm * sa_proto_valid_prop(handle, proto, prop, opt)
25a68471b9ababbc21cfdbbb2866014f34f419ecdougm * Check to see if the specified prop is valid for this protocol.
687915e946710e354e302fa654bf53bf38b57cc6dougmsa_proto_valid_prop(sa_handle_t handle, char *proto, sa_property_t prop,
6185db853e024a486ff8837e6784dd290d866112dougm * sa_proto_valid_space(proto, space)
25a68471b9ababbc21cfdbbb2866014f34f419ecdougm * Check if space is valid optionspace for proto.
6185db853e024a486ff8837e6784dd290d866112dougm * Protocols that don't implement this don't support spaces.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_proto_space_alias(proto, space)
25a68471b9ababbc21cfdbbb2866014f34f419ecdougm * If the name for space is an alias, return its proper name. This is
6185db853e024a486ff8837e6784dd290d866112dougm * used to translate "default" values into proper form.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_proto_security_prop(proto, token)
6185db853e024a486ff8837e6784dd290d866112dougm * Check to see if the property name in token is a valid named
6185db853e024a486ff8837e6784dd290d866112dougm * optionset property.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_proto_legacy_opts(proto, grouup, options)
6185db853e024a486ff8837e6784dd290d866112dougm * Have the protocol specific parser parse the options string and add
6185db853e024a486ff8837e6784dd290d866112dougm * an appropriate optionset to group.
6185db853e024a486ff8837e6784dd290d866112dougmsa_proto_legacy_opts(char *proto, sa_group_t group, char *options)
6185db853e024a486ff8837e6784dd290d866112dougm * sa_proto_legacy_format(proto, group, hier)
6185db853e024a486ff8837e6784dd290d866112dougm * Return a legacy format string representing either the group's
6185db853e024a486ff8837e6784dd290d866112dougm * properties or the groups hierarchical properties.
6185db853e024a486ff8837e6784dd290d866112dougmsa_proto_legacy_format(char *proto, sa_group_t group, int hier)
6185db853e024a486ff8837e6784dd290d866112dougm * sharectl related API functions
6185db853e024a486ff8837e6784dd290d866112dougm * sa_proto_get_properties(proto)
6185db853e024a486ff8837e6784dd290d866112dougm * Return the set of properties that are specific to the
6185db853e024a486ff8837e6784dd290d866112dougm * protocol. These are usually in /etc/dfs/<proto> and related files,
6185db853e024a486ff8837e6784dd290d866112dougm * but only the protocol module knows which ones for sure.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_proto_set_property(proto, prop)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Update the protocol specific property.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_valid_protocol(proto)
25a68471b9ababbc21cfdbbb2866014f34f419ecdougm * Check to see if the protocol specified is defined by a
6185db853e024a486ff8837e6784dd290d866112dougm * plugin. Returns true (1) or false (0)
6185db853e024a486ff8837e6784dd290d866112dougm * Return the current operational status of the protocol
6185db853e024a486ff8837e6784dd290d866112dougm * sa_proto_update_legacy(proto, share)
6185db853e024a486ff8837e6784dd290d866112dougm * Update the protocol specific legacy files if necessary for the
6185db853e024a486ff8837e6784dd290d866112dougm * specified share.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_delete_legacy(proto, share)
25a68471b9ababbc21cfdbbb2866014f34f419ecdougm * Remove the specified share from the protocol specific legacy files.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * sa_proto_delete_section(proto, section)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Remove the specified section from the protocol specific legacy files,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * if supported.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sa_proto_change_notify(share, char *protocol)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Notify the protocol that a change has been made to the share
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sa_proto_notify_resource(resource, char *protocol)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Notify the protocol that a change has been made to the share
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsa_proto_notify_resource(sa_resource_t resource, char *proto)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sa_proto_get_featureset(protocol)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Get bitmask of defined features of the protocol. These are
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * primarily things like SA_FEATURE_RESOURCE (shares are by resource
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * name rather than path) and other operational features that affect
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * behavior.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* if not implemented, zero is valid */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sa_proto_get_transients(sa_handle_t)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Called to get any protocol specific transient shares. NFS doesn't
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * use this since the info is in sharetab which is processed as a
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * common transient store.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The protocol plugin should verify that the share isn't in the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * repository and then add it as a transient.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Not having an entry is not a problem. It returns 0 in that case.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sa_proto_rename_resource(sa_handle_t, proto, sa_resource_t, newname)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Protocols may need to know when a resource has changed names in
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * order to notify clients. This must be done "before" the name in the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * resource has been changed. Not being implemented is not a problem.