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 /* 233910Sdougm * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 243034Sdougm * Use is subject to license terms. 253034Sdougm */ 263034Sdougm 273034Sdougm /* 283034Sdougm * basic declarations for implementation of the share management 293034Sdougm * libraries. 303034Sdougm */ 313034Sdougm 323034Sdougm #ifndef _LIBSHARE_IMPL_H 333034Sdougm #define _LIBSHARE_IMPL_H 343034Sdougm 353034Sdougm #pragma ident "%Z%%M% %I% %E% SMI" 363034Sdougm 373034Sdougm #include <libshare.h> 383034Sdougm #include <libscf.h> 393034Sdougm #include <scfutil.h> 403910Sdougm #include <libzfs.h> 414543Smarks #include <sharefs/share.h> 42*4544Smarks #include <sharefs/sharetab.h> 433034Sdougm 443034Sdougm #ifdef __cplusplus 453034Sdougm extern "C" { 463034Sdougm #endif 473034Sdougm 483034Sdougm /* directory to find plugin modules in */ 493034Sdougm #define SA_LIB_DIR "/usr/lib/fs" 503034Sdougm 513034Sdougm /* default group name for dfstab file */ 523034Sdougm #define SA_DEFAULT_FILE_GRP "sys" 533034Sdougm 543034Sdougm typedef void *sa_phandle_t; 553034Sdougm 563034Sdougm #define SA_PLUGIN_VERSION 1 573034Sdougm struct sa_plugin_ops { 583034Sdougm int sa_version; 593034Sdougm char *sa_protocol; /* protocol name */ 603034Sdougm int (*sa_init)(); 613034Sdougm void (*sa_fini)(); 623034Sdougm int (*sa_share)(sa_share_t); /* start sharing */ 634543Smarks int (*sa_unshare)(sa_share_t, char *); /* stop sharing */ 643034Sdougm int (*sa_valid_prop)(sa_property_t, sa_optionset_t); 653034Sdougm int (*sa_valid_space)(char *); /* is name valid optionspace? */ 663034Sdougm int (*sa_security_prop)(char *); /* property is security */ 673034Sdougm int (*sa_legacy_opts)(sa_group_t, char *); /* parse legacy opts */ 683034Sdougm char *(*sa_legacy_format)(sa_group_t, int); 693034Sdougm int (*sa_set_proto_prop)(sa_property_t); 703034Sdougm sa_protocol_properties_t (*sa_get_proto_set)(); 713034Sdougm char *(*sa_get_proto_status)(); 723034Sdougm char *(*sa_space_alias)(char *); 733034Sdougm int (*sa_update_legacy)(sa_share_t); 743034Sdougm int (*sa_delete_legacy)(sa_share_t); 753034Sdougm int (*sa_run_command)(int, int, char **); /* proto specific */ 763034Sdougm int (*sa_command_help)(); 773034Sdougm }; 783034Sdougm 793034Sdougm struct sa_proto_handle { 803034Sdougm int sa_num_proto; 813034Sdougm char **sa_proto; 823034Sdougm struct sa_plugin_ops **sa_ops; 833034Sdougm }; 843034Sdougm 853034Sdougm typedef struct propertylist { 863034Sdougm struct propertylist *pl_next; 873034Sdougm int pl_type; 883034Sdougm union propval { 893034Sdougm sa_optionset_t pl_optionset; 903034Sdougm sa_security_t pl_security; 913034Sdougm void *pl_void; 923034Sdougm } pl_value; 933034Sdougm } property_list_t; 943034Sdougm 953034Sdougm extern int sa_proto_share(char *, sa_share_t); 964543Smarks extern int sa_proto_unshare(sa_share_t, char *, char *); 973034Sdougm extern int sa_proto_valid_prop(char *, sa_property_t, sa_optionset_t); 983034Sdougm extern int sa_proto_security_prop(char *, char *); 993034Sdougm extern int sa_proto_legacy_opts(char *, sa_group_t, char *); 1003034Sdougm 1013034Sdougm /* internal utility functions */ 1023034Sdougm extern sa_optionset_t sa_get_derived_optionset(sa_group_t, char *, int); 1033034Sdougm extern void sa_free_derived_optionset(sa_optionset_t); 1043034Sdougm extern sa_optionset_t sa_get_all_security_types(void *, char *, int); 1053034Sdougm extern sa_security_t sa_get_derived_security(void *, char *, char *, int); 1063034Sdougm extern void sa_free_derived_security(sa_security_t); 1073034Sdougm extern sa_protocol_properties_t sa_create_protocol_properties(char *); 1083034Sdougm extern int sa_start_transaction(scfutilhandle_t *, char *); 1093034Sdougm extern int sa_end_transaction(scfutilhandle_t *); 1103034Sdougm extern void sa_abort_transaction(scfutilhandle_t *); 1113034Sdougm extern int sa_commit_share(scfutilhandle_t *, sa_group_t, sa_share_t); 1123034Sdougm extern int sa_set_property(scfutilhandle_t *, char *, char *); 1133034Sdougm extern void sa_free_fstype(char *fstyp); 1143034Sdougm extern int sa_delete_share(scfutilhandle_t *, sa_group_t, sa_share_t); 1153034Sdougm extern int sa_delete_instance(scfutilhandle_t *, char *); 1163034Sdougm extern int sa_create_pgroup(scfutilhandle_t *, char *); 1173034Sdougm extern int sa_delete_pgroup(scfutilhandle_t *, char *); 1184543Smarks extern void sa_fillshare(sa_share_t share, char *proto, struct share *sh); 1194543Smarks extern void sa_emptyshare(struct share *sh); 1203034Sdougm 1213034Sdougm /* ZFS functions */ 1223910Sdougm extern int sa_get_zfs_shares(sa_handle_t, char *); 1233034Sdougm extern int sa_zfs_update(sa_share_t); 1244543Smarks extern int sa_share_zfs(sa_share_t, char *, share_t *, void *, boolean_t); 1254543Smarks extern int sa_sharetab_fill_zfs(sa_share_t share, struct share *sh, 1264543Smarks char *proto); 1273034Sdougm 1283034Sdougm /* plugin specific functions */ 1293034Sdougm extern int proto_plugin_init(); 1303910Sdougm extern void proto_plugin_fini(); 1313034Sdougm extern int sa_proto_set_property(char *, sa_property_t); 1323034Sdougm extern int sa_proto_delete_legacy(char *, sa_share_t); 1333034Sdougm extern int sa_proto_update_legacy(char *, sa_share_t); 1343034Sdougm 1353034Sdougm #define PL_TYPE_PROPERTY 0 1363034Sdougm #define PL_TYPE_SECURITY 1 1373034Sdougm 1383034Sdougm /* values only used by the internal dfstab/sharetab parser */ 1393034Sdougm #define SA_SHARE_PARSER 0x1000 1403034Sdougm 1413034Sdougm /* plugin handler only */ 1423034Sdougm struct sa_proto_plugin { 1433034Sdougm struct sa_proto_plugin *plugin_next; 1443034Sdougm struct sa_plugin_ops *plugin_ops; 1453034Sdougm void *plugin_handle; 1463034Sdougm }; 1473034Sdougm 1483910Sdougm /* internal version of sa_handle_t */ 1493910Sdougm typedef struct sa_handle_impl { 1503910Sdougm uint64_t flags; 1513910Sdougm scfutilhandle_t *scfhandle; 1523910Sdougm libzfs_handle_t *zfs_libhandle; 1533910Sdougm zfs_handle_t **zfs_list; 1543910Sdougm size_t zfs_list_count; 1553910Sdougm xmlNodePtr tree; 1563910Sdougm xmlDocPtr doc; 1573910Sdougm } *sa_handle_impl_t; 1583910Sdougm 1593034Sdougm #ifdef __cplusplus 1603034Sdougm } 1613034Sdougm #endif 1623034Sdougm 1633034Sdougm #endif /* _LIBSHARE_IMPL_H */ 164