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 /* 235951Sdougm * Copyright 2008 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> 424544Smarks #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 { 586007Sthurlow int sa_version; /* version number */ 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 */ 64*6214Sdougm int (*sa_valid_prop)(sa_handle_t, sa_property_t, 65*6214Sdougm sa_optionset_t); /* validate */ 663034Sdougm int (*sa_valid_space)(char *); /* is name valid optionspace? */ 673034Sdougm int (*sa_security_prop)(char *); /* property is security */ 683034Sdougm int (*sa_legacy_opts)(sa_group_t, char *); /* parse legacy opts */ 693034Sdougm char *(*sa_legacy_format)(sa_group_t, int); 706007Sthurlow int (*sa_set_proto_prop)(sa_property_t); /* set a property */ 716007Sthurlow sa_protocol_properties_t (*sa_get_proto_set)(); /* get properties */ 723034Sdougm char *(*sa_get_proto_status)(); 733034Sdougm char *(*sa_space_alias)(char *); 743034Sdougm int (*sa_update_legacy)(sa_share_t); 753034Sdougm int (*sa_delete_legacy)(sa_share_t); 765331Samw int (*sa_change_notify)(sa_share_t); 775331Samw int (*sa_enable_resource)(sa_resource_t); 785331Samw int (*sa_disable_resource)(sa_resource_t); 795331Samw uint64_t (*sa_features)(void); 805331Samw int (*sa_get_transient_shares)(sa_handle_t); /* add transients */ 815331Samw int (*sa_notify_resource)(sa_resource_t); 825331Samw int (*sa_rename_resource)(sa_handle_t, sa_resource_t, char *); 833034Sdougm int (*sa_run_command)(int, int, char **); /* proto specific */ 843034Sdougm int (*sa_command_help)(); 856007Sthurlow int (*sa_delete_proto_section)(char *); 863034Sdougm }; 873034Sdougm 883034Sdougm struct sa_proto_handle { 893034Sdougm int sa_num_proto; 903034Sdougm char **sa_proto; 913034Sdougm struct sa_plugin_ops **sa_ops; 923034Sdougm }; 933034Sdougm 943034Sdougm typedef struct propertylist { 953034Sdougm struct propertylist *pl_next; 963034Sdougm int pl_type; 973034Sdougm union propval { 983034Sdougm sa_optionset_t pl_optionset; 993034Sdougm sa_security_t pl_security; 1003034Sdougm void *pl_void; 1013034Sdougm } pl_value; 1023034Sdougm } property_list_t; 1033034Sdougm 1045951Sdougm /* internal version of sa_handle_t */ 1055951Sdougm typedef struct sa_handle_impl { 1065951Sdougm uint64_t flags; 1075951Sdougm scfutilhandle_t *scfhandle; 1085951Sdougm libzfs_handle_t *zfs_libhandle; 1095951Sdougm zfs_handle_t **zfs_list; 1105951Sdougm size_t zfs_list_count; 1115951Sdougm xmlNodePtr tree; 1125951Sdougm xmlDocPtr doc; 1135951Sdougm uint64_t tssharetab; 1145951Sdougm uint64_t tstrans; 1155951Sdougm } *sa_handle_impl_t; 1165951Sdougm 1173034Sdougm extern int sa_proto_share(char *, sa_share_t); 1184543Smarks extern int sa_proto_unshare(sa_share_t, char *, char *); 119*6214Sdougm extern int sa_proto_valid_prop(sa_handle_t, char *, sa_property_t, 120*6214Sdougm sa_optionset_t); 1213034Sdougm extern int sa_proto_security_prop(char *, char *); 1223034Sdougm extern int sa_proto_legacy_opts(char *, sa_group_t, char *); 1235331Samw extern int sa_proto_share_resource(char *, sa_resource_t); 1245331Samw extern int sa_proto_unshare_resource(char *, sa_resource_t); 1253034Sdougm 1263034Sdougm /* internal utility functions */ 1273034Sdougm extern sa_optionset_t sa_get_derived_optionset(sa_group_t, char *, int); 1283034Sdougm extern void sa_free_derived_optionset(sa_optionset_t); 1293034Sdougm extern sa_optionset_t sa_get_all_security_types(void *, char *, int); 1303034Sdougm extern sa_security_t sa_get_derived_security(void *, char *, char *, int); 1313034Sdougm extern void sa_free_derived_security(sa_security_t); 1323034Sdougm extern sa_protocol_properties_t sa_create_protocol_properties(char *); 1333034Sdougm extern int sa_start_transaction(scfutilhandle_t *, char *); 1345951Sdougm extern int sa_end_transaction(scfutilhandle_t *, sa_handle_impl_t); 1353034Sdougm extern void sa_abort_transaction(scfutilhandle_t *); 1363034Sdougm extern int sa_commit_share(scfutilhandle_t *, sa_group_t, sa_share_t); 1373034Sdougm extern int sa_set_property(scfutilhandle_t *, char *, char *); 1383034Sdougm extern void sa_free_fstype(char *fstyp); 1393034Sdougm extern int sa_delete_share(scfutilhandle_t *, sa_group_t, sa_share_t); 1403034Sdougm extern int sa_delete_instance(scfutilhandle_t *, char *); 1413034Sdougm extern int sa_create_pgroup(scfutilhandle_t *, char *); 1423034Sdougm extern int sa_delete_pgroup(scfutilhandle_t *, char *); 1434543Smarks extern void sa_fillshare(sa_share_t share, char *proto, struct share *sh); 1444543Smarks extern void sa_emptyshare(struct share *sh); 1453034Sdougm 1463034Sdougm /* ZFS functions */ 1473910Sdougm extern int sa_get_zfs_shares(sa_handle_t, char *); 1483034Sdougm extern int sa_zfs_update(sa_share_t); 1495331Samw extern int sa_share_zfs(sa_share_t, char *, share_t *, void *, zfs_share_op_t); 1504543Smarks extern int sa_sharetab_fill_zfs(sa_share_t share, struct share *sh, 1514543Smarks char *proto); 1523034Sdougm 1533034Sdougm /* plugin specific functions */ 1543034Sdougm extern int proto_plugin_init(); 1553910Sdougm extern void proto_plugin_fini(); 1563034Sdougm extern int sa_proto_set_property(char *, sa_property_t); 1573034Sdougm extern int sa_proto_delete_legacy(char *, sa_share_t); 1583034Sdougm extern int sa_proto_update_legacy(char *, sa_share_t); 1595331Samw extern int sa_proto_rename_resource(sa_handle_t, char *, 1605331Samw sa_resource_t, char *); 1613034Sdougm 1623034Sdougm #define PL_TYPE_PROPERTY 0 1633034Sdougm #define PL_TYPE_SECURITY 1 1643034Sdougm 1653034Sdougm /* values only used by the internal dfstab/sharetab parser */ 1663034Sdougm #define SA_SHARE_PARSER 0x1000 1673034Sdougm 1683034Sdougm /* plugin handler only */ 1693034Sdougm struct sa_proto_plugin { 1703034Sdougm struct sa_proto_plugin *plugin_next; 1713034Sdougm struct sa_plugin_ops *plugin_ops; 1723034Sdougm void *plugin_handle; 1733034Sdougm }; 1743034Sdougm 1755951Sdougm #define TSTAMP(tm) (uint64_t)(((uint64_t)tm.tv_sec << 32) | \ 1765951Sdougm (tm.tv_nsec & 0xffffffff)) 1775951Sdougm 1783910Sdougm 1793034Sdougm #ifdef __cplusplus 1803034Sdougm } 1813034Sdougm #endif 1823034Sdougm 1833034Sdougm #endif /* _LIBSHARE_IMPL_H */ 184