1*3034Sdougm /*
2*3034Sdougm  * CDDL HEADER START
3*3034Sdougm  *
4*3034Sdougm  * The contents of this file are subject to the terms of the
5*3034Sdougm  * Common Development and Distribution License (the "License").
6*3034Sdougm  * You may not use this file except in compliance with the License.
7*3034Sdougm  *
8*3034Sdougm  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*3034Sdougm  * or http://www.opensolaris.org/os/licensing.
10*3034Sdougm  * See the License for the specific language governing permissions
11*3034Sdougm  * and limitations under the License.
12*3034Sdougm  *
13*3034Sdougm  * When distributing Covered Code, include this CDDL HEADER in each
14*3034Sdougm  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*3034Sdougm  * If applicable, add the following below this CDDL HEADER, with the
16*3034Sdougm  * fields enclosed by brackets "[]" replaced with your own identifying
17*3034Sdougm  * information: Portions Copyright [yyyy] [name of copyright owner]
18*3034Sdougm  *
19*3034Sdougm  * CDDL HEADER END
20*3034Sdougm  */
21*3034Sdougm 
22*3034Sdougm /*
23*3034Sdougm  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24*3034Sdougm  * Use is subject to license terms.
25*3034Sdougm  */
26*3034Sdougm 
27*3034Sdougm /*
28*3034Sdougm  * basic declarations for implementation of the share management
29*3034Sdougm  * libraries.
30*3034Sdougm  */
31*3034Sdougm 
32*3034Sdougm #ifndef _LIBSHARE_IMPL_H
33*3034Sdougm #define	_LIBSHARE_IMPL_H
34*3034Sdougm 
35*3034Sdougm #pragma ident	"%Z%%M%	%I%	%E% SMI"
36*3034Sdougm 
37*3034Sdougm #include <libshare.h>
38*3034Sdougm #include <libscf.h>
39*3034Sdougm #include <scfutil.h>
40*3034Sdougm 
41*3034Sdougm #ifdef	__cplusplus
42*3034Sdougm extern "C" {
43*3034Sdougm #endif
44*3034Sdougm 
45*3034Sdougm /* directory to find plugin modules in */
46*3034Sdougm #define	SA_LIB_DIR	"/usr/lib/fs"
47*3034Sdougm 
48*3034Sdougm /* default group name for dfstab file */
49*3034Sdougm #define	SA_DEFAULT_FILE_GRP	"sys"
50*3034Sdougm 
51*3034Sdougm typedef void *sa_phandle_t;
52*3034Sdougm 
53*3034Sdougm #define	SA_PLUGIN_VERSION	1
54*3034Sdougm struct sa_plugin_ops {
55*3034Sdougm 	int	sa_version;
56*3034Sdougm 	char	*sa_protocol;			/* protocol name */
57*3034Sdougm 	int	(*sa_init)();
58*3034Sdougm 	void	(*sa_fini)();
59*3034Sdougm 	int	(*sa_share)(sa_share_t);	/* start sharing */
60*3034Sdougm 	int	(*sa_unshare)(char *);	/* stop sharing */
61*3034Sdougm 	int	(*sa_valid_prop)(sa_property_t, sa_optionset_t);
62*3034Sdougm 	int	(*sa_valid_space)(char *);	/* is name valid optionspace? */
63*3034Sdougm 	int	(*sa_security_prop)(char *);	/* property is security */
64*3034Sdougm 	int	(*sa_legacy_opts)(sa_group_t, char *); /* parse legacy opts */
65*3034Sdougm 	char   *(*sa_legacy_format)(sa_group_t, int);
66*3034Sdougm 	int	(*sa_set_proto_prop)(sa_property_t);
67*3034Sdougm 	sa_protocol_properties_t (*sa_get_proto_set)();
68*3034Sdougm 	char   *(*sa_get_proto_status)();
69*3034Sdougm 	char   *(*sa_space_alias)(char *);
70*3034Sdougm 	int	(*sa_update_legacy)(sa_share_t);
71*3034Sdougm 	int	(*sa_delete_legacy)(sa_share_t);
72*3034Sdougm 	int	(*sa_run_command)(int, int, char **); /* proto specific */
73*3034Sdougm 	int	(*sa_command_help)();
74*3034Sdougm };
75*3034Sdougm 
76*3034Sdougm struct sa_proto_handle {
77*3034Sdougm 	int			sa_num_proto;
78*3034Sdougm 	char			**sa_proto;
79*3034Sdougm 	struct sa_plugin_ops	**sa_ops;
80*3034Sdougm };
81*3034Sdougm 
82*3034Sdougm typedef struct propertylist {
83*3034Sdougm 	struct propertylist	*pl_next;
84*3034Sdougm 	int			pl_type;
85*3034Sdougm 	union propval {
86*3034Sdougm 	    sa_optionset_t	pl_optionset;
87*3034Sdougm 	    sa_security_t	pl_security;
88*3034Sdougm 	    void		*pl_void;
89*3034Sdougm 	}			pl_value;
90*3034Sdougm } property_list_t;
91*3034Sdougm 
92*3034Sdougm extern int sa_proto_share(char *, sa_share_t);
93*3034Sdougm extern int sa_proto_unshare(char *, char *);
94*3034Sdougm extern int sa_proto_valid_prop(char *, sa_property_t, sa_optionset_t);
95*3034Sdougm extern int sa_proto_security_prop(char *, char *);
96*3034Sdougm extern int sa_proto_legacy_opts(char *, sa_group_t, char *);
97*3034Sdougm 
98*3034Sdougm /* internal utility functions */
99*3034Sdougm extern sa_optionset_t sa_get_derived_optionset(sa_group_t, char *, int);
100*3034Sdougm extern void sa_free_derived_optionset(sa_optionset_t);
101*3034Sdougm extern sa_optionset_t sa_get_all_security_types(void *, char *, int);
102*3034Sdougm extern sa_security_t sa_get_derived_security(void *, char *, char *, int);
103*3034Sdougm extern void sa_free_derived_security(sa_security_t);
104*3034Sdougm extern sa_protocol_properties_t sa_create_protocol_properties(char *);
105*3034Sdougm extern int sa_start_transaction(scfutilhandle_t *, char *);
106*3034Sdougm extern int sa_end_transaction(scfutilhandle_t *);
107*3034Sdougm extern void sa_abort_transaction(scfutilhandle_t *);
108*3034Sdougm extern int sa_commit_share(scfutilhandle_t *, sa_group_t, sa_share_t);
109*3034Sdougm extern int sa_set_property(scfutilhandle_t *, char *, char *);
110*3034Sdougm extern void sa_free_fstype(char *fstyp);
111*3034Sdougm extern int sa_delete_share(scfutilhandle_t *, sa_group_t, sa_share_t);
112*3034Sdougm extern int sa_delete_instance(scfutilhandle_t *, char *);
113*3034Sdougm extern int sa_create_pgroup(scfutilhandle_t *, char *);
114*3034Sdougm extern int sa_delete_pgroup(scfutilhandle_t *, char *);
115*3034Sdougm 
116*3034Sdougm /* ZFS functions */
117*3034Sdougm extern int sa_get_zfs_shares(char *);
118*3034Sdougm extern int sa_zfs_update(sa_share_t);
119*3034Sdougm 
120*3034Sdougm /* plugin specific functions */
121*3034Sdougm extern int proto_plugin_init();
122*3034Sdougm extern int sa_proto_set_property(char *, sa_property_t);
123*3034Sdougm extern int sa_proto_delete_legacy(char *, sa_share_t);
124*3034Sdougm extern int sa_proto_update_legacy(char *, sa_share_t);
125*3034Sdougm 
126*3034Sdougm #define	PL_TYPE_PROPERTY	0
127*3034Sdougm #define	PL_TYPE_SECURITY	1
128*3034Sdougm 
129*3034Sdougm /* values only used by the internal dfstab/sharetab parser */
130*3034Sdougm #define	SA_SHARE_PARSER		0x1000
131*3034Sdougm 
132*3034Sdougm /* plugin handler only */
133*3034Sdougm struct sa_proto_plugin {
134*3034Sdougm 	struct sa_proto_plugin	*plugin_next;
135*3034Sdougm 	struct sa_plugin_ops	*plugin_ops;
136*3034Sdougm 	void			*plugin_handle;
137*3034Sdougm };
138*3034Sdougm 
139*3034Sdougm #ifdef	__cplusplus
140*3034Sdougm }
141*3034Sdougm #endif
142*3034Sdougm 
143*3034Sdougm #endif /* _LIBSHARE_IMPL_H */
144