libshare.h revision 9e5da854b2fe0f3860a9b77dc30612faf2b0a42b
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* basic API declarations for share management
*/
#ifndef _LIBSHARE_H
#define _LIBSHARE_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Basic datatypes for most functions
*/
typedef void *sa_group_t;
typedef void *sa_share_t;
typedef void *sa_property_t;
typedef void *sa_optionset_t;
typedef void *sa_security_t;
typedef void *sa_protocol_properties_t;
typedef void *sa_resource_t;
typedef void *sa_handle_t; /* opaque handle to access core functions */
/*
* defined error values
*/
#define SA_OK 0
/* API Initialization */
/* not part of API returns */
/*
* other defined values
*/
/* Used in calls to sa_add_share() and sa_add_resource() */
#define SA_SHARE_TRANSIENT 0 /* shared but not across reboot */
/* sa_check_path() related */
#define SA_CHECK_NORMAL 0 /* only check against active shares */
/* RBAC related */
#define SA_RBAC_MANAGE "solaris.smf.manage.shares"
#define SA_RBAC_VALUE "solaris.smf.value.shares"
/*
* Feature set bit definitions
*/
/*
* legacy files
*/
#define SA_LEGACY_DFSTAB "/etc/dfs/dfstab"
#define SA_LEGACY_SHARETAB "/etc/dfs/sharetab"
/*
* SMF related
*/
#define SA_SVC_FMRI_BASE "svc:/network/shares/group"
/* initialization */
extern sa_handle_t sa_init(int);
extern void sa_fini(sa_handle_t);
extern int sa_update_config(sa_handle_t);
extern char *sa_errorstr(int);
/* protocol names */
extern int sa_get_protocols(char ***);
extern int sa_valid_protocol(char *);
/* group control (create, remove, etc) */
extern int sa_remove_group(sa_group_t);
extern char *sa_get_group_attr(sa_group_t, char *);
extern int sa_set_group_attr(sa_group_t, char *, char *);
extern int sa_valid_group_name(char *);
/* share control */
extern int sa_check_path(sa_group_t, char *, int);
extern int sa_remove_share(sa_share_t);
extern char *sa_get_share_attr(sa_share_t, char *);
extern char *sa_get_share_description(sa_share_t);
extern int sa_set_share_attr(sa_share_t, char *, char *);
extern int sa_set_share_description(sa_share_t, char *);
extern int sa_enable_share(sa_group_t, char *);
extern int sa_disable_share(sa_share_t, char *);
extern int sa_is_share(void *);
/* resource name related */
extern int sa_remove_resource(sa_resource_t);
extern char *sa_get_resource_attr(sa_resource_t, char *);
extern int sa_set_resource_attr(sa_resource_t, char *, char *);
extern int sa_set_resource_description(sa_resource_t, char *);
extern char *sa_get_resource_description(sa_resource_t);
extern int sa_enable_resource(sa_resource_t, char *);
extern int sa_disable_resource(sa_resource_t, char *);
extern int sa_rename_resource(sa_resource_t, char *);
extern void sa_fix_resource_name(char *);
/* data structure free calls */
extern void sa_free_attr_string(char *);
extern void sa_free_share_description(char *);
/* optionset control */
extern char *sa_get_optionset_attr(sa_optionset_t, char *);
extern void sa_set_optionset_attr(sa_optionset_t, char *, char *);
extern int sa_destroy_optionset(sa_optionset_t);
extern sa_optionset_t sa_get_derived_optionset(void *, char *, int);
extern void sa_free_derived_optionset(sa_optionset_t);
/* property functions */
extern char *sa_get_property_attr(sa_property_t, char *);
extern sa_property_t sa_create_section(char *, char *);
extern void sa_set_section_attr(sa_property_t, char *, char *);
extern sa_property_t sa_create_property(char *, char *);
extern int sa_add_property(void *, sa_property_t);
extern int sa_update_property(sa_property_t, char *);
extern int sa_remove_property(sa_property_t);
extern int sa_commit_properties(sa_optionset_t, int);
extern int sa_valid_property(void *, char *, sa_property_t);
extern int sa_is_persistent(void *);
/* security control */
extern char *sa_get_security_attr(sa_optionset_t, char *);
extern int sa_destroy_security(sa_security_t);
extern void sa_set_security_attr(sa_security_t, char *, char *);
extern sa_optionset_t sa_get_all_security_types(void *, char *, int);
extern sa_security_t sa_get_derived_security(void *, char *, char *, int);
extern void sa_free_derived_security(sa_security_t);
/* protocol specific interfaces */
extern int sa_parse_legacy_options(sa_group_t, char *, char *);
extern char *sa_proto_legacy_format(char *, sa_group_t, int);
extern int sa_is_security(char *, char *);
extern sa_protocol_properties_t sa_proto_get_properties(char *);
extern uint64_t sa_proto_get_featureset(char *);
extern int sa_set_protocol_property(sa_property_t, char *, char *);
extern char *sa_get_protocol_status(char *);
extern void sa_format_free(char *);
extern sa_protocol_properties_t sa_create_protocol_properties(char *);
extern int sa_proto_valid_space(char *, char *);
extern char *sa_proto_space_alias(char *, char *);
extern int sa_proto_get_transients(sa_handle_t, char *);
extern int sa_proto_notify_resource(sa_resource_t, char *);
extern int sa_proto_change_notify(sa_share_t, char *);
extern int sa_proto_delete_section(char *, char *);
extern int sa_delete_legacy(sa_share_t, char *);
extern int sa_update_legacy(sa_share_t, char *);
extern int sa_update_sharetab(sa_share_t, char *);
extern int sa_delete_sharetab(sa_handle_t, char *, char *);
/* ZFS functions */
extern int sa_zfs_is_shared(sa_handle_t, char *);
extern int sa_group_is_zfs(sa_group_t);
extern int sa_path_is_zfs(char *);
/* SA Handle specific functions */
#ifdef __cplusplus
}
#endif
#endif /* _LIBSHARE_H */