4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 /*
27 * basic API declarations for share management
28 */
29
30 #ifndef _LIBSHARE_H
31 #define _LIBSHARE_H
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #include <sys/types.h>
38 #include <libnvpair.h>
39
40 /*
41 * Basic datatypes for most functions
42 */
43 typedef void *sa_group_t;
44 typedef void *sa_share_t;
45 typedef void *sa_property_t;
46 typedef void *sa_optionset_t;
47 typedef void *sa_security_t;
48 typedef void *sa_protocol_properties_t;
49 typedef void *sa_resource_t;
50
51 typedef void *sa_handle_t; /* opaque handle to access core functions */
52
53 /*
54 * defined error values
55 */
56
57 #define SA_OK 0
58 #define SA_NO_SUCH_PATH 1 /* provided path doesn't exist */
59 #define SA_NO_MEMORY 2 /* no memory for data structures */
60 #define SA_DUPLICATE_NAME 3 /* object name is already in use */
61 #define SA_BAD_PATH 4 /* not a full path */
62 #define SA_NO_SUCH_GROUP 5 /* group is not defined */
63 #define SA_CONFIG_ERR 6 /* system configuration error */
64 #define SA_SYSTEM_ERR 7 /* system error, use errno */
65 #define SA_SYNTAX_ERR 8 /* syntax error on command line */
66 #define SA_NO_PERMISSION 9 /* no permission for operation */
67 #define SA_BUSY 10 /* resource is busy */
68 #define SA_NO_SUCH_PROP 11 /* property doesn't exist */
69 #define SA_INVALID_NAME 12 /* name of object is invalid */
70 #define SA_INVALID_PROTOCOL 13 /* specified protocol not valid */
71 #define SA_NOT_ALLOWED 14 /* operation not allowed */
160 extern char *sa_get_group_attr(sa_group_t, char *);
161 extern int sa_set_group_attr(sa_group_t, char *, char *);
162 extern sa_group_t sa_get_sub_group(sa_group_t);
163 extern int sa_valid_group_name(char *);
164
165 /* share control */
166 extern sa_share_t sa_add_share(sa_group_t, char *, int, int *);
167 extern int sa_check_path(sa_group_t, char *, int);
168 extern int sa_move_share(sa_group_t, sa_share_t);
169 extern int sa_remove_share(sa_share_t);
170 extern sa_share_t sa_get_share(sa_group_t, char *);
171 extern sa_share_t sa_find_share(sa_handle_t, char *);
172 extern sa_share_t sa_get_next_share(sa_share_t);
173 extern char *sa_get_share_attr(sa_share_t, char *);
174 extern char *sa_get_share_description(sa_share_t);
175 extern sa_group_t sa_get_parent_group(sa_share_t);
176 extern int sa_set_share_attr(sa_share_t, char *, char *);
177 extern int sa_set_share_description(sa_share_t, char *);
178 extern int sa_enable_share(sa_group_t, char *);
179 extern int sa_disable_share(sa_share_t, char *);
180 extern int sa_is_share(void *);
181
182 /* resource name related */
183 extern sa_resource_t sa_find_resource(sa_handle_t, char *);
184 extern sa_resource_t sa_get_resource(sa_group_t, char *);
185 extern sa_resource_t sa_get_next_resource(sa_resource_t);
186 extern sa_share_t sa_get_resource_parent(sa_resource_t);
187 extern sa_resource_t sa_get_share_resource(sa_share_t, char *);
188 extern sa_resource_t sa_add_resource(sa_share_t, char *, int, int *);
189 extern int sa_remove_resource(sa_resource_t);
190 extern char *sa_get_resource_attr(sa_resource_t, char *);
191 extern int sa_set_resource_attr(sa_resource_t, char *, char *);
192 extern int sa_set_resource_description(sa_resource_t, char *);
193 extern char *sa_get_resource_description(sa_resource_t);
194 extern int sa_enable_resource(sa_resource_t, char *);
195 extern int sa_disable_resource(sa_resource_t, char *);
196 extern int sa_rename_resource(sa_resource_t, char *);
197 extern void sa_fix_resource_name(char *);
198
199 /* data structure free calls */
200 extern void sa_free_attr_string(char *);
205 extern sa_optionset_t sa_get_next_optionset(sa_group_t);
206 extern char *sa_get_optionset_attr(sa_optionset_t, char *);
207 extern void sa_set_optionset_attr(sa_optionset_t, char *, char *);
208 extern sa_optionset_t sa_create_optionset(sa_group_t, char *);
209 extern int sa_destroy_optionset(sa_optionset_t);
210 extern sa_optionset_t sa_get_derived_optionset(void *, char *, int);
211 extern void sa_free_derived_optionset(sa_optionset_t);
212
213 /* property functions */
214 extern sa_property_t sa_get_property(sa_optionset_t, char *);
215 extern sa_property_t sa_get_next_property(sa_group_t);
216 extern char *sa_get_property_attr(sa_property_t, char *);
217 extern sa_property_t sa_create_section(char *, char *);
218 extern void sa_set_section_attr(sa_property_t, char *, char *);
219 extern sa_property_t sa_create_property(char *, char *);
220 extern int sa_add_property(void *, sa_property_t);
221 extern int sa_update_property(sa_property_t, char *);
222 extern int sa_remove_property(sa_property_t);
223 extern int sa_commit_properties(sa_optionset_t, int);
224 extern int sa_valid_property(sa_handle_t, void *, char *, sa_property_t);
225 extern int sa_is_persistent(void *);
226
227 /* security control */
228 extern sa_security_t sa_get_security(sa_group_t, char *, char *);
229 extern sa_security_t sa_get_next_security(sa_security_t);
230 extern char *sa_get_security_attr(sa_optionset_t, char *);
231 extern sa_security_t sa_create_security(sa_group_t, char *, char *);
232 extern int sa_destroy_security(sa_security_t);
233 extern void sa_set_security_attr(sa_security_t, char *, char *);
234 extern sa_optionset_t sa_get_all_security_types(void *, char *, int);
235 extern sa_security_t sa_get_derived_security(void *, char *, char *, int);
236 extern void sa_free_derived_security(sa_security_t);
237
238 /* protocol specific interfaces */
239 extern int sa_parse_legacy_options(sa_group_t, char *, char *);
240 extern char *sa_proto_legacy_format(char *, sa_group_t, int);
241 extern int sa_is_security(char *, char *);
242 extern sa_protocol_properties_t sa_proto_get_properties(char *);
243 extern uint64_t sa_proto_get_featureset(char *);
244 extern sa_property_t sa_get_protocol_section(sa_protocol_properties_t, char *);
245 extern sa_property_t sa_get_next_protocol_section(sa_property_t, char *);
246 extern sa_property_t sa_get_protocol_property(sa_protocol_properties_t, char *);
247 extern sa_property_t sa_get_next_protocol_property(sa_property_t, char *);
248 extern int sa_set_protocol_property(sa_property_t, char *, char *);
249 extern char *sa_get_protocol_status(char *);
250 extern void sa_format_free(char *);
251 extern sa_protocol_properties_t sa_create_protocol_properties(char *);
252 extern int sa_add_protocol_property(sa_protocol_properties_t, sa_property_t);
253 extern int sa_proto_valid_prop(sa_handle_t, char *, sa_property_t,
254 sa_optionset_t);
255 extern int sa_proto_valid_space(char *, char *);
256 extern char *sa_proto_space_alias(char *, char *);
257 extern int sa_proto_get_transients(sa_handle_t, char *);
258 extern int sa_proto_notify_resource(sa_resource_t, char *);
259 extern int sa_proto_change_notify(sa_share_t, char *);
260 extern int sa_proto_delete_section(char *, char *);
261
262 /* handle legacy (dfstab/sharetab) files */
263 extern int sa_delete_legacy(sa_share_t, char *);
264 extern int sa_update_legacy(sa_share_t, char *);
265 extern int sa_update_sharetab(sa_share_t, char *);
266 extern int sa_delete_sharetab(sa_handle_t, char *, char *);
267
268 /* ZFS functions */
269 extern int sa_zfs_is_shared(sa_handle_t, char *);
270 extern int sa_group_is_zfs(sa_group_t);
271 extern int sa_path_is_zfs(char *);
272 extern int sa_zfs_setprop(sa_handle_t, char *, nvlist_t *);
273
274 /* SA Handle specific functions */
275 extern sa_handle_t sa_find_group_handle(sa_group_t);
276
277 #ifdef __cplusplus
278 }
279 #endif
280
281 #endif /* _LIBSHARE_H */
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2013 RackTop Systems.
25 */
26
27 /*
28 * basic API declarations for share management
29 */
30
31 #ifndef _LIBSHARE_H
32 #define _LIBSHARE_H
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 #include <sys/types.h>
39 #include <libnvpair.h>
40
41 /*
42 * Basic datatypes for most functions
43 */
44 typedef void *sa_group_t;
45 typedef void *sa_share_t;
46 typedef void *sa_property_t;
47 typedef void *sa_optionset_t;
48 typedef void *sa_security_t;
49 typedef void *sa_protocol_properties_t;
50 typedef void *sa_resource_t;
51
52 typedef struct sa_handle *sa_handle_t; /* opaque handle to access core functions */
53
54 /*
55 * defined error values
56 */
57
58 #define SA_OK 0
59 #define SA_NO_SUCH_PATH 1 /* provided path doesn't exist */
60 #define SA_NO_MEMORY 2 /* no memory for data structures */
61 #define SA_DUPLICATE_NAME 3 /* object name is already in use */
62 #define SA_BAD_PATH 4 /* not a full path */
63 #define SA_NO_SUCH_GROUP 5 /* group is not defined */
64 #define SA_CONFIG_ERR 6 /* system configuration error */
65 #define SA_SYSTEM_ERR 7 /* system error, use errno */
66 #define SA_SYNTAX_ERR 8 /* syntax error on command line */
67 #define SA_NO_PERMISSION 9 /* no permission for operation */
68 #define SA_BUSY 10 /* resource is busy */
69 #define SA_NO_SUCH_PROP 11 /* property doesn't exist */
70 #define SA_INVALID_NAME 12 /* name of object is invalid */
71 #define SA_INVALID_PROTOCOL 13 /* specified protocol not valid */
72 #define SA_NOT_ALLOWED 14 /* operation not allowed */
161 extern char *sa_get_group_attr(sa_group_t, char *);
162 extern int sa_set_group_attr(sa_group_t, char *, char *);
163 extern sa_group_t sa_get_sub_group(sa_group_t);
164 extern int sa_valid_group_name(char *);
165
166 /* share control */
167 extern sa_share_t sa_add_share(sa_group_t, char *, int, int *);
168 extern int sa_check_path(sa_group_t, char *, int);
169 extern int sa_move_share(sa_group_t, sa_share_t);
170 extern int sa_remove_share(sa_share_t);
171 extern sa_share_t sa_get_share(sa_group_t, char *);
172 extern sa_share_t sa_find_share(sa_handle_t, char *);
173 extern sa_share_t sa_get_next_share(sa_share_t);
174 extern char *sa_get_share_attr(sa_share_t, char *);
175 extern char *sa_get_share_description(sa_share_t);
176 extern sa_group_t sa_get_parent_group(sa_share_t);
177 extern int sa_set_share_attr(sa_share_t, char *, char *);
178 extern int sa_set_share_description(sa_share_t, char *);
179 extern int sa_enable_share(sa_group_t, char *);
180 extern int sa_disable_share(sa_share_t, char *);
181 extern boolean_t sa_is_share(void *);
182
183 /* resource name related */
184 extern sa_resource_t sa_find_resource(sa_handle_t, char *);
185 extern sa_resource_t sa_get_resource(sa_group_t, char *);
186 extern sa_resource_t sa_get_next_resource(sa_resource_t);
187 extern sa_share_t sa_get_resource_parent(sa_resource_t);
188 extern sa_resource_t sa_get_share_resource(sa_share_t, char *);
189 extern sa_resource_t sa_add_resource(sa_share_t, char *, int, int *);
190 extern int sa_remove_resource(sa_resource_t);
191 extern char *sa_get_resource_attr(sa_resource_t, char *);
192 extern int sa_set_resource_attr(sa_resource_t, char *, char *);
193 extern int sa_set_resource_description(sa_resource_t, char *);
194 extern char *sa_get_resource_description(sa_resource_t);
195 extern int sa_enable_resource(sa_resource_t, char *);
196 extern int sa_disable_resource(sa_resource_t, char *);
197 extern int sa_rename_resource(sa_resource_t, char *);
198 extern void sa_fix_resource_name(char *);
199
200 /* data structure free calls */
201 extern void sa_free_attr_string(char *);
206 extern sa_optionset_t sa_get_next_optionset(sa_group_t);
207 extern char *sa_get_optionset_attr(sa_optionset_t, char *);
208 extern void sa_set_optionset_attr(sa_optionset_t, char *, char *);
209 extern sa_optionset_t sa_create_optionset(sa_group_t, char *);
210 extern int sa_destroy_optionset(sa_optionset_t);
211 extern sa_optionset_t sa_get_derived_optionset(void *, char *, int);
212 extern void sa_free_derived_optionset(sa_optionset_t);
213
214 /* property functions */
215 extern sa_property_t sa_get_property(sa_optionset_t, char *);
216 extern sa_property_t sa_get_next_property(sa_group_t);
217 extern char *sa_get_property_attr(sa_property_t, char *);
218 extern sa_property_t sa_create_section(char *, char *);
219 extern void sa_set_section_attr(sa_property_t, char *, char *);
220 extern sa_property_t sa_create_property(char *, char *);
221 extern int sa_add_property(void *, sa_property_t);
222 extern int sa_update_property(sa_property_t, char *);
223 extern int sa_remove_property(sa_property_t);
224 extern int sa_commit_properties(sa_optionset_t, int);
225 extern int sa_valid_property(sa_handle_t, void *, char *, sa_property_t);
226 extern boolean_t sa_is_persistent(void *);
227
228 /* security control */
229 extern sa_security_t sa_get_security(sa_group_t, char *, char *);
230 extern sa_security_t sa_get_next_security(sa_security_t);
231 extern char *sa_get_security_attr(sa_optionset_t, char *);
232 extern sa_security_t sa_create_security(sa_group_t, char *, char *);
233 extern int sa_destroy_security(sa_security_t);
234 extern void sa_set_security_attr(sa_security_t, char *, char *);
235 extern sa_optionset_t sa_get_all_security_types(void *, char *, int);
236 extern sa_security_t sa_get_derived_security(void *, char *, char *, int);
237 extern void sa_free_derived_security(sa_security_t);
238
239 /* protocol specific interfaces */
240 extern int sa_parse_legacy_options(sa_group_t, char *, char *);
241 extern char *sa_proto_legacy_format(char *, sa_group_t, int);
242 extern boolean_t sa_is_security(char *, char *);
243 extern sa_protocol_properties_t sa_proto_get_properties(char *);
244 extern uint64_t sa_proto_get_featureset(char *);
245 extern sa_property_t sa_get_protocol_section(sa_protocol_properties_t, char *);
246 extern sa_property_t sa_get_next_protocol_section(sa_property_t, char *);
247 extern sa_property_t sa_get_protocol_property(sa_protocol_properties_t, char *);
248 extern sa_property_t sa_get_next_protocol_property(sa_property_t, char *);
249 extern int sa_set_protocol_property(sa_property_t, char *, char *);
250 extern char *sa_get_protocol_status(char *);
251 extern void sa_format_free(char *);
252 extern sa_protocol_properties_t sa_create_protocol_properties(char *);
253 extern int sa_add_protocol_property(sa_protocol_properties_t, sa_property_t);
254 extern int sa_proto_valid_prop(sa_handle_t, char *, sa_property_t,
255 sa_optionset_t);
256 extern int sa_proto_valid_space(char *, char *);
257 extern char *sa_proto_space_alias(char *, char *);
258 extern int sa_proto_get_transients(sa_handle_t, char *);
259 extern int sa_proto_notify_resource(sa_resource_t, char *);
260 extern int sa_proto_change_notify(sa_share_t, char *);
261 extern int sa_proto_delete_section(char *, char *);
262
263 /* handle legacy (dfstab/sharetab) files */
264 extern int sa_delete_legacy(sa_share_t, char *);
265 extern int sa_update_legacy(sa_share_t, char *);
266 extern int sa_update_sharetab(sa_share_t, char *);
267 extern int sa_delete_sharetab(sa_handle_t, char *, char *);
268
269 /* ZFS functions */
270 extern boolean_t sa_zfs_is_shared(sa_handle_t, char *);
271 extern boolean_t sa_group_is_zfs(sa_group_t);
272 extern boolean_t sa_path_is_zfs(char *);
273 extern int sa_zfs_setprop(sa_handle_t, char *, nvlist_t *);
274
275 /* SA Handle specific functions */
276 extern sa_handle_t sa_find_group_handle(sa_group_t);
277
278 #ifdef __cplusplus
279 }
280 #endif
281
282 #endif /* _LIBSHARE_H */
|