13034Sdougm /*
23034Sdougm  * CDDL HEADER START
33034Sdougm  *
43034Sdougm  * The contents of this file are subject to the terms of the
53034Sdougm  * Common Development and Distribution License (the "License").
63034Sdougm  * You may not use this file except in compliance with the License.
73034Sdougm  *
83034Sdougm  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93034Sdougm  * or http://www.opensolaris.org/os/licensing.
103034Sdougm  * See the License for the specific language governing permissions
113034Sdougm  * and limitations under the License.
123034Sdougm  *
133034Sdougm  * When distributing Covered Code, include this CDDL HEADER in each
143034Sdougm  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153034Sdougm  * If applicable, add the following below this CDDL HEADER, with the
163034Sdougm  * fields enclosed by brackets "[]" replaced with your own identifying
173034Sdougm  * information: Portions Copyright [yyyy] [name of copyright owner]
183034Sdougm  *
193034Sdougm  * CDDL HEADER END
203034Sdougm  */
213034Sdougm 
223034Sdougm /*
233348Sdougm  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
243034Sdougm  * Use is subject to license terms.
253034Sdougm  */
263034Sdougm 
273034Sdougm /*
283034Sdougm  * basic API declarations for share management
293034Sdougm  */
303034Sdougm 
313034Sdougm #ifndef _LIBSHARE_H
323034Sdougm #define	_LIBSHARE_H
333034Sdougm 
343034Sdougm #pragma ident	"%Z%%M%	%I%	%E% SMI"
353034Sdougm 
363034Sdougm #ifdef	__cplusplus
373034Sdougm extern "C" {
383034Sdougm #endif
393034Sdougm 
403034Sdougm /*
413034Sdougm  * Basic datatypes for most functions
423034Sdougm  */
433034Sdougm typedef void *sa_group_t;
443034Sdougm typedef void *sa_share_t;
453034Sdougm typedef void *sa_property_t;
463034Sdougm typedef void *sa_optionset_t;
473034Sdougm typedef void *sa_security_t;
483034Sdougm typedef void *sa_protocol_properties_t;
493034Sdougm 
503034Sdougm typedef void *sa_handle_t;	/* opaque handle to access core functions */
513034Sdougm 
523034Sdougm /*
533034Sdougm  * defined error values
543034Sdougm  */
553034Sdougm 
563034Sdougm #define	SA_OK			0
573034Sdougm #define	SA_NO_SUCH_PATH		1	/* provided path doesn't exist */
583034Sdougm #define	SA_NO_MEMORY		2	/* no memory for data structures */
593034Sdougm #define	SA_DUPLICATE_NAME	3	/* object name is already in use */
603034Sdougm #define	SA_BAD_PATH		4	/* not a full path */
613034Sdougm #define	SA_NO_SUCH_GROUP	5	/* group is not defined */
623034Sdougm #define	SA_CONFIG_ERR		6	/* system configuration error */
633034Sdougm #define	SA_SYSTEM_ERR		7	/* system error, use errno */
643034Sdougm #define	SA_SYNTAX_ERR		8	/* syntax error on command line */
653034Sdougm #define	SA_NO_PERMISSION	9	/* no permission for operation */
663034Sdougm #define	SA_BUSY			10	/* resource is busy */
673034Sdougm #define	SA_NO_SUCH_PROP		11	/* property doesn't exist */
683034Sdougm #define	SA_INVALID_NAME		12	/* name of object is invalid */
693034Sdougm #define	SA_INVALID_PROTOCOL	13	/* specified protocol not valid */
703034Sdougm #define	SA_NOT_ALLOWED		14	/* operation not allowed */
713034Sdougm #define	SA_BAD_VALUE		15	/* bad value for property */
723034Sdougm #define	SA_INVALID_SECURITY	16	/* invalid security type */
733034Sdougm #define	SA_NO_SUCH_SECURITY	17	/* security set not found */
743034Sdougm #define	SA_VALUE_CONFLICT	18	/* property value conflict */
753034Sdougm #define	SA_NOT_IMPLEMENTED	19	/* plugin interface not implemented */
763034Sdougm #define	SA_INVALID_PATH		20	/* path is sub-dir of existing share */
773034Sdougm #define	SA_NOT_SUPPORTED	21	/* operation not supported for proto */
783034Sdougm #define	SA_PROP_SHARE_ONLY	22	/* property valid on share only */
793034Sdougm #define	SA_NOT_SHARED		23	/* path is not shared */
803034Sdougm 
813034Sdougm /* API Initialization */
823034Sdougm #define	SA_INIT_SHARE_API	0x0001	/* init share specific interface */
833034Sdougm #define	SA_INIT_CONTROL_API	0x0002	/* init control specific interface */
843034Sdougm 
853034Sdougm /* not part of API returns */
863034Sdougm #define	SA_LEGACY_ERR		32	/* share/unshare error return */
873034Sdougm 
883034Sdougm /*
893034Sdougm  * other defined values
903034Sdougm  */
913034Sdougm 
923034Sdougm #define	SA_MAX_NAME_LEN		100	/* must fit service instance name */
933348Sdougm 
943348Sdougm /* Used in calls to sa_add_share() */
953348Sdougm #define	SA_SHARE_TRANSIENT	0	/* shared but not across reboot */
963034Sdougm #define	SA_SHARE_LEGACY		1	/* share is in dfstab only */
973348Sdougm #define	SA_SHARE_PERMANENT	2	/* share goes to repository */
983348Sdougm 
993348Sdougm /* sa_check_path() related */
1003348Sdougm #define	SA_CHECK_NORMAL		0	/* only check against active shares */
1013348Sdougm #define	SA_CHECK_STRICT		1	/* check against all shares */
1023034Sdougm 
1033034Sdougm /* RBAC related */
1043034Sdougm #define	SA_RBAC_MANAGE	"solaris.smf.manage.shares"
1053034Sdougm #define	SA_RBAC_VALUE	"solaris.smf.value.shares"
1063034Sdougm 
1073034Sdougm /*
1083034Sdougm  * legacy files
1093034Sdougm  */
1103034Sdougm 
1113034Sdougm #define	SA_LEGACY_DFSTAB	"/etc/dfs/dfstab"
1123034Sdougm #define	SA_LEGACY_SHARETAB	"/etc/dfs/sharetab"
1133034Sdougm 
1143034Sdougm /*
1153034Sdougm  * SMF related
1163034Sdougm  */
1173034Sdougm 
1183034Sdougm #define	SA_SVC_FMRI_BASE	"svc:/network/shares/group"
1193034Sdougm 
1203034Sdougm /* initialization */
1213910Sdougm extern sa_handle_t sa_init(int);
1223910Sdougm extern void sa_fini(sa_handle_t);
1233910Sdougm extern int sa_update_config(sa_handle_t);
1243034Sdougm extern char *sa_errorstr(int);
1253034Sdougm 
1263034Sdougm /* protocol names */
1273034Sdougm extern int sa_get_protocols(char ***);
1283034Sdougm extern int sa_valid_protocol(char *);
1293034Sdougm 
1303034Sdougm /* group control (create, remove, etc) */
1313910Sdougm extern sa_group_t sa_create_group(sa_handle_t, char *, int *);
1323034Sdougm extern int sa_remove_group(sa_group_t);
1333910Sdougm extern sa_group_t sa_get_group(sa_handle_t, char *);
1343034Sdougm extern sa_group_t sa_get_next_group(sa_group_t);
1353034Sdougm extern char *sa_get_group_attr(sa_group_t, char *);
1363034Sdougm extern int sa_set_group_attr(sa_group_t, char *, char *);
1373034Sdougm extern sa_group_t sa_get_sub_group(sa_group_t);
1383034Sdougm extern int sa_valid_group_name(char *);
1393034Sdougm 
1403034Sdougm /* share control */
1413034Sdougm extern sa_share_t sa_add_share(sa_group_t, char *, int, int *);
1423348Sdougm extern int sa_check_path(sa_group_t, char *, int);
1433034Sdougm extern int sa_move_share(sa_group_t, sa_share_t);
1443034Sdougm extern int sa_remove_share(sa_share_t);
1453034Sdougm extern sa_share_t sa_get_share(sa_group_t, char *);
1463034Sdougm extern sa_share_t sa_get_resource(sa_group_t, char *);
1473910Sdougm extern sa_share_t sa_find_share(sa_handle_t, char *);
1483034Sdougm extern sa_share_t sa_get_next_share(sa_share_t);
1493034Sdougm extern char *sa_get_share_attr(sa_share_t, char *);
1503034Sdougm extern char *sa_get_share_description(sa_share_t);
1513034Sdougm extern sa_group_t sa_get_parent_group(sa_share_t);
1523034Sdougm extern int sa_set_share_attr(sa_share_t, char *, char *);
1533034Sdougm extern int sa_set_share_description(sa_share_t, char *);
1543034Sdougm extern int sa_enable_share(sa_group_t, char *);
1553034Sdougm extern int sa_disable_share(sa_group_t, char *);
1563034Sdougm extern int sa_is_share(void *);
1573034Sdougm 
1583034Sdougm /* data structure free calls */
1593034Sdougm extern void sa_free_attr_string(char *);
1603034Sdougm extern void sa_free_share_description(char *);
1613034Sdougm 
1623034Sdougm /* optionset control */
1633034Sdougm extern sa_optionset_t sa_get_optionset(sa_group_t, char *);
1643034Sdougm extern sa_optionset_t sa_get_next_optionset(sa_group_t);
1653034Sdougm extern char *sa_get_optionset_attr(sa_optionset_t, char *);
1663034Sdougm extern void sa_set_optionset_attr(sa_optionset_t, char *, char *);
1673034Sdougm extern sa_optionset_t sa_create_optionset(sa_group_t, char *);
1683034Sdougm extern int sa_destroy_optionset(sa_optionset_t);
1693034Sdougm extern sa_optionset_t sa_get_derived_optionset(void *, char *, int);
1703034Sdougm extern void sa_free_derived_optionset(sa_optionset_t);
1713034Sdougm 
1723034Sdougm /* property functions */
1734180Sdougm extern sa_property_t sa_get_property(sa_optionset_t, char *);
1744180Sdougm extern sa_property_t sa_get_next_property(sa_group_t);
1753034Sdougm extern char *sa_get_property_attr(sa_property_t, char *);
1763034Sdougm extern sa_property_t sa_create_property(char *, char *);
1773034Sdougm extern int sa_add_property(void *, sa_property_t);
1783034Sdougm extern int sa_update_property(sa_property_t, char *);
1793034Sdougm extern int sa_remove_property(sa_property_t);
1803034Sdougm extern int sa_commit_properties(sa_optionset_t, int);
1813034Sdougm extern int sa_valid_property(void *, char *, sa_property_t);
1823034Sdougm 
1833034Sdougm /* security control */
1843034Sdougm extern sa_security_t sa_get_security(sa_group_t, char *, char *);
1853034Sdougm extern sa_security_t sa_get_next_security(sa_security_t);
1863034Sdougm extern char *sa_get_security_attr(sa_optionset_t, char *);
1873034Sdougm extern sa_security_t sa_create_security(sa_group_t, char *, char *);
1883034Sdougm extern int sa_destroy_security(sa_security_t);
1893034Sdougm extern void sa_set_security_attr(sa_security_t, char *, char *);
1903034Sdougm extern sa_optionset_t sa_get_all_security_types(void *, char *, int);
1913034Sdougm extern sa_security_t sa_get_derived_security(void *, char *, char *, int);
1923034Sdougm extern void sa_free_derived_security(sa_security_t);
1933034Sdougm 
1943034Sdougm /* protocol specific interfaces */
1953034Sdougm extern int sa_parse_legacy_options(sa_group_t, char *, char *);
1963034Sdougm extern char *sa_proto_legacy_format(char *, sa_group_t, int);
1973034Sdougm extern int sa_is_security(char *, char *);
1983034Sdougm extern sa_protocol_properties_t sa_proto_get_properties(char *);
1993034Sdougm extern sa_property_t sa_get_protocol_property(sa_protocol_properties_t, char *);
2003034Sdougm extern sa_property_t sa_get_next_protocol_property(sa_property_t);
2013034Sdougm extern int sa_set_protocol_property(sa_property_t, char *);
2023034Sdougm extern char *sa_get_protocol_status(char *);
2033034Sdougm extern void sa_format_free(char *);
2043034Sdougm extern sa_protocol_properties_t sa_create_protocol_properties(char *);
2053034Sdougm extern int sa_add_protocol_property(sa_protocol_properties_t, sa_property_t);
2063034Sdougm extern int sa_proto_valid_prop(char *, sa_property_t, sa_optionset_t);
2073034Sdougm extern int sa_proto_valid_space(char *, char *);
2083034Sdougm extern char *sa_proto_space_alias(char *, char *);
2093034Sdougm 
2103034Sdougm /* handle legacy (dfstab/sharetab) files */
2113034Sdougm extern int sa_delete_legacy(sa_share_t);
2123034Sdougm extern int sa_update_legacy(sa_share_t, char *);
2133034Sdougm extern int sa_update_sharetab(sa_share_t, char *);
2143034Sdougm extern int sa_delete_sharetab(char *, char *);
2153034Sdougm 
2163034Sdougm /* ZFS functions */
2173910Sdougm extern int sa_zfs_is_shared(sa_handle_t, char *);
2183034Sdougm extern int sa_group_is_zfs(sa_group_t);
219*4543Smarks extern int sa_path_is_zfs(char *);
2203910Sdougm 
2213910Sdougm /* SA Handle specific functions */
2223910Sdougm extern sa_handle_t sa_find_group_handle(sa_group_t);
2233910Sdougm 
2243034Sdougm #ifdef	__cplusplus
2253034Sdougm }
2263034Sdougm #endif
2273034Sdougm 
2283034Sdougm #endif /* _LIBSHARE_H */
229